| 1 |
<?php |
| 2 |
/** |
| 3 |
* Handle the item content shortcode. |
| 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/shortcodes/item |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Handle the item content shortcode. |
| 14 |
* |
| 15 |
* @since 3.0.0 |
| 16 |
* @package WP_Ultimate_Post_Grid |
| 17 |
* @subpackage WP_Ultimate_Post_Grid/includes/public/shortcodes/item |
| 18 |
* @author Brecht Vandersmissen <brecht@bootstrapped.ventures> |
| 19 |
*/ |
| 20 |
class WPUPG_SC_Content extends WPUPG_Template_Shortcode { |
| 21 |
public static $shortcode = 'wpupg-item-content'; |
| 22 |
|
| 23 |
public static function init() { |
| 24 |
$atts = WPUPG_Template_Helper::limit_text_atts(); |
| 25 |
|
| 26 |
self::$attributes = $atts; |
| 27 |
parent::init(); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Output for the shortcode. |
| 32 |
* |
| 33 |
* @since 3.0.0 |
| 34 |
* @param array $atts Options passed along with the shortcode. |
| 35 |
*/ |
| 36 |
public static function shortcode( $atts ) { |
| 37 |
$atts = parent::get_attributes( $atts ); |
| 38 |
|
| 39 |
$item = WPUPG_Template_Shortcodes::get_item(); |
| 40 |
if ( ! $item ) { |
| 41 |
return ''; |
| 42 |
} |
| 43 |
|
| 44 |
// Output. |
| 45 |
$classes = array( |
| 46 |
'wpupg-item-content', |
| 47 |
); |
| 48 |
|
| 49 |
// Parse content before limitting. |
| 50 |
$content = apply_filters( 'the_content', $item->content() ); |
| 51 |
|
| 52 |
$text = WPUPG_Template_Helper::limit_text( $atts, $content ); |
| 53 |
$output = '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">' . $text . '</div>'; |
| 54 |
return apply_filters( parent::get_hook(), $output, $atts, $item ); |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
WPUPG_SC_Content::init(); |