예제 #1
0
 private function get_column_headers($omit_checkbox = true)
 {
     if (!empty($this->column_headers)) {
         $headers = $this->column_headers;
     } else {
         // If we're nuking the existing columns, still provide checkboxes
         if ($this->override) {
             $headers = array('cb' => '<input type="checkbox" />');
         } else {
             // Cause infinite loops get boring after a while
             remove_filter('manage_' . $this->post_type . '_posts_columns', array($this, 'column_headers'));
             $this->load_list_table();
             $list = new WP_Posts_List_Table();
             $headers = $list->get_columns();
             add_filter('manage_' . $this->post_type . '_posts_columns', array($this, 'column_headers'));
         }
         foreach ($this->columns as $key => $value) {
             $headers[$key] = $value['name'];
         }
         $this->column_headers = $headers;
     }
     if ($omit_checkbox && isset($headers['cb'])) {
         unset($headers['cb']);
     }
     return $headers;
 }
 /**
  * 	Get WP default supported admin columns per post type.
  *
  * 	@since     1.0
  */
 private function get_wp_default_posts_columns($post_type = 'post')
 {
     // You can use this filter to add thirdparty columns by hooking into this. See classes/third_party.php for an example.
     do_action('cpac-get-default-columns-posts', $post_type);
     // some plugins directly hook into get_column_headers, such as woocommerce
     $columns = get_column_headers('edit-' . $post_type);
     // get default columns
     if (empty($columns)) {
         // deprecated as of wp3.3
         if (file_exists(ABSPATH . 'wp-admin/includes/template.php')) {
             require_once ABSPATH . 'wp-admin/includes/template.php';
         }
         // introduced since wp3.3
         if (file_exists(ABSPATH . 'wp-admin/includes/screen.php')) {
             require_once ABSPATH . 'wp-admin/includes/screen.php';
         }
         // used for getting columns
         if (file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php')) {
             require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
         }
         if (file_exists(ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php')) {
             require_once ABSPATH . 'wp-admin/includes/class-wp-posts-list-table.php';
         }
         // As of WP Release 3.5 we can use the following.
         if (version_compare(get_bloginfo('version'), '3.4.10', '>=')) {
             $table = new WP_Posts_List_Table(array('screen' => $post_type));
             $columns = $table->get_columns();
         } else {
             // we need to change the current screen... first lets save original
             $org_current_screen = $current_screen;
             // prevent php warning
             if (!isset($current_screen)) {
                 $current_screen = new stdClass();
             }
             // overwrite current_screen global with our post type of choose...
             $current_screen->post_type = $post_type;
             // ...so we can get its columns
             $columns = WP_Posts_List_Table::get_columns();
             // reset current screen
             $current_screen = $org_current_screen;
         }
     }
     if (empty($columns)) {
         return false;
     }
     // change to uniform format
     $columns = $this->get_uniform_format($columns);
     // add sorting to some of the default links columns
     $columns = $this->set_sorting_to_default_posts_columns($columns);
     return $columns;
 }