private static function load_custom_columns() { if (self::$custom_columns === null) { $default_apm_columns = array('status' => __('Status', ApmConfig::i18n_domain), 'date' => __('Date', ApmConfig::i18n_domain), 'template' => __('Template', ApmConfig::i18n_domain), 'add_page' => ''); $filtered_columns = apply_filters('apm_manage_pages_columns', $default_apm_columns); //TODO : activate native custom columns hook when a specific APM option is set //$filtered_columns = apply_filters('manage_pages_columns',$filtered_columns); //$filtered_columns = apply_filters('manage_page_posts_columns',$filtered_columns); $default_keys = array_values(array_keys($default_apm_columns)); $filtered_keys = array_values(array_keys($filtered_columns)); //The 4 default columns must still be here AND in the same order : $only_custom_keys = array_values(array_diff($filtered_keys, $default_keys)); if (array_values(array_diff($filtered_keys, $only_custom_keys)) !== $default_keys) { return; } //Memorize the total number of custom columns : self::$nb_custom_columns = count($only_custom_keys); //Init self::$custom_columns : self::$custom_columns = array('before_status' => array(), 'before_date' => array(), 'before_template' => array(), 'before_add_page' => array(), 'after_add_page' => array()); $status_index = array_search('status', $filtered_keys); $date_index = array_search('date', $filtered_keys); $template_index = array_search('template', $filtered_keys); $add_page_index = array_search('add_page', $filtered_keys); $custom_columns_keys = array(); $custom_columns_keys['before_status'] = array_slice($filtered_keys, 0, $status_index); $custom_columns_keys['before_date'] = array_slice($filtered_keys, $status_index + 1, $date_index - $status_index - 1); $custom_columns_keys['before_template'] = array_slice($filtered_keys, $date_index + 1, $template_index - $date_index - 1); $custom_columns_keys['before_add_page'] = array_slice($filtered_keys, $template_index + 1, $add_page_index - $template_index - 1); $custom_columns_keys['after_add_page'] = array_slice($filtered_keys, $add_page_index + 1, count($filtered_keys) - $add_page_index - 1); foreach ($custom_columns_keys as $index => $columns_keys) { if (!empty($columns_keys)) { foreach ($columns_keys as $column_key) { self::$custom_columns[$index][$column_key] = $filtered_columns[$column_key]; } } } } }
//Use 'apm_manage_pages_custom_column' hook to add a column td : ApmCustomColumns::echo_custom_column_td('before_add_page', $node->wp_id, $node); ?> <td> <a href="<?php echo $where_is_page_link; ?> " class="button-secondary action-go-page"><?php _e('Where is it ?', ApmConfig::i18n_domain); ?> </a> </td> <?php //Use 'apm_manage_pages_custom_column' hook to add a column td : ApmCustomColumns::echo_custom_column_td('after_add_page', $node->wp_id, $node); ?> </tr> <?php } ?> <?php $cpt++; ?> <?php } ?> <?php }
?> </span> <span class="sorting-indicator"></span> </a> </th> <?php //Use 'apm_manage_pages_columns' hook to add a column th : ApmCustomColumns::echo_custom_column_th('before_add_page'); ?> <th scope="col" id="add_action" class="manage-column column-models sortable desc"><span></span></th> <?php //Use 'apm_manage_pages_columns' hook to add a column th : ApmCustomColumns::echo_custom_column_th('after_add_page'); ?> </tr> </tfoot> </table> </div> <div class="tablenav bottom"> <?php echo get_template_pagination('bottom'); ?> <?php if ($is_browse) { ?> <div class="container-pagination-browse"> <span class="displaying-num nb-selected-rows">0</span> <span class="displaying-num"><?php
<td><input type="submit" name="" class="button-secondary action-add-page" value="<?php _e('Add New', ApmConfig::i18n_domain); ?> "></td> <?php //Use 'apm_manage_pages_custom_column' hook to add a column td : ApmCustomColumns::echo_custom_column_td('after_add_page', $node->wp_id, $node); ?> <?php } else { ?> <td colspan="<?php echo 3 + ApmCustomColumns::get_nb_custom_columns(); ?> "></td> <?php } ?> </tr> <?php } ?> <?php } ?>