New answers tagged

2

No, deactivated_plugin won't fire during a plugin's uninstallation process. But there are indeed two hooks that fire when a plugin is uninstalled: pre_uninstall_plugin, which is called right before a plugin is uninstalled. It acts globally, targeting any plugin. uninstall_{$file}, which fires after a specific plugin is uninstalled. Its scope it's limited ...


0

You can pass a priority parameter to add_action. I don't actually know what priority Akismet has (default is 10), but you could start by trying this: add_action( 'wp_default_scripts', 'pwcc_jquery_to_footer', 9);


0

As long as you don't delete your theme by ftp, but use the regular way of switching to another theme in the admin, there is a hook to use, switch_theme. It works like this: add_action('switch_theme', 'mytheme_setup_options'); function mytheme_setup_options () { delete_option('mytheme_option1'); delete_option('mytheme_option2'); } There's a sister ...


4

Your analogy here is partially correct, but incomplete: I understand that when do_action is called wp looks for all registered listeners and invokes them according set priority. You need to consider what happens when you call add_action. WordPress never searches for the add_action statements, it has those in a list. When you call add_action, it ...


0

All your actions belong in your functions.php, assuming that you are building a theme. It is here that you add actions to certain events in your templates. Now, once it has read functions.php WP has a list of actions it is supposed to undertake at certain points in your theme templates. There are several predefined action hooks, such as wp_head() and ...


0

I've came across a very straight forward snippet that removes all Yoast WordPress Seo comments, it's short and works nice. It kind of does the same as @bwillis and @Ahmad M's answer using the output buffering approach. Simply place the following snippet on your theme's functions.php or equivalent functions file. I'll leave it here as a reference - credit ...


0

(I created a persistent login for my client, one login for two wordpress based site, on prestashop and 3 custom php application). I had the same challenge but this is the way i solved it. First step add_action('wp_logout', 'doMyLogoutCall'); add_action('init', 'runInitLogoutProcess'); second step function doMyLogoutCall() {?> <img style="display:...


2

The action name suggests it is run _after_the_content, not within the the_content itself, so you might have to do something different here like @SamuelElh is suggesting... You would add a function to the action with early priority to buffer, then add a filter to the final output with a late priority: add_action('tribe_events_single_event_after_the_content',...


0

I've found the source of the problem, I have redeclared the function comment_footer_die(). Which wordpress obviously can't accept. My supplied code works as intended.


0

Searching around and not being able to implement the action through init hook I've found this workaround which for sure isn't the best but does the job nicely. echo "<script type='text/javascript'> window.location=document.location.href; </script>"; at the end of $_POST instructions. If somebody has a better solution, welcome ...


0

Contrary to the comments... I'd say that you should use filter as in method 1 because... Message will depend on quite a few things right now, You just do a test if statement, later on message may depend on some other factors ( like maybe validating a nonce on failure giving message 'None invalid' ). Actions help in extending your code's functionality... ...


0

It's because your function archive_action is executed when the loop was already made. Try hooking your function into the init action, so it would be executed before the loop. Another prettier approach would be using ajax. So you send the request through Ajax to archive and just use javascript to remove the post from the DOM.


0

You always need to be sure that three things are defined (section, setting and control). If you are adding a control to an already defined section, i.e. title_tagline, then you don't need to re-register it, but always define the setting and the control. //adding setting for copyright text add_action('customize_register', 'theme_copyright_customizer'); ...


0

add the following code to active theme. Here I am replacing with [shell] before saving. add_filter( 'content_save_pre' , 'my_sanitize_content' , 10, 1); function my_sanitize_content( $value ) { return str_replace("<shell>", "[shell]", $value ); }



Top 50 recent answers are included