belabbesislam
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
This is already the case. i’m only checking Post content
But currently, for anyone stuck with the same issue, the workaround I did was create a must-use plugin that disables the plugin if we are doing REST.
<?php
/*
Plugin Name: wp external links rest api exclude
Description: Disable wp external links plugin on rest api requests
*/
function is_rest_api_request() {
if ( empty( $_SERVER['REQUEST_URI'] ) ) {
// Probably a CLI request
return false;
}
$rest_prefix = trailingslashit( rest_get_url_prefix() );
$is_rest_api_request = strpos( $_SERVER['REQUEST_URI'], $rest_prefix ) !== false;
return apply_filters( 'is_rest_api_request', $is_rest_api_request );
}
add_filter( 'option_active_plugins', function( $plugins ) {
if ( ! is_rest_api_request() ) {
return $plugins;
}
// Only run this logic during REST requests
$denylist_plugins = array_flip(
array(
'wp-external-links/wp-external-links.php',
)
);
/**
* Loop through the active plugins.
* If it's in the deny list, remove it from the list of plugins to load.
*/
foreach ( $plugins as $key => $plugin ) {
if ( isset( $denylist_plugins[ $plugin ] ) ) {
unset( $plugins[ $key ] );
}
}
return $plugins;
} );Or simply
return array_filter( $plugins, function( $plugin ) {
return ! in_array( $plugin, [
'wp-external-links/wp-external-links.php',
], true );
} );- This reply was modified 10 months, 2 weeks ago by belabbesislam.
you can use
Simple-JWT-Login plugin
or make a custom code to verify JWT and log in the users by id
see :
https://developer.ww.wp.xz.cn/reference/functions/wp_set_current_user/
https://developer.ww.wp.xz.cn/reference/functions/wp_set_auth_cookie/
Viewing 2 replies - 1 through 2 (of 2 total)