function custom_route_callback($request)
 {
     global $wpdb;
     // Retrieving the View ID
     if (null !== $request->get_param('id')) {
         $request_param_id = $request->get_param('id');
         $view = get_post($request_param_id);
         if ($view != null) {
             $view_id = $view->ID;
         } else {
             $view_by_name = $wpdb->get_row($wpdb->prepare("SELECT * FROM \n\t\t\t\t{$wpdb->posts} WHERE post_name = %s", $request_param_id));
             $view_id = $view_by_name->ID;
         }
     }
     //Handling the GET parameters to fit into the View $args
     if ($request->params['GET'] && !empty($request->params['GET'])) {
         $get_params = $request->params['GET'];
         foreach ($get_params as $key => $value) {
             $args[$key] = $value;
         }
     }
     // It lets you change the query only in the custom Rest Route
     add_filter('wpv_filter_query', array($this, 'toolset_rest_query_filter'), 99, 3);
     if (function_exists('get_view_query_results')) {
         $view_results = get_view_query_results($view_id, $post_in, $current_user_in, $args);
     }
     return $view_results;
 }
function ddl_views_content_grid_preview()
{
    if (WPDD_Utils::user_not_admin()) {
        die(__("You don't have permission to perform this action!", 'ddl-layouts'));
    }
    if (!isset($_POST['wpnonce']) || !wp_verify_nonce($_POST['wpnonce'], 'ddl_layout_view_nonce')) {
        die('verification failed');
    }
    global $wpdb;
    if (isset($_POST['view_id'])) {
        $view_id = $_POST['view_id'];
    } else {
        return __('View not set', 'ddl-layouts');
    }
    $layout_style = array('unformatted' => __('Unformatted', 'ddl-layouts'), 'bootstrap-grid' => __('Unformatted', 'ddl-layouts'), 'table' => __('Table-based grid', 'ddl-layouts'), 'table_of_fields' => __('Table', 'ddl-layouts'), 'un_ordered_list' => __('Unordered list', 'ddl-layouts'), 'ordered_list' => __('Ordered list', 'ddl-layouts'));
    $view = $wpdb->get_results($wpdb->prepare("SELECT ID, post_title FROM {$wpdb->posts} WHERE ID = %d AND post_type='view'", $view_id));
    if (isset($view[0])) {
        $post_title = $view[0]->post_title;
        $id = $view[0]->ID;
        $view_settings = get_post_meta($id, '_wpv_settings', true);
        $meta = get_post_meta($id, '_wpv_layout_settings', true);
        if (!isset($meta['style'])) {
            $meta['style'] = 'unformatted';
        }
        $view_purpose = '';
        if (isset($view_settings['view-query-mode']) && $view_settings['view-query-mode'] == 'normal') {
            $view_output = get_view_query_results($id);
            if (!isset($view_settings['view_purpose'])) {
                $view_settings['view_purpose'] = 'full';
            }
            switch ($view_settings['view_purpose']) {
                case 'all':
                    $view_purpose = __('Display all results', 'ddl-layouts');
                    break;
                case 'pagination':
                    $view_purpose = __('Display the results with pagination', 'ddl-layouts');
                    break;
                case 'slider':
                    $view_purpose = __('Display the results as a slider', 'ddl-layouts');
                    break;
                case 'parametric':
                    $content = $_POST['content'];
                    switch ($content['parametric_mode']) {
                        case 'full':
                            ?>
                            <div class="ddl-parametric-search-preview">
                                <img src="<?php 
                            echo WPDDL_RES_RELPATH . '/images/cell-icons/png/parametric-search-cells/both-search-form-and-results.png';
                            ?>
" height="204px">
                            </div>
                            <?php 
                            die;
                            break;
                        case 'form':
                            if ($content['parametric_mode_target'] == 'self' && $_POST['target_found'] != 'true') {
                                ?>
                                <div class="ddl-parametric-search-preview">
                                    <img src="<?php 
                                echo WPDDL_RES_RELPATH . '/images/cell-icons/png/parametric-search-cells/search-form-only-results-missing.png';
                                ?>
" height="204px">
                                </div>
                                <?php 
                                die;
                            }
                            if ($content['parametric_mode_target'] == 'other') {
                                ?>
                                <div class="ddl-parametric-search-preview">
                                    <img src="<?php 
                                echo WPDDL_RES_RELPATH . '/images/cell-icons/png/parametric-search-cells/search-form-only-results-in-a-different-page.png';
                                ?>
" height="204px">
                                </div>
                                <?php 
                                die;
                            }
                            ?>
                            <div class="ddl-parametric-search-preview">
                                <img src="<?php 
                            echo WPDDL_RES_RELPATH . '/images/cell-icons/png/parametric-search-cells/search-form-only.png';
                            ?>
" height="100px">
                            </div>
                            <?php 
                            die;
                            break;
                        case 'results':
                            ?>
                            <div class="ddl-parametric-search-preview">
                                <img src="<?php 
                            echo WPDDL_RES_RELPATH . '/images/cell-icons/png/parametric-search-cells/search-results-only.png';
                            ?>
" height="100px">
                            </div>
                            <?php 
                            die;
                            break;
                    }
                    break;
                case 'full':
                    $view_purpose = __('Displays a fully customized display', 'ddl-layouts');
                    break;
            }
            echo $view_purpose;
            echo '<br />';
        } else {
            $view_output = array();
            if ($meta['style'] == 'bootstrap-grid' || $meta['style'] == 'table') {
                if ($meta['style'] == 'bootstrap-grid') {
                    $col_number = $meta['bootstrap_grid_cols'];
                } else {
                    $col_number = $meta['table_cols'];
                }
                // add 2 rows of items.
                for ($i = 1; $i <= 2 * $col_number; $i++) {
                    $item = new stdClass();
                    $item->post_title = sprintf(__('Post %d', 'ddl-layouts'), $i);
                    $view_output[] = $item;
                }
            } else {
                // just add 3 items
                for ($i = 1; $i <= 3; $i++) {
                    $item = new stdClass();
                    $item->post_title = sprintf(__('Post %d', 'ddl-layouts'), $i);
                    $view_output[] = $item;
                }
            }
        }
        ddl_views_generate_cell_preview($post_title, $id, $meta, $view_output);
    }
    die;
}
示例#3
0
* Time: 3:04 PM
* Created to show how many posts were used by the user
**  @version     2.2.0*
*/

/**
 * My posts used
 *
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

$user_id = get_current_user_id();
$job_posts = get_view_query_results('818');

if ( $job_posts ) : ?>

<h2><?php echo apply_filters( 'woocommerce_my_account_my_orders_title', __( 'Recent Posts', 'woocommerce' ) ); ?></h2>

<table class="shop_table shop_table_responsive my_account_orders">
    <thead>
    <tr>
        <th class="order-number"><span class="nobr"><?php _e( 'Post ID', 'woocommerce' ); ?></span></th>
        <th class="order-date"><span class="nobr"><?php _e( 'Date', 'woocommerce' ); ?></span></th>
        <th class="order-total"><span class="nobr"><?php _e( 'Job Title', 'woocommerce' ); ?></span></th>
        <th class="order-actions">&nbsp;</th>
    </tr>
    </thead>
    <tbody><?php