function form($instance) { global $WP_Views; $views = wpv_check_views_exists('normal', array('post_status' => 'publish', 'orderby' => 'post_title')); $view_forms = array(); if ($views) { foreach ($views as $vi) { if ($WP_Views->does_view_have_form_control_with_submit($vi)) { $view_forms[] = $vi; } } } $instance = wp_parse_args((array) $instance, array('title' => '', 'view' => false, 'target_id' => '')); $title = $instance['title']; $view = $instance['view']; $target_id = $instance['target_id']; $target_title = ''; if ($target_id != '') { $target_title = esc_attr(get_the_title($target_id)); } if (count($view_forms) > 0) { ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'wpv-views'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /> </p> <p> <label for="<?php echo $this->get_field_id('view'); ?> "><?php _e('View containing the form:', 'wpv-views'); ?> </label> <select id="<?php echo $this->get_field_id('view'); ?> " name="<?php echo $this->get_field_name('view'); ?> " class="widefat js-wpv-view-form-id"> <?php foreach ($view_forms as $v) { ?> <option value="<?php echo $v; ?> "<?php if ($view == $v) { ?> selected="selected"<?php } ?> ><?php echo esc_html(get_the_title($v)); ?> </option> <?php } ?> </select> <span class="desc wpv-helper-text"><?php _e('Remember that only Views forms containing a <em>Submit</em> button can be used on a widget', 'wpv-views'); ?> </span> </p> <p> <label for="<?php echo $this->get_field_id('target_title'); ?> "><?php _e('Target page to show the results:', 'wpv-views'); ?> </label> <input type="text" id="<?php echo $this->get_field_id('target_title'); ?> " name="<?php echo $this->get_field_name('target_title'); ?> " value="<?php echo $target_title; ?> " class="widefat js-wpv-widget-form-target-suggest-title" placeholder="<?php echo esc_attr(__('Please type', 'wpv-views')); ?> " /> <input type="hidden" value="<?php echo $target_id; ?> " id="<?php echo $this->get_field_id('target_id'); ?> " name="<?php echo $this->get_field_name('target_id'); ?> " class="widefat js-wpv-widget-form-target-id" /> <input type="hidden" name="wpv-target-customizer-helper" class="js-wpv-target-customizer-helper" /> </p> <p class="toolset-alert toolset-error js-wpv-incomplete-setup-box" style="display:none"> <?php _e('Setup incomplete. Please select the page where you would like to show the search results.', 'wpv-views'); ?> </p> <div class="js-wpv-check-target-setup-box" style="display:none;background:#ddd;margin: 5px 0;padding: 5px 10px 10px;"> <?php _e('Be sure to complete the setup:', 'wpv-views'); ?> <br /> <a href="#" target="_blank" class="button-primary js-wpv-check-target-setup-link" data-editurl="<?php echo admin_url('post.php'); ?> ?post="><?php _e('Check the results page', 'wpv-views'); ?> </a> <a href="#" class="button-secondary js-wpv-discard-target-setup-link"><?php _e('Not now', 'wpv-views'); ?> </a> </div> <?php } else { if (!$WP_Views->is_embedded()) { ?> <p> <?php printf(__('There are no Views with a parametric search. You can add them <a%s>here</a>.', 'wpv-views'), ' href="' . admin_url('admin.php?page=views') . '"'); ?> </p> <p> <?php _e('Remember that only Views forms containing a <em>Submit</em> button can be used on a widget', 'wpv-views'); ?> </p> <?php } else { ?> <p> <?php _e('There are no Views with a parametric search.', 'wpv-views'); ?> </p> <?php } } }
/** * 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 }
public static function wpcf_access_show_error_list_ajax() { if (!current_user_can('manage_options')) { _e('There are security problems. You do not have permissions.', 'wpcf-access'); die; } if (!isset($_POST['wpnonce']) || !wp_verify_nonce($_POST['wpnonce'], 'wpcf-access-error-pages')) { die('verification failed'); } $post_type = sanitize_text_field($_POST['posttype']); $is_archive = sanitize_text_field($_POST['is_archive']); $out = ' <form method="" id="wpcf-access-set_error_page"> <input type="hidden" value="' . esc_attr($_POST['access_type']) . '" name="typename"> <input type="hidden" value="' . esc_attr($_POST['access_value']) . '" name="valuename">'; if ($is_archive == 1) { $out .= '<input type="hidden" value="' . esc_attr($_POST['access_archivetype']) . '" name="archivetypename"> <input type="hidden" value="' . esc_attr($_POST['access_archivevalue']) . '" name="archivevaluename">'; } $out .= '<h2>' . __('Single post error', 'wpcf-access') . '</h2>'; $checked = isset($_POST['cur_type']) && $_POST['cur_type'] == '' ? ' checked="checked" ' : ''; if ($_POST['forall'] != 1) { $out .= ' <p> <label> <input type="radio" value="default" name="error_type" class="js-wpcf-access-type"' . $checked . '> ' . __('Default error', 'wpcf-access') . ' </label> </p>'; } $checked = isset($_POST['cur_type']) && $_POST['cur_type'] == 'error_404' ? ' checked="checked" ' : ''; if ($_POST['forall'] == 1 && isset($_POST['cur_type']) && $_POST['cur_type'] == '') { $checked = ' checked="checked" '; } $out .= ' <p> <label> <input type="radio" value="error_404" name="error_type"' . $checked . ' class="js-wpcf-access-type"> ' . __('Show 404 - page not found', 'wpcf-access') . ' </label> </p>'; if (class_exists('WP_Views') && !class_exists('WPDD_Layouts')) { $checked = isset($_POST['cur_type']) && $_POST['cur_type'] == 'error_ct' ? ' checked="checked" ' : ''; $out .= ' <p> <label> <input type="radio" value="error_ct" name="error_type"' . $checked . ' class="js-wpcf-access-type"> ' . __('Show Content Template', 'wpcf-access') . ' </label> <select name="wpcf-access-ct" class="hidden" class="js-wpcf-error-ct-value"> <option value="">' . __('None', 'wpcf-access') . '</option>'; $wpv_args = array('post_type' => 'view-template', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'title', 'post_status' => 'publish'); $content_tempaltes = get_posts($wpv_args); foreach ($content_tempaltes as $post) { $selected = isset($_POST['cur_value']) && $_POST['cur_value'] == $post->ID ? ' selected="selected" ' : ''; $out .= ' <option value="' . esc_attr($post->ID) . '"' . $selected . '>' . $post->post_title . '</option>'; } $out .= ' </select> </p>'; } $templates = wp_get_theme()->get_page_templates(); if (!empty($templates)) { $checked = isset($_POST['cur_type']) && $_POST['cur_type'] == 'error_php' ? ' checked="checked" ' : ''; $out .= ' <p> <label> <input type="radio" value="error_php" name="error_type"' . $checked . ' class="js-wpcf-access-type"> ' . __('Show Page template', 'wpcf-access') . ' </label> <select name="wpcf-access-php" class="hidden" class="js-wpcf-error-php-value"> <option value="">' . __('None', 'wpcf-access') . '</option>'; foreach ($templates as $template_name => $template_filename) { $selected = isset($_POST['cur_value']) && $_POST['cur_value'] == $template_filename ? ' selected="selected" ' : ''; $out .= '<option value="' . esc_attr($template_filename) . '"' . $selected . '>' . $template_filename . '</option>'; } $out .= ' </select> </p>'; } $show_php_tempaltes = true; if ($is_archive == 1) { $archive_out = ''; //Hide php templates $show_php_tempaltes = true; $out .= '<h2>' . __('Archive error', 'wpcf-access') . '</h2>'; if (class_exists('WP_Views') && function_exists('wpv_force_wordpress_archive') && !class_exists('WPDD_Layouts')) { global $WPV_view_archive_loop, $WP_Views; $have_archives = wpv_has_wordpress_archive('post', $post_type); if ($have_archives > 0) { $show_php_tempaltes = false; $checked = isset($_POST['cur_archivetype']) && $_POST['cur_archivetype'] == 'error_ct' ? ' checked="checked" ' : ''; $has_items = wpv_check_views_exists('archive'); if (count($has_items) > 0) { $archive_out .= '<p><label> <input type="radio" value="error_ct" name="archive_error_type" ' . $checked . 'class="js-wpcf-access-type-archive"> ' . __('Choose a different WordPress archive for people without read permission', 'wpcf-access') . '<br />'; $custom_error = ''; $custom_error = ''; $view = get_post($have_archives); if (is_object($view)) { $has_items = array_diff($has_items, array($have_archives)); $custom_error = sprintf(__('This custom post archive displays with the WordPress Archive "%s".', 'wpcf-access'), esc_attr($view->post_title)); } $archive_out .= '</label>'; $wpv_args = array('post_type' => 'view', 'post__in' => $has_items, 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'title', 'post_status' => 'publish'); $wpv_query = new WP_Query($wpv_args); $wpv_count_posts = $wpv_query->post_count; if ($wpv_count_posts > 0) { $archive_out .= '<select name="wpcf-access-archive-ct" class="js-wpcf-error-ct-value"> <option value="">' . __('None', 'wpcf-access') . '</option>'; while ($wpv_query->have_posts()) { $wpv_query->the_post(); $post_id = get_the_id(); //$options = $WPV_view_archive_loop->_view_edit_options($post_id, $options); $post = get_post($post_id); $selected = isset($_POST['cur_archivevalue']) && $_POST['cur_archivevalue'] == $post->ID ? ' selected="selected" ' : ''; $archive_out .= '<option value="' . esc_attr($post->ID) . '" ' . $selected . '>' . $post->post_title . '</option>'; } $archive_out .= '</select>'; } $archive_out .= '<p class="toolset-alert toolset-alert- js-wpcf-error-ct-value-info" style="display: none; opacity: 1;"> ' . $custom_error . '</p>'; $archive_out .= '</p>'; } else { $archive_out .= '<p>' . __('Sorry, no alternative WordPress Archives. First, create a new WordPress Archive, then return here to choose it.', 'wpcf-access') . '</p>'; } } } if ($show_php_tempaltes) { $theme_files = array(); if (isset($_POST['cur_archivevalue'])) { $_POST['cur_archivevalue'] = urldecode($_POST['cur_archivevalue']); $_POST['cur_archivevalue'] = str_replace("\\\\", "\\", $_POST['cur_archivevalue']); } if (is_child_theme()) { $child_theme_dir = get_stylesheet_directory(); $theme_files = self::wpcf_access_scan_dir($child_theme_dir, $theme_files); } $theme_dir = get_template_directory() . '/'; if (file_exists($theme_dir . 'archive-' . $post_type . '.php')) { $curent_file = 'archive-' . $post_type . '.php'; } elseif (file_exists($theme_dir . 'archive.php')) { $current_file = 'archive.php'; } else { $current_file = 'index.php'; } $error_message = sprintf(__('This custom post archive displays with the PHP template "%s".', 'wpcf-access'), $current_file); $theme_files = self::wpcf_access_scan_dir($theme_dir, $theme_files, $current_file); $checked = isset($_POST['cur_archivetype']) && $_POST['cur_archivetype'] == 'error_php' ? ' checked="checked" ' : ''; $archive_out .= '<p><label> <input type="radio" value="error_php" name="archive_error_type"' . $checked . ' class="js-wpcf-access-type-archive"> ' . __('Choose a different PHP template for people without read permission', 'wpcf-access') . ' </label> <p class="toolset-alert toolset-alert- js-wpcf-error-php-value-info" style="display: none; opacity: 1;"> ' . $error_message . ' </p><select name="wpcf-access-archive-php" class="js-wpcf-error-php-value hidden"> <option value="">' . __('None', 'wpcf-access') . '</option>'; for ($i = 0, $limit = count($theme_files); $i < $limit; $i++) { $selected = isset($_POST['cur_archivevalue']) && $_POST['cur_archivevalue'] == $theme_files[$i] ? ' selected="selected" ' : ''; $archive_out .= '<option value="' . esc_attr($theme_files[$i]) . '" ' . $selected . '>' . preg_replace("/.*(\\/.*\\/)/", "\$1", $theme_files[$i]) . '</option>'; } $archive_out .= '</select></p>'; } //Default error, use for everyone if set. if ($_POST['forall'] != 1) { $checked = empty($checked) ? ' checked="checked" ' : ''; $out .= '<p><label> <input type="radio" value="default" name="archive_error_type" class="js-wpcf-access-type-archive"' . $checked . '> ' . __('Default error', 'wpcf-access') . ' </label></p>'; } //Show post not found message' //Set post type not queryable $checked = isset($_POST['cur_archivetype']) && $_POST['cur_archivetype'] == 'default_error' || empty($checked) ? ' checked="checked" ' : ''; $out .= '<p><label> <input type="radio" value="default_error" name="archive_error_type" class="js-wpcf-access-type-archive"' . $checked . '> ' . __('Display: "No posts found"', 'wpcf-access') . ' </label></p>'; $out .= $archive_out; } //End check if post type have archive $out .= '</form>'; echo $out; die; }
function form($instance) { global $WP_Views, $sitepress, $wpdb; $views = wpv_check_views_exists('normal'); $view_forms = array(); foreach ($views as $vi) { if ($WP_Views->does_view_have_form_controls($vi)) { $view_forms[] = $vi; } } $instance = wp_parse_args((array) $instance, array('title' => '', 'view' => false, 'target_id' => '0')); $title = $instance['title']; $view = $instance['view']; $target_id = $instance['target_id']; $trans_join = ''; $trans_where = ''; if (function_exists('icl_object_id')) { // Adjust for WPML support if ($target_id != '0') { $target_post_type = $wpdb->get_var("SELECT post_type FROM {$wpdb->posts} WHERE ID='{$target_id}'"); if ($target_post_type) { $target_id = icl_object_id($target_id, $target_post_type, true); $translatable_post_types = array_keys($sitepress->get_translatable_documents()); if (in_array($target_post_type, $translatable_post_types)) { $current_lang_code = $sitepress->get_current_language(); $trans_join = " JOIN {$wpdb->prefix}icl_translations t "; $trans_where = " AND ID = t.element_id AND t.language_code = '{$current_lang_code}' "; } } } else { // if there is no target set, for example when adding the widget for the first time $current_lang_code = $sitepress->get_current_language(); $trans_join = " JOIN {$wpdb->prefix}icl_translations t "; $trans_where = " AND ID = t.element_id AND t.language_code = '{$current_lang_code}' "; } } $posts = $wpdb->get_results("SELECT ID, post_title, post_content FROM {$wpdb->posts} {$trans_join} WHERE post_content LIKE '%[wpv-view%' AND post_type NOT IN ('view','view-template','revision','cred-form') AND post_status='publish' {$trans_where}"); ?> <?php if (count($view_forms) > 0) { ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> " /></label></p> <table width="100%"> <tr> <td> <?php _e('View:', 'wpv-views'); ?> </td> <td> <select name="<?php echo $this->get_field_name('view'); ?> " style="width:100%"> <?php foreach ($view_forms as $v) { ?> <option value="<?php echo $v; ?> "<?php if ($view == $v) { ?> selected="selected"<?php } ?> ><?php echo esc_html(get_the_title($v)); ?> </option> <?php } ?> </select> </td> </tr> <tr> <td> <?php _e('Target page:', 'wpv-views'); ?> </td> <td> <select name="<?php echo $this->get_field_name('target_id'); ?> " style="width:100%"> <?php foreach ($posts as $post) { ?> <option value="<?php echo $post->ID; ?> "<?php if ($target_id == $post->ID) { ?> selected="selected"<?php } ?> ><?php echo esc_html($post->post_title); ?> </option> <?php } ?> </select> </td> </tr> </table> <br clear="all"> <?php } else { ?> <?php if (!$WP_Views->is_embedded()) { printf(__('No Views with frontend forms defined. You can add them <a%s>here</a>.'), ' href="' . admin_url('admin.php?page=views') . '"'); } ?> <?php } ?> <?php }
/** * 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"> <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 $has_items = wpv_check_views_exists('archive'); $search_term = isset($_GET["search"]) ? urldecode(sanitize_text_field($_GET["search"])) : ''; 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'); ?> <?php if ($WPV_view_archive_loop->check_archive_loops_exists() && $has_items) { ?> <a href="#" data-target="<?php echo admin_url('admin-ajax.php'); ?> ?action=wpv_create_wp_archive_button" class="add-new-h2 js-wpv-views-archive-add-new wpv-views-archive-add-new"> <?php _e('Add new WordPress Archive', 'wpv-views'); ?> </a> <?php } ?> <?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 WordPress Archives', '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('WordPress Archive moved to the Trash', 'wpv-views'); ?> . <a href="<?php echo admin_url(); ?> admin.php?page=view-archives&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('WordPress Archive 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('WordPress Archive permanently deleted', 'wpv-views'); ?> </p> </div> <?php } ?> <?php if (isset($_GET["arrangeby"]) && sanitize_text_field($_GET["arrangeby"]) == 'usage') { wp_nonce_field('wpv_wp_archive_arrange_usage', 'wpv_wp_archive_arrange_usage'); ?> <?php if (!$WPV_view_archive_loop->check_archive_loops_exists()) { ?> <p id="js-wpv-no-archive" class="toolset-alert toolset-alert-info update below-h2"> <?php _e('All loops have a WordPress Archive assigned', 'wpv-views'); ?> </p> <?php } ?> <div class="wpv-views-listing-arrange js-wpv-views-listing-arrange"> <p><?php _e('Arrange by', 'wpv-views'); ?> : </p> <ul> <li data-sortby="name"><a href="<?php echo admin_url('admin.php'); ?> ?page=view-archives"><?php _e('Name', 'wpv-views'); ?> </a></li> <li data-sortby="usage" class="active"><?php _e('Usage', 'wpv-views'); ?> </li> </ul> </div> <?php wpv_admin_wordpress_archives_listing_table_by_usage(); if ($WPV_view_archive_loop->check_archive_loops_exists()) { ?> <p class="add-new-view js-add-new-view"> <a class="button js-wpv-views-archive-add-new wpv-views-archive-add-new" data-target="<?php echo admin_url('admin-ajax.php'); ?> ?action=wpv_create_wp_archive_button" href="admin.php?page=view-archives-new"> <i class="icon-plus"></i><?php _e('Add new WordPress Archive', 'wpv-views'); ?> </a> </p> <?php } } else { if ($has_items) { ?> <?php wpv_admin_wordpress_archives_listing_table_by_name($has_items); } else { ?> <?php if (!$WPV_view_archive_loop->check_archive_loops_exists()) { ?> <p id="js-wpv-no-archive" class="toolset-alert toolset-alert-info"> <?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.'); ?> </p> <p> <a class="button js-wpv-views-archive-create-new" data-target="<?php echo admin_url('admin-ajax.php'); ?> ?action=wpv_create_wp_archive_button" href="<?php get_admin_url(); ?> admin.php?page=view-archives-new"> <i class="icon-plus"></i> <?php _e('Create your first WordPress Archive'); ?> </a> </p> </div> <?php } } ?> </div> <!-- .wpv-settings-container" --> </div> <?php }
function remove_layouts_loop_pagination_links() { if (user_can_create_layouts() === false) { $data = array('type' => 'capability', 'message' => __('You do not have permissions for that.', 'ddl-layouts')); wp_send_json_error($data); } if (!isset($_POST["wpnonce"]) || !wp_verify_nonce($_POST["wpnonce"], 'ddl_remove_layouts_loop_pagination_links')) { $data = array('type' => 'nonce', 'message' => __('Your security credentials have expired. Please reload the page to get new ones.', 'ddl-layouts')); wp_send_json_error($data); } if (function_exists('wpv_check_views_exists')) { $ddl_archive_loop_ids = wpv_check_views_exists('layouts-loop'); if ($ddl_archive_loop_ids) { $ddl_archive_loop_ids = array_map('esc_attr', $ddl_archive_loop_ids); $ddl_archive_loop_ids = array_map('trim', $ddl_archive_loop_ids); $ddl_archive_loop_ids = array_filter($ddl_archive_loop_ids, 'is_numeric'); $ddl_archive_loop_ids = array_map('intval', $ddl_archive_loop_ids); if (count($ddl_archive_loop_ids)) { global $wpdb; $final_post_content = "[wpv-filter-meta-html]\n[wpv-layout-meta-html]"; $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts}\n\t\t\t\t\t\t\tSET post_content = %s\n\t\t\t\t\t\t\tWHERE ID IN ('" . implode("','", $ddl_archive_loop_ids) . "')", $final_post_content)); } } $data = array('message' => __('Pagination links deleted.', 'ddl-layouts')); wp_send_json_success($data); } else { $data = array('type' => 'missing', 'message' => __('You need Views to perform this action.', 'ddl-layouts')); wp_send_json_error($data); } }