How can one use variables in a template or template part without polluting the global scope?

I feel there is a bit of confusion — let me try and clarify some key concepts. A WordPress installation can potentially run huge amounts of 3rd party code. Code you can’t control. That leads to a high chance of naming collisions. That’s why WordPress coding standards suggest to “namespace” functions and variables declared in … Read more

Dequeue classic-themes.min.css

Thanks to @t31os I achieved dequeuing the stylesheet with this code: function disable_classic_theme_styles() { wp_deregister_style(‘classic-theme-styles’); wp_dequeue_style(‘classic-theme-styles’); } add_filter(‘wp_enqueue_scripts’, ‘disable_classic_theme_styles’, 100);

$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