/** * Output the view query metabox on the view edit page. * */ function settings_box($post) { // DEPRECATED global $WPV_view_archive_loop; ?> <div id="wpv_view_query_controls" style="position: relative"> <span id="wpv_view_query_controls_over" class="wpv_view_overlay" style="display:none"> <p><strong><?php echo __('The view query settings will be copied from the original', 'wpv-views'); ?> </strong></p> </span> <?php global $wp_version, $pagenow; if (version_compare($wp_version, '3.2', '<')) { echo '<p style="color:red;"><strong>'; _e('* Requires WordPress 3.2 or greater for best results.', 'wpv-views'); echo '</strong></p>'; } $this->include_admin_css(); wp_nonce_field('wpv_get_table_row_ui_nonce', 'wpv_get_table_row_ui_nonce'); ?> <script type="text/javascript"> var wpv_confirm_filter_change = '<?php _e("Are you sure you want to change the filter?\\n\\nIt appears that you made modifications to the filter.", 'wpv-views'); ?> '; <?php if ($pagenow == 'post-new.php') { ?> jQuery(document).ready(function($){ wpv_add_initial_filter_shortcode(); }); <?php } ?> var wpv_save_button_text = '<?php _e("Save View", 'wpv-views'); ?> '; </script> <?php global $WP_Views; $view_settings = $WP_Views->get_view_settings($post->ID); // check for creating a new view for an archive loop. if (isset($_GET['view_archive']) || isset($_GET['view_archive_taxonomy'])) { $view_settings['view-query-mode'] = 'archive'; global $wpv_wp_pointer; $wpv_wp_pointer->add_pointer('View Layout', 'This View displays results for an existing WordPress query.</p><p>Now choose the layout style and then add the fields you wish to display.', 'select[name="_wpv_layout_settings[style]"]', 'bottom', 'wpv_layout'); } ?> <p><span style="font-size:1.1em;font-weight:bold;">Does this View query it's own data or replace a standard WordPress archive?</span> <img src="<?php echo WPV_URL_EMBEDDED; ?> /common/res/images/question.png" style="position:relative;top:2px;" /> <a href="http://wp-types.com/documentation/user-guides/normal-vs-archive-views/" target="_blank"><?php _e('Learn about Normal and Archive Views »', 'wpv-views'); ?> </a></p> <ul style="margin-bottom:10px"> <?php $checked = $view_settings['view-query-mode'] == 'normal' ? 'checked="checked"' : ''; ?> <li><label><input type="radio" name="_wpv_settings[view-query-mode]" value="normal" <?php echo $checked; ?> onclick="jQuery('#wpv-normal-view-mode').show();jQuery('#wpv-archive-view-mode').hide()" /> <?php _e('<strong>Normal View:</strong> This View queries content from the database (good for inserting Views into content or widgets)', 'wpv-views'); ?> </label></li> <?php $checked = $view_settings['view-query-mode'] == 'archive' ? 'checked="checked"' : ''; ?> <li><label><input type="radio" name="_wpv_settings[view-query-mode]" value="archive" <?php echo $checked; ?> onclick="jQuery('#wpv-normal-view-mode').hide();jQuery('#wpv-archive-view-mode').show()" /> <?php _e('<strong>Archive View:</strong> This View displays results for an existing WordPress query (good for archive pages, taxonomy listing, search, etc.)', 'wpv-views'); ?> </label></li> </ul> <div id="wpv-normal-view-mode"<?php if ($view_settings['view-query-mode'] != 'normal') { echo ' style="display:none;"'; } ?> > <table id="wpv_filter_table" class="widefat fixed"> <thead> <tr> <th width="20px"></th> <th width="100%"> <?php _e('Filter', 'wpv-views'); ?>  <a class="wpv-help-link" target="_blank" href="http://wp-types.com/documentation/user-guides/views/"> <?php _e('Querying the database', 'wpv-views'); ?> </a> </th> </tr> </thead> <tbody> <tr id="wpv_filter_type"> <?php wpv_filter_types_admin($view_settings); ?> </tr> <?php global $view_settings_table_row; $view_settings_table_row = 0; do_action('wpv_add_filter_table_row', $view_settings); ?> </tbody> </table> <?php $view_settings = wpv_types_defaults($view_settings); wpv_filter_add_filter_admin($view_settings, null, 'popup_add_filter', '', 'wpv_add_filters', $view_settings['query_type'][0] == 'posts'); wpv_filter_add_filter_admin($view_settings, null, 'popup_add_filter_taxonomy', '', 'wpv_add_filters_taxonomy', $view_settings['query_type'][0] == 'taxonomy'); wpv_filter_controls_admin($view_settings); ?> <p> <span style="font-size:1.1em;font-weight:bold;"><?php _e('Pagination and Sliders settings', 'wpv-views'); ?> </span> <img src="<?php echo WPV_URL_EMBEDDED; ?> /common/res/images/question.png" style="position:relative;top:2px;" /> <a href="http://wp-types.com/documentation/user-guides/views-pagination/" target="_blank"><?php _e('Everything about Views pagination »', 'wpv-views'); ?> </a> </p> <?php wpv_pagination_admin($view_settings); wpv_filter_meta_html_admin($view_settings); ?> </div> <?php $WPV_view_archive_loop->view_edit_admin($post->ID, $view_settings); ?> </div> <?php }
/** * Return a table row for a category filter * */ function wpv_add_filter_category_table_row($view_settings) { global $view_settings_table_row; if (!isset($view_settings['taxonomy_relationship'])) { $view_settings['taxonomy_relationship'] = 'OR'; } // Find any taxonomy $summary = ''; $count = 0; $taxonomies = get_taxonomies('', 'objects'); foreach ($taxonomies as $category_slug => $category) { $save_name = $category->name == 'category' ? 'post_category' : 'tax_input_' . $category->name; $relationship_name = $category->name == 'category' ? 'tax_category_relationship' : 'tax_' . $category->name . '_relationship'; if (isset($view_settings[$relationship_name])) { if (!isset($view_settings[$save_name])) { $view_settings[$save_name] = array(); } $name = $category->name == 'category' ? 'post_category' : 'tax_input[' . $category->name . ']'; $td = wpv_get_table_row_ui_post_category($view_settings_table_row, $name, $view_settings[$save_name], null, $view_settings); echo '<tr class="wpv_taxonomy_edit_row wpv_filter_row wpv_post_type_filter_row wpv_edit_row" id="wpv_filter_row_' . $view_settings_table_row . '" style="background:' . WPV_EDIT_BACKGROUND . '; display:none;">' . $td . '</tr>'; $view_settings_table_row++; $count++; if ($summary != '') { if ($view_settings['taxonomy_relationship'] == 'OR') { $summary .= __(' OR ', 'wpv-views'); } else { $summary .= __(' AND ', 'wpv-views'); } } $summary .= wpv_get_taxonomy_summary($name, $view_settings, $view_settings[$save_name]); } } if ($summary != '') { if ($count > 1) { echo '<tr class="wpv_taxonomy_edit_row wpv_filter_row wpv_post_type_filter_row wpv_edit_row" id="wpv_filter_row_' . $view_settings_table_row . '" style="background:' . WPV_EDIT_BACKGROUND . '; display:none;">'; wpv_filter_taxonomy_relationship_admin($view_settings); echo '</tr>'; $view_settings_table_row++; } echo '<tr class="wpv_taxonomy_edit_row wpv_filter_row wpv_post_type_filter_row wpv_edit_row" id="wpv_filter_row_' . $view_settings_table_row . '" style="background:' . WPV_EDIT_BACKGROUND . '; display:none;"><td></td><td>'; ?> <?php $filters = wpv_add_filter_category(array()); wpv_filter_add_filter_admin($view_settings, $filters, 'popup_add_category_field', 'Add another taxonomy'); ?> <hr /> <div class="wpv_taxonomy_param_missing_ok"><?php echo __('A taxonomy parameter is missing or incorrect.', 'wpv-views'); ?> </div> <input class="button-primary" type="button" value="<?php echo __('OK', 'wpv-views'); ?> " name="<?php echo __('OK', 'wpv-views'); ?> " onclick="wpv_show_filter_taxonomy_edit_ok()"/> <input class="button-secondary" type="button" value="<?php echo __('Cancel', 'wpv-views'); ?> " name="<?php echo __('Cancel', 'wpv-views'); ?> " onclick="wpv_show_filter_taxonomy_edit_cancel()"/> <span class="wpv-taxonomy-help"><i> <?php echo sprintf(__('%sLearn about filtering by taxonomy%s', 'wpv-views'), '<a class="wpv-help-link" href="' . WPV_FILTER_BY_TAXONOMY_LINK . '" target="_blank">', ' »</a>'); ?> </i></span> <?php echo '</td></tr>'; $view_settings_table_row++; echo '<tr class="wpv_taxonomy_show_row wpv_filter_row wpv_post_type_filter_row" id="wpv_filter_row_' . $view_settings_table_row . '"><td><img src="' . WPV_URL . '/res/img/delete-disabled.png" title="' . __('Edit this filters group to delete items', 'wpv-views') . '"></td><td>'; _e('Select posts with taxonomy: ', 'wpv-views'); echo $summary; ?> <br /> <input class="button-secondary" type="button" value="<?php echo __('Edit', 'wpv-views'); ?> " name="<?php echo __('Edit', 'wpv-views'); ?> " onclick="wpv_show_filter_taxonomy_edit()"/> <?php echo '</td></tr>'; $view_settings_table_row++; } }
function wpv_add_filter_custom_field_table_row($view_settings) { global $view_settings_table_row; if (!isset($view_settings['custom_fields_relationship'])) { $view_settings['custom_fields_relationship'] = 'OR'; } // Find any custom fields $summary = ''; $count = 0; foreach (array_keys($view_settings) as $key) { if (strpos($key, 'custom-field-') === 0 && strpos($key, '_compare') === strlen($key) - strlen('_compare')) { $name = substr($key, 0, strlen($key) - strlen('_compare')); $td = wpv_get_table_row_ui_post_custom_field($view_settings_table_row, $name, null, null, $view_settings); echo '<tr class="wpv_custom_field_edit_row wpv_filter_row wpv_post_type_filter_row wpv_edit_row" id="wpv_filter_row_' . $view_settings_table_row . '" style="background:' . WPV_EDIT_BACKGROUND . '; display:none;">' . $td . '</tr>'; $view_settings_table_row++; $count++; if ($summary != '') { if ($view_settings['custom_fields_relationship'] == 'OR') { $summary .= __(' OR', 'wpv-views'); } else { $summary .= __(' AND', 'wpv-views'); } } $summary .= wpv_get_custom_field_summary($name, $view_settings); } } if ($summary != '') { if ($count > 1) { echo '<tr class="wpv_custom_field_edit_row wpv_filter_row wpv_post_type_filter_row wpv_edit_row" id="wpv_filter_row_' . $view_settings_table_row . '" style="background:' . WPV_EDIT_BACKGROUND . '; display:none;">'; wpv_filter_custom_field_relationship_admin($view_settings); echo '</tr>'; $view_settings_table_row++; } echo '<tr class="wpv_custom_field_edit_row wpv_filter_row wpv_post_type_filter_row wpv_edit_row" id="wpv_filter_row_' . $view_settings_table_row . '" style="background:' . WPV_EDIT_BACKGROUND . '; display:none;"><td></td><td>'; ?> <?php $filters = wpv_add_filter_custom_field(array()); wpv_filter_add_filter_admin($view_settings, $filters, 'popup_add_custom_field', 'Add another custom field'); ?> <hr /> <div class="wpv_custom_field_param_missing_ok"><?php echo __('A custom field parameter is missing or incorrect.', 'wpv-views'); ?> </div> <input class="button-primary" type="button" value="<?php echo __('OK', 'wpv-views'); ?> " name="<?php echo __('OK', 'wpv-views'); ?> " onclick="wpv_show_filter_custom_field_edit_ok()"/> <input class="button-secondary" type="button" value="<?php echo __('Cancel', 'wpv-views'); ?> " name="<?php echo __('Cancel', 'wpv-views'); ?> " onclick="wpv_show_filter_custom_field_edit_cancel()"/> <span class="wpv-custom-fields-help"><i> <?php echo sprintf(__('%sLearn about filtering by custom fields%s', 'wpv-views'), '<a href="' . WPV_FILTER_BY_CUSTOM_FIELD_LINK . '" target="_blank">', ' »</a>'); ?> </i></span> <?php echo '</td></tr>'; $view_settings_table_row++; echo '<tr class="wpv_custom_field_show_row wpv_filter_row wpv_post_type_filter_row" id="wpv_filter_row_' . $view_settings_table_row . '"><td><img src="' . WPV_URL . '/res/img/delete-disabled.png" title="' . __('Edit this filters group to delete items', 'wpv-views') . '"></td><td>'; _e('Select posts with custom fields: ', 'wpv-views'); echo $summary; ?> <br /> <input class="button-secondary" type="button" value="<?php echo __('Edit', 'wpv-views'); ?> " name="<?php echo __('Edit', 'wpv-views'); ?> " onclick="wpv_show_filter_custom_field_edit()"/> <?php echo '</td></tr>'; $view_settings_table_row++; } }