Exemplo n.º 1
0
	/**
	* wpv_get_list_item_ui_post_date
	*
	* Render date filter item content in the filters list
	*
	* @param $view_settings
	*
	* @since 1.8.0
	*/

	static function wpv_get_list_item_ui_post_date( $view_settings = array() ) {
		ob_start();
		?>
		<p class='wpv-filter-post-date-edit-summary js-wpv-filter-summary js-wpv-filter-post-date-summary'>
			<?php echo wpv_get_filter_post_date_summary_txt( $view_settings ); ?>
		</p>
		<?php
		WPV_Filter_Item::filter_list_item_buttons( 'post-date', 'wpv_filter_post_date_update', wp_create_nonce( 'wpv_view_filter_post_date_nonce' ), 'wpv_filter_post_date_delete', wp_create_nonce( 'wpv_view_filter_post_date_delete_nonce' ) );
		?>
		<div id="wpv-filter-post-date-edit" class="wpv-filter-edit js-wpv-filter-edit" style="padding-bottom:28px;">
			<div id="wpv-filter-post-date" class="js-wpv-filter-options js-wpv-filter-post-date-options">
				<?php WPV_Date_Filter::wpv_render_post_date_options( $view_settings ); ?>
			</div>
			<div class="js-wpv-filter-multiple-toolset-messages"></div>
			<span class="filter-doc-help">
				<?php echo sprintf(__('%sLearn about filtering by Post Date%s', 'wpv-views'),
					'<a class="wpv-help-link" href="' . WPV_FILTER_BY_POST_DATE_LINK . '" target="_blank">',
					' &raquo;</a>'
				); ?>
			</span>
		</div>
		<?php
		$res = ob_get_clean();
		return $res;
	}
	static function wpv_add_filter_custom_field_list_item( $view_settings ) {
		if ( ! isset($view_settings['custom_fields_relationship'] ) ) {
			$view_settings['custom_fields_relationship'] = 'AND';
		}
		$summary = '';
		$td = '';
		$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_Custom_Field_Filter::wpv_get_list_item_ui_post_custom_field( $name, $view_settings );
				$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 ( $count > 0 ) {
			ob_start();
			WPV_Filter_Item::filter_list_item_buttons( 'custom-field', 'wpv_filter_custom_field_update', wp_create_nonce( 'wpv_view_filter_custom_field_nonce' ), 'wpv_filter_custom_field_delete', wp_create_nonce( 'wpv_view_filter_custom_field_delete_nonce' ) );
			?>
				<?php if ( $summary != '' ) { ?>
					<p class='wpv-filter-custom-field-edit-summary js-wpv-filter-summary js-wpv-filter-custom-field-summary'>
					<?php
					_e('Select posts with custom field: ', 'wpv-views');
					echo $summary;
					?>
					</p>
				<?php } ?>
				<div id="wpv-filter-custom-field-edit" class="wpv-filter-edit js-wpv-filter-edit js-wpv-filter-custom-field-edit js-wpv-filter-options" style="padding-bottom:28px;">
				<?php echo $td; ?>
					<div class="wpv-filter-custom-field-relationship wpv-filter-multiple-element js-wpv-filter-custom-field-relationship-container">
						<h4><?php _e( 'Custom field relationship:', 'wpv-views' ) ?></h4>
						<div class="wpv-filter-multiple-element-options">
							<?php _e( 'Relationship to use when querying with multiple custom fields:', 'wpv-views' ); ?>
							<select name="custom_fields_relationship" class="js-wpv-filter-custom-fields-relationship" autocomplete="off">
								<option value="AND" <?php echo selected( $view_settings['custom_fields_relationship'], 'AND' ); ?>><?php _e('AND', 'wpv-views'); ?>&nbsp;</option>
								<option value="OR" <?php echo selected( $view_settings['custom_fields_relationship'], 'OR' ); ?>><?php _e('OR', 'wpv-views'); ?>&nbsp;</option>
							</select>
						</div>
					</div>
					<div class="js-wpv-filter-multiple-toolset-messages"></div>
					<span class="filter-doc-help">
						<?php 
						echo sprintf(
							__( '%sLearn about filtering by custom fields%s', 'wpv-views' ),
							'<a class="wpv-help-link" href="' . WPV_FILTER_BY_CUSTOM_FIELD_LINK . '" target="_blank">',
							' &raquo;</a>'
						); ?>
					</span>
				</div>
		<?php 
			$li_content = ob_get_clean();
			WPV_Filter_Item::multiple_filter_list_item( 'custom-field', 'posts', __( 'Custom field filter', 'wpv-views' ), $li_content );
		}
	}
