PluginProbe
WP Ultimate Post Grid / 1.5
WP Ultimate Post Grid v1.5
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / helpers / shortcodes / grid_shortcode.php

grid_shortcode.php in WP Ultimate Post Grid 1.5, at helpers/shortcodes/grid_shortcode.php

78 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPUPG_Grid_Shortcode {
4
5 public function __construct()
6 {
7 add_shortcode( 'wpupg-grid', array( $this, 'shortcode' ) );
8
9 // add_filter( 'mce_external_plugins', array( $this, 'tinymce_plugin' ) );
10 }
11
12 public function shortcode( $options )
13 {
14 $output = '';
15
16 $options = shortcode_atts( array(
17 'id' => false
18 ), $options );
19
20 $slug = strtolower( trim( $options['id'] ) );
21
22 if( $slug ) {
23 $post = get_page_by_path( $slug, OBJECT, WPUPG_POST_TYPE );
24
25 if( !is_null( $post ) ) {
26 $grid = new WPUPG_Grid( $post );
27
28 $link_type = $grid->link_type();
29 $layout_mode = $grid->layout_mode();
30 $centered = $grid->centered() ? 'true' : 'false';
31
32 $posts = '<div id="wpupg-grid-' . esc_attr( $slug ) . '" class="wpupg-grid" data-grid="' . esc_attr( $slug ) . '" data-link-type="' . $link_type . '" data-layout-mode="' . $layout_mode . '" data-centered="' . $centered . '">';
33 $posts .= $grid->draw_posts();
34 $posts .= '</div>';
35
36 $output = apply_filters( 'wpupg_posts_shortcode', $posts, $grid );
37
38 $pagination = '';
39 if( $grid->pagination_type() == 'pages' ) {
40 $pagination_type = $grid->pagination_type();
41 $pagination_style = $grid->pagination_style();
42
43 $style_data = ' data-margin-vertical="' . $pagination_style['margin_vertical'] . '"';
44 $style_data .= ' data-margin-horizontal="' . $pagination_style['margin_horizontal'] . '"';
45 $style_data .= ' data-padding-vertical="' . $pagination_style['padding_vertical'] . '"';
46 $style_data .= ' data-padding-horizontal="' . $pagination_style['padding_horizontal'] . '"';
47 $style_data .= ' data-border-width="' . $pagination_style['border_width'] . '"';
48
49 $style_data .= ' data-background-color="' . $pagination_style['background_color'] . '"';
50 $style_data .= ' data-text-color="' . $pagination_style['text_color'] . '"';
51 $style_data .= ' data-border-color="' . $pagination_style['border_color'] . '"';
52
53 $style_data .= ' data-active-background-color="' . $pagination_style['background_active_color'] . '"';
54 $style_data .= ' data-active-text-color="' . $pagination_style['text_active_color'] . '"';
55 $style_data .= ' data-active-border-color="' . $pagination_style['border_active_color'] . '"';
56
57 $style_data .= ' data-hover-background-color="' . $pagination_style['background_hover_color'] . '"';
58 $style_data .= ' data-hover-text-color="' . $pagination_style['text_hover_color'] . '"';
59 $style_data .= ' data-hover-border-color="' . $pagination_style['border_hover_color'] . '"';
60
61 $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 . '>';
62 $pagination .= $grid->draw_pagination();
63 $pagination .= '</div>';
64 }
65
66 $output .= apply_filters( 'wpupg_pagination_shortcode', $pagination, $grid );
67 }
68 }
69
70 return $output;
71 }
72
73 public function tinymce_plugin( $plugin_array )
74 {
75 $plugin_array['wpupg_grid_shortcode'] = WPUltimatePostGrid::get()->coreUrl . '/js/tinymce_shortcode.js';
76 return $plugin_array;
77 }
78 }