/** * wpv_admin_menu_views_listing_page * * Creates the main structure of the Views admin listing page: wrapper and header * */ function wpv_admin_menu_views_listing_page() { ?> <div class="wrap toolset-views"> <div class="wpv-views-listing-page"> <?php // 'trash' or 'publish' $current_post_status = wpv_getget('status', 'publish', array('trash', 'publish')); $search_term = urldecode(sanitize_text_field(wpv_getget('s'))); // IDs of possible results and counts per post status $views_pre_query_data = wpv_prepare_view_listing_query('normal', $current_post_status); // Do we have any Views at all? $has_views = $views_pre_query_data['total_count'] > 0; // general nonce // TODO please do NOT use this general nonce wp_nonce_field('work_views_listing', 'work_views_listing'); ?> <div id="icon-views" class="icon32"></div> <h2><!-- classname wpv-page-title removed --> <?php _e('Views', 'wpv-views'); printf(' <a href="#" class="add-new-h2 js-wpv-views-add-new-top">%s</a>', __('Add new View', 'wpv-views')); // TODO maybe have this nonce as a data attribute for all buttons opening the popup wp_nonce_field('wp_nonce_create_view_wrapper', 'wp_nonce_create_view_wrapper'); if (!empty($search_term)) { if ('trash' == $current_post_status) { $search_message = __('Search results for "%s" in trashed Views', 'wpv-views'); } else { $search_message = __('Search results for "%s"', '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_view_listing_message_undo', 10, 3); wpv_maybe_show_listing_message('trashed', __('View moved to the Trash.', 'wpv-views'), __('%d Views moved to the Trash.', 'wpv-views'), true); wpv_maybe_show_listing_message('untrashed', __('View restored from the Trash.', 'wpv-views'), __('%d Views restored from the Trash.', 'wpv-views')); wpv_maybe_show_listing_message('deleted', __('View permanently deleted.', 'wpv-views'), __('%d Views permanently deleted.', 'wpv-views')); if ($has_views) { // Display the rest of the content if there are Views to list wpv_admin_view_listing_table($views_pre_query_data, $current_post_status); } else { // Show a message in any other case ?> <div class="wpv-view-not-exist js-wpv-view-not-exist"> <p><?php _e('Views load content from the database and display on the site.'); ?> </p> <p> <a class="button js-wpv-views-add-first" href="#"> <i class="icon-plus"></i> <?php _e('Create your first View', 'wpv-views'); ?> </a> </p> </div> <?php } ?> </div> <!-- .wpv-views-listing-page" --> </div> <!-- .toolset-views" --> <?php wpv_render_view_listing_dialog_templates(); }
/** * wpv_admin_menu_views_listing_page * * Creates the main structure of the Views admin listing page: wrapper and header * */ function wpv_admin_menu_views_listing_page() { ?> <div class="wrap toolset-views"> <div class="wpv-views-listing-page"> <?php $has_views = wpv_check_views_exists('normal'); // $has_views holds an array with all the Views IDs or false if there isn't any $search_term = isset($_GET["search"]) ? urldecode(sanitize_text_field($_GET["search"])) : ''; wp_nonce_field('work_views_listing', 'work_views_listing'); // general nonce TODO please do NOT use this general nonce ?> <div id="icon-views" class="icon32"></div> <h2><!-- classname wpv-page-title removed --> <?php _e('Views', 'wpv-views'); ?> <?php if ($has_views) { ?> <a href="#" class="add-new-h2 js-wpv-views-add-new-top"><?php _e('Add new View', 'wpv-views'); ?> </a> <?php } ?> <?php wp_nonce_field('wp_nonce_create_view_wrapper', 'wp_nonce_create_view_wrapper'); // TODO maybe have this nonce as a data attribute for all buttons opening the popup ?> <?php 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 Views', 'wpv-views'); } ?> <span class="subtitle"> <?php echo sprintf($search_message, $search_term); ?> </span> <?php } ?> </h2> <?php // Messages: trashed, untrashed, deleted if (isset($_GET['trashed']) && is_numeric($_GET['trashed'])) { ?> <div id="message" class="updated below-h2"> <p> <?php _e('View moved to the Trash', 'wpv-views'); ?> . <a href="<?php echo admin_url(); ?> admin.php?page=views&untrashed=1" class="js-wpv-untrash" data-id="<?php echo $_GET['trashed']; ?> " data-nonce="<?php echo wp_create_nonce('wpv_view_listing_actions_nonce'); ?> "><?php _e('Undo', 'wpv-views'); ?> </a> </p> </div> <?php } if (isset($_GET['untrashed']) && is_numeric($_GET['untrashed']) && (int) $_GET['untrashed'] == 1) { ?> <div id="message" class="updated below-h2"> <p> <?php _e('View restored from the Trash', 'wpv-views'); ?> </p> </div> <?php } if (isset($_GET['deleted']) && is_numeric($_GET['deleted']) && (int) $_GET['deleted'] == 1) { ?> <div id="message" class="updated below-h2"> <p> <?php _e('View permanently deleted', 'wpv-views'); ?> </p> </div> <?php } ?> <?php if ($has_views) { // Display the rest of the content if there are Views to list wpv_admin_view_listing_table($has_views); } else { // Show a message in any other case ?> <div class="wpv-view-not-exist js-wpv-view-not-exist"> <p><?php _e('Views load content from the database and display on the site.'); ?> </p> <p><a class="button js-wpv-views-add-first" href="#"><i class="icon-plus"></i><?php _e('Create your first View', 'wpv-views'); ?> </a></p> </div> <?php } ?> </div> <!-- .wpv-views-listing-page" --> </div> <!-- .toolset-views" --> <div class="popup-window-container"> <!-- placeholder for static colorbox popups --> <!-- popup: create View --> <div class="wpv-dialog create-view-form-dialog js-create-view-form-dialog"> <?php wp_nonce_field('wp_nonce_create_view', 'wp_nonce_create_view'); ?> <input class="js-view-new-redirect" name="view_creation_redirect" type="hidden" value="<?php echo admin_url('admin.php?page=views-editor&view_id='); ?> " /> <div class="wpv-dialog-header"> <h2><?php _e('Add a new View', 'wpv-views'); ?> </h2> <i class="icon-remove js-dialog-close"></i> </div> <div class="wpv-dialog-content no-scrollbar"> <p> <?php _e('A View loads content from the database and displays with your HTML.', 'wpv-views'); ?> </p> <p> <strong><?php _e(' What kind of display do you want to create?', 'wpv-views'); ?> </strong> </p> <ul> <li> <p> <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_all" value="all" /> <label for="view_purpose_all"><?php _e('Display all results', 'wpv-views'); ?> </label> </p> <p class="tip"><?php _e('The View will output all the results returned from the query section.', 'wpv-views'); ?> </p> </li> <li> <p> <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_pagination" value="pagination" /> <label for="view_purpose_pagination"><?php _e('Display the results with pagination', 'wpv-views'); ?> </label> </p> <p class="tip"><?php _e('The View will display the query results in pages.', 'wpv-views'); ?> </p> </li> <li> <p> <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_slider" value="slider" /> <label for="view_purpose_slider"><?php _e('Display the results as a slider', 'wpv-views'); ?> </label> </p> <p class="tip"><?php _e('The View will display the query results as slides.', 'wpv-views'); ?> </p> </li> <li> <p> <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_parametric" value="parametric" /> <label for="view_purpose_parametric"><?php _e('Display the results as a parametric search', 'wpv-views'); ?> </label> </p> <p class="tip"><?php _e('Visitors will be able to search through your content using different search criteria.', 'wpv-views'); ?> </p> </li> <li> <p> <input type="radio" name="view_purpose" class="js-view-purpose" id="view_purpose_full" value="full" /> <label for="view_purpose_full"><?php _e('Full custom display mode', 'wpv-views'); ?> </label> </p> <p class="tip"><?php _e('See all the View controls open and set up things manually..', 'wpv-views'); ?> </p> </li> </ul> <p> <strong><label for="view_new_name"><?php _e('Name this View', 'wpv-views'); ?> </label></strong> </p> <p> <input type="text" name="view_new_name" id="view_new_name" class="js-new-post_title" placeholder="<?php echo htmlentities(__('Enter title here', 'wpv-views'), ENT_QUOTES); ?> " data-highlight="<?php echo htmlentities(__('Now give this View a name', 'wpv-views'), ENT_QUOTES); ?> " /> </p> <div class="js-error-container"> </div> </div> <div class="wpv-dialog-footer"> <?php wp_nonce_field('wp_nonce_create_view', 'wp_nonce_create_view'); ?> <button class="button js-dialog-close"><?php _e('Cancel', 'wpv-views'); ?> </button> <button class="button button-primary js-create-new-view"><?php _e('Create View', 'wpv-views'); ?> </button> </div> </div> <!-- .create-view-form-dialog --> <!-- popup: delete View - confirmation --> <div class="wpv-dialog js-delete-view-dialog"> <div class="wpv-dialog-header"> <h2><?php _e('Delete View', 'wpv-views'); ?> </h2> </div> <div class="wpv-dialog-content"> <p><?php _e('Are you sure want delete this View? ', 'wpv-views'); ?> </p> <p><?php _e('Please use the Scan button first to be sure that it is not used anywhere.', 'wpv-views'); ?> </p> </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-view-permanent" data-nonce="<?php echo wp_create_nonce('wpv_remove_view_permanent_nonce'); ?> "><?php _e('Delete', 'wpv-views'); ?> </button> </div> </div> <!-- .js-delete-view-dialog --> <!-- popup: duplicate View - take name for the new one --> <div class="wpv-dialog js-duplicate-view-dialog"> <div class="wpv-dialog-header"> <h2><?php _e('Duplicate View', 'wpv-views'); ?> </h2> </div> <div class="wpv-dialog-content"> <p> <label for="duplicated_view_name"><?php _e('Name this View', 'wpv-views'); ?> </label> <input type="text" value="" class="js-duplicated-view-name" placeholder="<?php _e('Enter name here', 'wpv-views'); ?> " name="duplicated_view_name"> </p> <div class="js-view-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-view" disabled="disabled" data-nonce="<?php echo wp_create_nonce('wpv_duplicate_view_nonce'); ?> " data-error="<?php echo htmlentities(__('A View with that name already exists. Please use another name.', 'wpv-views'), ENT_QUOTES); ?> "><?php _e('Duplicate', 'wpv-views'); ?> </button> </div> </div> <!-- .js-duplicate-view-dialog --> </div> <!-- .popup-window-container" --> <?php }