Exemplo n.º 3
0
	/**
	* wpv_add_filter_taxonomy_list_item
	*
	* Render taxonomy filter item in the filters list
	*
	* @param $view_settings
	*
	* @since unknown
	*/

	static function wpv_add_filter_taxonomy_list_item( $view_settings ) {
		if ( ! isset( $view_settings['taxonomy_relationship'] ) ) {
			$view_settings['taxonomy_relationship'] = 'AND';
		}
		$summary = '';
		$td = '';
		$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();
				}
				if ( ! empty( $view_settings[$save_name] ) ) {
					$adjusted_term_ids = array();
					foreach ( $view_settings[$save_name] as $candidate_term_id ) {
						// WordPress 4.2 compatibility - split terms
						$candidate_term_id_splitted = wpv_compat_get_split_term( $candidate_term_id, $category->name );
						if ( $candidate_term_id_splitted ) {
							$candidate_term_id = $candidate_term_id_splitted;
						}
						// WPML support
						$candidate_term_id = apply_filters( 'translate_object_id', $candidate_term_id, $category->name, true, null );
						$adjusted_term_ids[] = $candidate_term_id;
					}
					$view_settings[$save_name] = $adjusted_term_ids;
				}
				$name = ( $category->name == 'category' ) ? 'post_category' : 'tax_input[' . $category->name . ']';
				$td .= WPV_Taxonomy_Filter::wpv_get_list_item_ui_post_taxonomy( $category, $view_settings[$save_name], $view_settings );
				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 ( $td != '' ) {
			ob_start();
			WPV_Filter_Item::filter_list_item_buttons( 'taxonomy', 'wpv_filter_taxonomy_update', wp_create_nonce( 'wpv_view_filter_taxonomy_nonce' ), 'wpv_filter_taxonomy_delete', wp_create_nonce( 'wpv_view_filter_taxonomy_delete_nonce' ) );
			?>
			<?php if ( $summary != '' ) {
			?>
				<p class='wpv-filter-taxonomy-edit-summary js-wpv-filter-summary js-wpv-filter-taxonomy-summary'>
				<?php _e('Select posts with taxonomy: ', 'wpv-views');
				echo $summary; ?>
				</p>
			<?php 
			}
			?>
			<div id="wpv-filter-taxonomy-edit" class="wpv-filter-edit js-wpv-filter-edit js-wpv-filter-taxonomy-edit js-wpv-filter-options" style="padding-bottom:28px;">
				<?php echo $td;?>
				<div class="wpv-filter-taxonomy-relationship wpv-filter-multiple-element js-wpv-filter-taxonomy-relationship">
					<h4><?php _e('Taxonomy relationship:', 'wpv-views') ?></h4>
					<div class="wpv-filter-multiple-element-options">
						<?php _e('Relationship to use when querying with multiple taxonomies:', 'wpv-views'); ?>
						<select name="taxonomy_relationship">
							<option value="AND" <?php selected( $view_settings['taxonomy_relationship'], 'AND' ); ?>><?php _e( 'AND', 'wpv-views' ); ?>&nbsp;</option>
							<option value="OR" <?php selected( $view_settings['taxonomy_relationship'], 'OR' ); ?>><?php _e( 'OR', 'wpv-views' ); ?></option>
						</select>
					</div>
				</div>
				<div class="js-wpv-filter-multiple-toolset-messages"></div>
				<span class="filter-doc-help">
				<?php echo sprintf(
					__( '%sLearn about filtering by taxonomy%s', 'wpv-views' ),
					'<a class="wpv-help-link" href="' . WPV_FILTER_BY_TAXONOMY_LINK . '" target="_blank">',
					' &raquo;</a>'
				); ?>
				</span>
			</div>
		<?php 
			$li_content = ob_get_clean();
			WPV_Filter_Item::multiple_filter_list_item( 'taxonomy', 'posts', __( 'Taxonomy filter', 'wpv-views' ), $li_content );
		}
	}