Esempio n. 1
0
 /**
  * For WP versions older than 4.2, this includes styles and a script to make notices dismissible.
  */
 public function enqueue_dismissible()
 {
     if (version_compare($GLOBALS['wp_version'], '4.2', '<')) {
         $this->asset_manager->enqueue_script('dismissable');
         $this->asset_manager->enqueue_style('dismissable');
     }
 }
 /**
  * Enqueue's stylesheet for the dashboard if the current page is the dashboard
  */
 public function enqueue_dashboard_stylesheet()
 {
     $current_screen = get_current_screen();
     if ($current_screen instanceof WP_Screen && 'dashboard' === $current_screen->id) {
         $asset_manager = new WPSEO_Admin_Asset_Manager();
         $asset_manager->enqueue_style('wp-dashboard');
     }
 }
Esempio n. 3
0
 /**
  * Adds our inside the editor CSS file to the list of CSS files to be loaded inside the editor.
  *
  * @param string $css_files The CSS files that WordPress wants to load inside the editor.
  * @return string The CSS files WordPress wants to load and our CSS file.
  */
 public function add_css_inside_editor($css_files)
 {
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $styles = $asset_manager->special_styles();
     /** @var WPSEO_Admin_Asset $inside_editor */
     $inside_editor = $styles['inside-editor'];
     $url = $inside_editor->get_url(WPSEO_Admin_Asset::TYPE_CSS, WPSEO_FILE);
     if ('' === $css_files) {
         $css_files = $url;
     } else {
         $css_files .= ',' . $url;
     }
     return $css_files;
 }
Esempio n. 4
0
 /**
  * Queue assets for taxonomy screens.
  *
  * @since 1.5.0
  */
 public function admin_enqueue_scripts()
 {
     $pagenow = $GLOBALS['pagenow'];
     if (!(self::is_term_edit($pagenow) || self::is_term_overview($pagenow))) {
         return;
     }
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $asset_manager->enqueue_style('scoring');
     $tag_id = filter_input(INPUT_GET, 'tag_ID');
     if (self::is_term_edit($pagenow) && !empty($tag_id)) {
         wp_enqueue_media();
         // Enqueue files needed for upload functionality.
         $asset_manager->enqueue_style('metabox-css');
         $asset_manager->enqueue_style('snippet');
         $asset_manager->enqueue_style('scoring');
         wp_editor('', 'description');
         $asset_manager->enqueue_script('metabox');
         $asset_manager->enqueue_script('term-scraper');
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'term-scraper', 'wpseoTermScraperL10n', $this->localize_term_scraper_script());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'replacevar-plugin', 'wpseoReplaceVarsL10n', $this->localize_replace_vars_script());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'metabox', 'wpseoSelect2Locale', substr(get_locale(), 0, 2));
         $asset_manager->enqueue_script('admin-media');
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-media', 'wpseoMediaL10n', array('choose_image' => __('Use Image', 'wordpress-seo')));
     }
 }
 /**
  * Enqueues the assets needed for the wizard.
  */
 public function enqueue_assets()
 {
     wp_enqueue_media();
     /*
      * Print the `forms.css` WP stylesheet before any Yoast style, this way
      * it's easier to override selectors with the same specificity later.
      */
     wp_enqueue_style('forms');
     $assetManager = new WPSEO_Admin_Asset_Manager();
     $assetManager->register_assets();
     $assetManager->enqueue_script('configuration-wizard');
     $assetManager->enqueue_style('yoast-components');
     $config = $this->get_config();
     wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'configuration-wizard', 'yoastWizardConfig', $config);
 }
 /**
  * Enqueues all the assets needed for the primary term interface
  *
  * @return void
  */
 public function enqueue_assets()
 {
     global $pagenow;
     if (!WPSEO_Metabox::is_post_edit($pagenow)) {
         return;
     }
     $taxonomies = $this->get_primary_term_taxonomies();
     // Only enqueue if there are taxonomies that need a primary term.
     if (empty($taxonomies)) {
         return;
     }
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $asset_manager->enqueue_style('primary-category');
     $asset_manager->enqueue_script('primary-category');
     $taxonomies = array_map(array($this, 'map_taxonomies_for_js'), $taxonomies);
     $data = array('taxonomies' => $taxonomies);
     wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'primary-category', 'wpseoPrimaryCategoryL10n', $data);
 }
