/** * Register assets */ public final function register_scripts() { // JS Cookie wp_register_script('js-cookie', _2ch_plugin_dir_url('/dist/js/js.cookie.js'), array(), '2.1.0', true); // Google reCAPTCHA wp_register_script('recaptcha', 'https://www.google.com/recaptcha/api.js?render=explicit&onload=nichanCallback', array(), null, false); // Form helper wp_register_script('2ch-form', _2ch_plugin_dir_url('/dist/js/2ch.js'), array('jquery-form', 'js-cookie', 'recaptcha'), PLUGIN_2CH_VERSION, true); wp_localize_script('2ch-form', 'NichanVars', array('root' => get_rest_url(), 'nonce' => wp_create_nonce('wp_rest'), 'callback' => false, 'message' => __('Comment has been posted and waiting form moderation.', '2ch'))); }
/** * Load style sheet. */ public function enqueue_scripts() { /** * nichan_load_style * * If css can be load * * @param bool $load_style Flag used for deciding to load plugin's CSS. * @return bool */ $load_style = apply_filters('nichan_load_style', true); if ($load_style) { wp_enqueue_style('2ch-style', _2ch_plugin_dir_url('/dist/css/2ch.css'), array(), PLUGIN_2CH_VERSION); } }
/** * Enqueue assets * * @param string $page Page slug. */ public function admin_enqueue_scripts($page) { if ('settings_page_2ch-setting' === $page) { wp_enqueue_script('2ch-admin', _2ch_plugin_dir_url('/dist/js/2ch-admin.js'), array('jquery-form', 'jquery-effects-highlight', 'jquery-ui-autocomplete'), PLUGIN_2CH_VERSION, true); wp_localize_script('2ch-admin', 'NichanAdmin', array('endpoint' => admin_url('admin-ajax.php'), 'actionSearch' => '2ch_user_search')); wp_enqueue_style('2ch-admin', _2ch_plugin_dir_url('/dist/css/2ch-admin.css'), array(), PLUGIN_2CH_VERSION); } }