/** * WP Page - Mass edit tags * */ public static function pageMassEditTags() { global $wpdb, $wp_locale, $wp_query; list($post_stati, $avail_post_stati) = self::edit_data_query(); if (!isset($_GET['paged'])) { $_GET['paged'] = 1; } // Display message settings_errors(__CLASS__); ?> <div class="wrap"> <?php SimpleTags_Admin::boxSelectorTaxonomy('st_mass_terms'); ?> <form id="posts-filter" action="" method="get"> <input type="hidden" name="page" value="st_mass_terms" /> <input type="hidden" name="taxo" value="<?php echo esc_attr(SimpleTags_Admin::$taxonomy); ?> " /> <input type="hidden" name="cpt" value="<?php echo esc_attr(SimpleTags_Admin::$post_type); ?> " /> <h2><?php _e('Mass edit terms', 'simpletags'); ?> </h2> <ul class="subsubsub"> <?php $status_links = array(); $num_posts = wp_count_posts(SimpleTags_Admin::$post_type, 'readable'); $class = empty($_GET['post_status']) && empty($_GET['post_type']) ? ' class="current"' : ''; $status_links[] = '<li><a href="' . admin_url('tools.php') . '?page=st_mass_terms&cpt=' . SimpleTags_Admin::$post_type . '&taxo=' . SimpleTags_Admin::$taxonomy . '"' . $class . '>' . __('All', 'simpletags') . '</a>'; foreach ($post_stati as $status => $label) { $class = ''; if (!in_array($status, $avail_post_stati)) { continue; } if (empty($num_posts->{$status})) { continue; } if (isset($_GET['post_status']) && $status == $_GET['post_status']) { $class = ' class="current"'; } $status_links[] = '<li><a href="' . admin_url('tools.php') . '?page=st_mass_terms&cpt=' . SimpleTags_Admin::$post_type . '&taxo=' . SimpleTags_Admin::$taxonomy . '&post_status=' . $status . '"' . $class . '>' . sprintf(_n($label[2][0], $label[2][1], (int) $num_posts->{$status}), number_format_i18n($num_posts->{$status})) . '</a>'; } echo implode(' |</li>', $status_links) . '</li>'; unset($status_links); $class = !empty($_GET['post_type']) ? ' class="current"' : ''; ?> </ul> <?php if (isset($_GET['post_status'])) { ?> <input type="hidden" name="post_status" value="<?php echo esc_attr($_GET['post_status']); ?> " /> <?php } ?> <p class="search-box"> <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?> " /> <input type="submit" value="<?php _e('Search', 'simpletags'); ?> " class="button" /> </p> <div class="tablenav"> <?php $posts_per_page = isset($_GET['posts_per_page']) ? (int) $_GET['posts_per_page'] : 0; if ((int) $posts_per_page == 0) { $posts_per_page = 15; } $page_links = paginate_links(array('base' => add_query_arg('paged', '%#%'), 'format' => '', 'total' => ceil($wp_query->found_posts / $posts_per_page), 'current' => (int) $_GET['paged'])); if ($page_links) { echo "<div class='tablenav-pages'>{$page_links}</div>"; } ?> <div style="float: left"> <?php if (!is_singular()) { $arc_result = $wpdb->get_results($wpdb->prepare("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM {$wpdb->posts} WHERE post_type = %s ORDER BY post_date DESC", SimpleTags_Admin::$post_type)); $month_count = count($arc_result); if (!isset($_GET['m'])) { $_GET['m'] = ''; } if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) { ?> <select name='m'> <option<?php selected(@$_GET['m'], 0); ?> value='0'><?php _e('Show all dates', 'simpletags'); ?> </option> <?php foreach ($arc_result as $arc_row) { if ($arc_row->yyear == 0) { continue; } $arc_row->mmonth = zeroise($arc_row->mmonth, 2); if ($arc_row->yyear . $arc_row->mmonth == $_GET['m']) { $default = ' selected="selected"'; } else { $default = ''; } echo "<option{$default} value='{$arc_row->yyear}{$arc_row->mmonth}'>"; echo $wp_locale->get_month($arc_row->mmonth) . " {$arc_row->yyear}"; echo "</option>\n"; } ?> </select> <?php } ?> <select name="posts_per_page" id="posts_per_page"> <option <?php if (!isset($_GET['posts_per_page'])) { echo 'selected="selected"'; } ?> value=""><?php _e('Quantity…', 'simpletags'); ?> </option> <option <?php selected($posts_per_page, 10); ?> value="10">10</option> <option <?php selected($posts_per_page, 20); ?> value="20">20</option> <option <?php selected($posts_per_page, 30); ?> value="30">30</option> <option <?php selected($posts_per_page, 40); ?> value="40">40</option> <option <?php selected($posts_per_page, 50); ?> value="50">50</option> <option <?php selected($posts_per_page, 100); ?> value="100">100</option> <option <?php selected($posts_per_page, 200); ?> value="200">200</option> </select> <input type="submit" id="post-query-submit" value="<?php _e('Filter', 'simpletags'); ?> " class="button-secondary" /> <?php } ?> </div> <br style="clear:both;" /> </div> </form> <br style="clear:both;" /> <?php if (have_posts()) { add_filter('the_title', 'esc_html'); ?> <form name="post" id="post" method="post"> <table class="widefat post fixed"> <thead> <tr> <th class="manage-column"><?php _e('Post title', 'simpletags'); ?> </th> <th class="manage-column"><?php printf(__('Terms : %s', 'simpletags'), esc_html(SimpleTags_Admin::$taxo_name)); ?> </th> </tr> </thead> <tbody> <?php $class = 'alternate'; while (have_posts()) { the_post(); $class = $class == 'alternate' ? '' : 'alternate'; ?> <tr valign="top" class="<?php echo $class; ?> "> <th scope="row"><a href="<?php echo admin_url('post.php?action=edit&post=' . get_the_ID()); ?> " title="<?php _e('Edit', 'simpletags'); ?> "><?php echo get_the_title() == '' ? the_ID() : the_title(); ?> </a></th> <td><input id="tags-input<?php the_ID(); ?> " class="autocomplete-input tags_input" type="text" size="100" name="tags[<?php the_ID(); ?> ]" value="<?php echo SimpleTags_Admin::getTermsToEdit(SimpleTags_Admin::$taxonomy, get_the_ID()); ?> " /></td> </tr> <?php } ?> </tbody> </table> <p class="submit"> <input type="hidden" name="secure_mass" value="<?php echo wp_create_nonce('st_mass_terms'); ?> " /> <input class="button-primary" type="submit" name="update_mass" value="<?php _e('Update all »', 'simpletags'); ?> " /> </p> </form> <?php } else { ?> <p><?php _e('No content to edit.', 'simpletags'); ?> <?php } ?> <p><?php _e('Visit the <a href="https://github.com/herewithme/simple-tags">plugin\'s homepage</a> for further details. If you find a bug, or have a fantastic idea for this plugin, <a href="mailto:amaury@wordpress-fr.net">ask me</a> !', 'simpletags'); ?> </p> <?php SimpleTags_Admin::printAdminFooter(); ?> </div> <?php do_action('simpletags-mass_terms', SimpleTags_Admin::$taxonomy); }
/** * Content of custom meta box of Simple Tags * * @param object $post * @return void * @author Amaury Balmer */ public static function metabox($post) { // Get options $autocomplete_min = (int) SimpleTags_Plugin::get_option_value('autocomplete_min'); ?> <p> <?php if (SimpleTags_Plugin::get_option_value('autocomplete_type') == 'textarea') { ?> <textarea class="widefat" name="adv-tags-input" id="adv-tags-input" rows="3" cols="5"><?php echo SimpleTags_Admin::getTermsToEdit('post_tag', $post->ID); ?> </textarea> <?php } else { ?> <input type="text" class="widefat" name="adv-tags-input" id="adv-tags-input" value="<?php echo esc_attr(SimpleTags_Admin::getTermsToEdit('post_tag', $post->ID)); ?> " /> <?php } ?> <?php _e('Separate tags with commas', 'simpletags'); ?> </p> <script type="text/javascript"> <!-- st_init_autocomplete( '#adv-tags-input', '<?php echo admin_url("admin-ajax.php?action=simpletags&st_action=helper_js_collection"); ?> ', <?php echo $autocomplete_min; ?> ); --> </script> <?php }