Ajax call theme functions from front

I think that your problem is ajaxurl is not available for your script. Try to defined that varibale before your js code is loaded. The best way is using wp_localize_script: The PHP: add_action( ‘wp_enqueue_scripts’, ‘cyb_enqueue_scripts’ ); function cyb_enqueue_scripts() { //Change the key and url with yours wp_register_script(‘my-js’, get_stylesheet_directory_uri(). ‘/js/my-js.js’, array( ‘jquery’ ) ); wp_enqueue_script(‘my-js’); //Localize … Read more

WP_Remote_Get Not working

The very concept of HTTP API is to make sure transport will be done. It basically uses 5 different transport methods and it chooses the best one according to your server config. So it’s unlikely a compatibility issue with wp_remote_get() and your server. Plus if WP is not loaded, adding an action won’t help, it … Read more

Why is my Gutenberg block returning an error after initial save?

The main issue in your code is with these two attributes which use the exact same selector (the first span element in your block content): checkListItemOne: { type: ‘string’, source: ‘html’, selector: ‘span’ // same as below }, checkListItemTwo: { type: ‘string’, source: ‘html’, selector: ‘span’ // same as above } Which means the block … Read more

How to include all files within a folder to functions.php?

You can include/require all *.php files recursively using following function. foreach(glob(get_template_directory() . “/*.php”) as $file){ require $file; } Alternatively You can use following function as-well. $Directory = new RecursiveDirectoryIterator(get_template_directory().’functions/’); $Iterator = new RecursiveIteratorIterator($Directory); $Regex = new RegexIterator($Iterator, ‘/^.+\.php$/i’, RecursiveRegexIterator::GET_MATCH); foreach($Regex as $yourfiles) { include $yourfiles->getPathname(); } P.S Got the solution From Here.

Refactor create_function

There is an inbuilt function for returning null: __return_null. So you can replace create_function(‘$a’, ‘return null;’); with just ‘__return_null’ (note the quotes) as it seems $a is not used anyway. Or you can use an anonymous function as the argument directly: function($a) {return null;} (no quotes). Either way since the argument is expecting a function … Read more