class-foogallery-album-template-loader.php
2 months ago
class-rewrite-rules.php
2 months ago
class-shortcodes.php
2 months ago
class-shortcodes.php
45 lines
| 1 | <?php |
| 2 | /* |
| 3 | * FooGallery Album Shortcode |
| 4 | */ |
| 5 | |
| 6 | if ( ! class_exists( 'FooGallery_Album_Shortcodes' ) ) { |
| 7 | |
| 8 | class FooGallery_Album_Shortcodes { |
| 9 | |
| 10 | function __construct() { |
| 11 | add_action( 'foogallery_loaded_album_template', array( $this, 'render_custom_css' ) ); |
| 12 | add_shortcode( foogallery_album_shortcode_tag(), array( $this, 'render_foogallery_album_shortcode' ) ); |
| 13 | } |
| 14 | |
| 15 | function render_foogallery_album_shortcode( $atts ) { |
| 16 | |
| 17 | $args = wp_parse_args( $atts, array( |
| 18 | 'id' => 0, |
| 19 | 'album' => '', |
| 20 | ) ); |
| 21 | |
| 22 | $args = apply_filters( 'foogallery-album_shortcode_atts', $args ); |
| 23 | |
| 24 | //create new instance of template engine |
| 25 | $engine = new FooGallery_Album_Template_Loader(); |
| 26 | |
| 27 | ob_start(); |
| 28 | |
| 29 | $engine->render_template( $args ); |
| 30 | |
| 31 | $output_string = ob_get_contents(); |
| 32 | ob_end_clean(); |
| 33 | return $output_string; |
| 34 | } |
| 35 | |
| 36 | function render_custom_css( $foogallery_album ) { |
| 37 | if ( !empty( $foogallery_album->custom_css ) ) { |
| 38 | echo '<style type="text/css">'; |
| 39 | echo $foogallery_album->custom_css; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Custom CSS from album settings |
| 40 | echo '</style>'; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 |