/** * wpv_admin_archive_listing_page * * Creates the main structure of the WPA admin listing page: wrapper and header * */ function wpv_admin_archive_listing_page() { global $WPV_view_archive_loop; ?> <div class="wrap toolset-views"> <!-- wpv-views-listing-archive-page can be removed --> <div class="wpv-views-listing-page wpv-views-listing-archive-page" data-none-message="<?php _e("This WordPress Archive isn't being used for any loops.",'wpv-views') ?>" > <?php // 'trash' or 'publish' $current_post_status = wpv_getget( 'status', 'publish', array( 'trash', 'publish' ) ); $search_term = urldecode( sanitize_text_field( wpv_getget( 's' ) ) ); $arrange_by_usage = ( sanitize_text_field( wpv_getget( 'arrangeby' ) ) == 'usage' ); wp_nonce_field( 'work_views_listing', 'work_views_listing' ); wp_nonce_field( 'wpv_remove_view_permanent_nonce', 'wpv_remove_view_permanent_nonce' ); ?> <div id="icon-views" class="icon32"></div> <h2><!-- classname wpv-page-title removed --> <?php _e( 'WordPress Archives', 'wpv-views' ); ?> <a href="#" class="add-new-h2 page-title-action js-wpv-views-archive-add-new wpv-views-archive-add-new"> <?php _e('Add new WordPress Archive','wpv-views') ?> </a> <?php if ( !empty( $search_term ) ) { $search_message = __('Search results for "%s"','wpv-views'); if ( 'trash' == $current_post_status ) { $search_message = __('Search results for "%s" in trashed WordPress Archives', 'wpv-views'); } ?> <span class="subtitle"> <?php echo sprintf( $search_message, $search_term ); ?> </span> <?php } ?> </h2> <?php // Messages: trashed, untrashed, deleted // We can reuse the function from Views listing (there's a note saying we're doing that). add_filter( 'wpv_maybe_show_listing_message_undo', 'wpv_admin_view_listing_message_undo', 10, 3 ); wpv_maybe_show_listing_message( 'trashed', __( 'WordPress Archive moved to the Trash.', 'wpv-views' ), __( '%d WordPress Archives moved to the Trash.', 'wpv-views' ), true ); wpv_maybe_show_listing_message( 'untrashed', __( 'WordPress Archive restored from the Trash.', 'wpv-views' ), __( '%d WordPress Archives restored from the Trash.', 'wpv-views' ) ); wpv_maybe_show_listing_message( 'deleted', __( 'WordPress Archive permanently deleted.', 'wpv-views' ), __( '%d WordPress Archives permanently deleted.', 'wpv-views' ) ); // "Arrange by" tabs ?> <div class="wpv-admin-tabs"> <ul class="wpv-admin-tabs-links"> <li> <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'view-archives' ), admin_url( 'admin.php' ) ) ); ?>" <?php wpv_current_class( ! $arrange_by_usage ); ?> > <?php _e( 'Arrange by name', 'wpv-views' ); ?> </a> </li> <li> <a href="<?php echo esc_url( add_query_arg( array( 'page' => 'view-archives', 'arrangeby' => 'usage' ), admin_url( 'admin.php' ) ) ); ?>" <?php wpv_current_class( $arrange_by_usage ); ?> > <?php _e( 'Arrange by usage', 'wpv-views' ); ?> </a> </li> </ul> </div> <?php if ( $arrange_by_usage ) { // Show table arranged by Usage wp_nonce_field( 'wpv_wp_archive_arrange_usage', 'wpv_wp_archive_arrange_usage' ); if ( !$WPV_view_archive_loop->check_archive_loops_exists() ) { ?> <p id="js-wpv-no-archive" class="toolset-alert toolset-alert-success update below-h2"> <?php _e('All loops have a WordPress Archive assigned','wpv-views'); ?> </p> <?php } wpv_admin_wordpress_archives_listing_table_by_usage(); ?> <p class="add-new-view js-add-new-view"> <a class="button js-wpv-views-archive-add-new wpv-views-archive-add-new" href="#"> <i class="icon-plus"></i><?php _e('Add new WordPress Archive','wpv-views') ?> </a> </p> <?php } else { // IDs of possible results and counts per post status. $views_pre_query_data = wpv_prepare_view_listing_query( array( 'archive', 'layouts-loop' ), $current_post_status ); // Do we have any Views at all? $has_items = ( $views_pre_query_data['total_count'] > 0 ); // Show table arranged by item names if ( $has_items ) { wpv_admin_wordpress_archives_listing_table_by_name( $views_pre_query_data, $current_post_status ); } else { // No items are present. if ( !$WPV_view_archive_loop->check_archive_loops_exists() ) { ?> <p id="js-wpv-no-archive" class="toolset-alert toolset-alert-success"> <?php _e('All loops have a WordPress Archive assigned','wpv-views'); ?> </p> <?php } ?> <div class="wpv-view-not-exist js-wpv-view-not-exist"> <p><?php _e( 'WordPress Archives let you customize the output of standard Archive pages.', 'wpv-views' );?></p> <p> <a class="button js-wpv-views-archive-create-new" href="#"> <i class="icon-plus"></i> <?php _e( 'Create your first WordPress Archive', 'wpv-views' );?> </a> </p> </div> <?php } } ?> </div> <!-- .wpv-settings-container" --> </div> <?php }
function wpv_admin_menu_content_templates_listing_page() { ?> <div class="wrap toolset-views"> <div class="wpv-views-listing-page"> <?php wp_nonce_field( 'work_view_template', 'work_view_template' ); $search_term = isset( $_GET["s"] ) ? urldecode( sanitize_text_field($_GET["s"]) ) : ''; ?> <div id="icon-views" class="icon32"></div> <h2><!-- classname wpv-page-title removed --> <?php _e( 'Content Templates', 'wpv-views' ); printf( ' <a href="#" class="add-new-h2 page-title-action js-add-new-content-template" data-target="%s">%s</a>', esc_url( add_query_arg( array( 'action' => 'wpv_ct_create_new' ), admin_url( 'admin-ajax.php' ) ) ), __( 'Add new Content Template', 'wpv-views' ) ); if ( !empty( $search_term ) ) { $search_message = __('Search results for "%s"','wpv-views'); if ( isset( $_GET["status"] ) && 'trash' == sanitize_text_field( $_GET["status"] ) ) { $search_message = __('Search results for "%s" in trashed Content Templates', 'wpv-views'); } ?> <span class="subtitle"> <?php echo sprintf( $search_message, $search_term ); ?> </span> <?php } ?> </h2> <?php // Messages: trashed, untrashed, deleted add_filter( 'wpv_maybe_show_listing_message_undo', 'wpv_admin_ct_listing_message_undo', 10, 3 ); wpv_maybe_show_listing_message( 'trashed', __( 'Content Template moved to the Trash.', 'wpv-views' ), __( '%d Content Templates moved to the Trash.', 'wpv-views' ), true ); wpv_maybe_show_listing_message( 'untrashed', __( 'Content Template restored from the Trash.', 'wpv-views' ), __( '%d Content Templates restored from the Trash.', 'wpv-views' ) ); wpv_maybe_show_listing_message( 'deleted', __( 'Content Template permanently deleted.', 'wpv-views' ), __( '%d Content Templates permanently deleted.', 'wpv-views' ) ); // Determine how should we arrange the items (what should be displayed) if ( isset( $_GET["arrangeby"] ) && sanitize_text_field( $_GET["arrangeby"] ) == 'usage' ) { $arrange_by = 'single'; if ( isset( $_GET["usage"] ) ) { $arrange_by = sanitize_text_field($_GET["usage"]); } } else { $arrange_by = 'name'; } // "Arrange by" tabs ?> <div class="wpv-admin-tabs"> <ul class="wpv-admin-tabs-links"> <?php $tabs = array( 'name' => __( 'Name','wpv-views' ), 'single' => __( 'Usage for single page', 'wpv-views' ), 'post-archives' => __( 'Usage for custom post archives', 'wpv-views' ), 'taxonomy-archives' => __( 'Usage for taxonomy archives', 'wpv-views' ) ); foreach( $tabs as $tab_slug => $tab_label ) { printf( '<li><a href="%s" %s>%s</a></li>', esc_url( add_query_arg( array( 'page' => 'view-templates', 'arrangeby' => ( 'name' == $tab_slug ) ? 'name' : 'usage', 'usage' => $tab_slug ), admin_url( 'admin.php' ) ) ), wpv_current_class( $arrange_by, $tab_slug, false ), $tab_label ); } ?> </ul> </div> <?php // Render the actual listing if ( 'name' == $arrange_by ) { wpv_admin_content_template_listing_name(); } else { wpv_admin_content_template_listing_usage( $arrange_by ); } ?> </div> <!-- .wpv-views-listing-page --> </div> <!-- .toolset-views --> <?php }