fetching via fetch/ajax gutenberg block data from third party

Well, I figured it out. Though my solution is probably far from elegant (I’m not making concessions for timeouts or usability/accessibility). My problem was mostly overzealous configuration, copy and paste errors, and needing to apply async/await keywords. Attributes look like this: attributes: { url: { source: ‘attribute’, type: ‘string’, selector: ‘.o_microlink’, attribute: ‘href’, }, title: … Read more

API JSON Data in WordPress

Here is some quick first draft code for populating a dropdown from the Google Font API, I do not know about the options framework so this will not deal with that. 1. Get an API Access Key from Google Your request will need a valid key, you can follow the instruction here on how to … Read more

Javascript not included

You’re mixing up the singular wp_enqueue_script, which adds a script, with the plural wp_enqueue_scripts which is an action and a function that triggers that action. I think you want function theme_scripts() { wp_enqueue_script( ‘custom-script’, get_template_directory_uri() . ‘/js/menu-fix.js’, array(‘jquery’), ‘1.0’, true); } add_action(‘wp_enqueue_scripts’, ‘theme_scripts’); i.e. register against the enqueue_scripts-plural action that calls enqueue_script-singular.

How wp_enqueue_script works?

In simple case you need to enqueue script before header scripts are printed, which happens in wp_head hook. Basic approach would be this in functions.php of your theme: add_action(‘wp_enqueue_scripts’, ‘my_enqueue_scripts’); function my_enqueue_scripts() { wp_enqueue_script(‘jquery’); }

Add extra parameter in tag using script_loader_tag

You can use script_loader_tag filter to fulfill your requirement. add below code in your active theme’s functions.php file. it will add extra parameter in your script tag. function add_attribute_to_script_tag($tag, $handle) { # add script handles to the array below $scripts_to_defer = array(‘wpfrank-ptbw-pinit-js’); foreach($scripts_to_defer as $defer_script) { if ($defer_script === $handle) { return str_replace(‘ src’, ‘ … Read more

Javascript not working in admin

Script concatenation in admin area is normal behavior, but I am not sure that trying to load that many scripts is. You can disable concatenation by defining CONCATENATE_SCRIPTS constant to false. In wp-config.php would be fitting: define(‘CONCATENATE_SCRIPTS’, false); See Disable_Javascript_Concatenation in Codex. W3TC shouldn’t affect anything on admin side.