Esempio n. 7
0
 /**
  * Enqueues and handles all the tool dependencies.
  */
 private function enqueue_tools_scripts()
 {
     $tool = filter_input(INPUT_GET, 'tool');
     if (empty($tool)) {
         $this->asset_manager->enqueue_script('yoast-seo');
     }
     if ('bulk-editor' === $tool) {
         $this->asset_manager->enqueue_script('bulk-editor');
     }
 }
 /**
  * Enqueues and handles all the tool dependencies.
  */
 private function enqueue_tools_scripts()
 {
     $tool = filter_input(INPUT_GET, 'tool');
     if (empty($tool)) {
         $this->asset_manager->enqueue_script('yoast-seo');
     }
     if ('bulk-editor' === $tool) {
         $this->asset_manager->enqueue_script('bulk-editor');
     }
     if ('import-export' === $tool && filter_input(INPUT_POST, WPSEO_Export::NONCE_NAME) !== null) {
         $this->do_yoast_export();
     }
 }
Esempio n. 9
0
 /**
  * Loads the required scripts for the config page.
  */
 function config_page_scripts()
 {
     $this->asset_manager->enqueue_script('admin-script');
     wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-script', 'wpseoAdminL10n', $this->localize_admin_script());
     wp_enqueue_script('dashboard');
     wp_enqueue_script('thickbox');
     $page = filter_input(INPUT_GET, 'page');
     $tool = filter_input(INPUT_GET, 'tool');
     wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-script', 'wpseoSelect2Locale', substr(get_locale(), 0, 2));
     if (in_array($page, array('wpseo_social', 'wpseo_dashboard'))) {
         wp_enqueue_media();
         $this->asset_manager->enqueue_script('admin-media');
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-media', 'wpseoMediaL10n', $this->localize_media_script());
     }
     if ('wpseo_tools' === $page && empty($tool)) {
         $this->asset_manager->enqueue_script('yoast-seo');
     }
     if ('wpseo_tools' === $page && 'bulk-editor' === $tool) {
         $this->asset_manager->enqueue_script('bulk-editor');
     }
     if ('wpseo_tools' === $page && 'import-export' === $tool) {
         $this->asset_manager->enqueue_script('export');
     }
 }
/**
 * Enqueue CSS to format the Yoast SEO adminbar item.
 */
function wpseo_admin_bar_style()
{
    if (!is_admin_bar_showing()) {
        return;
    }
    $asset_manager = new WPSEO_Admin_Asset_Manager();
    $asset_manager->register_assets();
    $asset_manager->enqueue_style('adminbar');
}
/**
 * Enqueue a tiny bit of CSS to show so the adminbar shows right.
 */
function wpseo_admin_bar_style()
{
    $enqueue_style = false;
    // Single post in the frontend.
    if (!is_admin() && is_admin_bar_showing()) {
        $enqueue_style = is_singular() || is_category();
    }
    // Single post in the backend.
    if (is_admin()) {
        $screen = get_current_screen();
        // Post (every post_type) or category page.
        if ('post' === $screen->base || 'edit-tags' === $screen->base) {
            $enqueue_style = true;
        }
    }
    if ($enqueue_style) {
        $asset_manager = new WPSEO_Admin_Asset_Manager();
        $asset_manager->register_assets();
        $asset_manager->enqueue_style('adminbar');
    }
}
Esempio n. 12
0
 /**
  * Load the admin redirects scripts
  */
 public function page_scripts()
 {
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $asset_manager->enqueue_script('admin-gsc');
     $asset_manager->enqueue_style('metabox-css');
     add_screen_option('per_page', array('label' => __('Crawl errors per page', 'wordpress-seo'), 'default' => 50, 'option' => 'errors_per_page'));
 }
