What action is called when drafts are saved?

After WP 2.3 you have for all status an hook: {$new_status}_{$post->post_type} Alternative you can use ans if for the status on hook save_post; an example for post_type post, you can change this ‘post’ to your post_type or defaults form WP: public function set_status_private($id, $post) { if ( is_object($post) && ‘post’ === $post->post_type && ‘publish’ === … Read more

How to check if certain plugin exists and in expected version

There is is_plugin_active() function. Other method is to check if functions or classes, specific to required plugin, exist. Some plugins explicitly define their own constants for this, typically with version number and/or other identifying info. There has been some developments to make extension dependence logic more generic, such as Plugin Dependecies, but they hadn’t gained … Read more

Calling clean_term_cache() fails when called in the same plugin that creates terms, succeeds when called separately?

After creating about 40 test WP installs today on localhost, here’s what I can report: It appears that the correct function call to rebuild the category_children options is: _get_term_hierarchy(‘category’) Previously, I was trying to call: clean_term_cache(”,’category’) And I was calling it just after my categories were created in my plugin code. However, I could never … Read more

The changes I make to an external JS file of my WP plugin are only applied after I clear my browser’s cache

Use function filemtime($path), where $path is a path to your script, in wp_enqueue_script call, as fourth parameter (version). Every time you modify the script, the cache will be bypassed. Update Calls to wp_register_script and wp_enqueue_script: wp_register_script(‘DynamicMapScript’, plugins_url(‘DynamicMap.js’, __FILE__), array(‘jquery’), filemtime(dirname(__FILE__) . ‘/DynamicMap.js’)); wp_enqueue_script(‘DynamicMapScript’);

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.

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

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