Hot answers tagged

6

all is just a string the WordPress developers picked to behave differently than any other hook. When you attach to all, your callback will fire for all other hooks. I wouldn't spend too much time looking at the source of do_action, just know that: add_action( 'x', 'whatever' ) will mean whatever fires for do_action( 'x' ) add_action( 'all', 'whatever' ) ...


4

Conditional if ( isset($wp_filter['all']) ) { you can find right in these hook creating functions: apply_filters apply_filters_ref_array do_action do_action_ref_array The difference between these are in number of arguments sent. Either we need multiple arguments, thus ref_array or single argument. The other difference "action vs. filter" is simple, ...


3

Files to look at: wp-admin/includes/wp-current-screen.php and wp-admin/admin-header.php If we take a look at admin-header.php we can see that $current_screen->render_screen_meta(); is the one responsible for rendering the contextual help on screens. It gets the global $current_screen which is set via WP_Screen class. It has methods like ...


3

Loosely what you have should work already. However few things are off. Calling these function without time format will produce values like 1:36 pm (depending on your site's settings), which are not exactly comparable. Post modified time can be less than published in some cases, like scheduled posts. So I would write it along the lines of: if ( ...


2

Just some general remarks: Why isn't the following change working? $custom_message = get_the_title( $post->ID ) .''. $hash_tags; to: $custom_message = get_the_content( $post->ID ) .' '. $hash_tags; Note that get_the_content() doesn't take a post ID as an input parameter and it depends on global variables, like $pages that's ...


2

What I was looking for was transition_post_status. The documentation can be found here. What I did was to add one more filter add_filter('transition_post_status','myFunction');


1

The reason hooks ( Filters and Actions ) are in these templates is specifically so you don't need to copy the templates into your theme folder. The biggest issue with copying WooCommerce templates into your theme is that often time whenever WooCommerce updates they also update the templates. Then you'll need to bring your changes from the old template into ...


1

wp_login_form is completely separate from wp-login.php - the login_form hook only applies to the latter. For the former, you've got three filters at your disposal: login_form_top - return HTML to be injected right after the opening <form /> tag login_form_middle - return HTML to be injected between the password field and the remember me/submit field ...


1

To append text to the end of the titles in that widget and nothing more i.e. does not matter the URL, you can just use some CSS. <li> <a class="my-folder-categories">Category 1</a> </li> a.my-folder-categories-folder:after {content:" folder"; This will effectivly make the text appear as so: category 1 folder Be sure to add ...


1

I suggest post status transitions that runs only when your set conditions are met. Example: add_action( 'transition_post_status', 'add_awesome_terms', 10, 3 ); function add_awesome_terms( $new_status, $old_status, $post ) { // only run when it's a page, new status is publish and old status isn't publish if ( $post->post_type == 'page' ...


1

Check the documentation of add_filter() first argument is name of filter and second one is callback function name. (both are required) See the example for your case:- add_filter('bimber_facebook_sdk_src', 'change_fb_sdk_url'); function change_fb_sdk_url($current_url) { // Variable $current_url hold the current value of URL // You can manipulate ...


1

You can use the_content with an high prioriety (lower number). add_filter( 'the_content', function( $content ) { return 'Hello World '.$content; }, 0); You can even use negative priority: add_filter( 'the_content', function( $content ) { return 'Hello World '.$content; }, -10); Note that this will apply everytime 'the_content' is used, no matter ...


1

There is no other global filter applied before the_content - you can use the $priority argument in your add_filter call to ensure your function runs before any others: function wpse_225625_to_the_top( $content ) { return "Hello World\n\n\$content"; } add_filter( 'the_content', 'wpse_225625_to_the_top', -1 /* Super important yo */ );


1

In the context of official plugin repository this is very explicitly forbidden by the guidelines (emphasis mine): 7. No "phoning home" without user's informed consent. This seemingly simple rule actually covers several different aspects: No unauthorized collection of user data. For example, sending the admin's email address back to your own ...


1

That is due to the fact, that your filter woocommerce_breadcrumb doesn't even exist. This filter here works and pulls out all the elements, that are currently in the breadcrumb (as an array): add_filter( 'woocommerce_get_breadcrumb', 'change_breadcrumb' ); function change_breadcrumb( $crumbs ) { var_dump( $crumbs ); return $crumbs; } And this ...



Only top voted, non community-wiki answers of a minimum length are eligible