* @copyright Copyright (c) 2018, Chris Baldelomar * @link https://webplantmedia.com/product/brimstone-wordpress-theme/ * @license http://www.gnu.org/licenses/gpl-2.0.html */ if ( ! class_exists( 'Brimstone_Content_Widget_Static_Content' ) ) : /** * Class: Display static content from an specific page. * * @since Brimstone 1.01 * * @see Brimstone_Widget */ class Brimstone_Content_Widget_Static_Content extends Brimstone_Widget { /** * Constructor */ public function __construct() { $this->widget_id = 'brimstone-content-widget-static-content'; $this->widget_description = esc_html__( 'Displays content from a specified page on your widgetized page.', 'brimstone' ); $this->widget_name = esc_html__( 'Brimstone: Static Content', 'brimstone' ); $this->settings = array( 'page' => array( 'type' => 'page', 'std' => '', 'label' => esc_html__( 'Select Page:', 'brimstone' ), 'description' => esc_html__( 'Create a new page with the the content and featured image you want to display.', 'brimstone' ), 'sanitize' => 'text', ), 'background_color' => array( 'type' => 'colorpicker', 'std' => '#ffffff', 'label' => esc_html__( 'Background Color:', 'brimstone' ), 'sanitize' => 'color', ), 'background_opacity' => array( 'type' => 'number', 'std' => '80', 'step' => '1', 'min' => '0', 'max' => '100', 'label' => esc_html__( 'Background Color Opacity:', 'brimstone' ), 'sanitize' => 'absint', ), 'text_color' => array( 'type' => 'colorpicker', 'std' => '', 'label' => esc_html__( 'Text Color:', 'brimstone' ), 'sanitize' => 'color', ), 'link_color' => array( 'type' => 'colorpicker', 'std' => '', 'label' => esc_html__( 'Link Color:', 'brimstone' ), 'sanitize' => 'color', ), 'padding_top' => array( 'type' => 'number', 'std' => 80, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Top padding of widget:', 'brimstone' ), 'sanitize' => 'number', ), 'padding_bottom' => array( 'type' => 'number', 'std' => 80, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Bottom padding of widget:', 'brimstone' ), 'sanitize' => 'number', ), 'margin_bottom' => array( 'type' => 'number', 'std' => 80, 'step' => 1, 'min' => 0, 'label' => esc_html__( 'Bottom margin of widget:', 'brimstone' ), 'sanitize' => 'number', ), ); parent::__construct(); } /** * Widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ public function widget( $args, $instance ) { $o = $this->sanitize( $instance ); $post = null; /* no default page is set for starter-content. */ $featured_image_url = null; if ( ! empty( $o['page'] ) ) { $post = new WP_Query( array( 'page_id' => $o['page'] ) ); $featured_image_url = get_the_post_thumbnail_url( $o['page'], 'full' ); } $style = array(); $bg_style = array(); $fullwidth = false; $classes[] = 'static-page-content'; $classes[] = 'no-top-bottom-margins'; if ( ! empty( $o['padding_top'] ) ) { $style[] = 'padding-top:' . $o['padding_top'] . 'px;'; } if ( ! empty( $o['padding_bottom'] ) ) { $style[] = 'padding-bottom:' . $o['padding_bottom'] . 'px;'; } if ( ! empty( $o['margin_bottom'] ) ) { $style[] = 'margin-bottom:' . $o['margin_bottom'] . 'px;'; } if ( ! empty( $featured_image_url ) ) { $bg_style[] = 'background-image:url(' . esc_url( $featured_image_url ) . ');'; $fullwidth = true; } if ( ! empty( $o['background_color'] ) ) { $rgb = $this->hex2rgb( $o['background_color'] ); $opacity = absint( $o['background_opacity'] ) / 100; $fullwidth = true; } $page_template = get_page_template_slug( $o['page'] ); if ( ( 'templates/full-width-page.php' === $page_template ) ) { $classes[] = 'full-width-static-content'; } if ( ( '#ffffff' === $o['text_color'] ) || ( '#fff' === $o['text_color'] ) ) { $classes[] = 'option-white-text'; } // Allow site-wide customization of the 'Read more' link text. $read_more = apply_filters( 'brimstone_read_more_text', esc_html__( 'Read more', 'brimstone' ) ); if ( $fullwidth ) { $args['before_widget'] = str_replace( 'class="content-widget', 'class="content-widget full-width-bar', $args['before_widget'] ); } echo $args['before_widget']; /* WPCS: XSS OK. HTML output. */ ?>
have_posts() ) : ?> have_posts() ) : ?> the_post(); ?>
>
%2$s', esc_html__( 'Edit', 'brimstone' ), get_the_title() ), '' ); ?>