Problem requiring/including plugin files with plugin_dir_path( __FILE__ )

When using plugin_dir_path() like you do: plugin_dir_path( __FILE__ ); It does return something like: /var/www//wordpress/wp-content/plugins/your-plugin/ So it adds a trailing slash, because as the documentation states: It is a wrapper for trailingslashit( dirname( $file ) );. So remove the slash before the file in your calls: require_once plugin_dir_path( __FILE__ ) . ‘file.php’;

Why my browser keeps loading old version of custom JavaScript files in \divi\js? [closed]

First get datetime stamp of your js file’s last modification, and use it as fourth parameter of wp_enqueue_script function: $path=”full path to your script file”); $handle=”your_handle”; $src=”https://wordpress.stackexchange.com/questions/283374/path of the script, relative to the WordPress root directory”; $depts = array(); // dependencies, if any $ver = filemtime($path); $in_footer = false; wp_enqueue_script($handle, $scr, $depts, $ver, $in_footer); If … Read more

Filter out results from REST API

If you’re using WP 4.7+ you can filter the query using the rest_$type_query hook wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php:L267 This is a working example that filters current query by given terms $types = [ ‘post’, ‘page’, ]; foreach ( $types as $type ) { add_filter( ‘rest_’ . $type . ‘_query’, ‘filter_rest_query_by_zone’, 10, 2 ); } function filter_rest_query_by_zone( $args, $request … Read more

How can i force Display names to be the same as Usernames?

You can use the wp_pre_insert_user_data filter. function wpse_filter_user_data( $data, $update, $id) { if( isset( $data[ ‘user_login’ ] ) ) { $data[ ‘display_name’ ] = $data[ ‘user_login’ ]; return $data; } $user = get_user_by( ’email’, $data[ ‘user_email’ ] ); $data[ ‘display_name’ ] = $user->user_login; return $data; } add_filter( ‘wp_pre_insert_user_data’, ‘wpse_filter_user_data’, 10, 3 ); You’ll probably want … Read more

WP showing “warning: call_user_func_array()”, What to do?

The error you’re getting is showing, because somewhere on your site (your theme or one of your plugins) is registering a filter function that doesn’t exist. Somewhere in your code, there will be such line (or similar to it): add_filter( ‘rewrite_rules_array’, ‘disable_embeds_rewrites’ ); It may use different hook, so it may also look like: add_filter( … Read more

How to remove filter added by another plugin in a class

You did not write where you put the filter removal code, but I suspect you tried to delete it before it was added. Another important point, you have not given the priority parameter in remove_filter(). Quote from the documentation: remove_filter( $tag, $function_to_remove, $priority ); Important: To remove a hook, the $function_to_remove and $priority arguments must … Read more

How to create gutenberg block using REST API independently or as headless way?

Block editor blocks are dynamically constructed by parsing the HTML of post_content. Blocks are delimited by HTML comments that looks like these: <!– wp:image –> <figure class=”wp-block-image”><img src=”https://wordpress.stackexchange.com/questions/359758/source.jpg” alt=”” /></figure> <!– /wp:image –> The way the actual data of blocks is stored depends entirely on the block. Blocks can either store their attributes inside the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)