React Plugin Settings Page Localization

adds an admin menu page with a div that React replaces, but the localization inside this React doesn’t work Actually, since you are enqueueing the same script (build/index.js), which is automatically registered by register_block_type(), then in your my_enqueue_admin_scripts() function, just do wp_enqueue_script( ‘my-block-local-editor-script’ ) to enqueue/load the script on your admin menu page. And secondly, … Read more

register_activation_hook doesn’t execute without add_action(‘init’,’some-function’)

The register_activation_hook() function takes two parameters: the first parameter is the path to the main plugin file, and the second parameter is the name of the function to be executed when the plugin is activated. In your case, you are passing the plugin directory path to the register_activation_hook() function instead of the path to the … Read more

esc_url, esc_url_raw or sanitize_url?

This might be a more useful demonstration: <a href=”<?php echo esc_url( $url ); ?>>I’m printing a URL to the frontend</a> $url = sanitize_url( $_GET[‘user_inputted_data’] ); update_post_meta( $post_id, ‘that_url’, $url ); esc_url is an escaping function, sanitize_url is a sanitising function. Sanitising functions clean incoming data, e.g. removing letters from phone numbers, stripping trailing space etc. … Read more

add category id to option name when adding an option on edit_category

There are 4 problems a small one, a security problem, a misunderstanding, and a big problem. The Small Problem Because you used [] notation in the name you’ve indicated that there are multiple category_meta_ values: category_meta_[<?php echo $cat->term_id ?>] Which means $_POST[‘category_meta_’] will always be an array. It would be much easier to append the … Read more

How to prepend a header section to all pages related to my WordPress Plugin

it didn’t work for you because hook admin_head is designed to add <link> tags inside <head> section. So even if you will render something there it won’t be visible, because it is outside <body>. If you want to render something after admin head bar, you should use wp_after_admin_bar_render hook: https://developer.wordpress.org/reference/hooks/wp_after_admin_bar_render/ To determine if you are … Read more