function get_column_info() { $columns = get_column_headers($this->_screen); $hidden = get_hidden_columns($this->_screen); $sortable = array(); return array($columns, $hidden, $sortable); }
/** * @access protected * * @return array */ protected function get_column_info() { $columns = get_column_headers($this->_screen); $hidden = get_hidden_columns($this->_screen); $sortable = array(); $primary = $this->get_default_primary_column_name(); return array($columns, $hidden, $sortable, $primary); }
/** * Gets the name of the primary column in the Entries screen * * @since 2.0.14 * * @return string $primary_column */ protected function get_primary_column_name() { $columns = get_column_headers($this->screen); $hidden = get_hidden_columns($this->screen); $primary_column = ''; foreach ($columns as $column_key => $column_display_name) { if ('cb' != $column_key && !in_array($column_key, $hidden)) { $primary_column = $column_key; break; } } return $primary_column; }
/** * @see CPAC_Type::get_default_columns() */ public function get_default_columns() { if (!function_exists('_get_list_table')) { return array(); } // You can use this filter to add third_party columns by hooking into this. do_action("cac/columns/default/storage_key={$this->key}"); // get columns $table = _get_list_table('WP_Users_List_Table', array('screen' => 'users')); $columns = (array) $table->get_columns(); if ($this->is_settings_page()) { $columns = array_merge(get_column_headers('users'), $columns); } return $columns; }
public function get_default_columns() { if (!function_exists('_get_list_table')) { return array(); } // You can use this filter to add thirdparty columns by hooking into this. // See classes/third_party.php for an example. do_action("cac/columns/default/storage_key={$this->key}"); $table = _get_list_table('WP_Media_List_Table', array('screen' => 'upload')); $columns = (array) $table->get_columns(); if (cac_is_setting_screen()) { $columns = array_merge(get_column_headers('upload'), $columns); } return $columns; }
} ?> <?php $this->notices(); ?> <?php ShoppScreenOrders::navigation(); ?> <br class="clear" /> <?php $totalsedit = isset($_GET['edit']) && 'totals' == $_GET['edit']; $columns = get_column_headers($this->id); $hidden = get_hidden_columns($this->id); $colspan = count($columns); ?> <div id="order"> <div class="title"> <div id="titlewrap"> <span class="date"><?php $datetime = $Purchase->exists() ? $Purchase->created : current_time('timestamp'); echo Shopp::_d(get_option('date_format'), $datetime); ?> <small><?php echo date(get_option('time_format'), $datetime); ?> </small>
<br class="clear" /> </div> <div class="clear"></div> <?php if ('all' == $cat_id) { $cat_id = ''; } $args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0); if (!empty($_GET['s'])) { $args['search'] = $_GET['s']; } $links = get_bookmarks($args); if ($links) { $link_columns = get_column_headers('link-manager'); $hidden = get_hidden_columns('link-manager'); ?> <?php wp_nonce_field('bulk-bookmarks'); ?> <table class="widefat fixed" cellspacing="0"> <thead> <tr> <?php print_column_headers('link-manager'); ?> </tr> </thead>
/** * Get a list of all, hidden and sortable columns, with filter applied * * @since 3.1.0 * @access protected * * @return array */ function get_column_info() { if (isset($this->_column_headers)) { return $this->_column_headers; } $columns = get_column_headers($this->screen); $hidden = get_hidden_columns($this->screen); $sortable_columns = $this->get_sortable_columns(); /** * Filter the list table sortable columns for a specific screen. * * The dynamic portion of the hook name, $this->screen->id, refers * to the ID of the current screen, usually a string. * * @since 3.5.0 * * @param array $sortable_columns An array of sortable columns. */ $_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns); $sortable = array(); foreach ($_sortable as $id => $data) { if (empty($data)) { continue; } $data = (array) $data; if (!isset($data[1])) { $data[1] = false; } $sortable[$id] = $data; } $this->_column_headers = array($columns, $hidden, $sortable); return $this->_column_headers; }
/** * Output JSON for the children of a node * $arrOpenChilds = array with id of pages to open children on */ function cms_tpv_print_childs($pageID, $view = "all", $arrOpenChilds = null, $post_type) { $arrPages = cms_tpv_get_pages("parent={$pageID}&view={$view}&post_type={$post_type}"); if ($arrPages) { global $current_screen; $screen = convert_to_screen("edit"); #return; // If this is set to null then quick/bul edit stops working on posts (not pages) // If did set it to null sometime. Can't remember why... // $screen->post_type = null; $post_type_object = get_post_type_object($post_type); ob_start(); // some plugins, for example magic fields, return javascript and things here. we're not compatible with that, so just swallow any output $posts_columns = get_column_headers($screen); ob_get_clean(); unset($posts_columns["cb"], $posts_columns["title"], $posts_columns["author"], $posts_columns["categories"], $posts_columns["tags"], $posts_columns["date"]); global $post; // Translated post statuses $post_statuses = get_post_statuses(); ?> [<?php for ($i = 0, $pagesCount = sizeof($arrPages); $i < $pagesCount; $i++) { $onePage = $arrPages[$i]; $tmpPost = $post; $post = $onePage; $page_id = $onePage->ID; $arrChildPages = NULL; $editLink = get_edit_post_link($onePage->ID, 'notDisplay'); $content = esc_html($onePage->post_content); $content = str_replace(array("\n", "\r"), "", $content); $hasChildren = false; // if viewing trash, don't get children. we watch them "flat" instead if ($view == "trash") { } else { $arrChildPages = cms_tpv_get_pages("parent={$onePage->ID}&view={$view}&post_type={$post_type}"); } if (!empty($arrChildPages)) { $hasChildren = true; } // if no children, output no state $strState = '"state": "closed",'; if (!$hasChildren) { $strState = ''; } // type of node $rel = $onePage->post_status; if ($onePage->post_password) { $rel = "password"; } // modified time $post_modified_time = strtotime($onePage->post_modified); $post_modified_time = date_i18n(get_option('date_format'), $post_modified_time, false); // last edited by setup_postdata($post); $post_author = cms_tpv_get_the_modified_author(); if (empty($post_author)) { $post_author = __("Unknown user", 'cms-tree-page-view'); } $title = get_the_title($onePage->ID); // so hooks and stuff will do their work $title = apply_filters("cms_tree_page_view_post_title", $title, $onePage); if (empty($title)) { $title = __("<Untitled page>", 'cms-tree-page-view'); } $arr_page_css_styles = array(); $user_can_edit_page = apply_filters("cms_tree_page_view_post_can_edit", current_user_can($post_type_object->cap->edit_post, $page_id), $page_id); $user_can_add_inside = apply_filters("cms_tree_page_view_post_user_can_add_inside", current_user_can($post_type_object->cap->create_posts, $page_id), $page_id); $user_can_add_after = apply_filters("cms_tree_page_view_post_user_can_add_after", current_user_can($post_type_object->cap->create_posts, $page_id), $page_id); if ($user_can_edit_page) { $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_yes"; } else { $arr_page_css_styles[] = "cms_tpv_user_can_edit_page_no"; } if ($user_can_add_inside) { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_yes"; } else { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_inside_no"; } if ($user_can_add_after) { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_yes"; } else { $arr_page_css_styles[] = "cms_tpv_user_can_add_page_after_no"; } $page_css = join(" ", $arr_page_css_styles); // fetch columns $str_columns = ""; foreach ($posts_columns as $column_name => $column_display_name) { $col_name = $column_display_name; if ($column_name == "comments") { $col_name = __("Comments"); } $str_columns .= "<dt>{$col_name}</dt>"; $str_columns .= "<dd>"; if ($column_name == "comments") { $str_columns .= '<div class="post-com-count-wrapper">'; $left = get_pending_comments_num($onePage->ID); $pending_phrase = sprintf(__('%s pending'), number_format($left)); $pending_phrase2 = ""; if ($left) { $pending_phrase2 = " + {$left} " . __("pending"); } if ($left) { $str_columns .= '<strong>'; } ob_start(); comments_number("<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}'><span>" . _x('0', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('1', 'comment count') . "{$pending_phrase2}</span></a>", "<a href='edit-comments.php?p={$page_id}' title='{$pending_phrase}' class=''><span class=''>" . _x('%', 'comment count') . "{$pending_phrase2}</span></a>"); $str_columns .= ob_get_clean(); if ($left) { $str_columns .= '</strong>'; } $str_columns .= "</div>"; } else { ob_start(); do_action('manage_pages_custom_column', $column_name, $onePage->ID); $str_columns .= ob_get_clean(); } $str_columns .= "</dd>"; } if ($str_columns) { $str_columns = "<dl>{$str_columns}</dl>"; } $str_columns = json_encode($str_columns); ?> { "data": { "title": <?php echo json_encode($title); ?> , "attr": { "href": "<?php echo $editLink; ?> " <?php /* , "xid": "cms-tpv-<?php echo $onePage->ID ?>" */ ?> }<?php /*, "xicon": "<?php echo CMS_TPV_URL . "images/page_white_text.png" ?>"*/ ?> }, "attr": { <?php /* "xhref": "<?php echo $editLink ?>", */ ?> "id": "cms-tpv-<?php echo $onePage->ID; ?> ", <?php /* "xtitle": "<?php _e("Click to edit. Drag to move.", 'cms-tree-page-view') ?>", */ ?> "class": "<?php echo $page_css; ?> " }, <?php echo $strState; ?> "metadata": { "id": "cms-tpv-<?php echo $onePage->ID; ?> ", "post_id": "<?php echo $onePage->ID; ?> ", "post_type": "<?php echo $onePage->post_type; ?> ", "post_status": "<?php echo $onePage->post_status; ?> ", "post_status_translated": "<?php echo isset($post_statuses[$onePage->post_status]) ? $post_statuses[$onePage->post_status] : $onePage->post_status; ?> ", "rel": "<?php echo $rel; ?> ", "childCount": <?php echo !empty($arrChildPages) ? sizeof($arrChildPages) : 0; ?> , "permalink": "<?php echo htmlspecialchars_decode(get_permalink($onePage->ID)); ?> ", "editlink": "<?php echo htmlspecialchars_decode($editLink); ?> ", "modified_time": "<?php echo $post_modified_time; ?> ", "modified_author": "<?php echo $post_author; ?> ", "columns": <?php echo $str_columns; ?> , "user_can_edit_page": "<?php echo (int) $user_can_edit_page; ?> ", "user_can_add_page_inside": "<?php echo (int) $user_can_add_inside; ?> ", "user_can_add_page_after": "<?php echo (int) $user_can_add_after; ?> ", "post_title": <?php echo json_encode($title); ?> } <?php // if id is in $arrOpenChilds then also output children on this one // TODO: if only "a few" (< 100?) pages then load all, but keep closed, so we don't have to do the ajax thingie if ($hasChildren && isset($arrOpenChilds) && in_array($onePage->ID, $arrOpenChilds)) { ?> , "children": <?php cms_tpv_print_childs($onePage->ID, $view, $arrOpenChilds, $post_type); } ?> } <?php // no comma for last page if ($i < $pagesCount - 1) { ?> ,<?php } // return orgiginal post $post = $tmpPost; } ?> ]<?php } }
function get_column_info() { $columns = get_column_headers($this->_screen); $hidden = get_hidden_columns($this->_screen); $_sortable = $this->get_sortable_columns(); foreach ($_sortable as $id => $data) { if (empty($data)) { continue; } $data = (array) $data; if (!isset($data[1])) { $data[1] = false; } $sortable[$id] = $data; } return array($columns, $hidden, $sortable); }
/** * Outputs <td> tags based on an array of cell data. * * @since 2.1 * * @param $headers Array of (CSS class => Cell data) */ function table_cells($cells) { if (count($this->get_admin_table_columns())) { $columns = get_column_headers($this->plugin_page_hook); $hidden = get_hidden_columns($this->plugin_page_hook); foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = in_array($column_name, $hidden) ? ' style="display:none;"' : ''; echo "\t\t<td {$class}{$style}>" . $cells[$column_name] . "</td>\n"; } } elseif (is_array($cells) && count($cells)) { foreach ($cells as $class => $content) { $class = is_numeric($class) ? '' : " class='su-{$class}'"; echo "\t\t<td{$class}>{$content}</td>\n"; } } }
/** * prints the individual row * * @param object $post * @param int $comment_pending_count * @param string $mode */ protected function _manage_row($post, $comment_pending_count, $mode) { static $rowclass; $global_post = $post; setup_postdata($post); $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; $current_user = wp_get_current_user(); $post_owner = $current_user->ID == $post->post_author ? 'self' : 'other'; $edit_link = get_edit_post_link($post->ID); $title = _draft_or_post_title($post->ID); ?> <tr id='post-<?php echo $post->ID; ?> ' class='<?php echo trim($rowclass . ' author-' . $post_owner . ' status-' . $post->post_status); ?> iedit' valign="top"> <?php $posts_columns = get_column_headers($this->get_content_type()); $hidden = get_hidden_columns($this->get_content_type()); foreach ($posts_columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': ?> <th scope="row" class="check-column"><?php if (current_user_can('edit_post', $post->ID)) { ?> <input type="checkbox" name="post[]" value="<?php the_ID(); ?> " /><?php } ?> </th> <?php break; //end case 'cb' //end case 'cb' case 'date': if ('0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name) { $t_time = $h_time = __('Unpublished'); $time_diff = 0; } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } echo '<td ' . $attributes . '>'; if ('excerpt' == $mode) { echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); } else { echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; } echo '<br />'; if ('publish' == $post->post_status) { _e('Published'); } elseif ('future' == $post->post_status) { if ($time_diff > 0) { echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; } else { _e('Scheduled'); } } else { _e('Last Modified'); } echo '</td>'; break; //end case 'date' //end case 'date' case 'title': $attributes = 'class="post-title column-title"' . $style; ?> <td <?php echo $attributes; ?> ><strong><?php if (current_user_can('edit_post', $post->ID) && $post->post_status != 'trash') { ?> <a class="row-title" href="<?php echo $edit_link; ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?> "><?php echo $title; ?> </a><?php } else { echo $title; } _post_states($post); ?> </strong> <?php if ('excerpt' == $mode) { the_excerpt(); } $actions = array(); if ('trash' == $post->post_status && current_user_can('delete_post', $post->ID)) { $actions['untrash'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&post={$post->ID}", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>"; $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post={$post->ID}", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; } else { if (current_user_can('edit_post', $post->ID)) { $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; //removing quickedit for now //$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>'; } if (current_user_can('delete_post', $post->ID) && function_exists('wp_trash_post')) { $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=trash&post={$post->ID}", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>"; } else { $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&post={$post->ID}", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; } if (in_array($post->post_status, array('pending', 'draft'))) { if (current_user_can('edit_post', $post->ID)) { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; } } else { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; } } $actions = apply_filters('post_row_actions', $actions, $post); $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; get_inline_data($post); ?> </td> <?php break; //end case 'title' //end case 'title' case 'categories': ?> <td <?php echo $attributes; ?> ><?php $categories = get_the_category(); if (!empty($categories)) { $out = array(); foreach ($categories as $c) { $out[] = "<a href='edit.php?category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; } echo join(', ', $out); } else { _e('Uncategorized'); } ?> </td> <?php break; //end case 'categories' //end case 'categories' case 'tags': ?> <td <?php echo $attributes; ?> ><?php $tags = get_the_tags($post->ID); if (!empty($tags)) { $out = array(); foreach ($tags as $c) { $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; } echo join(', ', $out); } else { _e('No Tags'); } ?> </td> <?php break; //end case 'tags' //end case 'tags' case 'comments': ?> <td <?php echo $attributes; ?> > <div class="post-com-count-wrapper"> <?php if (!isset($pending_comments)) { $pending_comments = 0; } $pending_phrase = sprintf(__('%s pending'), number_format($pending_comments)); if ($pending_comments) { echo '<strong>'; } comments_number("<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count') . '</span></a>'); if ($pending_comments) { echo '</strong>'; } ?> </div> </td> <?php break; //end case 'comments' //end case 'comments' case 'author': ?> <td <?php echo $attributes; ?> ><a href="edit.php?author=<?php the_author_meta('ID'); ?> "><?php the_author(); ?> </a></td> <?php break; //end case 'author' //end case 'author' case 'control_view': ?> <td><a href="<?php the_permalink(); ?> " rel="permalink" class="view"><?php _e('View'); ?> </a></td> <?php break; //end case 'control_view' //end case 'control_view' case 'control_edit': ?> <td><?php if (current_user_can('edit_post', $post->ID)) { echo "<a href='{$edit_link}' class='edit'>" . __('Edit') . "</a>"; } ?> </td> <?php break; //end case 'control_edit' //end case 'control_edit' case 'control_delete': ?> <td><?php if (current_user_can('delete_post', $post->ID)) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post={$post->ID}", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?> </td> <?php break; //end case 'control_delete //end case 'control_delete default: ?> <td <?php echo $attributes; ?> ><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?> </td> <?php break; } } ?> </tr> <?php $post = $global_post; }
function screen_meta($screen) { global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options; if (is_string($screen)) { $screen = convert_to_screen($screen); } $columns = get_column_headers($screen); $hidden = get_hidden_columns($screen); $meta_screens = array('index' => 'dashboard'); if (isset($meta_screens[$screen->id])) { $screen->id = $meta_screens[$screen->id]; $screen->base = $screen->id; } $show_screen = false; if (!empty($wp_meta_boxes[$screen->id]) || !empty($columns)) { $show_screen = true; } $screen_options = screen_options($screen); if ($screen_options) { $show_screen = true; } if (!isset($_wp_contextual_help)) { $_wp_contextual_help = array(); } $settings = apply_filters('screen_settings', '', $screen); switch ($screen->id) { case 'widgets': $settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n"; $show_screen = true; break; } if (!empty($settings)) { $show_screen = true; } if (!empty($wp_current_screen_options)) { $show_screen = true; } $show_screen = apply_filters('screen_options_show_screen', $show_screen, $screen); ?> <div id="screen-meta"> <?php if ($show_screen) { ?> <div id="screen-options-wrap" class="hidden"> <form id="adv-settings" action="" method="post"> <?php if (isset($wp_meta_boxes[$screen->id])) { ?> <h5><?php _ex('Show on screen', 'Metaboxes'); ?> </h5> <div class="metabox-prefs"> <?php meta_box_prefs($screen); ?> <br class="clear" /> </div> <?php } if (!empty($columns)) { ?> <h5><?php echo isset($columns['_title']) ? $columns['_title'] : _x('Show on screen', 'Columns'); ?> </h5> <div class="metabox-prefs"> <?php $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); foreach ($columns as $column => $title) { // Can't hide these for they are special if (in_array($column, $special)) { continue; } if (empty($title)) { continue; } if ('comments' == $column) { $title = __('Comments'); } $id = "{$column}-hide"; echo '<label for="' . $id . '">'; echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked(!in_array($column, $hidden), true, false) . ' />'; echo "{$title}</label>\n"; } ?> <br class="clear" /> </div> <?php } echo screen_layout($screen); if (!empty($screen_options)) { ?> <h5><?php _ex('Show on screen', 'Screen Options'); ?> </h5> <?php } echo $screen_options; echo $settings; ?> <div><?php wp_nonce_field('screen-options-nonce', 'screenoptionnonce', false); ?> </div> </form> </div> <?php } // $show_screen $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); ?> <div id="contextual-help-wrap" class="hidden"> <?php $contextual_help = ''; if (isset($_wp_contextual_help[$screen->id])) { $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen->id] . "</div>\n"; } else { $contextual_help .= '<div class="metabox-prefs">'; $default_help = __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>'); $default_help .= '<br />'; $default_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>'); $contextual_help .= apply_filters('default_contextual_help', $default_help); $contextual_help .= "</div>\n"; } echo apply_filters('contextual_help', $contextual_help, $screen->id, $screen); ?> </div> <div id="screen-meta-links"> <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help'); ?> </a> </div> <?php if ($show_screen) { ?> <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options'); ?> </a> </div> <?php } ?> </div> </div> <?php }
function prepare_items() { global $wpdb, $sll; //get number of successful and failed logins so we can display them in parentheces for each view //building a WHERE SQL query for each view $where = $sll->make_where_query(); //we only need the date filter, everything else need to be unset if (is_array($where) && isset($where['datefilter'])) { $where = array('datefilter' => $where['datefilter']); } else { $where = false; } $where3 = $where2 = $where1 = $where; $where2['login_result'] = "login_result = '1'"; $where3['login_result'] = "login_result = '0'"; if (is_array($where1) && !empty($where1)) { $where1 = 'WHERE ' . implode(' AND ', $where1); } $where2 = 'WHERE ' . implode(' AND ', $where2); $where3 = 'WHERE ' . implode(' AND ', $where3); $sql1 = "SELECT count(*) FROM {$sll->table} {$where1}"; $allTotal = $wpdb->get_var($sql1); $sql2 = "SELECT count(*) FROM {$sll->table} {$where2}"; $successTotal = $wpdb->get_var($sql2); $sql3 = "SELECT count(*) FROM {$sll->table} {$where3}"; $failedTotal = $wpdb->get_var($sql3); $this->set('allTotal', $allTotal); $this->set('successTotal', $successTotal); $this->set('failedTotal', $failedTotal); $screen = get_current_screen(); /** * First, lets decide how many records per page to show */ $per_page_option = $screen->id . '_per_page'; $per_page = get_option($per_page_option, 20); $per_page = $per_page != false ? $per_page : 20; $offset = $per_page * ($this->get_pagenum() - 1); $orderby = isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby']) ? $_REQUEST['orderby'] : false; $order = isset($_REQUEST['order']) && !empty($_REQUEST['order']) ? $_REQUEST['order'] : false; $this->items = $sll->log_get_data($orderby, $order, $per_page, $offset); /** * REQUIRED. Now we need to define our column headers. This includes a complete * array of columns to be displayed (slugs & titles), a list of columns * to keep hidden, and a list of columns that are sortable. Each of these * can be defined in another method (as we've done here) before being * used to build the value for our _column_headers property. */ $columns = $this->get_columns(); $hidden_cols = get_user_option('manage' . $screen->id . 'columnshidden'); $hidden = $hidden_cols ? $hidden_cols : array(); $sortable = $this->get_sortable_columns(); /** * REQUIRED. Finally, we build an array to be used by the class for column * headers. The $this->_column_headers property takes an array which contains * 3 other arrays. One for all columns, one for hidden columns, and one * for sortable columns. */ $this->_column_headers = array($columns, $hidden, $sortable); $columns = get_column_headers($screen); /** * Optional. You can handle your bulk actions however you see fit. In this * case, we'll handle them within our package just to keep things clean. */ //$this->process_bulk_action(); /** * Instead of querying a database, we're going to fetch the example data * property we created for use in this plugin. This makes this example * package slightly different than one you might build on your own. In * this example, we'll be using array manipulation to sort and paginate * our data. In a real-world implementation, you will probably want to * use sort and pagination data to build a custom query instead, as you'll * be able to use your precisely-queried data immediately. */ // $data = $this->items; /** * This checks for sorting input and sorts the data in our array accordingly. * * In a real-world situation involving a database, you would probably want * to handle sorting by passing the 'orderby' and 'order' values directly * to a custom query. The returned data will be pre-sorted, and this array * sorting technique would be unnecessary. */ // function usort_reorder($a,$b) // { // $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'time'; //If no sort, default to title // $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'desc'; //If no order, default to asc // $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order // return ($order==='asc') ? $result : -$result; //Send final sort direction to usort // } // usort($data, 'usort_reorder'); /*********************************************************************** * --------------------------------------------------------------------- * vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv * * In a real-world situation, this is where you would place your query. * * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * --------------------------------------------------------------------- **********************************************************************/ /** * REQUIRED for pagination. Let's figure out what page the user is currently * looking at. We'll need this later, so you should always include it in * your own package classes. */ $current_page = $this->get_pagenum(); /** * REQUIRED for pagination. Let's check how many items are in our data array. * In real-world use, this would be the total number of items in your database, * without filtering. We'll need this later, so you should always include it * in your own package classes. */ if (isset($_GET['result']) && $_GET['result'] == '1') { $total_items = $wpdb->get_var("SELECT COUNT(*) FROM {$sll->table} {$where2}"); } else { if (isset($_GET['result']) && $_GET['result'] == '0') { $total_items = $wpdb->get_var("SELECT COUNT(*) FROM {$sll->table} {$where3}"); } else { $total_items = $wpdb->get_var("SELECT COUNT(*) FROM {$sll->table}"); } } /** * The WP_List_Table class does not handle pagination for us, so we need * to ensure that the data is trimmed to only the current page. We can use * array_slice() to */ // $data = array_slice($data,(($current_page-1)*$per_page),$per_page); /** * REQUIRED. Now we can add our *sorted* data to the items property, where * it can be used by the rest of the class. */ // $this->items = $data; /** * REQUIRED. We also have to register our pagination options & calculations. */ $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page))); }
/** * Renders the report table to the WP admin screen * * @author Jonathan Davis * @since 1.3 * * @return void **/ public function table() { extract($this->options, EXTR_SKIP); // Get only the records for this page $beginning = (int) ($paged - 1) * $per_page; $report = array_values($this->data); $report = array_slice($report, $beginning, $beginning + $per_page, true); unset($this->data); // Free memory ?> <table class="widefat" cellspacing="0"> <thead> <tr><?php ShoppUI::print_column_headers($this->screen); ?> </tr> </thead> <?php if (false !== $report && count($report) > 0) { ?> <tbody id="report" class="list stats"> <?php $columns = get_column_headers($this->screen); $hidden = get_hidden_columns($this->screen); $even = false; $records = 0; while (list($id, $data) = each($report)) { if ($records++ > $per_page) { break; } ?> <tr<?php if (!$even) { echo " class='alternate'"; } $even = !$even; ?> > <?php foreach ($columns as $column => $column_title) { $classes = array($column, "column-{$column}"); if (in_array($column, $hidden)) { $classes[] = 'hidden'; } if (method_exists(get_class($this), $column)) { ?> <td class="<?php echo esc_attr(join(' ', $classes)); ?> "><?php echo call_user_func(array($this, $column), $data, $column, $column_title, $this->options); ?> </td> <?php } else { ?> <td class="<?php echo esc_attr(join(' ', $classes)); ?> "> <?php do_action('shopp_manage_report_custom_column', $column, $column_title, $data); ?> </td> <?php } } /* $columns */ ?> </tr> <?php } /* records */ ?> <tr class="summary average"> <?php $averages = clone $this->totals; $first = true; foreach ($columns as $column => $column_title) { if ($first) { $averages->id = $averages->period = $averages->{$column} = __('Average', 'Shopp'); $first = false; } else { $value = isset($averages->{$column}) ? $averages->{$column} : null; $total = isset($this->total) ? $this->total : 0; if (null == $value) { $averages->{$column} = ''; } elseif (0 === $total) { $averages->{$column} = 0; } else { $averages->{$column} = $value / $total; } } $classes = array($column, "column-{$column}"); if (in_array($column, $hidden)) { $classes[] = 'hidden'; } ?> <td class="<?php echo esc_attr(join(' ', $classes)); ?> "> <?php if (method_exists(get_class($this), $column)) { echo call_user_func(array($this, $column), $averages, $column, $column_title, $this->options); } else { do_action('shopp_manage_report_custom_column_average', $column, $column_title, $data); } ?> </td> <?php } ?> </tr> <tr class="summary total"> <?php $first = true; foreach ($columns as $column => $column_title) { if ($first) { $label = __('Total', 'Shopp'); $this->totals->id = $this->totals->period = $this->totals->{$column} = $label; $first = false; } $classes = array($column, "column-{$column}"); if (in_array($column, $hidden)) { $classes[] = 'hidden'; } ?> <td class="<?php echo esc_attr(join(' ', $classes)); ?> "> <?php if (method_exists(get_class($this), $column)) { echo call_user_func(array($this, $column), $this->totals, $column, $column_title, $this->options); } else { do_action('shopp_manage_report_custom_column_total', $column, $column_title, $data); } ?> </td> <?php } ?> </tr> </tbody> <?php } else { ?> <tbody><tr><td colspan="<?php echo count(get_column_headers($this->screen)); ?> "><?php _e('No report data available.', 'Shopp'); ?> </td></tr></tbody> <?php } ?> <tfoot> <tr><?php ShoppUI::print_column_headers($this->screen, false); ?> </tr> </tfoot> </table> <?php }
/** * Spits out the current products details in a table row for manage products page and variations on edit product page. * @access public * * @deprecated since 3.8.9 * @since 3.8 * @param $product (Object), $parent_product (Int) Note: I believe parent_product is unused */ function wpsc_product_row(&$product, $parent_product = null) { _wpsc_deprecated_function(__FUNCTION__, '3.8.9'); global $mode, $current_user, $wpsc_products; //is this good practice? <*****@*****.**> static $rowclass, $object_terms_cache = array(); // store terms associated with variants inside a cache array. This only requires 1 DB query. if (empty($object_terms_cache)) { $ids = wp_list_pluck($wpsc_products, 'ID'); $object_terms = wp_get_object_terms($ids, 'wpsc-variation', array('fields' => 'all_with_object_id')); foreach ($object_terms as $term) { if (!array_key_exists($term->object_id, $object_terms_cache)) { $object_terms_cache[$term->object_id] = array(); } $object_terms_cache[$term->object_id][$term->parent] = $term->name; } } $global_product = $product; setup_postdata($product); $product_post_type_object = get_post_type_object('wpsc-product'); $current_user_can_edit_this_product = current_user_can($product_post_type_object->cap->edit_post, $product->ID); $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; $post_owner = $current_user->ID == $product->post_author ? 'self' : 'other'; $edit_link = get_edit_post_link($product->ID); if (isset($object_terms_cache[$product->ID])) { ksort($object_terms_cache[$product->ID]); $title = implode(', ', $object_terms_cache[$product->ID]); } else { $title = get_the_title($product->ID); } if (empty($title)) { $title = __('(no title)', 'wp-e-commerce'); } ?> <tr id='post-<?php echo $product->ID; ?> ' class='<?php echo trim($rowclass . ' author-' . $post_owner . ' status-' . $product->post_status); ?> iedit <?php if (get_option('wpsc_sort_by') == 'dragndrop') { echo 'product-edit'; } ?> ' valign="top"> <?php $posts_columns = get_column_headers('wpsc-product_variants'); if (empty($posts_columns)) { $posts_columns = array('image' => '', 'title' => __('Name', 'wp-e-commerce'), 'weight' => __('Weight', 'wp-e-commerce'), 'stock' => __('Stock', 'wp-e-commerce'), 'price' => __('Price', 'wp-e-commerce'), 'sale_price' => __('Sale Price', 'wp-e-commerce'), 'SKU' => __('SKU', 'wp-e-commerce'), 'hidden_alerts' => ''); } foreach ($posts_columns as $column_name => $column_display_name) { $attributes = "class=\"{$column_name} column-{$column_name}\""; switch ($column_name) { case 'date': /* !date case */ if ('0000-00-00 00:00:00' == $product->post_date && 'date' == $column_name) { $t_time = $h_time = __('Unpublished', 'wp-e-commerce'); $time_diff = 0; } else { $t_time = get_the_time(__('Y/m/d g:i:s A', 'wp-e-commerce')); $m_time = $product->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago', 'wp-e-commerce'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d', 'wp-e-commerce'), $m_time); } } echo '<td ' . $attributes . '>'; if ('excerpt' == $mode) { echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); } else { echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; } echo '<br />'; if ('publish' == $product->post_status) { _e('Published', 'wp-e-commerce'); } elseif ('future' == $product->post_status) { if ($time_diff > 0) { echo '<strong class="attention">' . __('Missed schedule', 'wp-e-commerce') . '</strong>'; } else { _e('Scheduled', 'wp-e-commerce'); } } else { _e('Last Modified', 'wp-e-commerce'); } echo '</td>'; break; case 'title': /* !title case */ $attributes = 'class="post-title column-title"'; $edit_link = wp_nonce_url($edit_link, 'edit-product_' . $product->ID); ?> <td <?php echo $attributes; ?> > <strong> <?php if ($current_user_can_edit_this_product && $product->post_status != 'trash') { ?> <span><a class="row-title" href="<?php echo esc_url($edit_link); ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”', 'wp-e-commerce'), $title)); ?> "><?php echo esc_html($title); ?> </a></span> <?php if ($parent_product) { ?> <a href="<?php echo esc_url($edit_link); ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”', 'wp-e-commerce'), $title)); ?> "><?php echo esc_html($title); ?> </a> <?php } ?> <?php } else { echo esc_html($title); } _post_states($product); $product_alert = apply_filters('wpsc_product_alert', array(false, ''), $product); if (!empty($product_alert['messages'])) { $product_alert['messages'] = implode("\n", (array) $product_alert['messages']); } if ($product_alert['state'] === true) { ?> <img alt='<?php echo $product_alert['messages']; ?> ' title='<?php echo $product_alert['messages']; ?> ' class='product-alert-image' src='<?php echo WPSC_CORE_IMAGES_URL; ?> /product-alert.jpg' alt='' /> <?php } // If a product alert has stuff to display, show it. // Can be used to add extra icons etc if (!empty($product_alert['display'])) { echo $product_alert['display']; } ?> </strong> <?php $has_var = ''; if (!$parent_product && wpsc_product_has_children($product->ID)) { $has_var = 'wpsc_has_variation'; } $actions = array(); if ($current_user_can_edit_this_product && 'trash' != $product->post_status) { $actions['edit'] = '<a class="edit-product" href="' . $edit_link . '" title="' . esc_attr__('Edit this product', 'wp-e-commerce') . '">' . __('Edit', 'wp-e-commerce') . '</a>'; //commenting this out for now as we are trying new variation ui quick edit boxes are open by default so we dont need this link. //$actions['quick_edit'] = "<a class='wpsc_editinline ".$has_var."' title='".esc_attr(__('Quick Edit', 'wp-e-commerce'))."' href='#'>".__('Quick Edit', 'wp-e-commerce')."</a>"; } $actions = apply_filters('post_row_actions', $actions, $product); $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; ?> </td> <?php break; case 'image': /* !image case */ ?> <td class="product-image "> <?php $attachment_args = array('post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $product->ID, 'orderby' => 'menu_order', 'order' => 'ASC'); if (isset($product->ID) && has_post_thumbnail($product->ID)) { echo get_the_post_thumbnail($product->ID, 'admin-product-thumbnails'); } else { $image_url = WPSC_CORE_IMAGES_URL . "/no-image-uploaded.gif"; ?> <img title='<?php esc_attr_e('Drag to a new position', 'wp-e-commerce'); ?> ' src='<?php echo esc_url($image_url); ?> ' alt='<?php echo esc_attr($title); ?> ' width='38' height='38' /> <?php } ?> </td> <?php break; case 'price': /* !price case */ $price = get_product_meta($product->ID, 'price', true); ?> <td <?php echo $attributes; ?> > <?php echo wpsc_currency_display($price); ?> <input type="text" class="wpsc_ie_field wpsc_ie_price" value="<?php echo esc_attr($price); ?> "> <a href="<?php echo $edit_link; ?> /#wpsc_downloads"><?php esc_html_e('Variant Download Files', 'wp-e-commerce'); ?> </a> </td> <?php break; case 'weight': $product_data['meta'] = array(); $product_data['meta'] = get_post_meta($product->ID, ''); foreach ($product_data['meta'] as $meta_name => $meta_value) { $product_data['meta'][$meta_name] = maybe_unserialize(array_pop($meta_value)); } $product_data['transformed'] = array(); if (!isset($product_data['meta']['_wpsc_product_metadata']['weight'])) { $product_data['meta']['_wpsc_product_metadata']['weight'] = ""; } if (!isset($product_data['meta']['_wpsc_product_metadata']['weight_unit'])) { $product_data['meta']['_wpsc_product_metadata']['weight_unit'] = ""; } $product_data['transformed']['weight'] = wpsc_convert_weight($product_data['meta']['_wpsc_product_metadata']['weight'], "pound", $product_data['meta']['_wpsc_product_metadata']['weight_unit'], false); $weight = $product_data['transformed']['weight']; if ($weight == '') { $weight = '0'; } ?> <td <?php echo $attributes; ?> > <span><?php echo esc_html($weight); ?> </span> <input type="text" class="wpsc_ie_field wpsc_ie_weight" value="<?php echo esc_attr($weight); ?> "> <a href="<?php echo $edit_link; ?> /#wpsc_tax"><?php esc_html_e('Set Variant Tax', 'wp-e-commerce'); ?> </a> </td> <?php break; case 'stock': $stock = get_post_meta($product->ID, '_wpsc_stock', true); ?> <td <?php echo $attributes; ?> > <span><?php echo $stock ? $stock : __('N/A', 'wp-e-commerce'); ?> </span> <input type="text" class="wpsc_ie_field wpsc_ie_stock" value="<?php echo esc_attr($stock); ?> "> <a href="<?php echo $edit_link; ?> /#wpsc_shipping"><?php esc_html_e('Set Variant Shipping', 'wp-e-commerce'); ?> </a> </td> <?php break; case 'categories': /* !categories case */ ?> <td <?php echo $attributes; ?> ><?php $categories = get_the_product_category($product->ID); if (!empty($categories)) { $out = array(); foreach ($categories as $c) { $out[] = "<a href='admin.php?page=wpsc-edit-products&category={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; } echo join(', ', $out); } else { esc_html_e('Uncategorized', 'wp-e-commerce'); } ?> </td> <?php break; case 'tags': /* !tags case */ ?> <td <?php echo $attributes; ?> ><?php $tags = get_the_tags($product->ID); if (!empty($tags)) { $out = array(); foreach ($tags as $c) { $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; } echo join(', ', $out); } else { esc_html_e('No Tags', 'wp-e-commerce'); } ?> </td> <?php break; case 'SKU': $sku = get_post_meta($product->ID, '_wpsc_sku', true); ?> <td <?php echo $attributes; ?> > <span><?php echo $sku ? $sku : esc_html__('N/A', 'wp-e-commerce'); ?> </span> <input type="text" class="wpsc_ie_field wpsc_ie_sku" value="<?php echo esc_attr($sku); ?> "> <input type="hidden" class="wpsc_ie_id wpsc_ie_field" value="<?php echo $product->ID; ?> "> <div class="wpsc_inline_actions"><input type="button" class="button-primary wpsc_ie_save" value="Save"><img src="<?php echo admin_url('images/wpspin_light.gif'); ?> " class="loading_indicator"><br/></div> </td> <?php break; case 'sale_price': $sale_price = get_post_meta($product->ID, '_wpsc_special_price', true); ?> <td <?php echo $attributes; ?> > <span><?php echo wpsc_currency_display($sale_price); ?> </span> <input type="text" class="wpsc_ie_field wpsc_ie_special_price" value="<?php echo esc_attr($sale_price); ?> "> </td> <?php break; case 'comments': /* !comments case */ ?> <td <?php echo $attributes; ?> ><div class="post-com-count-wrapper"> <?php $pending_phrase = sprintf(__('%s pending', 'wp-e-commerce'), number_format($pending_comments)); if ($pending_comments) { echo '<strong>'; } comments_number("<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count', 'wp-e-commerce') . '</span></a>', "<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count', 'wp-e-commerce') . '</span></a>', "<a href='edit-comments.php?p={$product->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count', 'wp-e-commerce') . '</span></a>'); if ($pending_comments) { echo '</strong>'; } ?> </div></td> <?php break; case 'author': /* !author case */ ?> <td <?php echo $attributes; ?> ><a href="edit.php?author=<?php the_author_meta('ID'); ?> "><?php the_author(); ?> </a></td> <?php break; case 'control_view': /* !control view case */ ?> <td><a href="<?php the_permalink(); ?> " rel="permalink" class="view"><?php esc_html_e('View', 'wp-e-commerce'); ?> </a></td> <?php break; case 'control_edit': /* !control edit case */ ?> <td><?php if ($current_user_can_edit_this_product) { echo "<a href='{$edit_link}' class='edit'>" . esc_html__('Edit', 'wp-e-commerce') . "</a>"; } ?> </td> <?php break; case 'control_delete': /* !control delete case */ ?> <td><?php if ($current_user_can_edit_this_product) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post={$id}", 'delete-post_' . $product->ID) . "' class='delete'>" . __('Delete', 'wp-e-commerce') . "</a>"; } ?> </td> <?php break; case 'featured': /* !control featured case */ ?> <td><?php do_action('manage_posts_featured_column', $product->ID); ?> </td> <?php break; default: /* !default case */ ?> <td <?php echo $attributes; ?> ><?php do_action('manage_posts_custom_column', $column_name, $product->ID); ?> </td> <?php break; } } ?> </tr> <?php $product = $global_product; }
function screen_meta($screen) { global $wp_meta_boxes, $_wp_contextual_help; $screen = str_replace('.php', '', $screen); $screen = str_replace('-new', '', $screen); $screen = str_replace('-add', '', $screen); $screen = apply_filters('screen_meta_screen', $screen); $column_screens = get_column_headers($screen); $meta_screens = array('index' => 'dashboard'); if ( isset($meta_screens[$screen]) ) $screen = $meta_screens[$screen]; $show_screen = false; if ( !empty($wp_meta_boxes[$screen]) || !empty($column_screens) ) $show_screen = true; ?> <div id="screen-meta"> <?php if ( $show_screen ) : ?> <div id="screen-options-wrap" class="hidden"> <h5><?php _e('Show on screen') ?></h5> <form id="adv-settings" action="" method="get"> <div class="metabox-prefs"> <?php if ( !meta_box_prefs($screen) && isset($column_screens) ) { manage_columns_prefs($screen); wp_nonce_field( 'hiddencolumns', 'hiddencolumnsnonce', false ); } ?> <br class="clear" /> </div></form> </div> <?php endif; global $title; if ( !isset($_wp_contextual_help) ) $_wp_contextual_help = array(); if ( !isset($_wp_contextual_help['post']) ) { $help = drag_drop_help(); $help .= '<p>' . __('<a href="http://codex.wordpress.org/Writing_Posts" target="_blank">Writing Posts</a>') . '</p>'; $_wp_contextual_help['post'] = $help; } if ( !isset($_wp_contextual_help['page']) ) { $help = drag_drop_help(); $_wp_contextual_help['page'] = $help; } if ( !isset($_wp_contextual_help['dashboard']) ) { $help = drag_drop_help(); $_wp_contextual_help['dashboard'] = $help; } if ( !isset($_wp_contextual_help['link']) ) { $help = drag_drop_help(); $_wp_contextual_help['link'] = $help; } if ( !isset($_wp_contextual_help['options-general']) ) $_wp_contextual_help['options-general'] = __('<a href="http://codex.wordpress.org/Settings_General_SubPanel" target="_blank">General Settings</a>'); $_wp_contextual_help = apply_filters('contextual_help_list', $_wp_contextual_help, $screen); ?> <div id="contextual-help-wrap" class="hidden"> <?php $contextual_help = ''; if ( isset($_wp_contextual_help[$screen]) ) { if ( !empty($title) ) $contextual_help .= '<h5>' . sprintf(__('Get help with "%s"'), $title) . '</h5>'; else $contextual_help .= '<h5>' . __('Get help with this page') . '</h5>'; $contextual_help .= '<div class="metabox-prefs">' . $_wp_contextual_help[$screen] . "</div>\n"; $contextual_help .= '<h5>' . __('Other Help') . '</h5>'; } else { $contextual_help .= '<h5>' . __('Help') . '</h5>'; } $contextual_help .= '<div class="metabox-prefs">'; $contextual_help .= __('<a href="http://codex.wordpress.org/" target="_blank">Documentation</a>'); $contextual_help .= '<br />'; $contextual_help .= __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>'); $contextual_help .= "</div>\n"; echo apply_filters('contextual_help', $contextual_help, $screen); ?> </div> <div id="screen-meta-links"> <div id="contextual-help-link-wrap" class="hide-if-no-js screen-meta-toggle"> <a href="#contextual-help" id="contextual-help-link" class="show-settings"><?php _e('Help') ?></a> </div> <?php if ( $show_screen ) { ?> <div id="screen-options-link-wrap" class="hide-if-no-js screen-meta-toggle"> <a href="#screen-options" id="show-settings-link" class="show-settings"><?php _e('Screen Options') ?></a> </div> <?php } ?> </div> </div> <?php }
function ewww_image_optimizer_ims() { global $wpdb; $ims_columns = get_column_headers('ims_gallery'); echo "<div class='wrap'><h1>" . esc_html__('Image Store Optimization', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</h1>"; if (empty($_REQUEST['ewww_gid'])) { $galleries = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'ims_gallery' ORDER BY ID"); $gallery_string = implode(',', $galleries); echo "<p>" . esc_html__('Choose a gallery or', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <a href='upload.php?page=ewww-image-optimizer-bulk&ids={$gallery_string}'>" . esc_html__('optimize all galleries', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</a></p>"; echo '<table class="wp-list-table widefat media" cellspacing="0"><thead><tr><th>' . esc_html__('Gallery ID', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . esc_html__('Gallery Name', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . esc_html__('Images', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . esc_html__('Image Optimizer', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th></tr></thead>'; foreach ($galleries as $gid) { $image_count = $wpdb->get_var("SELECT count(ID) FROM {$wpdb->posts} WHERE post_type = 'ims_image' AND post_mime_type LIKE '%%image%%' AND post_parent = {$gid}"); $gallery_name = get_the_title($gid); echo "<tr><td>{$gid}</td>"; echo "<td><a href='edit.php?post_type=ims_gallery&page=ewww-ims-optimize&ewww_gid={$gid}'>{$gallery_name}</a></td>"; echo "<td>{$image_count}</td>"; echo "<td><a href='upload.php?page=ewww-image-optimizer-bulk&ids={$gid}'>" . esc_html__('Optimize Gallery', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</a></td></tr>"; } echo "</table>"; } else { $gid = (int) $_REQUEST['ewww_gid']; $attachments = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'ims_image' AND post_mime_type LIKE '%%image%%' AND post_parent = {$gid} ORDER BY ID"); echo "<p><a href='upload.php?page=ewww-image-optimizer-bulk&ids={$gid}'>" . esc_html__('Optimize Gallery', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</a></p>"; echo '<table class="wp-list-table widefat media" cellspacing="0"><thead><tr><th>ID</th><th> </th><th>' . esc_html__('Title', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . esc_html__('Gallery', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . esc_html__('Image Optimizer', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th></tr></thead>'; $alternate = true; foreach ($attachments as $ID) { $meta = get_metadata('post', $ID); if (empty($meta['_wp_attachment_metadata'])) { continue; } $meta = maybe_unserialize($meta['_wp_attachment_metadata'][0]); $image_name = get_the_title($ID); $gallery_name = get_the_title($gid); $image_url = esc_url($meta['sizes']['mini']['url']); ?> <tr<?php if ($alternate) { echo " class='alternate'"; } ?> ><td><?php echo $ID; ?> </td> <?php echo "<td style='width:80px' class='column-icon'><img src='{$image_url}' /></td>"; echo "<td class='title'>{$image_name}</td>"; echo "<td>{$gallery_name}</td><td>"; ewww_image_optimizer_custom_column('ewww-image-optimizer', $ID); echo "</td></tr>"; $alternate = !$alternate; } echo '</table>'; } echo '</div>'; return; }
function cwp_post_row($a_post, $pending_comments, $mode, $page) { global $post; static $rowclass; $global_post = $post; $post = $a_post; setup_postdata($post); $rowclass = 'alternate' == $rowclass ? '' : 'alternate'; $rowclass = apply_filters('cwp_post_row_class', $rowclass, $post, $page); global $current_user; $post_owner = $current_user->ID == $post->post_author ? 'self' : 'other'; $edit_link = $page->get_edit_link($post->ID); $delete_link = add_query_arg('post', $post->ID, add_query_arg('action', 'delete', $page->get_page_url())); $trash_link = wp_nonce_url(add_query_arg('post', $post->ID, add_query_arg('action', 'trash', $page->get_page_url())), "trash-post_" . $post->ID); $untrash_link = wp_nonce_url(add_query_arg('post', $post->ID, add_query_arg('action', 'untrash', $page->get_page_url())), "untrash-post_" . $post->ID); $title = _draft_or_post_title(); ?> <tr id='post-<?php echo $post->ID; ?> ' class='<?php echo trim($rowclass . ' author-' . $post_owner . ' status-' . $post->post_status); ?> iedit' valign="top"> <?php $posts_columns = get_column_headers('cwp_manage'); $hidden = get_hidden_columns('edit'); foreach ($posts_columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': ?> <th scope="row" class="check-column"><?php if (current_user_can('edit_post', $post->ID)) { ?> <input type="checkbox" name="post[]" value="<?php the_ID(); ?> " /><?php } ?> </th> <?php break; case 'date': if ('0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name) { $t_time = $h_time = __('Unpublished'); $time_diff = 0; } else { $t_time = get_the_time(__('Y/m/d g:i:s A')); $m_time = $post->post_date; $time = get_post_time('G', true, $post); $time_diff = time() - $time; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago'), human_time_diff($time)); } else { $h_time = mysql2date(__('Y/m/d'), $m_time); } } echo '<td ' . $attributes . '>'; if ('excerpt' == $mode) { echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode); } else { echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>'; } echo '<br />'; if ('publish' == $post->post_status) { _e('Published'); } elseif ('future' == $post->post_status) { if ($time_diff > 0) { echo '<strong class="attention">' . __('Missed schedule') . '</strong>'; } else { _e('Scheduled'); } } else { _e('Last Modified'); } echo '</td>'; break; case 'title': $attributes = 'class="post-title column-title"' . $style; ?> <td <?php echo $attributes; ?> ><strong><?php if (current_user_can('edit_post', $post->ID)) { ?> <a class="row-title" href="<?php echo $edit_link; ?> " title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?> "><?php echo $title; ?> </a><?php } else { echo $title; } _post_states($post); ?> </strong> <?php if ('excerpt' == $mode) { the_excerpt(); } $actions = array(); if (current_user_can('edit_post', $post->ID)) { $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>'; } if (current_user_can('delete_post', $post->ID)) { if ('trash' == $post->post_status) { $actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . $untrash_link . "'>" . __('Restore') . "</a>"; } elseif (EMPTY_TRASH_DAYS) { $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . $trash_link . "'>" . __('Trash') . "</a>"; } if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) { $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url($delete_link, 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>"; } } /* if ( current_user_can('delete_post', $post->ID) ) { $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post')) . "' href='" . wp_nonce_url($delete_link, 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . esc_js(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>"; } */ if (in_array($post->post_status, array('pending', 'draft'))) { if (current_user_can('edit_post', $post->ID)) { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>'; } } else { $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>'; } $actions = apply_filters('post_row_actions', $actions, $post); $action_count = count($actions); $i = 0; echo '<div class="row-actions">'; foreach ($actions as $action => $link) { ++$i; $i == $action_count ? $sep = '' : ($sep = ' | '); echo "<span class='{$action}'>{$link}{$sep}</span>"; } echo '</div>'; get_inline_data($post); ?> </td> <?php break; case 'categories': ?> <td <?php echo $attributes; ?> ><?php $categories = get_the_category(); if (!empty($categories)) { $out = array(); foreach ($categories as $c) { $out[] = "<a href='edit.php?category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>"; } echo join(', ', $out); } else { _e('Uncategorized'); } ?> </td> <?php break; case 'tags': ?> <td <?php echo $attributes; ?> ><?php $tags = get_the_tags($post->ID); if (!empty($tags)) { $out = array(); foreach ($tags as $c) { $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>"; } echo join(', ', $out); } else { _e('No Tags'); } ?> </td> <?php break; case 'comments': ?> <td <?php echo $attributes; ?> ><div class="post-com-count-wrapper"> <?php $pending_phrase = sprintf(__('%s pending'), number_format($pending_comments)); if ($pending_comments) { echo '<strong>'; } comments_number("<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count') . '</span></a>'); if ($pending_comments) { echo '</strong>'; } ?> </div></td> <?php break; case 'author': ?> <td <?php echo $attributes; ?> ><a href="edit.php?author=<?php the_author_meta('ID'); ?> "><?php the_author(); ?> </a></td> <?php break; case 'control_view': ?> <td><a href="<?php the_permalink(); ?> " rel="permalink" class="view"><?php _e('View'); ?> </a></td> <?php break; case 'control_edit': ?> <td><?php if (current_user_can('edit_post', $post->ID)) { echo "<a href='{$edit_link}' class='edit'>" . __('Edit') . "</a>"; } ?> </td> <?php break; case 'control_delete': ?> <td><?php if (current_user_can('delete_post', $post->ID)) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post={$id}", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?> </td> <?php break; case is_taxonomy($column_name): ?> <td <?php echo $attributes; ?> ><?php $tags = wp_get_object_terms($post->ID, $column_name); if (!empty($tags)) { $out = array(); foreach ($tags as $c) { $out[] = "<a href=\"" . $page->get_edit_term_link($column_name, $c) . '">' . $c->name . "</a>"; } echo join(', ', $out); } else { _e('No ' . $column_display_name); } ?> </td> <?php break; case function_exists($column_name): ?> <td> <?php echo call_user_func_array($column_name, array($post)); ?> </td> <?php break; default: ?> <td <?php echo $attributes; ?> ><?php do_action('manage_posts_custom_column', $column_name, $post->ID); ?> </td> <?php break; } } ?> </tr> <?php $post = $global_post; }
/** * Get a list of all, hidden and sortable columns, with filter applied * * @since 3.1.0 * @access protected * * @return array */ function get_column_info() { if (isset($this->_column_headers)) { return $this->_column_headers; } $screen = convert_to_screen($this->_args['current_screen']); $columns = get_column_headers($screen); $hidden = get_hidden_columns($screen); $_sortable = apply_filters("manage_{$screen->id}_sortable_columns", $this->get_sortable_columns()); $sortable = array(); foreach ($_sortable as $id => $data) { if (empty($data)) { continue; } $data = (array) $data; if (!isset($data[1])) { $data[1] = false; } $sortable[$id] = $data; } $this->_column_headers = array($columns, $hidden, $sortable); return $this->_column_headers; }
<h2><?php Shopp::_e('New Order'); ?> </h2> <?php } ?> <?php $this->notices(); ?> <?php $totalsedit = isset($_GET['edit']) && 'totals' == $_GET['edit']; $columns = get_column_headers($this->screen); $hidden = get_hidden_columns($this->screen); $colspan = count($columns); $timestamp = empty($Purchase->created) ? current_time('timestamp') : $Purchase->created; ?> <div id="order"> <div class="title"> <div id="titlewrap"> <span class="date"><?php echo Shopp::_d(get_option('date_format'), $timestamp); ?> <small><?php echo date(get_option('time_format'), $timestamp); ?> </small>
function get_columns() { return get_column_headers(get_current_screen()); }
/** * Render the screen options tab. * * @since 3.3.0 */ public function render_screen_options() { global $wp_meta_boxes; $columns = get_column_headers($this); $hidden = get_hidden_columns($this); ?> <div id="screen-options-wrap" class="hidden" tabindex="-1" aria-label="<?php esc_attr_e('Screen Options Tab'); ?> "> <form id="adv-settings" action="" method="post"> <?php if (isset($wp_meta_boxes[$this->id]) || $this->get_option('per_page') || $columns && empty($columns['_title'])) { ?> <h5><?php _e('Show on screen'); ?> </h5> <?php } if (isset($wp_meta_boxes[$this->id])) { ?> <div class="metabox-prefs"> <?php meta_box_prefs($this); if ('dashboard' === $this->id && has_action('welcome_panel') && current_user_can('edit_theme_options')) { if (isset($_GET['welcome'])) { $welcome_checked = empty($_GET['welcome']) ? 0 : 1; update_user_meta(get_current_user_id(), 'show_welcome_panel', $welcome_checked); } else { $welcome_checked = get_user_meta(get_current_user_id(), 'show_welcome_panel', true); if (2 == $welcome_checked && wp_get_current_user()->user_email != get_option('admin_email')) { $welcome_checked = false; } } echo '<label for="wp_welcome_panel-hide">'; echo '<input type="checkbox" id="wp_welcome_panel-hide"' . checked((bool) $welcome_checked, true, false) . ' />'; echo _x('Welcome', 'Welcome panel') . "</label>\n"; } ?> <br class="clear" /> </div> <?php } if ($columns) { if (!empty($columns['_title'])) { ?> <h5><?php echo $columns['_title']; ?> </h5> <?php } ?> <div class="metabox-prefs"> <?php $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); foreach ($columns as $column => $title) { // Can't hide these for they are special if (in_array($column, $special)) { continue; } if (empty($title)) { continue; } if ('comments' == $column) { $title = __('Comments'); } $id = "{$column}-hide"; echo '<label for="' . $id . '">'; echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" id="' . $id . '" value="' . $column . '"' . checked(!in_array($column, $hidden), true, false) . ' />'; echo "{$title}</label>\n"; } ?> <br class="clear" /> </div> <?php } $this->render_screen_layout(); $this->render_per_page_options(); echo $this->_screen_settings; ?> <div><?php wp_nonce_field('screen-options-nonce', 'screenoptionnonce', false); ?> </div> </form> </div> <?php }
/** * Get a list of all, hidden and sortable columns, with filter applied * * @since 3.1.0 * @access protected * * @return array */ protected function get_column_info() { // $_column_headers is already set / cached if (isset($this->_column_headers) && is_array($this->_column_headers)) { // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. // In 4.3, we added a fourth argument for primary column. $column_headers = array(array(), array(), array(), $this->get_primary_column_name()); foreach ($this->_column_headers as $key => $value) { $column_headers[$key] = $value; } return $column_headers; } $columns = get_column_headers($this->screen); $hidden = get_hidden_columns($this->screen); $sortable_columns = $this->get_sortable_columns(); /** * Filter the list table sortable columns for a specific screen. * * The dynamic portion of the hook name, `$this->screen->id`, refers * to the ID of the current screen, usually a string. * * @since 3.5.0 * * @param array $sortable_columns An array of sortable columns. */ $_sortable = apply_filters("manage_{$this->screen->id}_sortable_columns", $sortable_columns); $sortable = array(); foreach ($_sortable as $id => $data) { if (empty($data)) { continue; } $data = (array) $data; if (!isset($data[1])) { $data[1] = false; } $sortable[$id] = $data; } $primary = $this->get_primary_column_name(); $this->_column_headers = array($columns, $hidden, $sortable, $primary); return $this->_column_headers; }
/** * Filter our hidden columns so that they are handled on a per-form basis. * * @access public * @since 2.7 * @return void */ public function filter_hidden_columns() { global $pagenow; // Bail if we aren't on the edit.php page, we aren't editing our custom post type, or we don't have a form_id set. if ($pagenow != 'edit.php' || !isset($_REQUEST['post_type']) || $_REQUEST['post_type'] != 'nf_sub' || !isset($_REQUEST['form_id'])) { return false; } // Grab our current user. $user = wp_get_current_user(); // Grab our form id. $form_id = $_REQUEST['form_id']; // Get the columns that should be hidden for this form ID. $hidden_columns = get_user_option('manageedit-nf_subcolumnshidden-form-' . $form_id); if ($hidden_columns === false) { // If we don't have custom hidden columns set up for this form, then only show the first five columns. // Get our column headers $columns = get_column_headers('edit-nf_sub'); $hidden_columns = array(); $x = 0; foreach ($columns as $slug => $name) { if ($x > 5) { if ($slug != 'sub_date') { $hidden_columns[] = $slug; } } $x++; } } update_user_option($user->ID, 'manageedit-nf_subcolumnshidden', $hidden_columns, true); }
<tr> <?php print_column_headers('upload'); ?> </tr> </thead> <tfoot> <tr> <?php print_column_headers('upload', false); ?> </tr> </tfoot> <tbody id="the-list" class="list:post"> <?php add_filter('the_title','esc_html'); $alt = ''; $posts_columns = get_column_headers('upload'); $hidden = get_hidden_columns('upload'); while ( have_posts() ) : the_post(); if ( $is_trash && $post->post_status != 'trash' ) continue; elseif ( !$is_trash && $post->post_status == 'trash' ) continue; $alt = ( 'alternate' == $alt ) ? '' : 'alternate'; global $current_user; $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' ); $att_title = _draft_or_post_title(); ?> <tr id='post-<?php echo $id; ?>' class='<?php echo trim( $alt . ' author-' . $post_owner . ' status-' . $post->post_status ); ?>' valign="top">
/** * Returns an array of columns to show. * * @see members_manage_roles_columns() * @since 1.0.0 * @access public * @return array */ public function get_columns() { return get_column_headers($this->screen); }
/** * Prints manage row for dynamic taxonomy * * @param Dynamic_Taxonomy_Handler $taxonomy_obj * @param string $style * @return unknown */ public function dynamic_taxonomy_row($taxonomy_obj, $style) { $checkbox = "<input type='checkbox' name='taxonomies[]' id='taxonomy_{$taxonomy_obj->get_taxonomy_name()}' value='{$taxonomy_obj->get_taxonomy_name()}' />"; $r = "<tr id='taxonomy-{$taxonomy_obj->get_taxonomy_name()}'{$style}>"; $columns = get_column_headers('dynamic_taxonomy'); $hidden = get_hidden_columns('dynamic_taxonomy'); foreach ($columns as $column_name => $column_display_name) { $class = "class=\"{$column_name} column-{$column_name}\""; $style = ''; if (in_array($column_name, $hidden)) { $style = ' style="display:none;"'; } $attributes = "{$class}{$style}"; switch ($column_name) { case 'cb': $r .= "<th scope='row' class='check-column'>{$checkbox}</th>"; break; case 'taxonomy': $r .= sprintf('<td %s>%s<br /><div class="row-actions"><span class="edit"><a href="%s">Edit</a> | </span><span class="delete"><a href="%s" class="submitdelete">Delete</a></span></div></td>', $attributes, $taxonomy_obj->get_taxonomy_name(), $this->get_edit_taxonomy_url($taxonomy_obj->get_taxonomy_name()), wp_nonce_url($this->get_manage_taxonomies_url(array('action' => 'delete', 'taxonomy' => $taxonomy_obj->get_taxonomy_name())), 'delete_taxonomy')); break; case 'label': $r .= "<td {$attributes}>{$taxonomy_obj->get_taxonomy_label()}</td>"; break; case 'object_types': $obect_types = count($taxonomy_obj->get_object_types()) > 0 ? join(', ', $taxonomy_obj->get_object_types()) : "none"; $r .= "<td {$attributes}>{$obect_types}</td>"; break; default: $r .= "<td {$attributes}>"; $r .= apply_filters('manage_users_custom_column', '', $column_name, $taxonomy_obj->get_taxonomy_name()); $r .= "</td>"; } } $r .= '</tr>'; return $r; }
function ewww_image_optimizer_ims() { $ims_columns = get_column_headers('ims_gallery'); echo "<div class='wrap'><h3>" . __('Image Store Optimization', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</h3>"; if (empty($_REQUEST['ewww_gid'])) { $galleries = get_posts(array('numberposts' => -1, 'post_type' => 'ims_gallery', 'post_status' => 'any', 'fields' => 'ids')); sort($galleries, SORT_NUMERIC); $gallery_string = implode(',', $galleries); echo "<p>" . __('Choose a gallery or', EWWW_IMAGE_OPTIMIZER_DOMAIN) . " <a href='upload.php?page=ewww-image-optimizer-bulk&ids={$gallery_string}'>" . __('optimize all galleries', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</a></p>"; echo '<table class="wp-list-table widefat media" cellspacing="0"><thead><tr><th>' . __('Gallery ID', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . __('Gallery Name', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . __('Images', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . __('Image Optimizer', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th></tr></thead>'; foreach ($galleries as $gid) { $attachments = get_posts(array('numberposts' => -1, 'post_type' => 'ims_image', 'post_status' => 'any', 'post_mime_type' => 'image', 'post_parent' => $gid, 'fields' => 'ids')); $image_count = sizeof($attachments); $image_string = implode(',', $attachments); $gallery_name = get_the_title($gid); echo "<tr><td>{$gid}</td>"; echo "<td><a href='edit.php?post_type=ims_gallery&page=ewww-ims-optimize&ewww_gid={$gid}'>{$gallery_name}</a></td>"; echo "<td>{$image_count}</td>"; echo "<td><a href='upload.php?page=ewww-image-optimizer-bulk&ids={$image_string}'>" . __('Optimize Gallery', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</a></td></tr>"; } echo "</table>"; } else { $gid = $_REQUEST['ewww_gid']; $attachments = get_posts(array('numberposts' => -1, 'post_type' => 'ims_image', 'post_status' => 'any', 'post_mime_type' => 'image', 'post_parent' => $gid, 'fields' => 'ids')); sort($attachments, SORT_NUMERIC); $image_string = implode(',', $attachments); echo "<p><a href='upload.php?page=ewww-image-optimizer-bulk&ids={$image_string}'>" . __('Optimize Gallery', EWWW_IMAGE_OPTIMIZER_DOMAIN) . "</a></p>"; echo '<table class="wp-list-table widefat media" cellspacing="0"><thead><tr><th>ID</th><th> </th><th>' . __('Title', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . __('Gallery', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th><th>' . __('Image Optimizer', EWWW_IMAGE_OPTIMIZER_DOMAIN) . '</th></tr></thead>'; $alternate = true; foreach ($attachments as $ID) { $meta = get_metadata('post', $ID); $meta = maybe_unserialize($meta['_wp_attachment_metadata'][0]); $image_name = get_the_title($ID); $gallery_name = get_the_title($gid); $image_url = $meta['sizes']['mini']['url']; ?> <tr<?php if ($alternate) { echo " class='alternate'"; } ?> ><td><?php echo $ID; ?> </td> <?php echo "<td style='width:80px' class='column-icon'><img src='{$image_url}' /></td>"; echo "<td class='title'>{$image_name}</td>"; echo "<td>{$gallery_name}</td><td>"; ewww_image_optimizer_custom_column('ewww-image-optimizer', $ID); echo "</td></tr>"; $alternate = !$alternate; } echo '</table>'; } echo '</div>'; return; }
/** * Render the list table columns preferences. * * @since 4.4.0 */ public function render_list_table_columns_preferences() { $columns = get_column_headers($this); $hidden = get_hidden_columns($this); if (!$columns) { return; } $legend = !empty($columns['_title']) ? $columns['_title'] : __('Columns'); ?> <fieldset class="metabox-prefs"> <legend><?php echo $legend; ?> </legend> <?php $special = array('_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname'); foreach ($columns as $column => $title) { // Can't hide these for they are special if (in_array($column, $special)) { continue; } if (empty($title)) { continue; } if ('comments' == $column) { $title = __('Comments'); } $id = "{$column}-hide"; echo '<label>'; echo '<input class="hide-column-tog" name="' . $id . '" type="checkbox" value="' . $column . '"' . checked(!in_array($column, $hidden), true, false) . ' />'; echo "{$title}</label>\n"; } ?> </fieldset> <?php }