/** * wpv_get_list_item_ui_post_status * * Render status filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_post_status( $view_settings = array() ) { if ( ! isset( $view_settings['post_status'] ) || ! is_array( $view_settings['post_status'] ) ) { $view_settings['post_status'] = array(); } ob_start(); ?> <p class='wpv-filter-post-status-summary js-wpv-filter-summary js-wpv-filter-post-status-summary'> <?php echo wpv_get_filter_status_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'post-status', 'wpv_filter_post_status_update', wp_create_nonce( 'wpv_view_filter_post_status_nonce' ), 'wpv_filter_post_status_delete', wp_create_nonce( 'wpv_view_filter_post_status_delete_nonce' ) ); ?> <div id="wpv-filter-post-status-edit" class="wpv-filter-edit js-wpv-filter-edit"> <div id="wpv-filter-post-status" class="js-wpv-filter-options js-wpv-filter-post-status-options js-filter-post-status-list"> <?php WPV_Status_Filter::wpv_render_post_status_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> </div> <?php $res = ob_get_clean(); return $res; }
static function wpv_render_custom_field_options( $args, $view_settings = array() ) { global $WP_Views_fapi; $compare = array( '=' => __( 'equal to', 'wpv-views' ), '!=' => __( 'different from', 'wpv-views' ), '>' => __( 'greater than', 'wpv-views' ), '>=' => __( 'greater than or equal', 'wpv-views' ), '<' => __( 'lower than', 'wpv-views' ), '<=' => __( 'lower than or equal', 'wpv-views' ), 'LIKE' => __( 'like', 'wpv-views' ), 'NOT LIKE' => __( 'not like', 'wpv-views' ), 'IN' => __( 'in', 'wpv-views' ), 'NOT IN' => __( 'not in', 'wpv-views' ), 'BETWEEN' => __( 'between', 'wpv-views' ), 'NOT BETWEEN' => __( 'not between', 'wpv-views' ) ); $types = array( 'CHAR' => __( 'string', 'wpv-views' ), 'NUMERIC' => __( 'number', 'wpv-views' ), 'BINARY' => __( 'boolean', 'wpv-views' ), 'DECIMAL' => 'DECIMAL', 'DATE' => 'DATE', 'DATETIME' => 'DATETIME', 'TIME' => 'TIME', 'SIGNED' => 'SIGNED', 'UNSIGNED' => 'UNSIGNED' ); $options = array( __( 'Constant', 'wpv-views' ) => 'constant', __( 'URL parameter', 'wpv-views' ) => 'url', __( 'Shortcode attribute', 'wpv-views' ) => 'attribute', 'NOW' => 'now', 'TODAY' => 'today', 'FUTURE_DAY' => 'future_day', 'PAST_DAY' => 'past_day', 'THIS_MONTH' => 'this_month', 'FUTURE_MONTH' => 'future_month', 'PAST_MONTH' => 'past_month', 'THIS_YEAR' => 'this_year', 'FUTURE_YEAR' => 'future_year', 'PAST_YEAR' => 'past_year', 'SECONDS_FROM_NOW' => 'seconds_from_now', 'MONTHS_FROM_NOW' => 'months_from_now', 'YEARS_FROM_NOW' => 'years_from_now', 'DATE' => 'date' ); $options_with_framework = array( __( 'Constant', 'wpv-views' ) => 'constant', __( 'URL parameter', 'wpv-views' ) => 'url', __( 'Shortcode attribute', 'wpv-views' ) => 'attribute', __( 'Framework value', 'wpv-views' ) => 'framework', 'NOW' => 'now', 'TODAY' => 'today', 'FUTURE_DAY' => 'future_day', 'PAST_DAY' => 'past_day', 'THIS_MONTH' => 'this_month', 'FUTURE_MONTH' => 'future_month', 'PAST_MONTH' => 'past_month', 'THIS_YEAR' => 'this_year', 'FUTURE_YEAR' => 'future_year', 'PAST_YEAR' => 'past_year', 'SECONDS_FROM_NOW' => 'seconds_from_now', 'MONTHS_FROM_NOW' => 'months_from_now', 'YEARS_FROM_NOW' => 'years_from_now', 'DATE' => 'date' ); $options_with_framework_broken = array( __( 'Select one option...', 'wpv-views' ) => '', __( 'Constant', 'wpv-views' ) => 'constant', __( 'URL parameter', 'wpv-views' ) => 'url', __( 'Shortcode attribute', 'wpv-views' ) => 'attribute', 'NOW' => 'now', 'TODAY' => 'today', 'FUTURE_DAY' => 'future_day', 'PAST_DAY' => 'past_day', 'THIS_MONTH' => 'this_month', 'FUTURE_MONTH' => 'future_month', 'PAST_MONTH' => 'past_month', 'THIS_YEAR' => 'this_year', 'FUTURE_YEAR' => 'future_year', 'PAST_YEAR' => 'past_year', 'SECONDS_FROM_NOW' => 'seconds_from_now', 'MONTHS_FROM_NOW' => 'months_from_now', 'YEARS_FROM_NOW' => 'years_from_now', 'DATE' => 'date' ); $fw_key_options = array(); $fw_key_options = apply_filters( 'wpv_filter_extend_framework_options_for_custom_field', $fw_key_options ); $name_sanitized = str_replace( ' ', '_', $args['name'] ); if ( isset( $view_settings['custom-field-' . $name_sanitized . '_value'] ) ) { $value = $view_settings['custom-field-' . $name_sanitized . '_value']; } else { $value = ''; } $parts = array( $value ); $value = WPV_Filter_Item::encode_date( $value ); if ( isset( $view_settings['custom-field-' . $name_sanitized . '_compare'] ) ) { $compare_selected = $view_settings['custom-field-' . $name_sanitized . '_compare']; } else { $compare_selected = '='; } if ( isset( $view_settings['custom-field-' . $name_sanitized . '_type'] ) ) { $type_selected = $view_settings['custom-field-' . $name_sanitized . '_type']; } else { $type_selected = 'CHAR'; } $name = 'custom-field-' . $name_sanitized . '%s'; switch ( $compare_selected ) { case 'BETWEEN': case 'NOT BETWEEN': $parts = explode( ',', $value ); // Make sure we have only 2 items while ( count( $parts ) < 2 ) { $parts[] = ''; } while ( count( $parts ) > 2 ) { array_pop($parts); } break; case 'IN': case 'NOT IN': $parts = explode( ',', $value ); if ( count( $parts ) < 1 ) { $parts = array( $value ); } break; } $value = WPV_Filter_Item::unencode_date( $value ); ?> <?php echo sprintf( __( 'The custom field %s is a', 'wpv-views' ), $args['nicename'] ); ?> <select name="<?php echo esc_attr( sprintf( $name, '_type' ) ); ?>" class="js-wpv-custom-field-type-select" autocomplete="off"> <?php foreach ( $types as $type_key => $type_val ) { ?> <option value="<?php echo esc_attr( $type_key ); ?>" <?php selected( $type_selected, $type_key ); ?>><?php echo $type_val; ?></option> <?php } ?> </select> <?php _e( 'that is', 'wpv-views' ); ?> <select name="<?php echo esc_attr( sprintf( $name, '_compare' ) ); ?>" class="wpv_custom_field_compare_select js-wpv-custom-field-compare-select" autocomplete="off"> <?php foreach ( $compare as $com_key => $com_val ) { ?> <option value="<?php echo esc_attr( $com_key ); ?>" <?php selected( $compare_selected, $com_key ); ?>><?php echo $com_val; ?></option> <?php } ?> </select> <div class="wpv-filter-multiple-element-options-mode js-wpv-custom-field-values"> <input type="hidden" class="js-wpv-custom-field-values-real" name="<?php echo esc_attr( sprintf( $name, '_value' ) ); ?>" value="<?php echo esc_attr( $value ); ?>" autocomplete="off" /> <?php foreach ( $parts as $i => $value_part ) { ?> <div class="wpv_custom_field_value_div js-wpv-custom-field-value-div"> <?php _e( 'the', 'wpv-views' ); ?> <?php $function_value = WPV_Filter_Item::get_custom_filter_function_and_value( $value_part ); $selected_function = $function_value['function']; $options_to_pass = $options; if ( $WP_Views_fapi->framework_valid ) { $options_to_pass = $options_with_framework; } else if ( $selected_function == 'framework' ) { $options_to_pass = $options_with_framework_broken; } echo wpv_form_control( array( 'field' => array( '#name' => 'wpv_custom_field_compare_mode-' . $name_sanitized . $i , '#type' => 'select', '#attributes' => array( 'style' => '', 'class' => 'wpv_custom_field_compare_mode js-wpv-custom-field-compare-mode js-wpv-element-not-serialize js-wpv-filter-validate', 'data-type' => 'select', 'autocomplete' => 'off' ), '#inline' => true, '#options' => $options_to_pass, '#default_value' => $selected_function, ) ) ); $validate_class = ''; $validate_type = 'none'; $hidden_input = ''; $hidden_date = ''; $hidden_framework_select = ''; switch ( $selected_function ) { case 'constant': case 'future_day': case 'past_day': case 'future_month': case 'past_month': case 'future_year': case 'past_year': case 'seconds_from_now': case 'months_from_now': case 'years_from_now': $hidden_date = ' style="display:none"'; $hidden_framework_select = ' style="display:none"'; break; case 'url': $validate_class = 'js-wpv-filter-validate'; $validate_type = 'url'; $hidden_date = ' style="display:none"'; $hidden_framework_select = ' style="display:none"'; break; case 'attribute': $validate_class = 'js-wpv-filter-validate'; $validate_type = 'shortcode'; $hidden_date = ' style="display:none"'; $hidden_framework_select = ' style="display:none"'; break; case 'date': $hidden_input = ' style="display:none"'; $hidden_framework_select = ' style="display:none"'; break; case 'framework': $hidden_input = ' style="display:none"'; $hidden_date = ' style="display:none"'; break; default: $hidden_input = ' style="display:none"'; $hidden_date = ' style="display:none"'; $hidden_framework_select = ' style="display:none"'; break; } ?> <span class="js-wpv-custom-field-value-combo-input" <?php echo $hidden_input; ?>> <input type="text" class="js-wpv-custom-field-value-text js-wpv-element-not-serialize <?php echo $validate_class; ?>" value="<?php echo esc_attr( $function_value['value'] ); ?>" data-class="js-wpv-custom-field-<?php echo esc_attr( $args['name'] ); ?>-value-text" data-type="<?php echo esc_attr( $validate_type ); ?>" name="wpv-custom-field-<?php echo esc_attr( $args['name'] ); ?>-value-text" autocomplete="off" /> </span> <span class="js-wpv-custom-field-value-combo-framework" <?php echo $hidden_framework_select; ?>> <?php if ( $WP_Views_fapi->framework_valid ) { ?> <select class="js-wpv-custom-field-framework-value js-wpv-custom-field-framework-value-text js-wpv-element-not-serialize" name="wpv-custom-field-<?php echo esc_attr( $args['name'] ); ?>-framework-value-text" autocomplete="off"> <option value=""><?php _e( 'Select a key', 'wpv-views' ); ?></option> <?php foreach ( $fw_key_options as $index => $value ) { ?> <option value="<?php echo esc_attr( $index ); ?>" <?php selected( $function_value['value'], $index ); ?>><?php echo $value; ?></option> <?php } ?> </select> <?php } else { ?> <span class="wpv-combo"> <input type="hidden" class="js-wpv-custom-field-framework-value js-wpv-custom-field-framework-value-text js-wpv-element-not-serialize" value="" autocomplete="off" /> <?php $WP_Views_fapi->framework_missing_message_for_filters( false, false ); ?> </span> <?php } ?> </span> <span class="js-wpv-custom-field-value-combo-date" <?php echo $hidden_date; ?>> <?php WPV_Filter_Item::date_field_controls( $function_value['function'], $function_value['value'] ); ?> </span> <button class="button-secondary js-wpv-custom-field-remove-value"><i class="icon-remove"></i> <?php echo __( 'Remove', 'wpv-views' ); ?></button> </div> <?php } ?> <button class="button button-secondary js-wpv-custom-field-add-value" style="margin-top:10px;"><i class="icon-plus"></i> <?php echo __( 'Add another value', 'wpv-views' ); ?></button> </div> <?php }
/** * wpv_get_list_item_ui_taxonomy_parent * * Render taxonomy parent filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_taxonomy_parent( $view_settings = array() ) { if ( isset( $view_settings['taxonomy_type'] ) && is_array( $view_settings['taxonomy_type'] ) && sizeof( $view_settings['taxonomy_type'] ) > 0 ) { $view_settings['taxonomy_type'] = $view_settings['taxonomy_type'][0]; if ( ! taxonomy_exists( $view_settings['taxonomy_type'] ) ) { return '<p class="toolset-alert">' . __( 'This View has a filter for a taxonomy that no longer exists. Please select one taxonomy and update the Content Selection section.', 'wpv-views' ) . '</p>'; } } if ( isset( $view_settings['taxonomy_parent_mode'] ) && is_array( $view_settings['taxonomy_parent_mode'] ) ) { $view_settings['taxonomy_parent_mode'] = $view_settings['taxonomy_parent_mode'][0]; } if ( isset( $view_settings['taxonomy_type'] ) && isset( $view_settings['taxonomy_parent_id'] ) && ! empty( $view_settings['taxonomy_parent_id'] ) ) { // WordPress 4.2 compatibility - split terms $candidate_term_id_splitted = wpv_compat_get_split_term( $view_settings['taxonomy_parent_id'], $view_settings['taxonomy_type'] ); if ( $candidate_term_id_splitted ) { $view_settings['taxonomy_parent_id'] = $candidate_term_id_splitted; } // Adjust for WPML support $view_settings['taxonomy_parent_id'] = apply_filters( 'translate_object_id', $view_settings['taxonomy_parent_id'], $view_settings['taxonomy_type'], true, null ); } ob_start(); ?> <p class='wpv-filter-taxonomy-parent-edit-summary js-wpv-filter-summary js-wpv-filter-taxonomy-parent-summary'> <?php echo wpv_get_filter_taxonomy_parent_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'taxonomy-parent', 'wpv_filter_taxonomy_parent_update', wp_create_nonce( 'wpv_view_filter_taxonomy_parent_nonce' ), 'wpv_filter_taxonomy_parent_delete', wp_create_nonce( 'wpv_view_filter_taxonomy_parent_delete_nonce' ) ); ?> <span class="wpv-filter-title-notice js-wpv-filter-taxonomy-parent-notice hidden"> <i class="icon-bookmark icon-rotate-270 icon-large" title="<?php echo esc_attr( __( 'This filters needs some action', 'wpv-views' ) ); ?>"></i> </span> <div id="wpv-filter-taxonomy-parent-edit" class="wpv-filter-edit js-wpv-filter-edit"> <div id="wpv-filter-taxonomy-parent" class="js-wpv-filter-options js-wpv-filter-taxonomy-parent-options"> <?php WPV_Parent_Filter::wpv_render_taxonomy_parent_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> </div> <?php $res = ob_get_clean(); return $res; }
/** * wpv_render_post_date_condition * * Render date filter options * * @param $view_settings * * @since 1.8.0 */ static function wpv_render_post_date_condition( $date_condition ) { if ( is_array( $date_condition ) && isset ( $date_condition['date_operator'] ) ) { ?> <div class="wpv-filter-multiple-element js-wpv-filter-multiple-element js-wpv-date-condition"> <h4><?php _e( 'Date condition', 'wpv-views' ); ?></h4> <span class="wpv-filter-multiple-element-delete"> <button class="button button-secondary button-small js-filter-remove js-wpv-date-condition-remove"> <i class="icon-trash"></i> <?php _e( 'Delete', 'wpv-views' ); ?> </button> </span> <div class="wpv-filter-multiple-element-options js-wpv-date-condition-options"> <?php _e( 'Select posts with', 'wpv-views' ); ?> <select class="js-wpv-date-condition-column" name="date_column" autocomplete="off"> <?php foreach ( self::$date_columns as $column_name => $column_title ) { echo '<option value="' . esc_attr( $column_name ) . '" ' . selected( $column_name, $date_condition['date_column'], false ) . '>' . $column_title . '</option>'; } ?> </select> <select class="js-wpv-date-condition-operator" name="date_operator" autocomplete="off"> <?php foreach ( self::$date_operator['single'] as $single_compare => $single_name ) { ?> <option value="<?php echo esc_attr( $single_compare ); ?>" <?php selected( $single_compare, $date_condition['date_operator'] ); ?>><?php echo $single_name; ?></option> <?php } foreach ( self::$date_operator['group'] as $group_compare => $group_name ) { ?> <option value="<?php echo esc_attr( $group_compare ); ?>" <?php selected( $group_compare, $date_condition['date_operator'] ); ?>><?php echo $group_name; ?></option> <?php } ?> <?php ?> </select> <ul> <li class="js-wpv-date-condition-single<?php if ( ! isset( self::$date_operator['single'][$date_condition['date_operator']] ) ) { echo ' hidden'; } ?>"> <table style="margin:5px 0;"> <?php foreach ( self::$date_options as $date_name => $date_title ) { $this_options = explode( ',', $date_condition[$date_name] ); $this_function_value = WPV_Filter_Item::get_custom_filter_function_and_value( $this_options[0] ); ?> <tr class="js-wpv-filter-date-condition-combo-value<?php if ( empty( $this_function_value['function'] ) ) { echo ' unused'; } ?>"> <td> <?php echo $date_title; ?> </td> <td> <?php echo WPV_Date_Filter::wpv_get_date_origin_dropdown( $this_function_value['function'] ); ?> </td> <td> <?php $extra_classname = ''; if ( $this_function_value['function'] == 'current_one' ) { $extra_classname = ' hidden'; } ?> <input type="text" name="wpv-date-condition-single-<?php echo esc_attr( $date_name ); ?>" class="js-wpv-element-not-serialize js-wpv-filter-date-data <?php echo esc_attr( $extra_classname ); ?> js-wpv-filter-date-<?php echo esc_attr( $date_name ); ?>" data-combotype="<?php echo esc_attr( $date_name ); ?>" value="<?php echo esc_attr( $this_function_value['value'] ); ?>" autocomplete="off" /> <input type="hidden" name="wpv-<?php echo esc_attr( $date_name ); ?>" class="js-wpv-filter-date-data-real" value="<?php echo esc_attr( $this_options[0] ); ?>" autocomplete="off" /> </td> </tr> <?php } ?> </table> </li> <li class="js-wpv-date-condition-group<?php if ( ! isset( self::$date_operator['group'][$date_condition['date_operator']] ) ) { echo ' hidden'; } ?>"> <select class="js-wpv-date-condition-group-selected" name="date_multiple_selected" style="margin:5px 0 0;" autocomplete="off"> <?php foreach ( self::$date_options as $date_name => $date_title ) { echo '<option value="' . esc_attr( $date_name ) . '" ' . selected( $date_name, $date_condition['date_multiple_selected'], false ) . '>' . $date_title . '</option>'; } ?> </select> <input type="hidden" name="date_multiple_value" class="js-wpv-filter-date-data-real" value="<?php echo esc_attr( $date_condition[$date_condition['date_multiple_selected']] ); ?>" autocomplete="off" /> <?php $this_options = explode( ',', $date_condition[$date_condition['date_multiple_selected']] ); $show_buttons = in_array( $date_condition['date_operator'], array( 'IN', 'NOT IN' ) ); foreach ( $this_options as $this_option_key => $this_option_val ) { $this_option_function_and_value = WPV_Filter_Item::get_custom_filter_function_and_value( $this_option_val ); ?> <div class="wpv-filter-date-condition-group-item js-wpv-filter-date-condition-combo-value js-wpv-filter-date-condition-group-value" style="margin:5px 0;"> <?php echo WPV_Date_Filter::wpv_get_date_origin_dropdown( $this_option_function_and_value['function'] ); $extra_classname = ''; if ( $this_option_function_and_value['function'] == 'current_one' ) { $extra_classname = ' hidden'; } ?> <input type="text" name="wpv-date-condition-group-data" class="js-wpv-element-not-serialize js-wpv-filter-date-data <?php echo esc_attr( $extra_classname ); ?>" data-combotype="group" value="<?php echo esc_attr( $this_option_function_and_value['value'] ); ?>" autocomplete="off" /> <button class="button button-secondary js-wpv-date-condition-group-value-delete <?php if ( ! $show_buttons || $this_option_key == 0 ) { echo 'hidden'; } ?>"><i class="icon-remove"></i> <?php _e( 'Remove', 'wpv-views' ); ?></button> </div> <?php } ?> <button style="margin-top:5px;" class="button button-secondary js-wpv-date-condition-group-value-add <?php if ( ! $show_buttons ) { echo 'hidden'; } ?>"><i class="icon-plus"></i> <?php _e( 'Add another option', 'wpv-views' ); ?></button> </li> </ul> </div> <div class="js-wpv-filter-toolset-messages"></div> </div> <?php } }
/** * wpv_get_list_item_ui_post_id * * Render ID filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_post_id( $view_settings = array() ) { if ( isset( $view_settings['id_mode'] ) && is_array( $view_settings['id_mode'] ) ) { $view_settings['id_mode'] = $view_settings['id_mode'][0]; } if ( isset( $view_settings['post_id_ids_list'] ) && ! empty( $view_settings['post_id_ids_list'] ) ) { // Adjust for WPML support $id_ids_list = explode( ',', $view_settings['post_id_ids_list'] ); $id_ids_list = array_map( 'esc_attr', $id_ids_list ); $id_ids_list = array_map( 'trim', $id_ids_list ); // is_numeric does sanitization $id_ids_list = array_filter( $id_ids_list, 'is_numeric' ); $id_ids_list = array_map( 'intval', $id_ids_list ); $trans_ids = array(); if ( ! empty ( $id_ids_list ) ) { foreach ( $id_ids_list as $id_ids_item ) { // Adjust for WPML support $id_ids_item = apply_filters( 'translate_object_id', $id_ids_item, 'any', true, null ); $trans_ids[] = $id_ids_item; } } if ( count( $trans_ids ) > 0 ) { $view_settings['post_id_ids_list'] = implode( ",", $trans_ids ); } } ob_start(); ?> <p class='wpv-filter-post-id-edit-summary js-wpv-filter-summary js-wpv-filter-post-id-summary'> <?php echo wpv_get_filter_post_id_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'post-id', 'wpv_filter_post_id_update', wp_create_nonce( 'wpv_view_filter_post_id_nonce' ), 'wpv_filter_post_id_delete', wp_create_nonce( 'wpv_view_filter_post_id_delete_nonce' ) ); ?> <div id="wpv-filter-post-id-edit" class="wpv-filter-edit js-wpv-filter-edit" style="padding-bottom:28px;"> <div id="wpv-filter-post-id" class="js-wpv-filter-options js-wpv-filter-post-id-options"> <?php WPV_ID_Filter::wpv_render_post_id_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> <span class="filter-doc-help"> <?php echo sprintf(__('%sLearn about filtering by Post ID%s', 'wpv-views'), '<a class="wpv-help-link" href="' . WPV_FILTER_BY_POST_ID_LINK . '" target="_blank">', ' »</a>' ); ?> </span> </div> <?php $res = ob_get_clean(); return $res; }
/** * 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' ); ?> </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">', ' »</a>' ); ?> </span> </div> <?php $li_content = ob_get_clean(); WPV_Filter_Item::multiple_filter_list_item( 'taxonomy', 'posts', __( 'Taxonomy filter', 'wpv-views' ), $li_content ); } }
/** * wpv_get_list_item_ui_post_post_relationship * * Render post relationship filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_post_post_relationship( $view_settings = array() ) { if ( isset( $view_settings['post_relationship_mode'] ) && is_array( $view_settings['post_relationship_mode'] ) ) { $view_settings['post_relationship_mode'] = $view_settings['post_relationship_mode'][0]; } if ( isset( $view_settings['post_relationship_id'] ) && ! empty( $view_settings['post_relationship_id'] ) ) { // Adjust for WPML support $view_settings['post_relationship_id'] = apply_filters( 'translate_object_id', $view_settings['post_relationship_id'], 'any', true, null ); } if ( ! isset( $view_settings['post_type'] ) ) { $view_settings['post_type'] = array(); } ob_start() ?> <p class='wpv-filter-post-relationship-edit-summary js-wpv-filter-summary js-wpv-filter-post-relationship-summary'> <?php echo wpv_get_filter_post_relationship_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'post-relationship', 'wpv_filter_post_relationship_update', wp_create_nonce( 'wpv_view_filter_post_relationship_nonce' ), 'wpv_filter_post_relationship_delete', wp_create_nonce( 'wpv_view_filter_post_relationship_delete_nonce' ) ); ?> <span class="wpv-filter-title-notice js-wpv-filter-post-relationship-notice hidden"> <i class="icon-bookmark icon-rotate-270 icon-large" title="<?php echo esc_attr( __( 'This filters needs some action', 'wpv-views' ) ); ?>"></i> </span> <div id="wpv-filter-post-relationship-edit" class="wpv-filter-edit js-wpv-filter-edit" style="padding-bottom:28px;"> <div id="wpv-filter-post-relationship" class="js-wpv-filter-options js-wpv-filter-post-relationship-options"> <?php WPV_Post_Relationship_Filter::wpv_render_post_relationship( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> <span class="filter-doc-help"> <a class="wpv-help-link" target="_blank" href="http://wp-types.com/documentation/user-guides/querying-and-displaying-child-posts/?utm_source=viewsplugin&utm_campaign=views&utm_medium=edit-view-relationships-filter&utm_term=Querying and Displaying Child Posts"> <?php _e('Querying and Displaying Child Posts', 'wpv-views'); ?> »</a> </span> </div> <?php $res = ob_get_clean(); return $res; }
/** * wpv_get_list_item_ui_taxonomy_term * * Render taxonomy term filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_taxonomy_term( $view_settings = array() ) { if ( isset( $view_settings['taxonomy_type'] ) && is_array( $view_settings['taxonomy_type'] ) ) { $view_settings['taxonomy_type'] = $view_settings['taxonomy_type'][0]; } if ( ! isset( $view_settings['taxonomy_terms_mode'] ) ) { $view_settings['taxonomy_terms_mode'] = 'THESE'; } if ( ! isset( $view_settings['taxonomy_terms'] ) ) { $view_settings['taxonomy_terms'] = array(); } if ( ! empty( $view_settings['taxonomy_terms'] ) ) { $adjusted_term_ids = array(); foreach ( $view_settings['taxonomy_terms'] as $candidate_term_id ) { // WordPress 4.2 compatibility - split terms $candidate_term_id_splitted = wpv_compat_get_split_term( $candidate_term_id, $view_settings['taxonomy_type'] ); 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, $view_settings['taxonomy_type'], true, null ); $adjusted_term_ids[] = $candidate_term_id; } $view_settings['taxonomy_terms'] = $adjusted_term_ids; } ob_start() ?> <p class='wpv-filter-taxonomy-term-summary js-wpv-filter-summary js-wpv-filter-taxonomy-term-summary'> <?php echo wpv_get_filter_taxonomy_term_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'taxonomy-term', 'wpv_filter_taxonomy_term_update', wp_create_nonce( 'wpv_view_filter_taxonomy_term_nonce' ), 'wpv_filter_taxonomy_term_delete', wp_create_nonce( 'wpv_view_filter_taxonomy_term_delete_nonce' ) ); ?> <div id="wpv-filter-taxonomy-term-edit" class="wpv-filter-edit js-wpv-filter-edit"> <div id="wpv-filter-taxonomy-term" class="js-wpv-filter-options js-wpv-filter-taxonomy-term-options"> <?php WPV_Taxonomy_Term_Filter::wpv_render_taxonomy_term_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> </div> <?php $res = ob_get_clean(); return $res; }
/** * wpv_get_list_item_ui_taxonomy_search * * Render taxonomy search filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_taxonomy_search( $selected, $view_settings = array() ) { if ( isset( $view_settings['taxonomy_search_mode'] ) && is_array( $view_settings['taxonomy_search_mode'] ) ) { $view_settings['taxonomy_search_mode'] = $view_settings['taxonomy_search_mode'][0]; } if ( !isset( $view_settings['taxonomy_search_value'] ) ) { $view_settings['taxonomy_search_value'] = ''; } ob_start(); ?> <p class='wpv-filter-taxonomy-search-summary js-wpv-filter-summary js-wpv-filter-taxonomy-search-summary'> <?php echo wpv_get_filter_taxonomy_search_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'taxonomy-search', 'wpv_filter_taxonomy_search_update', wp_create_nonce( 'wpv_view_filter_taxonomy_search_nonce' ), 'wpv_filter_taxonomy_search_delete', wp_create_nonce( 'wpv_view_filter_taxonomy_search_delete_nonce' ) ); ?> <div id="wpv-filter-taxonomy-search-edit" class="wpv-filter-edit js-wpv-filter-edit"> <div id="wpv-filter-taxonomy-search" class="js-wpv-filter-options js-wpv-filter-taxonomy-search-options"> <?php WPV_Search_Filter::wpv_render_taxonomy_search_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> </div> <?php $res = ob_get_clean(); return $res; }
/** * wpv_get_list_item_ui_post_author * * Render author filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_post_author( $view_settings = array() ) { if ( isset( $view_settings['author_mode'] ) && is_array( $view_settings['author_mode'] ) ) { $view_settings['author_mode'] = $view_settings['author_mode'][0]; } ob_start(); ?> <p class='wpv-filter-post-author-edit-summary js-wpv-filter-summary js-wpv-filter-post-author-summary'> <?php echo wpv_get_filter_post_author_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'post-author', 'wpv_filter_post_author_update', wp_create_nonce( 'wpv_view_filter_post_author_nonce' ), 'wpv_filter_post_author_delete', wp_create_nonce( 'wpv_view_filter_post_author_delete_nonce' ) ); ?> <div id="wpv-filter-post-author-edit" class="wpv-filter-edit js-wpv-filter-edit" style="padding-bottom:28px;"> <div id="wpv-filter-post-author" class="js-wpv-filter-options js-wpv-filter-post-author-options"> <?php WPV_Author_Filter::wpv_render_post_author_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> <span class="filter-doc-help"> <?php echo sprintf(__('%sLearn about filtering by Post Author%s', 'wpv-views'), '<a class="wpv-help-link" href="' . WPV_FILTER_BY_AUTHOR_LINK . '" target="_blank">', ' »</a>' ); ?> </span> </div> <?php $res = ob_get_clean(); return $res; }
/** * wpv_get_list_item_ui_users * * Render users filter item content in the filters list * * @param $view_settings * * @since unknown */ static function wpv_get_list_item_ui_users( $view_settings = array() ) { if ( isset( $view_settings['users_mode'] ) && is_array( $view_settings['users_mode'] ) ) { $view_settings['users_mode'] = $view_settings['users_mode'][0]; } ob_start(); ?> <p class='wpv-filter-users-edit-summary js-wpv-filter-summary js-wpv-filter-users-summary'> <?php echo wpv_get_filter_users_summary_txt( $view_settings ); ?> </p> <?php WPV_Filter_Item::simple_filter_list_item_buttons( 'users', 'wpv_filter_users_update', wp_create_nonce( 'wpv_view_filter_users_nonce' ), 'wpv_filter_users_delete', wp_create_nonce( 'wpv_view_filter_users_delete_nonce' ) ); ?> <div id="wpv-filter-users-edit" class="wpv-filter-users-edit wpv-filter-edit js-wpv-filter-edit"> <div id="wpv-filter-users" class="js-wpv-filter-options js-wpv-filter-users-options"> <?php WPV_Users_Filter::wpv_render_users_options( $view_settings ); ?> </div> <div class="js-wpv-filter-toolset-messages"></div> </div> <?php $res = ob_get_clean(); return $res; }