Ejemplo n.º 1
0
Archivo: base.php Proyecto: fovoc/make
        /**
         * Reusable component for adding an image uploader.
         *
         * @since  1.0.0.
         *
         * @param  string    $section_name    Name of the current section.
         * @param  int       $image_id        ID of the current image.
         * @param  string    $title           Title for the media modal.
         * @return string                     Either return the string or echo it.
         */
        public function add_uploader($section_name, $image_id = 0, $title = '')
        {
            $image = ttfmake_get_image_src($image_id, 'large');
            $title = !empty($title) ? $title : esc_html__('Set image', 'make');
            ob_start();
            ?>
		<div class="ttfmake-uploader<?php 
            if (!empty($image[0])) {
                ?>
 ttfmake-has-image-set<?php 
            }
            ?>
">
			<div data-title="<?php 
            echo esc_attr($title);
            ?>
" class="ttfmake-media-uploader-placeholder ttfmake-media-uploader-add"<?php 
            if (!empty($image[0])) {
                ?>
 style="background-image: url(<?php 
                echo addcslashes(esc_url_raw($image[0]), '"');
                ?>
);"<?php 
            }
            ?>
></div>
			<input type="hidden" name="<?php 
            echo esc_attr($section_name);
            ?>
[image-id]" value="<?php 
            echo ttfmake_sanitize_image_id($image_id);
            ?>
" class="ttfmake-media-uploader-value" />
		</div>
	<?php 
            $output = ob_get_clean();
            return $output;
        }
Ejemplo n.º 2
0
/**
 * Get the CSS for a slide.
 *
 * @since  1.0.0.
 *
 * @param  array     $slide                   The slide data.
 * @param  array     $ttfmake_section_data    The section data.
 * @return string                             The CSS.
 */
function ttfmake_builder_banner_slide_style($slide, $ttfmake_section_data)
{
    $slide_style = '';
    // Background color
    if (isset($slide['background-color']) && '' !== $slide['background-color']) {
        $slide_style .= 'background-color:' . maybe_hash_hex_color($slide['background-color']) . ';';
    }
    // Background image
    if (isset($slide['image-id']) && 0 !== ttfmake_sanitize_image_id($slide['image-id'])) {
        $image_src = ttfmake_get_image_src($slide['image-id'], 'full');
        if (isset($image_src[0])) {
            $slide_style .= 'background-image: url(\'' . addcslashes(esc_url_raw($image_src[0]), '"') . '\');';
        }
    }
    /**
     * Allow developers to change the CSS for a Banner section.
     *
     * @since 1.2.3.
     *
     * @param string    $slide_style             The CSS for the banner.
     * @param array     $slide                   The slide data.
     * @param array     $ttfmake_section_data    The section data.
     */
    return apply_filters('make_builder_banner_slide_style', esc_attr($slide_style), $slide, $ttfmake_section_data);
}