Hot answers tagged

2

comment_post hook pass to attached functions 3 parameters. The fourth parameter of add_action() indicates to how many parameters the attached function will be able to access. add_action( 'comment_post', 'save_chbox_in_db', 10, 3 ); function save_chbox_in_db( $comment_ID, $comment_approved, $commentdata ) { $post_id = (int)$commentdata['comment_post_ID'...


1

As @sally-cj already hinted at in his comment this is used for debugging purposes, helping developers by notifying them of the use of deprecated arguments in their codebase. In core this is for example used to alert people of wrong arguments when using the REST API: https://core.trac.wordpress.org/browser/branches/5.2/src/wp-includes/rest-api.php#L177 But ...


1

Here's couple examples on how to determine which page you're on within a filter and how to return different data based on it. On these examples I'm using the apply_filter() part of the code you linked to to hook the custom code to the theme code. The custom function recieves the variabels from apply_filter() as parameters. The custom function should ...


1

Looking at the source of the wp_mail() function, there's a filter right near the top: $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); // Expanded for clarity. (Aside: compact() is a PHP function that creates an array from a set of arguments. In this case, it's making an array of the $to, $...


1

The second parameter in add_filter is a function with accepted arguments, not returned values. This is an example how I pass my custom array $args to change an existing array $filter_args: add_filter( 'woocommerce_dropdown_variation_attribute_options_args', function( $filter_args ) use ( $args ) { return eswc_var_dropdown_args( $filter_args, $args )...


1

You could restrict the plugin menu to only certain user access levels like admin. You will still want the link to be available without making a code change in the backend. This article should help you if you want to go this route. Remove ability to access certain admin menus


1

Maybe the problem happens because you don't check if your hook is already scheduled. if ( !wp_next_scheduled( 'first_hook' ) ) { wp_schedule_event(time()+60, 'daily', 'first_hook'); }


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