public function shortcode($options)
 {
     $output = '';
     $options = shortcode_atts(array('id' => false), $options);
     $slug = strtolower(trim($options['id']));
     if ($slug) {
         $post = get_page_by_path($slug, OBJECT, WPUPG_POST_TYPE);
         if (!is_null($post)) {
             $grid = new WPUPG_Grid($post);
             $filter_type = $grid->filter_type();
             $filter = '';
             if ($filter_type == 'isotope') {
                 $filter_style = $grid->filter_style();
                 $filter_style = $filter_style[$filter_type];
                 $style_data = 'data-filter-type="' . $filter_type . '"';
                 $style_data .= ' data-margin-vertical="' . $filter_style['margin_vertical'] . '"';
                 $style_data .= ' data-margin-horizontal="' . $filter_style['margin_horizontal'] . '"';
                 $style_data .= ' data-padding-vertical="' . $filter_style['padding_vertical'] . '"';
                 $style_data .= ' data-padding-horizontal="' . $filter_style['padding_horizontal'] . '"';
                 $style_data .= ' data-border-width="' . $filter_style['border_width'] . '"';
                 $style_data .= ' data-background-color="' . $filter_style['background_color'] . '"';
                 $style_data .= ' data-text-color="' . $filter_style['text_color'] . '"';
                 $style_data .= ' data-border-color="' . $filter_style['border_color'] . '"';
                 $style_data .= ' data-active-background-color="' . $filter_style['background_active_color'] . '"';
                 $style_data .= ' data-active-text-color="' . $filter_style['text_active_color'] . '"';
                 $style_data .= ' data-active-border-color="' . $filter_style['border_active_color'] . '"';
                 $style_data .= ' data-hover-background-color="' . $filter_style['background_hover_color'] . '"';
                 $style_data .= ' data-hover-text-color="' . $filter_style['text_hover_color'] . '"';
                 $style_data .= ' data-hover-border-color="' . $filter_style['border_hover_color'] . '"';
                 $multiselect = $grid->filter_multiselect() ? 'true' : 'false';
                 $filter .= '<div id="wpupg-grid-' . esc_attr($slug) . '-filter" class="wpupg-filter wpupg-filter-' . $filter_type . '" style="text-align: ' . $filter_style['alignment'] . ';" data-grid="' . esc_attr($slug) . '" data-type="' . $filter_type . '" data-multiselect="' . $multiselect . '" data-multiselect-type="' . $grid->filter_multiselect_type() . '"' . $style_data . '>';
                 $filter .= $grid->filter();
                 $filter .= '</div>';
             }
             $output = apply_filters('wpupg_filter_shortcode', $filter, $grid);
         }
     }
     return $output;
 }
Esempio n. 2
0
 public function shortcode($options)
 {
     $output = '';
     $slug = strtolower(trim($options['id']));
     if ($slug) {
         unset($options['id']);
         $post = get_page_by_path($slug, OBJECT, WPUPG_POST_TYPE);
         if (!is_null($post)) {
             $grid = new WPUPG_Grid($post);
             // Check if we need to filter the grid dynamically
             $dynamic_rules = array();
             if (count($options) > 0 && WPUltimatePostGrid::is_premium_active()) {
                 foreach ($options as $taxonomy => $terms) {
                     if (taxonomy_exists($taxonomy)) {
                         $dynamic_rules[] = array('post_type' => 'wpupg_dynamic', 'taxonomy' => $taxonomy, 'values' => explode(';', str_replace(',', ';', $terms)), 'type' => 'restrict');
                     }
                 }
             }
             if (count($dynamic_rules) > 0) {
                 $grid->set_dynamic_rules($dynamic_rules);
             }
             $filter_type = $grid->filter_type();
             $filter = '';
             if ($filter_type == 'isotope') {
                 $filter_style = $grid->filter_style();
                 $filter_style = $filter_style[$filter_type];
                 $style_data = ' data-filter-type="' . $filter_type . '"';
                 $style_data .= ' data-margin-vertical="' . $filter_style['margin_vertical'] . '"';
                 $style_data .= ' data-margin-horizontal="' . $filter_style['margin_horizontal'] . '"';
                 $style_data .= ' data-padding-vertical="' . $filter_style['padding_vertical'] . '"';
                 $style_data .= ' data-padding-horizontal="' . $filter_style['padding_horizontal'] . '"';
                 $style_data .= ' data-border-width="' . $filter_style['border_width'] . '"';
                 $style_data .= ' data-background-color="' . $filter_style['background_color'] . '"';
                 $style_data .= ' data-text-color="' . $filter_style['text_color'] . '"';
                 $style_data .= ' data-border-color="' . $filter_style['border_color'] . '"';
                 $style_data .= ' data-active-background-color="' . $filter_style['background_active_color'] . '"';
                 $style_data .= ' data-active-text-color="' . $filter_style['text_active_color'] . '"';
                 $style_data .= ' data-active-border-color="' . $filter_style['border_active_color'] . '"';
                 $style_data .= ' data-hover-background-color="' . $filter_style['background_hover_color'] . '"';
                 $style_data .= ' data-hover-text-color="' . $filter_style['text_hover_color'] . '"';
                 $style_data .= ' data-hover-border-color="' . $filter_style['border_hover_color'] . '"';
                 $multiselect = $grid->filter_multiselect() ? 'true' : 'false';
                 $inverse = $grid->filter_inverse() ? 'true' : 'false';
                 $filter .= '<div id="wpupg-grid-' . esc_attr($slug) . '-filter" class="wpupg-filter wpupg-filter-' . $filter_type . '" style="text-align: ' . $filter_style['alignment'] . ';" data-grid="' . esc_attr($slug) . '" data-type="' . $filter_type . '" data-multiselect="' . $multiselect . '" data-multiselect-type="' . $grid->filter_multiselect_type() . '" data-inverse="' . $inverse . '"' . $style_data . '>';
                 $filter .= $grid->filter();
                 $filter .= '</div>';
             }
             $output = apply_filters('wpupg_filter_shortcode', $filter, $grid);
         }
     }
     return $output;
 }
