Wait a result before enqueue

There are various ways to do that, e.g. by moving the add_action for method b inside a class AwesomeClass{ private storedResult; private __construct(){ add_action( ‘set_logged_in_cookie’, array($this, ‘a’),10,1); } Function a(p1){ //some interesting process with p1 // UPDATE $this->storedResult add_action(‘wp_enqueue_scripts’, array($this, ‘b’)); } Function b(){ //some interesting process // USAGE OF $this->storedResult } }

Reuse variable in hook callback

If you want to use a variable from a another context in a function, create a class: class CustomLog { private $debug_msg = “”; public function __construct( $msg ) { $this->debug_msg = $msg; } public function log() { error_log( $this->debug_msg, 0 ); } } add_action( ‘init’, [ new CustomLog( “Hi there!” ), ‘log’ ], 20 … Read more

WordPress taxonomy and archive custom class

Add another layer of condition to your is_archive() test, so that your archive class is only output when the other two are NOT true: function fotogruf_layout_class(){ if ( is_search() ) { echo $search_layout_class; } if ( (is_post_type_archive(‘gallery’) ) || ( taxonomy_exists(‘gallery_category’) ) ){ echo $gallery_layout_class; } if ( is_archive() ) { if ( ( !is_post_type_archive(‘gallery’) … Read more

How to modify single widget in child theme?

Looks like I’ve found the answer here. Here’s the working version of the code I’m using in my child theme’s functions.php file. function my_widgets_init() { register_sidebar( array( ‘name’ => esc_html__( ‘Default Sidebar’, ‘codilight-lite’ ), ‘id’ => ‘sidebar-1’, ‘description’ => ”, ‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</aside>’, ‘before_title’ => ‘<h2 class=”widget-title”><span>’, ‘after_title’ => … Read more

How to pass variables to custom filter from multiple functions

I think from your code add_action( ‘wp_footer’, ‘purewpns_googlefont_loader’ ); Function purewpns_googlefont_loader maybe typo mistake. You use the action wp_footer and added empty array which obviously print empty array. Okay. You can use: googlefont_filter_callback( $font ); Except $fonts = apply_filters( ‘googlefont_loader’, $fonts ); In function googlefont_loader() And add filter in function googlefont_filter_callback like: function googlefont_filter_callback( $fonts=array() … Read more