function wpv_admin_content_template_listing_name() { $mod_url = array('orderby' => '', 'order' => '', 'search' => '', 'items_per_page' => '', 'paged' => '', 'status' => ''); $wpv_args = array('post_type' => 'view-template', 'posts_per_page' => WPV_ITEMS_PER_PAGE, 'order' => 'ASC', 'orderby' => 'title', 'post_status' => 'publish'); if (isset($_GET["status"]) && '' != $_GET["status"]) { // apply post_status coming from the URL parameters $wpv_args['post_status'] = sanitize_text_field($_GET["status"]); $mod_url['status'] = '&status=' . sanitize_text_field($_GET["status"]); } if (isset($_GET["search"]) && '' != $_GET["search"]) { $s_param = urldecode(sanitize_text_field($_GET["search"])); $new_args = $wpv_args; $unique_ids = array(); $new_args['posts_per_page'] = '-1'; $new_args['s'] = $s_param; $query_1 = new WP_Query($new_args); while ($query_1->have_posts()) { $query_1->the_post(); $unique_ids[] = get_the_id(); } unset($new_args['s']); $new_args['meta_query'] = array(array('key' => '_wpv-content-template-decription', 'value' => $s_param, 'compare' => 'LIKE')); $query_2 = new WP_Query($new_args); while ($query_2->have_posts()) { $query_2->the_post(); $unique_ids[] = get_the_id(); } $unique = array_unique($unique_ids); if (count($unique) == 0) { $wpv_args['post__in'] = array('-1'); } else { $wpv_args['post__in'] = $unique; } $mod_url['search'] = '&search=' . sanitize_text_field($_GET["search"]); } if (isset($_GET["items_per_page"]) && '' != $_GET["items_per_page"]) { $wpv_args['posts_per_page'] = (int) $_GET["items_per_page"]; $mod_url['items_per_page'] = '&items_per_page=' . (int) $_GET["items_per_page"]; } if (isset($_GET["orderby"]) && '' != $_GET["orderby"]) { $wpv_args['orderby'] = sanitize_text_field($_GET["orderby"]); $mod_url['orderby'] = '&orderby=' . sanitize_text_field($_GET["orderby"]); if (isset($_GET["order"]) && '' != $_GET["order"]) { $wpv_args['order'] = sanitize_text_field($_GET["order"]); $mod_url['order'] = '&order=' . sanitize_text_field($_GET["order"]); } } if (isset($_GET["paged"]) && '' != $_GET["paged"]) { $wpv_args['paged'] = (int) $_GET["paged"]; $mod_url['paged'] = '&paged=' . (int) $_GET["paged"]; } $query = new WP_Query($wpv_args); $wpv_count_posts = $query->post_count; $wpv_found_posts = $query->found_posts; $all_posts = wp_count_posts('view-template'); $wpv_views_status = array(); // to hold the number of Views in each status $wpv_views_status['publish'] = $all_posts->publish; $wpv_views_status['trash'] = $all_posts->trash; ?> <?php if ($wpv_views_status['publish'] > 0 || $wpv_views_status['trash'] > 0) { ?> <div class="wpv-views-listing-arrange" style="clear:none;float:left"> <p style="margin-bottom:0"><?php _e('Arrange by', 'wpv-views'); ?> : </p> <ul> <li data-sortby="name" class="active"><?php _e('Name', 'wpv-views'); ?> </li> <li data-sortby="usage-single"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&arrangeby=usage&usage=single"><?php _e('Usage for single page', 'wpv-views'); ?> </a></li> <li data-sortby="usage-post-archives"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&arrangeby=usage&usage=post-archives"><?php _e('Usage for custom post archives', 'wpv-views'); ?> </a></li> <li data-sortby="usage-taxonomy-archives"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&arrangeby=usage&usage=taxonomy-archives"><?php _e('Usage for taxonomy archives', 'wpv-views'); ?> </a></li> </ul> </div> <ul class="subsubsub" style="clear:left"><!-- links to lists WPA in different statuses --> <li><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&status=publish"<?php if ($wpv_args['post_status'] == 'publish' && !isset($_GET["search"])) { echo ' class="current"'; } ?> ><?php _e('Published', 'wpv-views'); ?> </a> (<?php echo $wpv_views_status['publish']; ?> ) | </li> <li><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&status=trash"<?php if ($wpv_args['post_status'] == 'trash' && !isset($_GET["search"])) { echo ' class="current"'; } ?> ><?php _e('Trash', 'wpv-views'); ?> </a> (<?php echo $wpv_views_status['trash']; ?> )</li> </ul> <?php if ($wpv_found_posts > 0) { ?> <form id="posts-filter" action="" method="get"> <p class="search-box"> <label class="screen-reader-text" for="post-search-input"><?php _e('Search Views:', 'wpv-views'); ?> </label> <?php $search_term = isset($_GET["search"]) ? urldecode(sanitize_text_field($_GET["search"])) : ''; ?> <input type="search" id="ct-post-search-input" name="search" value="<?php echo $search_term; ?> "> <input type="submit" name="" id="ct-search-submit" class="button" value="<?php echo htmlentities(__('Search Content Templates', 'wpv-views'), ENT_QUOTES); ?> "> <input type="hidden" name="paged" value="1" /> </p> </form> <?php } ?> <?php } else { ?> <p class="wpv-view-not-exist"> <?php _e('Content Templates let you design single pages.', 'wpv-views'); ?> </p> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo admin_url('admin-ajax.php'); ?> ?action=wpv_ct_create_new"> <i class="icon-plus"></i><?php _e('Add new Content Template', 'wpv-views'); ?> </button> </p> <?php } ?> <?php if ($wpv_count_posts == 0 && ($wpv_views_status['publish'] > 0 || $wpv_views_status['trash'] > 0)) { //When no posts found if (isset($_GET["search"]) && '' != $_GET["search"]) { ?> <?php if (isset($_GET["status"]) && $_GET["status"] == 'trash') { ?> <div class="wpv-views-listing views-empty-list"> <p><?php echo __('No Content Templates in trash matched your criteria.', 'wpv-views'); ?> <a class="button-secondary" href="<?php echo admin_url('admin.php'); ?> ?page=view-templates<?php echo $mod_url['orderby'] . $mod_url['order'] . $mod_url['items_per_page']; ?> &paged=1&status=trash"><?php _e('Return', 'wpv-views'); ?> </a></p> </div> <?php } else { ?> <div class="wpv-views-listing views-empty-list"> <p><?php echo __('No Content Templates matched your criteria.', 'wpv-views'); ?> <a class="button-secondary" href="<?php echo admin_url('admin.php'); ?> ?page=view-templates<?php echo $mod_url['orderby'] . $mod_url['order'] . $mod_url['items_per_page']; ?> &paged=1"><?php _e('Return', 'wpv-views'); ?> </a></p> </div> <?php } ?> <?php } else { ?> <?php if (isset($_GET["status"]) && $_GET["status"] == 'trash') { ?> <div class="wpv-views-listing views-empty-list"> <p><?php echo __('No Content Templates in trash.', 'wpv-views'); ?> <a class="button-secondary" href="<?php echo admin_url('admin.php'); ?> ?page=view-templates<?php echo $mod_url['orderby'] . $mod_url['order'] . $mod_url['items_per_page']; ?> &paged=1"><?php _e('Return', 'wpv-views'); ?> </a></p> </div> <?php } else { ?> <p class="wpv-view-not-exist"> <?php _e('Content Templates let you design single pages.', 'wpv-views'); ?> </p> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo admin_url('admin-ajax.php'); ?> ?action=wpv_ct_create_new"> <i class="icon-plus"></i><?php _e('Add new Content Template', 'wpv-views'); ?> </button> </p> <?php } ?> <?php } ?> <?php } else { if ($wpv_count_posts != 0) { global $wpdb; ?> <table class="wpv-views-listing widefat"> <!-- section for: sort by name --> <thead> <tr> <?php $column_active = ''; $column_sort_to = 'ASC'; $column_sort_now = 'ASC'; if ($wpv_args['orderby'] === 'title') { $column_active = ' views-list-sort-active'; $column_sort_to = $wpv_args['order'] === 'ASC' ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } ?> <th class="wpv-admin-listing-col-title"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&orderby=title&order=<?php echo $column_sort_to . $mod_url['search'] . $mod_url['items_per_page'] . $mod_url['paged']; ?> " class="js-views-list-sort views-list-sort<?php echo $column_active; ?> " data-orderby="title"><?php _e('Title', 'wpv-views'); ?> <i class="icon-sort-by-alphabet<?php if ($column_sort_now === 'DESC') { echo '-alt'; } ?> "></i></a></th> <th class="wpv-admin-listing-col-usage js-wpv-col-two"><?php _e('Used on', 'wpv-views'); ?> </th> <th class="wpv-admin-listing-col-action"><?php _e('Action', 'wpv-views'); ?> </th> <?php $column_active = ''; $column_sort_to = 'DESC'; $column_sort_now = 'DESC'; if ($wpv_args['orderby'] === 'date') { $column_active = ' views-list-sort-active'; $column_sort_to = $wpv_args['order'] === 'ASC' ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } ?> <th class="wpv-admin-listing-col-date"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&orderby=date&order=<?php echo $column_sort_to . $mod_url['search'] . $mod_url['items_per_page'] . $mod_url['paged']; ?> " class="js-views-list-sort views-list-sort<?php echo $column_active; ?> " data-orderby="date"><?php _e('Date', 'wpv-views'); ?> <i class="icon-sort-by-attributes<?php if ($column_sort_now === 'DESC') { echo '-alt'; } ?> "></i></a></th> </tr> </thead> <tfoot> <tr> <?php $column_active = ''; $column_sort_to = 'ASC'; $column_sort_now = 'ASC'; if ($wpv_args['orderby'] === 'title') { $column_active = ' views-list-sort-active'; $column_sort_to = $wpv_args['order'] === 'ASC' ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } ?> <th class="wpv-admin-listing-col-title"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&orderby=title&order=<?php echo $column_sort_to . $mod_url['search'] . $mod_url['items_per_page'] . $mod_url['paged']; ?> " class="js-views-list-sort views-list-sort<?php echo $column_active; ?> " data-orderby="title"><?php _e('Title', 'wpv-views'); ?> <i class="icon-sort-by-alphabet<?php if ($column_sort_now === 'DESC') { echo '-alt'; } ?> "></i></a></th> <th class="wpv-admin-listing-col-usage js-wpv-col-two"><?php _e('Used on', 'wpv-views'); ?> </th> <th class="wpv-admin-listing-col-action"><?php _e('Action', 'wpv-views'); ?> </th> <?php $column_active = ''; $column_sort_to = 'DESC'; $column_sort_now = 'DESC'; if ($wpv_args['orderby'] === 'date') { $column_active = ' views-list-sort-active'; $column_sort_to = $wpv_args['order'] === 'ASC' ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } ?> <th class="wpv-admin-listing-col-date"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-templates&orderby=date&order=<?php echo $column_sort_to . $mod_url['search'] . $mod_url['items_per_page'] . $mod_url['paged']; ?> " class="js-views-list-sort views-list-sort<?php echo $column_active; ?> " data-orderby="date"><?php _e('Date', 'wpv-views'); ?> <i class="icon-sort-by-attributes<?php if ($column_sort_now === 'DESC') { echo '-alt'; } ?> "></i></a></th> </tr> </tfoot> <tbody class="js-wpv-views-listing-body"> <?php $alternate = ''; while ($query->have_posts()) { $query->the_post(); $post = get_post(get_the_id()); $wpv_content_template_decription = get_post_meta($post->ID, '_wpv-content-template-decription', true); $alternate = ' alternate' == $alternate ? '' : ' alternate'; ?> <tr id="wpv_ct_list_row_<?php echo $post->ID; ?> " class="js-wpv-ct-list-row<?php echo $alternate; ?> "> <td class="wpv-admin-listing-col-title post-title page-title column-title"> <h3 class="row-title"> <?php if ($wpv_args['post_status'] == 'trash') { ?> <?php echo $post->post_title; ?> <?php } else { ?> <a href="post.php?post=<?php echo $post->ID; ?> &action=edit"><?php echo $post->post_title; ?> </a> <?php } ?> </h3> <?php if (!empty($wpv_content_template_decription)) { ?> <p class="desc"> <?php echo nl2br($wpv_content_template_decription); ?> </p> <?php } ?> </td> <td class="wpv-admin-listing-col-usage"> <?php echo wpv_content_template_used_for_list($post->ID); ?> </td> <td class="wpv-admin-listing-col-action"> <?php $template_id = $post->ID; $asigned_count = $wpdb->get_var("SELECT COUNT(post_id) FROM {$wpdb->postmeta} JOIN {$wpdb->posts} p WHERE\r\n\t\t\t\t\t\t\t\t\t\tmeta_key='_views_template' AND meta_value='{$template_id}' AND post_id = p.ID AND p.post_status NOT IN ('auto-draft') AND p.post_type != 'revision'"); ?> <select class="js-list-ct-action" name="list_ct_action_<?php echo $post->ID; ?> " id="list_ct_action_<?php echo $post->ID; ?> " data-ct-id="<?php echo $post->ID; ?> " data-postcount="<?php echo $asigned_count; ?> " data-ct-name="<?php echo htmlentities($post->title, ENT_QUOTES); ?> " data-viewactionnonce="<?php echo wp_create_nonce('wpv_view_listing_actions_nonce'); ?> "> <option value="0"><?php _e('Choose', 'wpv-views'); ?> …</option> <?php if ($wpv_args['post_status'] == 'publish') { ?> <option value="change"><?php _e('Change template usage', 'wpv-views'); ?> </option> <option value="duplicate" data-msg="<?php echo htmlentities(__('Enter new title', 'wpv-views'), ENT_QUOTES); ?> "><?php _e('Duplicate', 'wpv-views'); ?> </option> <option value="trash"><?php _e('Move to trash', 'wpv-views'); ?> </option> <?php } else { if ($wpv_args['post_status'] == 'trash') { ?> <option value="restore-from-trash"><?php _e('Restore from trash', 'wpv-views'); ?> </option> <option value="delete"><?php _e('Delete', 'wpv-views'); ?> </option> <?php } } ?> </select> </td> <td class="wpv-admin-listing-col-date"> <?php echo get_the_time(get_option('date_format'), $post->ID); ?> </td> </tr> <?php } ?> </tbody> </table> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo admin_url('admin-ajax.php'); ?> ?action=wpv_ct_create_new"> <i class="icon-plus"></i><?php _e('Add new Content Template', 'wpv-views'); ?> </button> </p> <?php } } ?> <?php wpv_admin_listing_pagination('view-templates', $wpv_found_posts, $wpv_args["posts_per_page"], $mod_url); ?> <div class="popup-window-container"> <div class="wpv-dialog js-remove-content-template-dialog"> <div class="wpv-dialog-header"> <h2><?php _e('Delete Content Template', 'wpv-views'); ?> </h2> </div> <div class="wpv-dialog-content"> <p><?php echo sprintf(__('There are %s single posts that are currently using this template.', 'wpv-views'), '<span class="js-ct-single-postcount"></span>'); ?> </p> <p><?php _e('Are you sure you want to delete it?', 'wpv-views'); ?> </div> <div class="wpv-dialog-footer"> <button class="button js-dialog-close"><?php _e('Cancel', 'wpv-views'); ?> </button> <button class="button button-primary js-remove-template-permanent"><?php _e('Delete', 'wpv-views'); ?> </button> </div> </div> <div class="wpv-dialog js-duplicate-ct-dialog"> <div class="wpv-dialog-header"> <h2><?php _e('Duplicate Content Template', 'wpv-views'); ?> </h2> </div> <div class="wpv-dialog-content"> <p> <label for="duplicated_ct_name"><?php _e('Name this Content Template', 'wpv-views'); ?> </label> <input type="text" value="" class="js-duplicated-ct-name" placeholder="<?php _e('Enter name here', 'wpv-views'); ?> " name="duplicated_ct_name"> </p> <div class="js-ct-duplicate-error"></div> </div> <div class="wpv-dialog-footer"> <button class="button js-dialog-close"><?php _e('Cancel', 'wpv-views'); ?> </button> <button class="button button-secondary js-duplicate-ct" disabled><?php _e('Duplicate', 'wpv-views'); ?> </button> </div> </div> <!-- .js-duplicate-view-dialog --> </div> <?php }
function wpv_admin_content_template_listing_name() { $mod_url = array( // array of URL modifiers 'orderby' => '', 'order' => '', 's' => '', 'items_per_page' => '', 'paged' => '', 'status' => '' ); $wpv_args = array( 'post_type' => 'view-template', 'posts_per_page' => WPV_ITEMS_PER_PAGE, 'order' => 'ASC', 'orderby' => 'title', 'post_status' => 'publish' ); // Apply post_status coming from the URL parameters. $post_status = wpv_getget( 'status', 'publish', array( 'publish', 'trash' ) ); $wpv_args['post_status'] = $post_status; $mod_url['status'] = $post_status; $the_other_post_status = ( 'publish' == $post_status ) ? 'trash' : 'publish'; if ( isset( $_GET["s"] ) && '' != $_GET["s"] ) { $wpv_args = wpv_modify_wpquery_for_search( $_GET["s"], $wpv_args ); $mod_url['s'] = sanitize_text_field( $_GET["s"] ); } if ( isset( $_GET["items_per_page"] ) && '' != $_GET["items_per_page"] ) { $wpv_args['posts_per_page'] = (int) $_GET["items_per_page"]; $mod_url['items_per_page'] = (int) $_GET["items_per_page"]; } if ( isset( $_GET["orderby"] ) && '' != $_GET["orderby"] ) { $wpv_args['orderby'] = sanitize_text_field($_GET["orderby"]); $mod_url['orderby'] = sanitize_text_field($_GET["orderby"]); if ( isset( $_GET["order"] ) && '' != $_GET["order"] ) { $wpv_args['order'] = sanitize_text_field($_GET["order"]); $mod_url['order'] = sanitize_text_field($_GET["order"]); } } if ( isset( $_GET["paged"] ) && '' != $_GET["paged"]) { $wpv_args['paged'] = (int) $_GET["paged"]; $mod_url['paged'] = (int) $_GET["paged"]; } // Build a query for the other post status. We're interested only in post count $other_post_status_args = $wpv_args; $other_post_status_args['post_status'] = $the_other_post_status; $other_post_status_args['fields'] = 'ids'; // All querying must be done between those two switch_lang() calls otherwise CT translations // will be also (wrongly) included. global $sitepress; $default_language = ''; if( isset( $sitepress ) ) { //changes to the default language $default_language = $sitepress->get_default_language(); $sitepress->switch_lang( $default_language ); } $query = new WP_Query( $wpv_args ); $other_post_status_query = new WP_Query( $other_post_status_args ); if( isset( $sitepress ) ) { //changes to the current language $sitepress->switch_lang( ICL_LANGUAGE_CODE ); } // Number of posts that are being displayed. $wpv_count_posts = $query->post_count; // Total number of posts matching the query. $wpv_found_posts = $query->found_posts; // to hold the number of Views in each status $ct_counts_by_post_status = array( $post_status => $wpv_found_posts, $the_other_post_status => $other_post_status_query->found_posts ); // True if some content templates (even those not matching current query) exist. $some_posts_exist = ( $ct_counts_by_post_status['publish'] > 0 || $ct_counts_by_post_status['trash'] > 0 ); $active_nondefault_languages = array(); $add_translation_icon = ''; $edit_translation_icon = ''; $are_cts_translatable = WPV_Content_Template_Embedded::is_translatable(); if( $are_cts_translatable ) { $active_languages = apply_filters( 'wpml_active_languages', array() ); // just remove the default language $active_nondefault_languages = $active_languages; unset( $active_nondefault_languages[ $default_language ] ); // store urls to add/edit translaton icons if( defined( 'ICL_PLUGIN_URL' ) ) { $add_translation_icon = ICL_PLUGIN_URL . '/res/img/add_translation.png'; $edit_translation_icon = ICL_PLUGIN_URL . '/res/img/edit_translation.png'; } } ?> <?php if ( $some_posts_exist ) { ?> <ul class="subsubsub" style="clear:both"><!-- links to lists WPA in different statuses --> <li> <?php $is_plain_publish_current_status = ( $wpv_args['post_status'] == 'publish' && !isset( $_GET["s"] ) ); printf( '<a href="%s" %s>%s</a> (%s) | ', esc_url( add_query_arg( array( 'page' => 'view-templates', 'status' => 'publish' ), admin_url( 'admin.php' ) ) ), $is_plain_publish_current_status ? ' class="current" ' : '', __( 'Published', 'wpv-views' ), $ct_counts_by_post_status['publish'] ); ?> </li> <li> <?php $is_plain_trash_current_status = ( $wpv_args['post_status'] == 'trash' && !isset( $_GET["s"] ) ); printf( '<a href="%s" %s>%s</a> (%s)', esc_url( add_query_arg( array( 'page' => 'view-templates', 'status' => 'trash' ), admin_url( 'admin.php' ) ) ), $is_plain_trash_current_status ? ' class="current" ' : '', __( 'Trash', 'wpv-views' ), $ct_counts_by_post_status['trash'] ); ?> </li> </ul> <?php } else { // No post exist at all ?> <p class="wpv-view-not-exist"> <?php _e('Content Templates let you design single pages.','wpv-views'); ?> </p> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo esc_url( add_query_arg( array( 'action' => 'wpv_ct_create_new' ), admin_url( 'admin-ajax.php' ) ) ); ?>"> <i class="icon-plus"></i><?php _e('Add new Content Template','wpv-views') ?> </button> </p><?php } // A nonce for CT action - used for individual as well as for bulk actions. // It will have a value only if some posts exist. $ct_action_nonce = ''; if( $some_posts_exist ) { $ct_action_nonce = wp_create_nonce( 'wpv_view_listing_actions_nonce' ); // === Render "tablenav" section (Bulk actions and Search box) === echo '<div class="tablenav top">'; if( $wpv_count_posts > 0 ) { // Prepare to render bulk actions dropdown. if( 'publish' == $wpv_args['post_status'] ) { $bulk_actions = array( 'trash' => __( 'Move to trash', 'wpv-views' ) ); } else { $bulk_actions = array( 'restore-from-trash' => __( 'Restore from trash', 'wpv-views' ), 'delete' => __( 'Delete permanently', 'wpv-views' ) ); } $bulk_actions_args = array( 'data-viewactionnonce' => $ct_action_nonce ); $bulk_actions_class = 'js-wpv-ct-listing-bulk-action'; echo wpv_admin_table_bulk_actions( $bulk_actions, $bulk_actions_class, $bulk_actions_args, 'top' ); } // Show search box if ( $wpv_found_posts > 0 ) { ?> <div class="alignright"> <form id="posts-filter" action="" method="get"> <p class="search-box"> <label class="screen-reader-text" for="post-search-input"><?php _e('Search Views:', 'wpv-views') ?></label> <?php $search_term = isset( $_GET["s"] ) ? urldecode( sanitize_text_field($_GET["s"]) ) : ''; ?> <input type="search" id="ct-post-search-input" name="s" value="<?php echo $search_term; ?>"> <input type="submit" name="" id="ct-search-submit" class="button" value="<?php echo htmlentities( __('Search Content Templates', 'wpv-views'), ENT_QUOTES ); ?>"> <input type="hidden" name="paged" value="1" /> </p> </form> </div> <?php } echo '</div>'; // End of tablenav section } if ( $wpv_count_posts == 0 && $some_posts_exist ) { // No posts are displayed, but some exist if ( isset( $_GET["s"] ) && '' != $_GET["s"] ) { if ( $wpv_args['post_status'] == 'trash' ) { // Searching in trash ?> <div class="wpv-views-listing views-empty-list"> <p> <?php printf( '<p>%s</p><p><a class="button-secondary" href="%s">%s</a></p>', __( 'No Content Templates in trash matched your criteria.', 'wpv-views' ), wpv_maybe_add_query_arg( array( 'page' => 'view-templates', 'orderby' => $mod_url['orderby'], 'order' => $mod_url['order'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => '1', 'status' => 'trash' ), admin_url( 'admin.php' ) ), __( 'Return', 'wpv-views' ) ); ?> </p> </div> <?php } else { // Normal search ?> <div class="wpv-views-listing views-empty-list"> <p> <?php printf( '<p>%s</p><p><a class="button-secondary" href="%s">%s</a></p>', __( 'No Content Templates matched your criteria.', 'wpv-views' ), wpv_maybe_add_query_arg( array( 'page' => 'view-templates', 'orderby' => $mod_url['orderby'], 'order' => $mod_url['order'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => '1' ), admin_url( 'admin.php' ) ), __( 'Return', 'wpv-views' ) ); ?> </p> </div> <?php } } else { if ( $wpv_args['post_status'] == 'trash' ) { // No items in trash ?> <div class="wpv-views-listing views-empty-list"> <p> <?php printf( '<p>%s</p><p><a class="button-secondary" href="%s">%s</a></p>', __( 'No Content Templates in trash.', 'wpv-views' ), wpv_maybe_add_query_arg( array( 'page' => 'view-templates', 'orderby' => $mod_url['orderby'], 'order' => $mod_url['order'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => '1' ), admin_url( 'admin.php' ) ), __( 'Return', 'wpv-views' ) ); ?> </p> </div> <?php } else { ?> <p class="wpv-view-not-exist"> <?php _e('Content Templates let you design single pages.','wpv-views'); ?> </p> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo esc_url( add_query_arg( array( 'action' => 'wpv_ct_create_new' ), admin_url( 'admin-ajax.php' ) ) ); ?>"> <i class="icon-plus"></i><?php _e( 'Add new Content Template', 'wpv-views') ?> </button> </p> <?php } } } else if ( $wpv_count_posts != 0 ) { // We have some results to display. global $wpdb; ?> <table class="wpv-views-listing widefat"> <!-- section for: sort by name --> <thead> <?php /* To avoid code duplication, table header is stored in output buffer and echoed twice - within * thead and tfoot tags. */ ob_start(); ?> <tr> <th class="wpv-admin-listing-col-bulkactions check-column"> <input type="checkbox" /> </th> <?php $column_active = ''; $column_sort_to = 'ASC'; $column_sort_now = 'ASC'; $status = ''; if ( $wpv_args['orderby'] === 'title' ) { $column_active = ' views-list-sort-active'; $column_sort_to = ( $wpv_args['order'] === 'ASC' ) ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } if ( isset($_GET['status']) && $_GET['status'] == 'trash' ){ $status = 'trash'; } ?> <th class="wpv-admin-listing-col-title"> <?php printf( '<a href="%s" class="%s" data-orderby="title">%s <i class="%s"></i></a>', wpv_maybe_add_query_arg( array( 'page' => 'view-templates', 'status' => $status, 'orderby' => 'title', 'order' => $column_sort_to, 's' => $mod_url['s'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => $mod_url['paged'] ), admin_url( 'admin.php' ) ), 'js-views-list-sort views-list-sort ' . $column_active, __( 'Title', 'wpv-views' ), ( 'DESC' === $column_sort_now ) ? 'icon-sort-by-alphabet-alt' : 'icon-sort-by-alphabet' ); ?> </th> <?php if( $are_cts_translatable ) { $flag_images = array(); foreach( $active_nondefault_languages as $language_info ) { $flag_images[] = sprintf( '<img style="padding: 2px;" src="%s" title="%s" alt="%s" />', $language_info['country_flag_url'], $language_info['translated_name'], $language_info['code'] ); } if( empty( $flag_images ) ) { $translation_column_header = __( 'Translations', 'wpv-views' ); } else { $translation_column_header = implode( '', $flag_images ); } printf( '<th>%s</th>', $translation_column_header ); } ?> <th class="wpv-admin-listing-col-usage js-wpv-col-two"><?php _e('Used on','wpv-views') ?></th> <?php $column_active = ''; $column_sort_to = 'DESC'; $column_sort_now = 'DESC'; if ( $wpv_args['orderby'] === 'date' ) { $column_active = ' views-list-sort-active'; $column_sort_to = ( $wpv_args['order'] === 'ASC' ) ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } ?> <th class="wpv-admin-listing-col-date"> <?php printf( '<a href="%s" class="%s" data-orderby="date">%s <i class="%s"></i></a>', wpv_maybe_add_query_arg( array( 'page' => 'view-templates', 'status' => $status, 'orderby' => 'date', 'order' => $column_sort_to, 's' => $mod_url['s'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => $mod_url['paged'] ), admin_url( 'admin.php' ) ), 'js-views-list-sort views-list-sort ' . $column_active, __( 'Date', 'wpv-views' ), ( 'DESC' === $column_sort_now ) ? 'icon-sort-by-attributes-alt' : 'icon-sort-by-attributes' ); ?> </th> </tr> <?php // Get table header from output buffer and stop buffering $table_header = ob_get_contents(); ob_end_clean(); echo $table_header; ?> </thead> <tfoot> <?php echo $table_header; ?> </tfoot> <tbody class="js-wpv-views-listing-body"> <?php $alternate = ''; while ( $query->have_posts() ) : $query->the_post(); $post = get_post( get_the_id() ); $template_id = $post->ID; $ct = WPV_Content_Template::get_instance( $template_id ); $wpv_content_template_decription = get_post_meta( $template_id, '_wpv-content-template-decription', true ); $layout_loop_template_for_view_id = get_post_meta( $template_id, '_view_loop_id', true ); $alternate = ( ' alternate' == $alternate ) ? '' : ' alternate'; ?> <tr id="wpv_ct_list_row_<?php echo $template_id; ?>" class="js-wpv-ct-list-row<?php echo $alternate; ?>"> <th class="wpv-admin-listing-col-bulkactions check-column"> <?php if ( empty( $layout_loop_template_for_view_id ) ) { printf( '<input type="checkbox" value="%s" name="view[]" />', $template_id ); } ?> </th> <td class="wpv-admin-listing-col-title post-title page-title column-title"> <span class="row-title"> <?php if ( $wpv_args['post_status'] == 'trash' ) { echo esc_html( $post->post_title ); } else { wpv_ct_editor_render_link( $template_id, esc_html( $post->post_title ) ); } ?> </span> <?php if ( ! empty( $wpv_content_template_decription ) ) { ?> <p class="desc"> <?php echo nl2br( $wpv_content_template_decription )?> </p> <?php } /* Generate and show row actions. * Note that we want to add also 'simple' action names to the action list because * they get echoed as a class of the span tag and get styled from WordPress core css * accordingly (e.g. trash in different colour than the rest) */ $row_actions = array(); $asigned_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(post_id) FROM {$wpdb->postmeta} JOIN {$wpdb->posts} p WHERE meta_key = '_views_template' AND meta_value = %s AND post_id = p.ID AND p.post_status NOT IN ('auto-draft') AND p.post_type != 'revision'", $template_id ) ); if ( 'publish' == $wpv_args['post_status'] ) { $row_actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( array( 'page' => WPV_CT_EDITOR_PAGE_NAME, 'ct_id' => $template_id ), admin_url( 'admin.php' ) ) ), __( 'Edit', 'wpv-views' ) ); if ( empty( $layout_loop_template_for_view_id ) ) { $row_actions['change js-wpv-ct-change-usage-popup'] = sprintf( '<a href="#">%s</a>', __( 'Change template usage', 'wpv-views' ) ); } $row_actions['duplicate js-list-ct-action-duplicate'] = sprintf( '<a href="#">%s</a>', __( 'Duplicate', 'wpv-views' ) ); if ( empty( $layout_loop_template_for_view_id ) ) { $row_actions['trash js-wpv-ct-action-trash'] = sprintf( '<a href="#">%s</a>', __( 'Move to trash', 'wpv-views' ) ); } } else if ( 'trash' == $wpv_args['post_status'] ) { $row_actions['restore-from-trash js-wpv-ct-action-restore-from-trash'] = sprintf( '<a href="#">%s</a>', __( 'Restore from trash', 'wpv-views' ) ); $row_actions['delete js-list-ct-action-delete'] = sprintf( '<a href="#">%s</a>', __( 'Delete', 'wpv-views' ) ); } echo wpv_admin_table_row_actions( $row_actions, array( "data-ct-id" => $template_id, "data-postcount" => $asigned_count, "data-ct-name" => htmlentities( $post->post_title, ENT_QUOTES ), "data-viewactionnonce" => $ct_action_nonce, // Used by the "duplicate" action "data-msg" => htmlentities( __( 'Enter new title','wpv-views'), ENT_QUOTES ) ) ); ?> </td> <?php if( $are_cts_translatable ) { echo '<td>'; $ct_translations = $ct->wpml_translations; foreach( $active_nondefault_languages as $language_info ) { $translation = wpv_getarr( $ct_translations, $language_info['code'], null ); if( null == $translation ) { $translation_text = __( 'Add translation', 'wpv-views' ); $translation_icon = $add_translation_icon; } else { $translation_text = __( 'Edit translation', 'wpv-views' ); $translation_icon = $edit_translation_icon; } $translation_editor_link = $ct->get_wpml_tm_link( $language_info['code'] ); if( null != $translation_editor_link ) { printf( '<a style="padding: 2px;" href="%s"><img alt="%s" src="%s" title="%s" /></a>', $translation_editor_link, $language_info['code'], $translation_icon, $translation_text ); } else { /** @noinspection CssInvalidFunction */ /** @noinspection CssUnknownProperty */ printf( '<span style="padding: 2px"> <img alt="%s" src="%s" title="%s" style="-webkit-filter: grayscale(100%%); filter: grayscale(100%%)"/> </span>', $language_info['code'], $translation_icon, __( 'WPML Translation Management must be active for this link to work.', 'wpv-view' ) ); } } echo '</td>'; } ?> <td class="wpv-admin-listing-col-usage"> <?php echo wpv_content_template_used_for_list( $template_id ); ?> </td> <td class="wpv-admin-listing-col-date"> <?php echo get_the_time( get_option( 'date_format' ), $template_id ); ?> </td> </tr> <?php endwhile; ?> </tbody> </table> <div class="tablenav bottom"> <?php echo wpv_admin_table_bulk_actions( $bulk_actions, $bulk_actions_class, $bulk_actions_args, 'bottom' ); ?> </div> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo esc_url( add_query_arg( array( 'action' => 'wpv_ct_create_new' ), admin_url( 'admin-ajax.php' ) ) ); ?>"> <i class="icon-plus"></i><?php _e( 'Add new Content Template','wpv-views' ) ?> </button> </p> <?php } wpv_admin_listing_pagination( 'view-templates', $wpv_found_posts, $wpv_args["posts_per_page"], $mod_url ); // Render dialog templates. wpv_render_ct_listing_dialog_templates_arrangeby_name(); }
function wpv_admin_content_template_listing_name() { $mod_url = array('orderby' => '', 'order' => '', 's' => '', 'items_per_page' => '', 'paged' => '', 'status' => ''); $wpv_args = array('post_type' => 'view-template', 'posts_per_page' => WPV_ITEMS_PER_PAGE, 'order' => 'ASC', 'orderby' => 'title', 'post_status' => 'publish'); // Apply post_status coming from the URL parameters. if (isset($_GET["status"]) && '' != $_GET["status"]) { $wpv_args['post_status'] = sanitize_text_field($_GET["status"]); $mod_url['status'] = sanitize_text_field($_GET["status"]); } if (isset($_GET["s"]) && '' != $_GET["s"]) { $wpv_args = wpv_modify_wpquery_for_search($_GET["s"], $wpv_args); $mod_url['s'] = sanitize_text_field($_GET["s"]); } if (isset($_GET["items_per_page"]) && '' != $_GET["items_per_page"]) { $wpv_args['posts_per_page'] = (int) $_GET["items_per_page"]; $mod_url['items_per_page'] = (int) $_GET["items_per_page"]; } if (isset($_GET["orderby"]) && '' != $_GET["orderby"]) { $wpv_args['orderby'] = sanitize_text_field($_GET["orderby"]); $mod_url['orderby'] = sanitize_text_field($_GET["orderby"]); if (isset($_GET["order"]) && '' != $_GET["order"]) { $wpv_args['order'] = sanitize_text_field($_GET["order"]); $mod_url['order'] = sanitize_text_field($_GET["order"]); } } if (isset($_GET["paged"]) && '' != $_GET["paged"]) { $wpv_args['paged'] = (int) $_GET["paged"]; $mod_url['paged'] = (int) $_GET["paged"]; } $query = new WP_Query($wpv_args); // Number of posts that are being displayed. $wpv_count_posts = $query->post_count; // Total number of posts matching the query. $wpv_found_posts = $query->found_posts; $all_posts = wp_count_posts('view-template'); $wpv_views_status = array(); // to hold the number of Views in each status $wpv_views_status['publish'] = $all_posts->publish; $wpv_views_status['trash'] = $all_posts->trash; // True if some content templates (even those not matching current query) exist. $some_posts_exist = $wpv_views_status['publish'] > 0 || $wpv_views_status['trash'] > 0; ?> <?php if ($some_posts_exist) { ?> <ul class="subsubsub" style="clear:both"><!-- links to lists WPA in different statuses --> <li> <?php $is_plain_publish_current_status = $wpv_args['post_status'] == 'publish' && !isset($_GET["s"]); printf('<a href="%s" %s>%s</a> (%s) | ', esc_url(add_query_arg(array('page' => 'view-templates', 'status' => 'publish'), admin_url('admin.php'))), $is_plain_publish_current_status ? ' class="current" ' : '', __('Published', 'wpv-views'), $wpv_views_status['publish']); ?> </li> <li> <?php $is_plain_trash_current_status = $wpv_args['post_status'] == 'trash' && !isset($_GET["s"]); printf('<a href="%s" %s>%s</a> (%s)', esc_url(add_query_arg(array('page' => 'view-templates', 'status' => 'trash'), admin_url('admin.php'))), $is_plain_trash_current_status ? ' class="current" ' : '', __('Trash', 'wpv-views'), $wpv_views_status['trash']); ?> </li> </ul> <?php } else { // No post exist at all ?> <p class="wpv-view-not-exist"> <?php _e('Content Templates let you design single pages.', 'wpv-views'); ?> </p> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo esc_url(add_query_arg(array('action' => 'wpv_ct_create_new'), admin_url('admin-ajax.php'))); ?> "> <i class="icon-plus"></i><?php _e('Add new Content Template', 'wpv-views'); ?> </button> </p><?php } if ($some_posts_exist) { // A nonce for CT action - used for individual as well as for bulk actions $ct_action_nonce = wp_create_nonce('wpv_view_listing_actions_nonce'); // === Render "tablenav" section (Bulk actions and Search box) === echo '<div class="tablenav top">'; if ($wpv_count_posts > 0) { // Prepare to render bulk actions dropdown. if ('publish' == $wpv_args['post_status']) { $bulk_actions = array('trash' => __('Move to trash', 'wpv-views')); } else { $bulk_actions = array('restore-from-trash' => __('Restore from trash', 'wpv-views'), 'delete' => __('Delete permanently', 'wpv-views')); } $bulk_actions_args = array('data-viewactionnonce' => $ct_action_nonce); $bulk_actions_class = 'js-wpv-ct-listing-bulk-action'; echo wpv_admin_table_bulk_actions($bulk_actions, $bulk_actions_class, $bulk_actions_args, 'top'); } // Show search box if ($wpv_found_posts > 0) { ?> <div class="alignright"> <form id="posts-filter" action="" method="get"> <p class="search-box"> <label class="screen-reader-text" for="post-search-input"><?php _e('Search Views:', 'wpv-views'); ?> </label> <?php $search_term = isset($_GET["s"]) ? urldecode(sanitize_text_field($_GET["s"])) : ''; ?> <input type="search" id="ct-post-search-input" name="s" value="<?php echo $search_term; ?> "> <input type="submit" name="" id="ct-search-submit" class="button" value="<?php echo htmlentities(__('Search Content Templates', 'wpv-views'), ENT_QUOTES); ?> "> <input type="hidden" name="paged" value="1" /> </p> </form> </div> <?php } echo '</div>'; // End of tablenav section } if ($wpv_count_posts == 0 && $some_posts_exist) { // No posts are displayed, but some exist if (isset($_GET["s"]) && '' != $_GET["s"]) { if ($wpv_args['post_status'] == 'trash') { // Searching in trash ?> <div class="wpv-views-listing views-empty-list"> <p> <?php printf('<p>%s</p><p><a class="button-secondary" href="%s">%s</a></p>', __('No Content Templates in trash matched your criteria.', 'wpv-views'), wpv_maybe_add_query_arg(array('page' => 'view-templates', 'orderby' => $mod_url['orderby'], 'order' => $mod_url['order'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => '1', 'status' => 'trash'), admin_url('admin.php')), __('Return', 'wpv-views')); ?> </p> </div> <?php } else { // Normal search ?> <div class="wpv-views-listing views-empty-list"> <p> <?php printf('<p>%s</p><p><a class="button-secondary" href="%s">%s</a></p>', __('No Content Templates matched your criteria.', 'wpv-views'), wpv_maybe_add_query_arg(array('page' => 'view-templates', 'orderby' => $mod_url['orderby'], 'order' => $mod_url['order'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => '1'), admin_url('admin.php')), __('Return', 'wpv-views')); ?> </p> </div> <?php } } else { if ($wpv_args['post_status'] == 'trash') { // No items in trash ?> <div class="wpv-views-listing views-empty-list"> <p> <?php printf('<p>%s</p><p><a class="button-secondary" href="%s">%s</a></p>', __('No Content Templates in trash.', 'wpv-views'), wpv_maybe_add_query_arg(array('page' => 'view-templates', 'orderby' => $mod_url['orderby'], 'order' => $mod_url['order'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => '1'), admin_url('admin.php')), __('Return', 'wpv-views')); ?> </p> </div> <?php } else { ?> <p class="wpv-view-not-exist"> <?php _e('Content Templates let you design single pages.', 'wpv-views'); ?> </p> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo esc_url(add_query_arg(array('action' => 'wpv_ct_create_new'), admin_url('admin-ajax.php'))); ?> "> <i class="icon-plus"></i><?php _e('Add new Content Template', 'wpv-views'); ?> </button> </p> <?php } } } else { if ($wpv_count_posts != 0) { // We have some results to display. global $wpdb; ?> <table class="wpv-views-listing widefat"> <!-- section for: sort by name --> <thead> <?php /* To avoid code duplication, table header is stored in output buffer and echoed twice - within * thead and tfoot tags. */ ob_start(); ?> <tr> <th class="wpv-admin-listing-col-bulkactions check-column"> <input type="checkbox" /> </th> <?php $column_active = ''; $column_sort_to = 'ASC'; $column_sort_now = 'ASC'; $status = ''; if ($wpv_args['orderby'] === 'title') { $column_active = ' views-list-sort-active'; $column_sort_to = $wpv_args['order'] === 'ASC' ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } if (isset($_GET['status']) && $_GET['status'] == 'trash') { $status = 'trash'; } ?> <th class="wpv-admin-listing-col-title"> <?php printf('<a href="%s" class="%s" data-orderby="title">%s <i class="%s"></i></a>', wpv_maybe_add_query_arg(array('page' => 'view-templates', 'status' => $status, 'orderby' => 'title', 'order' => $column_sort_to, 's' => $mod_url['s'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => $mod_url['paged']), admin_url('admin.php')), 'js-views-list-sort views-list-sort ' . $column_active, __('Title', 'wpv-views'), 'DESC' === $column_sort_now ? 'icon-sort-by-alphabet-alt' : 'icon-sort-by-alphabet'); ?> </th> <th class="wpv-admin-listing-col-usage js-wpv-col-two"><?php _e('Used on', 'wpv-views'); ?> </th> <?php $column_active = ''; $column_sort_to = 'DESC'; $column_sort_now = 'DESC'; if ($wpv_args['orderby'] === 'date') { $column_active = ' views-list-sort-active'; $column_sort_to = $wpv_args['order'] === 'ASC' ? 'DESC' : 'ASC'; $column_sort_now = $wpv_args['order']; } ?> <th class="wpv-admin-listing-col-date"> <?php printf('<a href="%s" class="%s" data-orderby="date">%s <i class="%s"></i></a>', wpv_maybe_add_query_arg(array('page' => 'view-templates', 'status' => $status, 'orderby' => 'date', 'order' => $column_sort_to, 's' => $mod_url['s'], 'items_per_page' => $mod_url['items_per_page'], 'paged' => $mod_url['paged']), admin_url('admin.php')), 'js-views-list-sort views-list-sort ' . $column_active, __('Date', 'wpv-views'), 'DESC' === $column_sort_now ? 'icon-sort-by-attributes-alt' : 'icon-sort-by-attributes'); ?> </th> </tr> <?php // Get table header from output buffer and stop buffering $table_header = ob_get_contents(); ob_end_clean(); echo $table_header; ?> </thead> <tfoot> <?php echo $table_header; ?> </tfoot> <tbody class="js-wpv-views-listing-body"> <?php $alternate = ''; while ($query->have_posts()) { $query->the_post(); $post = get_post(get_the_id()); $template_id = $post->ID; $wpv_content_template_decription = get_post_meta($template_id, '_wpv-content-template-decription', true); $layout_loop_template_for_view_id = get_post_meta($template_id, '_view_loop_id', true); $alternate = ' alternate' == $alternate ? '' : ' alternate'; ?> <tr id="wpv_ct_list_row_<?php echo $template_id; ?> " class="js-wpv-ct-list-row<?php echo $alternate; ?> "> <th class="wpv-admin-listing-col-bulkactions check-column"> <?php if (empty($layout_loop_template_for_view_id)) { printf('<input type="checkbox" value="%s" name="view[]" />', $template_id); } ?> </th> <td class="wpv-admin-listing-col-title post-title page-title column-title"> <span class="row-title"> <?php if ($wpv_args['post_status'] == 'trash') { echo $post->post_title; } else { printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('action' => 'edit', 'post' => $template_id), admin_url('post.php'))), $post->post_title); } ?> </span> <?php if (!empty($wpv_content_template_decription)) { ?> <p class="desc"> <?php echo nl2br($wpv_content_template_decription); ?> </p> <?php } /* Generate and show row actions. * Note that we want to add also 'simple' action names to the action list because * they get echoed as a class of the span tag and get styled from WordPress core css * accordingly (e.g. trash in different colour than the rest) */ $row_actions = array(); $asigned_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(post_id) FROM {$wpdb->postmeta} JOIN {$wpdb->posts} p \n\t\t\t\t\t\t\t\t\t\t\tWHERE meta_key = '_views_template' \n\t\t\t\t\t\t\t\t\t\t\tAND meta_value = %s\n\t\t\t\t\t\t\t\t\t\t\tAND post_id = p.ID \n\t\t\t\t\t\t\t\t\t\t\tAND p.post_status NOT IN ('auto-draft') \n\t\t\t\t\t\t\t\t\t\t\tAND p.post_type != 'revision'", $template_id)); if ('publish' == $wpv_args['post_status']) { $row_actions['edit'] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('action' => 'edit', 'post' => $template_id), admin_url('post.php'))), __('Edit', 'wpv-views')); /* Note that hash in <a href="#"> is present so the link behaves like a link. * <a href=""> causes problems with colorbox and with mere <a> the mouse cursor * doesn't change when hovering over the link. */ if (empty($layout_loop_template_for_view_id)) { $row_actions['change js-list-ct-action-change'] = sprintf('<a href="#">%s</a>', __('Change template usage', 'wpv-views')); } $row_actions['duplicate js-list-ct-action-duplicate'] = sprintf('<a href="#">%s</a>', __('Duplicate', 'wpv-views')); if (empty($layout_loop_template_for_view_id)) { $row_actions['trash js-list-ct-action-trash'] = sprintf('<a href="#">%s</a>', __('Move to trash', 'wpv-views')); } } else { if ('trash' == $wpv_args['post_status']) { $row_actions['restore-from-trash js-list-ct-action-restore-from-trash'] = sprintf('<a href="#">%s</a>', __('Restore from trash', 'wpv-views')); $row_actions['delete js-list-ct-action-delete'] = sprintf('<a href="#">%s</a>', __('Delete', 'wpv-views')); } } echo wpv_admin_table_row_actions($row_actions, array("data-ct-id" => $template_id, "data-postcount" => $asigned_count, "data-ct-name" => htmlentities($post->post_title, ENT_QUOTES), "data-viewactionnonce" => $ct_action_nonce, "data-msg" => htmlentities(__('Enter new title', 'wpv-views'), ENT_QUOTES))); ?> </td> <td class="wpv-admin-listing-col-usage"> <?php echo wpv_content_template_used_for_list($template_id); ?> </td> <td class="wpv-admin-listing-col-date"> <?php echo get_the_time(get_option('date_format'), $template_id); ?> </td> </tr> <?php } ?> </tbody> </table> <div class="tablenav bottom"> <?php echo wpv_admin_table_bulk_actions($bulk_actions, $bulk_actions_class, $bulk_actions_args, 'bottom'); ?> </div> <p class="add-new-view"> <button class="button js-add-new-content-template" data-target="<?php echo esc_url(add_query_arg(array('action' => 'wpv_ct_create_new'), admin_url('admin-ajax.php'))); ?> "> <i class="icon-plus"></i><?php _e('Add new Content Template', 'wpv-views'); ?> </button> </p> <?php } } wpv_admin_listing_pagination('view-templates', $wpv_found_posts, $wpv_args["posts_per_page"], $mod_url); // Render dialog templates. wpv_render_ct_listing_dialog_templates_arrangeby_name(); }