'text/css' ) ); wp_localize_script( 'jquery', 'cm_settings', $cm_settings ); wp_enqueue_script( 'wp-theme-plugin-editor' ); wp_enqueue_style( 'wp-codemirror' ); } /** * Add inline style for wpLingua custom CSS */ $custom_css = get_option( 'wplng_custom_css' ); if ( ! empty( $custom_css ) && is_string( $custom_css ) ) { $custom_css = wp_strip_all_tags( $custom_css ); wp_add_inline_style( 'wplingua', $custom_css ); } } /** * Register wpLingua assets for option page : Exclusions * * @param string $hook * @return void */ function wplng_option_page_exclusions_assets( $hook ) { if ( ! is_admin() || $hook !== 'wplingua_page_wplingua-exclusions' ) { return; } /** * Enqueue jQuery */ wp_enqueue_script( 'jquery' ); /** * Enqueue wpLingua CSS styles */ wp_enqueue_style( 'wplingua-option-exclusions', plugins_url() . '/wplingua/assets/css/admin/option-page-exclusions.css', array(), WPLNG_API_VERSION ); wp_enqueue_style( 'wplingua-option-pages', plugins_url() . '/wplingua/assets/css/admin/option-page.css', array(), WPLNG_API_VERSION ); } /** * Register wpLingua assets for option page : Dictionary * * @param string $hook * @return void */ function wplng_option_page_dictionary_assets( $hook ) { if ( ! is_admin() || $hook !== 'wplingua_page_wplingua-dictionary' ) { return; } /** * Enqueue jQuery */ wp_enqueue_script( 'jquery' ); /** * Enqueue wpLingua JS scripts */ wp_enqueue_script( 'wplingua-option-dictionary', plugins_url() . '/wplingua/assets/js/admin/option-page-dictionary.js', array( 'jquery' ), WPLNG_API_VERSION ); /** * Enqueue wpLingua CSS styles */ wp_enqueue_style( 'wplingua-option-dictionary', plugins_url() . '/wplingua/assets/css/admin/option-page-dictionary.css', array(), WPLNG_API_VERSION ); wp_enqueue_style( 'wplingua-option-pages', plugins_url() . '/wplingua/assets/css/admin/option-page.css', array(), WPLNG_API_VERSION ); } /** * Register wpLingua assets on translations edit pages * * @return void */ function wplng_translation_assets() { global $post_type; if ( 'wplng_translation' === $post_type ) { /** * Enqueue jQuery */ wp_enqueue_script( 'jquery' ); /** * Enqueue wpLingua JS scripts */ wp_enqueue_script( 'wplingua-translation', plugins_url() . '/wplingua/assets/js/admin/translation.js', array( 'jquery' ), WPLNG_API_VERSION ); /** * Localize script for AJAX */ wp_localize_script( 'wplingua-translation', 'adminAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), ) ); /** * Enqueue wpLingua CSS styles */ wp_enqueue_style( 'wplingua-translation', plugins_url() . '/wplingua/assets/css/admin/translation.css', array(), WPLNG_API_VERSION ); } } /** * Print wpLingua head script (JSON with all languages informations) * * @return void */ function wplng_inline_script_languages() { $languages = array(); $languages_allow = wplng_get_languages_allow(); if ( ! empty( $languages_allow ) && is_array( $languages_allow ) ) { $language_website = wplng_get_language_website(); if ( ! in_array( $language_website, $languages_allow, true ) ) { $languages_allow[] = $language_website; } $languages = $languages_allow; } else { $languages = wplng_get_languages_all(); } ?>