<?php

// Grid should never be null. Construct just allows easy access to WPUPG_Grid functions in IDE.
if (is_null($grid)) {
    $grid = new WPUPG_Grid(0);
}
?>

<?php 
if ($grid->post()->post_status !== 'publish') {
    _e('You have to publish the grid first.', 'wp-ultimate-post-grid');
} else {
    ?>
    <strong>Grid</strong><br/>
    [wpupg-grid id="<?php 
    echo $grid->post()->post_name;
    ?>
"]
    <?php 
    if ($grid->filter_type() !== 'none') {
        ?>
    <br/><br/>
    <strong>Filter</strong><br/>
    [wpupg-filter id="<?php 
        echo $grid->post()->post_name;
        ?>
"]
    <?php 
    }
}
<div id="wpupg_no_taxonomies"><?php 
_e('There are no taxonomies associated with this post type', 'wp-ultimate-post-grid');
?>
</div>
<table id="wpupg_form_filter" class="wpupg_form">
    <tr class="wpupg_no_filter">
        <td><label for="wpupg_filter_type"><?php 
_e('Type', 'wp-ultimate-post-grid');
?>
</label></td>
        <td>
            <select name="wpupg_filter_type" id="wpupg_filter_type" class="wpupg-select2">
                <?php 
$filter_type_options = array('none' => __('No Filter', 'wp-ultimate-post-grid'), 'isotope' => __('Isotope', 'wp-ultimate-post-grid'), 'dropdown' => __('Dropdown', 'wp-ultimate-post-grid') . $premium_only);
foreach ($filter_type_options as $filter_type => $filter_type_name) {
    $selected = $filter_type == $grid->filter_type() ? ' selected="selected"' : '';
    echo '<option value="' . esc_attr($filter_type) . '"' . $selected . '>' . $filter_type_name . '</option>';
}
?>
            </select>
        </td>
        <td><?php 
_e('Type of filter to be used for this grid.', 'wp-ultimate-post-grid');
?>
</td>
    </tr>
    <tr class="wpupg_divider">
        <td><label for="wpupg_filter_taxonomy_post"><?php 
_e('Taxonomy', 'wp-ultimate-post-grid');
?>
</label></td>
<?php

/*
 * -> 1.2
 *
 * Set active colors to hover colors
 */
$args = array('post_type' => WPUPG_POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'nopaging' => true);
$query = new WP_Query($args);
$posts = $query->have_posts() ? $query->posts : array();
foreach ($posts as $grid_post) {
    $grid = new WPUPG_Grid($grid_post);
    $filter_type = $grid->filter_type();
    if ($filter_type == 'isotope') {
        $filter_style = $grid->filter_style();
        $filter_style['isotope']['background_active_color'] = $filter_style['isotope']['background_hover_color'];
        $filter_style['isotope']['text_active_color'] = $filter_style['isotope']['text_hover_color'];
        $filter_style['isotope']['border_active_color'] = $filter_style['isotope']['border_hover_color'];
        update_post_meta($grid->ID(), 'wpupg_filter_style', $filter_style);
    }
}
// Successfully migrated to 1.2
$migrate_version = '1.2';
update_option('wpupg_migrate_version', $migrate_version);
if ($notices) {
    WPUltimatePostGrid::get()->helper('notices')->add_admin_notice('<strong>WP Ultimate Post Grid</strong> Successfully migrated to 1.2+');
}