how to determine how many and what kind of arguments are passed to hooks

When calling an action hook using add_action(‘some_action_tag’,’callback_function’,$priority,$number_of_arguments); The callback function is called when a do_action() call is fired with the corresponding tag for example: do_action(‘some_action_tag’,$argument1,$argument2,$argument3….); And when calling a filter hook using: add_filter(‘some_filter_tag’,’callback_function’,$priority,$number_of_arguments); The callback function is called when a apply_filters() call is fired with the corresponding tag for example: $value = apply_filters(‘some_filter_tag’,$argument1,$argument2,$argument3…); Now as … Read more

Is there any way to allow a plugin to write over a previous version?

If you’re manually installing a plugin, you need to disable and delete the old version. However, WordPress does allow you to update your plugin programatically. If your plugin is hosted on the WordPress.org repository, it will prompt the users to install updates for you. You’ve likely seen this with Akismet and other plugins already. If … Read more

How to check if upload window came from the featured image link?

There is a filter for the html of the ‘postimagediv’ called ‘admin_post_thumbnail_html’. There may be more elegant ways, but this works: add_filter(‘admin_post_thumbnail_html’, ‘wpse61502_change_thumbnail_link’); function wpse61502_change_thumbnail_link($content) { return str_replace(‘media-upload.php?’, ‘media-upload.php?is_thumbnail=true&’, $content); } In your plugin / script check the querystring: if ( isset($_GET[‘is_thumbnail’]) ) { // do stuff, actions, enqueue, … }

WordPress Ajax Problems

You have nothing specific to do to “load” modified php code in WordPress. All files are just loaded as is at execution time (ie when the HTTP request is processed by the server). You just have to verify that your plugin is active. Your curl command is malformed. Use this instead : curl -X POST … Read more

Does update_comment_meta hook exists?

Well, it’s a little bit complicated 😉 If you will search update_comment_meta hook, you won’t find it. But it exists 🙂 There is update_comment_meta function and it calls update_metadata function with first param set to comment. This update_metadata function does something like this (meta.php line 149): do_action( “update_{$meta_type}_meta”, $meta_id, $object_id, $meta_key, $_meta_value ); where $meta_type … Read more

How to center oEmbedded content

After some Googling, I found a solution that was originally done for a Twitter embed, but I modified it to work with all oEmbed contents. Keep in mind that for this to work on existing posts, you’ll need to do an “update” for the oEmbed content to refresh from the cache. add_filter(‘oembed_result’,’center_oembed’,10,3); function center_oembed($html, $url, … Read more

Question about how do wordpress filters/actions work

For every filter or action hook that you use with the add_filter or add_action functions, there is a corresponding apply_filters or do_action function called somewhere in the WordPress core. This function sets up which parameters will be sent to the filter or action. For the filter hook the_content example that you gave, the filter hook … Read more