Ejemplo n.º 1
0
/**
 * Is doing ajax
 *
 * @since 2.3.4
 */
function cac_is_doing_ajax()
{
    if (!defined('DOING_AJAX') || !DOING_AJAX) {
        return false;
    }
    $is_doing_ajax = cac_wp_is_doing_ajax() || isset($_REQUEST['storage_model']);
    return apply_filters('cac/is_doing_ajax', $is_doing_ajax);
}
Ejemplo n.º 2
0
 /**
  * Only set columns on current screens or on specific ajax calls
  *
  * @since 2.4.9
  */
 public function set_columns()
 {
     // Listings screen
     $storage_model = $this->get_current_storage_model();
     // WP Ajax calls (not AC)
     if ($model = cac_wp_is_doing_ajax()) {
         $storage_model = $this->get_storage_model($model);
     }
     if ($storage_model) {
         $storage_model->init_layout();
         $storage_model->init_manage_columns();
     }
 }
Ejemplo n.º 3
0
 /**
  * @since 2.0
  */
 public function add_headings($columns)
 {
     if (empty($columns)) {
         return $columns;
     }
     // for the rare case where a screen hasn't been set yet and a
     // plugin uses a custom version of apply_filters( "manage_{$screen->id}_columns", array() )
     if (!get_current_screen() && !cac_wp_is_doing_ajax()) {
         return $columns;
     }
     // Stores the default columns on the listings screen
     $this->store_default_columns($columns);
     // make sure we run this only once
     if ($this->column_headings) {
         return $this->column_headings;
     }
     $stored_columns = $this->get_stored_columns();
     if (!$stored_columns) {
         return $columns;
     }
     $this->column_headings = array();
     // add mandatory checkbox
     if (isset($columns['cb'])) {
         $this->column_headings['cb'] = $columns['cb'];
     }
     $types = array_keys($this->get_column_types());
     // add active stored headings
     foreach ($stored_columns as $column_name => $options) {
         // Label needs stripslashes() for HTML tagged labels, like icons and checkboxes
         $label = stripslashes($options['label']);
         // Remove 3rd party columns that are no longer available (deactivated or removed from code)
         if (!in_array($options['type'], $types)) {
             continue;
         }
         /**
          * Filter the stored column headers label for use in a WP_List_Table
          * Label needs stripslashes() for HTML tagged labels, like icons and checkboxes
          *
          * @since 2.0
          *
          * @param string $label Label
          * @param string $column_name Column name
          * @param array $options Column options
          * @param CPAC_Storage_Model $storage_model Storage model class instance
          */
         $label = apply_filters('cac/headings/label', $label, $column_name, $options, $this);
         $label = str_replace('[cpac_site_url]', site_url(), $label);
         $this->column_headings[$column_name] = $label;
     }
     // Add 3rd party columns that have ( or could ) not been stored.
     // For example when a plugin has been activated after storing column settings.
     // When $diff contains items, it means an available column has not been stored.
     if (!$this->is_using_php_export() && ($diff = array_diff(array_keys($columns), array_keys((array) $this->get_default_stored_columns())))) {
         foreach ($diff as $column_name) {
             $this->column_headings[$column_name] = $columns[$column_name];
         }
     }
     return $this->column_headings;
 }