PluginProbe
WP Ultimate Post Grid / 3.5.0
WP Ultimate Post Grid v3.5.0
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 / includes / public / class-wpupg-shortcode.php

class-wpupg-shortcode.php in WP Ultimate Post Grid 3.5.0, at includes/public/class-wpupg-shortcode.php

130 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handle the grid shortcodes.
4 *
5 * @link https://bootstrapped.ventures
6 * @since 3.0.0
7 *
8 * @package WP_Ultimate_Post_Grid
9 * @subpackage WP_Ultimate_Post_Grid/includes/public
10 */
11
12 /**
13 * Handle the grid shortcodes.
14 *
15 * @since 3.0.0
16 * @package WP_Ultimate_Post_Grid
17 * @subpackage WP_Ultimate_Post_Grid/includes/public
18 * @author Brecht Vandersmissen <brecht@bootstrapped.ventures>
19 */
20 class WPUPG_Shortcode {
21
22 /**
23 * Register actions and filters.
24 *
25 * @since 3.0.0
26 */
27 public static function init() {
28 add_shortcode( 'wpupg-grid-with-filters', array( __CLASS__, 'grid_with_filters_shortcode' ) );
29 add_shortcode( 'wpupg-grid', array( __CLASS__, 'grid_shortcode' ) );
30 add_shortcode( 'wpupg-filter', array( __CLASS__, 'filter_shortcode' ) );
31 }
32
33 /**
34 * Output the entire grid shortcode.
35 *
36 * @since 3.0.0
37 * @param mixed $atts Shortcode attributes.
38 */
39 public static function grid_with_filters_shortcode( $atts ) {
40 $output = '';
41 $atts = shortcode_atts( array(
42 'id' => '',
43 'align' => '',
44 ), $atts, 'wpupg_grid_with_filters' );
45
46 $slug = strtolower( trim( $atts['id'] ) );
47
48 unset( $atts['id'] );
49
50 $grid = WPUPG_Grid_Manager::get_grid( $slug );
51
52 if ( $grid ) {
53 WPUPG_Assets::load();
54
55 $output = WPUPG_Grid_Output::entire( $grid, $atts );
56 wp_localize_script( 'wpupg-public', 'wpupg_grid_args_' . $grid->id(), $grid->get_javascript_args() );
57 }
58
59 return $output;
60 }
61
62 /**
63 * Output the grid shortcode.
64 *
65 * @since 3.0.0
66 * @param mixed $atts Shortcode attributes.
67 */
68 public static function grid_shortcode( $atts ) {
69 $output = '';
70 $atts = shortcode_atts( array(
71 'id' => '',
72 'align' => '',
73 ), $atts, 'wpupg_grid' );
74
75 $slug = strtolower( trim( $atts['id'] ) );
76
77 unset( $atts['id'] );
78
79 $grid = WPUPG_Grid_Manager::get_grid( $slug );
80
81 if ( $grid ) {
82 WPUPG_Assets::load();
83
84 $output = WPUPG_Grid_Output::grid( $grid, $atts );
85 wp_localize_script( 'wpupg-public', 'wpupg_grid_args_' . $grid->id(), $grid->get_javascript_args() );
86 }
87
88 return $output;
89 }
90
91 /**
92 * Output the filter shortcode.
93 *
94 * @since 3.0.0
95 * @param mixed $atts Shortcode attributes.
96 */
97 public static function filter_shortcode( $atts ) {
98 $output = '';
99 $atts = shortcode_atts( array(
100 'id' => '',
101 'filter' => '',
102 'align' => '',
103 ), $atts, 'wpupg_filter' );
104
105 $slug = strtolower( trim( $atts['id'] ) );
106
107 unset( $atts['id'] );
108
109 $grid = WPUPG_Grid_Manager::get_grid( $slug );
110
111 if ( $grid ) {
112 WPUPG_Assets::load();
113
114 if ( ! $atts['filter'] ) {
115 $output = WPUPG_Grid_Output::filters( $grid, $atts );
116 } else {
117 $filter = $grid->filter( $atts['filter'] );
118
119 if ( $filter ) {
120 $output = WPUPG_Grid_Output::filter( $grid, $filter, $atts );
121 }
122 }
123 }
124
125 return $output;
126 }
127 }
128
129 WPUPG_Shortcode::init();
130