Passing nonce at admin menu link

WordPress do not accept nonce in the slug that you are trying to provide in the above code. I mean in this line: ‘my_dashboard&nonce-field=’ . wp_create_nonce(‘my_action’), ‘show_dashboard’ I was facing the same issue like you are facing. As the admin menu already verified for specific users so we don’t need to verify it again with … Read more

Any ideas to trigger some code after plugin update?

I’ve always used the upgrader_process_complete hook: function my_plugins_update_completed( $upgrader_object, $options ) { // If an update has taken place and the updated type is plugins and the plugins element exists if ( $options[‘action’] == ‘update’ && $options[‘type’] == ‘plugin’ && isset( $options[‘plugins’] ) ) { foreach( $options[‘plugins’] as $plugin ) { // Check to ensure … Read more

Display update notification messages like ‘What’s New’

You can hook into in_plugin_update_message-{$file}. For the above plugin, the according code looks as follows: add_action(‘admin_menu’, array($this,’admin_menu’), 11); function admin_menu() { global $pagenow; if( $pagenow == ‘plugins.php’ ) { $hook = apply_filters(‘acf/get_info’, ‘hook’); add_action( ‘in_plugin_update_message-‘ . $hook, array($this, ‘in_plugin_update_message’), 10, 2 ); } } function in_plugin_update_message( $plugin_data, $r ) { $version = apply_filters(‘acf/get_info’, ‘version’); $readme … Read more

Extending theme PHP class in plugin

Make your class visible to PHP after the theme has declared the parent class. Plugins are loaded first, the theme maybe later. This can be overridden. Theme code is available when the action after_setup_theme is fired, so you could use it like this: add_action( ‘after_setup_theme’, function() { require ‘ChildClass.php’; }); However, if the theme loads … Read more

How to filter the_content() & include content from template

My guess is that single-template.php uses the_content. Now think about what happens: Your filter causes single-template.php to load single-template.php uses the_content So single-template.php loads again Which uses the_content Which loads single-template.php Which uses the_content … I am not entirely sure how to fix that, as your question is light on detail. It is hard to … Read more