Example #1
0
/**
 * Fix for getting the columns loaded by WordPress SEO Yoast
 *
 * The added columns from WordPress SEO by Yoast weren't available on
 * the admin columns settings page. The reason was that class-metabox.php was prevented
 * from loading. This fix will also load this class when admin columns is loaded.
 *
 * @since 1.4.6
 */
function cpac_pre_load_wordpress_seo_class_metabox()
{
    if (!defined('WPSEO_PATH')) {
        return;
    }
    if (!cac_is_doing_ajax() && !cac_is_setting_screen()) {
        return;
    }
    // Yoast SEO version > 3.0
    if (file_exists(WPSEO_PATH . 'admin/class-meta-columns.php')) {
        require_once WPSEO_PATH . 'admin/class-meta-columns.php';
        if (class_exists('WPSEO_Meta_Columns', false)) {
            $metabox = new WPSEO_Meta_Columns();
            if (method_exists($metabox, 'setup_hooks')) {
                $metabox->setup_hooks();
            }
        }
    }
    // Yoast SEO version < 3.0
    if (file_exists(WPSEO_PATH . 'admin/class-meta-box.php')) {
        require_once WPSEO_PATH . 'admin/class-meta-box.php';
        if (class_exists('WPSEO_Meta_Columns', false)) {
            new WPSEO_Metabox();
        }
    }
}
 /**
  * Whether the current screen is a screen in which Admin Columns is used
  * Used to quickly check whether storage models should be loaded
  *
  * @since 2.2
  * @return bool Whether the current screen is an Admin Columns screen
  */
 public function is_cac_screen()
 {
     /**
      * Filter whether the current screen is a screen in which Admin Columns is active
      *
      * @since 2.2
      *
      * @param bool $is_cac_screen Whether the current screen is an Admin Columns screen
      */
     return apply_filters('cac/is_cac_screen', $this->is_columns_screen() || cac_is_doing_ajax() || $this->is_settings_screen());
 }
 /**
  * Whether this request is an AJAX request and marked as admin-column-ajax request.
  * Mark your admin columns ajax request with plugin_id : 'cpac'.
  *
  * @since 2.0.5
  * @return boolean
  */
 public function is_doing_ajax()
 {
     return cac_is_doing_ajax();
 }