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