Add Admin Menu Inside Construct or Init

The callback you have given in add_menu_page() is a static function, not a class method. It should be: add_menu_page( ‘School Manager Settings’, ‘School Manager’, ‘administrator’, ‘school-manager-settings’, array ( $this, ‘show_admin_settings_page’ ) ); And please don’t use &$this anymore, that’s PHP 4. 🙂 My demo plugin T5 Admin Menu Demo might help understanding how that works.

How to fetch serialized data from wordpress options

No, this won’t work: <?php echo get_option(‘notice_data[Message]’); ?> Because get_option pulls whole option value by option_name, it doesn’t pull by pieces of the serialized array. What you are asking for is a key (option_name) called literally notice_data[Message]. Assuming you’ve saved the option as notice_data you aren’t going to get a match, and I am not … Read more

How to list the Hooks and order of execution in current loading page? [duplicate]

Paste this into your functions.php //LIST ALL HOOKS function dump_hook( $tag, $hook ) { ksort($hook); echo “<pre>>>>>>\t$tag<br>”; foreach( $hook as $priority => $functions ) { echo $priority; foreach( $functions as $function ) if( $function[‘function’] != ‘list_hook_details’ ) { echo “\t”; if( is_string( $function[‘function’] ) ) echo $function[‘function’]; elseif( is_string( $function[‘function’][0] ) ) echo $function[‘function’][0] . … Read more

Check spam in custom form – akismet

The problem is the globals global $akismet_api_host, $akismet_api_port; are not available everywhere. I suggest calling your function in the “init” hook… add_action(‘init’, ‘myAkismetInit’); function myAkismetInit() { var_dump ( bm_checkSpam(”) ); } Check out the Akismet API documentation. The other option is to use one of these wrapper classes: https://github.com/tijsverkoyen/Akismet use \TijsVerkoyen\Akismet\Akismet; // create instance $akismet … Read more

URLs of plugin resources?

I am trying to add in a script and css file for my plugin into the admin header. Then like any good developer you should be using wp_enqueue_script or wp_enqueue_style so you’re not hard-coding those script/style includes into the plugin(meaning a user can unhook them if he/she needed to). http://codex.wordpress.org/Function_Reference/wp_enqueue_script http://codex.wordpress.org/Function_Reference/wp_enqueue_style If the styles/scripts are … Read more