$value) { if (isset($options[$key])) { if (is_numeric($options[$key])) { $js_options[$key] = intval($options[$key]); } elseif ($options[$key] === "on") { $js_options[$key] = true; } } else { $js_options[$key] = $value; } } // Enqueue script for backend. wp_enqueue_script( 'squeeze-script', // Handle. plugins_url('/assets/js/script.bundle.js', __FILE__), array('jquery', 'wp-mediaelement'), // Dependencies, defined above. null, true // Enqueue the script in the footer. ); // WP Localized globals. Use dynamic PHP stuff in JavaScript via `squeeze` object. wp_localize_script( 'squeeze-script', 'squeeze', // Array containing dynamic data for a JS Global. [ 'pluginUrl' => SQUEEZE_PLUGIN_URL, 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('squeeze-nonce'), 'options' => json_encode($js_options), ] ); wp_set_script_translations('squeeze-script', 'squeeze', plugin_dir_path(__DIR__) . 'languages'); }