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 } }

Set spesific size of featured images

In your functions.php you want to issue a call to set_post_thumbnail_size() https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size As with add_image_size, you provide the target width, height & whether you want the image hard cropped to these dimensions. So, for example, set_post_thumbnail_size(427, 427, true); will crop all your thumbnails to be a maximum of 427px high or wide, depending on aspect … Read more

Automatically include all php files in a child theme directory

I suspect glob needs the current working directory to work, so you could try passing the full path of the file to the existing function you have… include_all_php(dirname(__FILE__).’/includes’); Or set the current working directory first: setcwd(dirname(__FILE__).”https://wordpress.stackexchange.com/”); include_all_php(‘includes’); Alternatively you could also use scandir: $filepath = dirname(__FILE__).’/includes/’; $files = scandir($filepath); foreach ($files as $file) { // … Read more

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

Conditional Gravity Forms filter in WordPress Multisite

Based on @jdm2112 response, I did the following: add_filter(‘gform_paypalpaymentspro_args_before_payment’,’add_donation_comment’, 10, 2 ); function add_donation_comment( $args, $form_id ) { // do not edit $args or $form_id global $blog_id; // Make this available to the function // Apply filter only if blog id is 2 if ( 2 == $blog_id ) { // apply to form 1 … Read more