Esempio n. 13
0
 /**
  * Enqueues the (tiny) global stylesheet needed for the plugin.
  */
 public function enqueue_global_style()
 {
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $asset_manager->enqueue_style('admin-global');
 }
 /**
  * Run the localize script.
  */
 public function recalculate_assets()
 {
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $asset_manager->enqueue_script('recalculate');
 }
Esempio n. 15
0
 /**
  * Enqueue our styling for dismissible yoast notifications.
  */
 public function enqueue_dismissible()
 {
     $this->asset_manager->enqueue_style('dismissible');
 }
Esempio n. 16
0
 /**
  * Enqueues all the needed JS and CSS.
  *
  * @todo [JRF => whomever] create css/metabox-mp6.css file and add it to the below allowed colors array when done
  */
 public function enqueue()
 {
     global $pagenow;
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $is_editor = self::is_post_overview($pagenow) || self::is_post_edit($pagenow);
     /* Filter 'wpseo_always_register_metaboxes_on_admin' documented in wpseo-main.php */
     if (!$is_editor && apply_filters('wpseo_always_register_metaboxes_on_admin', false) === false || $this->is_metabox_hidden() === true) {
         return;
     }
     if (self::is_post_overview($pagenow)) {
         $asset_manager->enqueue_style('edit-page');
     } else {
         if (0 != get_queried_object_id()) {
             wp_enqueue_media(array('post' => get_queried_object_id()));
             // Enqueue files needed for upload functionality.
         }
         $asset_manager->enqueue_style('metabox-css');
         $asset_manager->enqueue_style('scoring');
         $asset_manager->enqueue_style('snippet');
         $asset_manager->enqueue_style('select2');
         $asset_manager->enqueue_style('kb-search');
         $asset_manager->enqueue_script('metabox');
         $asset_manager->enqueue_script('admin-media');
         $asset_manager->enqueue_script('post-scraper');
         $asset_manager->enqueue_script('replacevar-plugin');
         $asset_manager->enqueue_script('shortcode-plugin');
         wp_enqueue_script('jquery-ui-autocomplete');
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-media', 'wpseoMediaL10n', $this->localize_media_script());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'post-scraper', 'wpseoPostScraperL10n', $this->localize_post_scraper_script());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'replacevar-plugin', 'wpseoReplaceVarsL10n', $this->localize_replace_vars_script());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'shortcode-plugin', 'wpseoShortcodePluginL10n', $this->localize_shortcode_plugin_script());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'metabox', 'wpseoAdminL10n', WPSEO_Help_Center::get_translated_texts());
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'metabox', 'wpseoSelect2Locale', WPSEO_Utils::get_language(get_locale()));
         if (post_type_supports(get_post_type(), 'thumbnail')) {
             $asset_manager->enqueue_style('featured-image');
             $asset_manager->enqueue_script('featured-image');
             $featured_image_l10 = array('featured_image_notice' => __('The featured image should be at least 200x200 pixels to be picked up by Facebook and other social media sites.', 'wordpress-seo'));
             wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'metabox', 'wpseoFeaturedImageL10n', $featured_image_l10);
         }
     }
 }
Esempio n. 17
0
 /**
  * Enqueues the (tiny) global JS needed for the plugin.
  */
 function config_page_scripts()
 {
     if (WPSEO_Utils::grant_access()) {
         $asset_manager = new WPSEO_Admin_Asset_Manager();
         $asset_manager->enqueue_script('admin-global-script');
         wp_localize_script(WPSEO_Admin_Asset_Manager::PREFIX . 'admin-global-script', 'wpseoAdminGlobalL10n', $this->localize_admin_global_script());
     }
 }
Esempio n. 18
0
 /**
  * Enqueue assets
  */
 public function enqueue_assets()
 {
     $asset_manager = new WPSEO_Admin_Asset_Manager();
     $asset_manager->enqueue_style('alerts');
 }