Exemplo n.º 1
0
function wpv_get_taxonomy_filter_summary($view_settings)
{
    $view_settings = wpv_taxonomy_default_settings($view_settings);
    $selected = $view_settings['taxonomy_type'];
    $taxonomies = get_taxonomies('', 'objects');
    if (isset($taxonomies[$selected[0]])) {
        $name = $taxonomies[$selected[0]]->labels->name;
    } else {
        $name = $selected[0];
    }
    echo sprintf(__('This View selects <strong>Taxonomy</strong> of type <strong>%s</strong>', 'wpv-views'), $name);
}
Exemplo n.º 2
0
/**
 * wpv_get_query_type_summary
 *
 * Returns the query type summary for a View
 *
 * @param $view_settings
 *
 * @returns string $summary
 *
 * @since 1.6.0
 */
function wpv_get_query_type_summary( $view_settings, $context = 'listing' ) {
	$view_settings = wpv_post_default_settings( $view_settings );
	$return = '';
	if ( 
		! isset( $view_settings['query_type'] ) 
		|| ( 
			isset( $view_settings['query_type'] ) 
			&& $view_settings['query_type'][0] == 'posts' 
		) 
	) {
		$selected = isset( $view_settings['post_type'] ) ? $view_settings['post_type'] : array();
		$post_types = get_post_types( array( 'public' => true ), 'objects' );
		$selected_post_types = sizeof( $selected );
		switch ( $selected_post_types ) {
			case 0:
				if ( $context == 'embedded-info' ) {
					$return .= __('all post types', 'wpv-views');
				} else {
					$return .= __('All post types', 'wpv-views');
				}
				break;
			case 1:
				if ( isset( $post_types[$selected[0]] ) ) {
					$name = $post_types[$selected[0]]->labels->name;
				} else {
					$name = sprintf( __( '%s (missing post type)', 'wpv-views' ), $selected[0] );
				}
				if ( $name == 'any' ) {
					$name = __('All post types', 'wpv-views');
				}
				$return .= esc_html( $name );
				break;
			default:
				$name_array = array();
				foreach ( $selected as $select_pt ) {
					if ( isset( $post_types[$select_pt] ) ) {
						$name_array[] = $post_types[$select_pt]->labels->name;
					} else {
						$name_array[] = sprintf( __( '%s (missing post type)', 'wpv-views' ), $select_pt );
					}
				}
				$return .= esc_html( implode( ', ', $name_array ) );
				break;
		}
	}
	if ( 
		isset( $view_settings['query_type'] ) 
		&& $view_settings['query_type'][0] == 'taxonomy' 
	) {
		$view_settings = wpv_taxonomy_default_settings( $view_settings );
		$selected = $view_settings['taxonomy_type'];
		if ( isset( $selected[0] ) && !empty( $selected[0] ) && taxonomy_exists( $selected[0] ) ) {
			$taxonomies = get_taxonomies( '', 'objects' );
			if ( isset( $taxonomies[$selected[0]] ) ) {
				$name = $taxonomies[$selected[0]]->labels->name;
			} else {
				$name = $selected[0];
			}
			$name = esc_html( $name );
			if ( $context == 'embedded-info' ) {
				$return .= sprintf( __( 'terms of the taxonomy %s', 'wpv-views' ), $name );
			} else {
				$return .= sprintf( __( 'Terms of the taxonomy %s', 'wpv-views' ), $name );
			}
		} else {
			if ( $context == 'embedded-info' ) {
				$return .= __( 'terms of a taxonomy that no longer exists', 'wpv-views' );
			} else {
				$return .= __( 'Terms of a taxonomy that no longer exists', 'wpv-views' );
			}
		}
	}
	if ( 
		isset( $view_settings['query_type'] ) 
		&& $view_settings['query_type'][0] == 'users' 
	) {
		$user_role = '';
		if ( isset( $view_settings['roles_type'][0] ) ) {
			$user_role = esc_html( $view_settings['roles_type'][0] );
		}
		if ( $context == 'embedded-info' ) {
			if ( $user_role == 'any' ) {
				$return .= __( 'users with any role', 'wpv-views' );
			} else {
				$return .= sprintf( __( 'users with role %s', 'wpv-views' ),  $user_role );
			}
		} else {
			if ( $user_role == 'any' ) {
				$return .= __( 'This View selects users with any role', 'wpv-views' );
			} else {
				$return .= sprintf( __( 'This View selects users with role %s', 'wpv-views' ),  $user_role );
			}
		}
    }
	return $return;
}
Exemplo n.º 3
0
function wpv_filter_types_admin($view_settings)
{
    $view_settings = wpv_types_defaults($view_settings);
    $view_settings = wpv_post_default_settings($view_settings);
    $view_settings = wpv_taxonomy_default_settings($view_settings);
    $view_settings = wpv_order_by_default_settings($view_settings);
    ?>
    <td></td>
    <td>
        <div id="wpv-filter-type-show">
            <?php 
    wpv_get_type_filter_summary($view_settings);
    ?>
        </div>
        <div id="wpv-filter-type-edit" style="background:<?php 
    echo WPV_EDIT_BACKGROUND;
    ?>
;display:none">
            <?php 
    wp_nonce_field('wpv_type_filter_nonce', 'wpv_type_filter_nonce');
    ?>
            <fieldset>
                <legend style="margin-bottom:5px"><strong><?php 
    _e('Select what content type to load:', 'wpv-views');
    ?>
</strong></legend>
                <ul style="padding-left:20px;">
                    <?php 
    $checked = $view_settings['query_type'][0] == 'posts' ? ' checked="checked"' : '';
    ?>
                    <li><label><input type="radio" name="_wpv_settings[query_type][]" value="posts" <?php 
    echo $checked;
    ?>
 onclick="wpv_select_post_type_filter()"/>&nbsp;<?php 
    echo __("Posts (This View returns posts)", 'wpv-views');
    ?>
</label></li>
                    <?php 
    $checked = $view_settings['query_type'][0] == 'taxonomy' ? ' checked="checked"' : '';
    ?>
                    <li><label><input type="radio" name="_wpv_settings[query_type][]" value="taxonomy" <?php 
    echo $checked;
    ?>
 onclick="wpv_select_taxonomy_type_filter()"/>&nbsp;<?php 
    echo __("Taxonomy (This View returns taxonomies)", 'wpv-views');
    ?>
</label></li>
                </ul>
                
                <div id="wpv-post-type-checkboxes"<?php 
    if ($view_settings['query_type'][0] != 'posts') {
        echo ' style="display:none"';
    }
    ?>
>
                    <?php 
    wpv_post_types_checkboxes($view_settings);
    ?>
                </div>

                <div id="wpv-taxonomy-radios"<?php 
    if ($view_settings['query_type'][0] != 'taxonomy') {
        echo ' style="display:none"';
    }
    ?>
>
                    <?php 
    wpv_taxonomy_radios($view_settings);
    ?>
                </div>
            </fieldset>
            
            <div id="wpv-post-types-settings"<?php 
    if ($view_settings['query_type'][0] != 'posts') {
        echo ' style="display:none"';
    }
    ?>
>
                <?php 
    wpv_post_types_settings($view_settings);
    ?>
            </div>
            <div id="wpv-post-order-by"<?php 
    if ($view_settings['query_type'][0] != 'posts') {
        echo ' style="display:none"';
    }
    ?>
>
                <?php 
    wpv_filter_order_by_admin($view_settings);
    ?>
            </div>
            <div id="wpv-post-limit"<?php 
    if ($view_settings['query_type'][0] != 'posts') {
        echo ' style="display:none"';
    }
    ?>
>
                <?php 
    wpv_filter_limit_admin($view_settings);
    ?>
            </div>

            <div id="wpv-taxonomy-settings"<?php 
    if ($view_settings['query_type'][0] != 'taxonomy') {
        echo ' style="display:none"';
    }
    ?>
>
                <?php 
    wpv_taxonomy_settings($view_settings);
    ?>
            </div>
            <div id="wpv-taxonomy-order-by"<?php 
    if ($view_settings['query_type'][0] != 'taxonomy') {
        echo ' style="display:none"';
    }
    ?>
>
                <?php 
    wpv_filter_taxonomy_order_by_admin($view_settings);
    ?>
            </div>
            <div id="wpv-taxonomy-limit"<?php 
    if ($view_settings['query_type'][0] != 'taxonomy') {
        echo ' style="display:none"';
    }
    ?>
>
                <?php 
    wpv_filter_limit_admin($view_settings, 'taxonomy');
    ?>
            </div>

            
            <input class="button-primary" type="button" value="<?php 
    echo __('OK', 'wpv-views');
    ?>
" name="<?php 
    echo __('OK', 'wpv-views');
    ?>
" onclick="wpv_show_type_edit_ok()"/>
            <input class="button-secondary" type="button" value="<?php 
    echo __('Cancel', 'wpv-views');
    ?>
" name="<?php 
    echo __('Cancel', 'wpv-views');
    ?>
" onclick="wpv_show_type_edit_cancel()"/>
        </div>
    </td>
    
    <?php 
}