$GLOBALS & global doesn’t work [closed]

In my opinion you shouldn’t use $GLOBALS at all. add_filter shouldn’t be used the way you are using it. So there is apply_filter in wordpress that returns a filtered value such that $my_variable = apply_filter(‘my_filter_tag’, ‘default_value’, $arg1); In the above code ‘default_value’ can be anything. $my_variable will hold the value ‘default_value’ if no one called … Read more

admin_post hook not working

You’re missing a ‘ in your code and your function name is different. function my_maybe_add_redirect( $entry, $form ) { wp_redirect( ‘https://www.google.com/’, 301 ); exit(); } add_action( ‘admin_post_submit_images’, ‘my_maybe_add_redirect’, 10, 2 );

change position of element using hook [closed]

Instead of adding and removing the hooks like this. You should do the work on some action/hook. which gets fire before these hooks. so you can call it in this way add_action( ‘init’ , ‘sf_change_header_position’ , 10 ); function sf_change_header_position() { remove_action( ‘storefront_header’, ‘storefront_secondary_navigation’, 30 ); add_action( ‘storefront_header’, ‘storefront_secondary_navigation’, 52 ); }

Transform .wp-video to the native video player of the browser

I’ve found the right way digging through the WP documentation: https://developer.wordpress.org/reference/hooks/wp_video_shortcode/ This code seems to do the trick: function buildVideoPlayer($output, $attr) { // $output contains the default HTML string, created by the WP core // $attr is an associative array, which contains the parameters // (src, poster, preload, etc.) specified in the shortcode // The … Read more

PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered

Before you can use, those two lines : wp_enqueue_style( ‘wp-auth-check’ ); wp_enqueue_script( ‘wp-auth-check’ ); you should register those assets, inside wp_enqueue_scripts or admin_enqueue_scripts, like the following : function my_assets() { wp_register_style( ‘wp-auth-check’, ‘path/to/style’, $deps = array, $ver = false, $media=”all” ) wp_register_script( ‘wp-auth-check’, ‘path/to/your-script’, $deps = array, $ver = false, $in_footer = false ) } … Read more

How To Apply Different Styles To All Blocks Based on Post Meta Value?

I was able to solve this problem by using the admin_body_class filter to add a class name to the <body> element of the admin page, and writing selectors for that class in my stylesheet. add_filter( ‘admin_body_class’, ‘add_status_classes’ ); function add_status_classes( $classes ) { $post_meta = get_post_meta( get_the_ID() ); $is_darkmode = $post_meta[‘_is_post_dark_mode’]; if ( $is_darkmode ) … Read more

How to change Akismet commenter privacy notice?

Aha, I finally got it working: <?php /* Plugin Name: Akismet Better Privacy Notice Description: Inform users about what’s actually happening with their data */ add_filter ( ‘akismet_comment_form_privacy_notice_markup’, ‘better_display_comment_form_privacy_notice’ ); function better_display_comment_form_privacy_notice() { echo sprintf( ‘<p class=”akismet_comment_form_privacy_notice”>’ . ‘Warning: This site uses Akismet to filter spam.’ . ‘ Until or unless I can find a … Read more