public function add_meta_box() { add_meta_box('wpupg_meta_box_shortcode', __('Shortcode', 'wp-ultimate-post-grid'), array($this, 'meta_box_shortcode'), WPUPG_POST_TYPE, 'side', 'high'); if (!WPUltimatePostGrid::is_premium_active()) { add_meta_box('wpupg_meta_box_premium_only', __('Premium Only', 'wp-ultimate-post-grid'), array($this, 'meta_box_premium_only'), WPUPG_POST_TYPE, 'side', 'default'); } }
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); } $link_type = $grid->link_type(); $link_target = $grid->link_target(); $layout_mode = $grid->layout_mode(); $centered = $grid->centered() ? 'true' : 'false'; $posts = '<div id="wpupg-grid-' . esc_attr($slug) . '" class="wpupg-grid" data-grid="' . esc_attr($slug) . '" data-grid-id="' . $grid->ID() . '" data-link-type="' . $link_type . '" data-link-target="' . $link_target . '" data-layout-mode="' . $layout_mode . '" data-centered="' . $centered . '">'; $posts .= $grid->draw_posts(); $posts .= '</div>'; $output = apply_filters('wpupg_posts_shortcode', $posts, $grid); $pagination = ''; if ($grid->pagination_type() == 'pages') { $pagination_type = $grid->pagination_type(); $pagination_style = $grid->pagination_style(); $style_data = ' data-margin-vertical="' . $pagination_style['margin_vertical'] . '"'; $style_data .= ' data-margin-horizontal="' . $pagination_style['margin_horizontal'] . '"'; $style_data .= ' data-padding-vertical="' . $pagination_style['padding_vertical'] . '"'; $style_data .= ' data-padding-horizontal="' . $pagination_style['padding_horizontal'] . '"'; $style_data .= ' data-border-width="' . $pagination_style['border_width'] . '"'; $style_data .= ' data-background-color="' . $pagination_style['background_color'] . '"'; $style_data .= ' data-text-color="' . $pagination_style['text_color'] . '"'; $style_data .= ' data-border-color="' . $pagination_style['border_color'] . '"'; $style_data .= ' data-active-background-color="' . $pagination_style['background_active_color'] . '"'; $style_data .= ' data-active-text-color="' . $pagination_style['text_active_color'] . '"'; $style_data .= ' data-active-border-color="' . $pagination_style['border_active_color'] . '"'; $style_data .= ' data-hover-background-color="' . $pagination_style['background_hover_color'] . '"'; $style_data .= ' data-hover-text-color="' . $pagination_style['text_hover_color'] . '"'; $style_data .= ' data-hover-border-color="' . $pagination_style['border_hover_color'] . '"'; $pagination .= '<div id="wpupg-grid-' . esc_attr($slug) . '-pagination" class="wpupg-pagination wpupg-pagination-' . $pagination_type . '" style="text-align: ' . $pagination_style['alignment'] . ';" data-grid="' . esc_attr($slug) . '" data-type="' . $pagination_type . '"' . $style_data . '>'; $pagination .= $grid->draw_pagination(); $pagination .= '</div>'; } $output .= apply_filters('wpupg_pagination_shortcode', $pagination, $grid); wp_localize_script('wpupg_grid', 'wpupg_grid_' . $grid->ID(), array('posts' => $grid->posts())); } } return $output; }
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; }
public function dropdown_filters_css() { if (WPUltimatePostGrid::is_premium_active()) { $border_color = WPUltimatePostGrid::option('filters_dropdown_border_color', '#AAAAAA'); $text_color = WPUltimatePostGrid::option('filters_dropdown_text_color', '#444444'); $background_highlight_color = WPUltimatePostGrid::option('filters_dropdown_highlight_background_color', '#5897FB'); $text_highlight_color = WPUltimatePostGrid::option('filters_dropdown_highlight_text_color', '#FFFFFF'); echo '<style type="text/css">'; // Border Color echo '.select2wpupg-selection, .select2wpupg-dropdown { border-color: ' . $border_color . '!important; }'; echo '.select2wpupg-selection__arrow b { border-top-color: ' . $border_color . '!important; }'; echo '.select2wpupg-container--open .select2wpupg-selection__arrow b { border-bottom-color: ' . $border_color . '!important; }'; // Text color echo '.select2wpupg-selection__placeholder, .select2wpupg-search__field, .select2wpupg-selection__rendered, .select2wpupg-results__option { color: ' . $text_color . '!important; }'; echo '.select2wpupg-search__field::-webkit-input-placeholder { color: ' . $text_color . '!important; }'; echo '.select2wpupg-search__field:-moz-placeholder { color: ' . $text_color . '!important; }'; echo '.select2wpupg-search__field::-moz-placeholder { color: ' . $text_color . '!important; }'; echo '.select2wpupg-search__field:-ms-input-placeholder { color: ' . $text_color . '!important; }'; // Highlight colors echo '.select2wpupg-results__option--highlighted { color: ' . $text_highlight_color . '!important; background-color: ' . $background_highlight_color . '!important; }'; echo '</style>'; } }
public function filter_multiselect() { if (WPUltimatePostGrid::is_premium_active()) { return $this->meta('wpupg_filter_multiselect'); } else { return false; } }
<?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); } $premium_only = WPUltimatePostGrid::is_premium_active() ? '' : ' (' . __('Premium only', 'wp-ultimate-post-grid') . ')'; ?> <input type="hidden" name="wpupg_nonce" value="<?php echo wp_create_nonce('grid'); ?> " /> <table id="wpupg_form_data_source" class="wpupg_form"> <tr> <td><label for="wpupg_post_types"><?php _e('Post Types', 'wp-ultimate-post-grid'); ?> </label></td> <td> <select name="wpupg_post_types" id="wpupg_post_types" class="wpupg-select2"> <?php $post_types = get_post_types('', 'objects'); unset($post_types[WPUPG_POST_TYPE]); unset($post_types['revision']); unset($post_types['nav_menu_item']); foreach ($post_types as $post_type => $options) { $selected = in_array($post_type, $grid->post_types()) ? ' selected="selected"' : ''; echo '<option value="' . esc_attr($post_type) . '"' . $selected . '>' . $options->labels->name . '</option>'; } ?>
<?php // Subpage $sub = isset($_GET['sub']) ? $_GET['sub'] : 'getting_started'; if (!in_array($sub, array('getting_started', 'whats_new', 'support', 'our_plugins'))) { $sub = 'getting_started'; } // Active version if (WPUltimatePostGrid::is_premium_active()) { $name = 'WP Ultimate Post Grid Premium'; $version = WPUPG_PREMIUM_VERSION; } else { $name = 'WP Ultimate Post Grid'; $version = WPUPG_VERSION; } $full_name = $name . ' ' . $version; // Image directory $img_dir = WPUltimatePostGrid::get()->coreUrl . '/img/faq/'; ?> <div class="wrap about-wrap"> <h1><?php echo $name; ?> </h1> <div class="about-text">Welcome to version <?php echo $version; ?> of the very best grid plugin!</div>
</tr> <tr class="wpupg_divider"> <td><label for="wpupg_filter_taxonomy_post"><?php _e('Taxonomy', 'wp-ultimate-post-grid'); ?> </label></td> <td> <?php $post_types = get_post_types('', 'objects'); unset($post_types[WPUPG_POST_TYPE]); unset($post_types['revision']); unset($post_types['nav_menu_item']); foreach ($post_types as $post_type => $options) { $taxonomies = get_object_taxonomies($post_type, 'objects'); if (count($taxonomies) > 0) { $multiple = WPUltimatePostGrid::is_premium_active() ? ' multiple' : ''; echo '<div id="wpupg_filter_taxonomy_' . $post_type . '_container" class="wpupg_filter_taxonomy_container">'; echo '<select name="wpupg_filter_taxonomy_' . $post_type . '[]" id="wpupg_filter_taxonomy_' . $post_type . '" class="wpupg-select2"' . $multiple . '>'; foreach ($taxonomies as $taxonomy => $tax_options) { $selected = in_array($taxonomy, $grid->filter_taxonomies()) ? ' selected="selected"' : ''; echo '<option value="' . esc_attr($taxonomy) . '"' . $selected . '>' . $tax_options->labels->name . '</option>'; } echo '</select>'; echo '</div>'; } } ?> </td> <td><?php _e('Taxonomy to be used for filtering the grid.', 'wp-ultimate-post-grid'); ?>
/** * Helper functions */ public function set_dynamic_rules($dynamic_rules) { if (WPUltimatePostGrid::is_premium_active()) { $this->meta['wpupg_limit_posts'][0] = 'on'; $limit_rules = maybe_unserialize($this->meta('wpupg_limit_rules')); $limit_rules = is_array($limit_rules) ? $limit_rules : array(); $new_rules = array_merge($limit_rules, $dynamic_rules); $this->meta['wpupg_limit_rules'][0] = serialize($new_rules); $generated = WPUltimatePostGrid::get()->helper('grid_cache')->dynamic_generate($this); $this->meta['wpupg_posts'][0] = serialize($generated['cache']); $this->meta['wpupg_filter'][0] = $generated['filter']; } }