Why does re-using this function not work? [closed]

Function “works” once because before first call of is_service_class(), function is_personal not exists and whole this block is executed if ( ! function_exists( ‘is_personal’ ) ) { // declaration and use of function } In next call of is_service_class() is_personal is declared and the entire block is skipped. Inside the condition if ( !function_exists( ‘is_personal’ … Read more

How can I output all apply_filters and do_action?

apply_filters and do_action are NOT stored in $wp_filter, ONLY add_filter and add_action are stored in $wp_filter When you call apply_filters or do_action, core WordPress loops through all of the registered filters or actions (added by add_filter and add_action), looking for any matching ones, and then executes the associated function. The only difference being actions which … Read more

Gutenberg Block – Post Featured Image Filter Hook

From the documentation: Prepend and append to the panel contents: var el = wp.element.createElement; function wrapPostFeaturedImage( OriginalComponent ) { return function( props ) { return ( el( wp.element.Fragment, {}, ‘Prepend above’, el( OriginalComponent, props ), ‘Append below’ ) ); } } wp.hooks.addFilter( ‘editor.PostFeaturedImage’, ‘my-plugin/wrap-post-featured-image’, wrapPostFeaturedImage ); So did you intentionally not using wp.element.Fragment? You may … Read more

Redirecting from login

There’s a filter called login_redirect. add_filter( ‘login_redirect’, ‘wpse377295_login_redirect’, 10, 3 ); function wpse377295_login_redirect( $url, $request, $user ) { if ( is_wp_error( $user ) ) { // It’s possible that the $user param is a WP_Error. If so, bail out. return $url; } if ( ! user_can( $user, ‘update_core’ ) { // Only admin users can … Read more

Pass argument to event hook

I would suggest first read the wordpress documentation about actions to understand how they work. Actions are aplit into two section, add_action and do_action do_action is the “location” where you hook into it. A basic example of do_action do_action(‘my_custom_action’); You can also pass arguments into do_action which can be available in add_action if you choose … Read more