| @@ -23,9 +23,10 @@ | ||
| 23 | 23 | * Register actions and filters. |
| 24 | 24 | * |
| 25 | 25 | * @since 3.0.0 |
| 26 | 26 | */ |
| 27 | - public static function init() { | |
| 27 | + public static function init() { | |
| 28 | + add_shortcode( 'wpupg-grid-limit', array( __CLASS__, 'grid_limit_shortcode' ) ); | |
| 28 | 29 | add_shortcode( 'wpupg-grid-with-filters', array( __CLASS__, 'grid_with_filters_shortcode' ) ); |
| 29 | 30 | add_shortcode( 'wpupg-grid', array( __CLASS__, 'grid_shortcode' ) ); |
| 30 | 31 | add_shortcode( 'wpupg-filter', array( __CLASS__, 'filter_shortcode' ) ); |
| 31 | 32 | } |
| @@ -30,8 +31,23 @@ | ||
| 30 | 31 | add_shortcode( 'wpupg-filter', array( __CLASS__, 'filter_shortcode' ) ); |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | /** |
| 35 | + * Output the grid limit shortcode. | |
| 36 | + * | |
| 37 | + * @since 3.9.0 | |
| 38 | + * @param mixed $atts Shortcode attributes. | |
| 39 | + */ | |
| 40 | + public static function grid_limit_shortcode( $atts ) { | |
| 41 | + $atts = shortcode_atts( array( | |
| 42 | + 'id' => '', | |
| 43 | + ), $atts, 'wpupg_grid_limit' ); | |
| 44 | + | |
| 45 | + // Just output empty. Grid Limit Rules class will handle the rest based on the shortcode attributes. | |
| 46 | + return ''; | |
| 47 | + } | |
| 48 | + | |
| 49 | + /** | |
| 34 | 50 | * Output the entire grid shortcode. |
| 35 | 51 | * |
| 36 | 52 | * @since 3.0.0 |
| 37 | 53 | * @param mixed $atts Shortcode attributes. |
| @@ -52,9 +68,9 @@ | ||
| 52 | 68 | if ( $grid ) { |
| 53 | 69 | WPUPG_Assets::load(); |
| 54 | 70 | |
| 55 | 71 | $output = WPUPG_Grid_Output::entire( $grid, $atts ); |
| 56 | - wp_localize_script( 'wpupg-public', 'wpupg_grid_args_' . $grid->id(), $grid->get_javascript_args() ); | |
| 72 | + WPUPG_Assets::add_js_data( 'wpupg_grid_args_' . $grid->id(), $grid->get_javascript_args() ); | |
| 57 | 73 | } |
| 58 | 74 | |
| 59 | 75 | return $output; |
| 60 | 76 | } |
| @@ -81,9 +97,9 @@ | ||
| 81 | 97 | if ( $grid ) { |
| 82 | 98 | WPUPG_Assets::load(); |
| 83 | 99 | |
| 84 | 100 | $output = WPUPG_Grid_Output::grid( $grid, $atts ); |
| 85 | - wp_localize_script( 'wpupg-public', 'wpupg_grid_args_' . $grid->id(), $grid->get_javascript_args() ); | |
| 101 | + WPUPG_Assets::add_js_data( 'wpupg_grid_args_' . $grid->id(), $grid->get_javascript_args() ); | |
| 86 | 102 | } |
| 87 | 103 | |
| 88 | 104 | return $output; |
| 89 | 105 | } |
| @@ -122,8 +138,22 @@ | ||
| 122 | 138 | } |
| 123 | 139 | } |
| 124 | 140 | |
| 125 | 141 | return $output; |
| 142 | + } | |
| 143 | + | |
| 144 | + /** | |
| 145 | + * Sanitize HTML in shortcode for output. | |
| 146 | + * | |
| 147 | + * @since 3.9.0 | |
| 148 | + */ | |
| 149 | + public static function sanitize_html( $text ) { | |
| 150 | + if ( $text ) { | |
| 151 | + $text = str_replace( '"', '"', $text ); | |
| 152 | + $text = wp_kses_post( $text ); | |
| 153 | + } | |
| 154 | + | |
| 155 | + return $text; | |
| 126 | 156 | } |
| 127 | 157 | } |
| 128 | 158 | |
| 129 | 159 | WPUPG_Shortcode::init(); |