/**
  * Save the data for the gallery section.
  *
  * @since  1.0.0.
  *
  * @param  array    $data    The data from the $_POST array for the section.
  * @return array             The cleaned data.
  */
 public function save_gallery($data)
 {
     $clean_data = array();
     if (isset($data['columns'])) {
         if (in_array($data['columns'], range(1, 4))) {
             $clean_data['columns'] = $data['columns'];
         }
     }
     if (isset($data['caption-color'])) {
         if (in_array($data['caption-color'], array('light', 'dark'))) {
             $clean_data['caption-color'] = $data['caption-color'];
         }
     }
     if (isset($data['captions'])) {
         if (in_array($data['captions'], array('none', 'overlay', 'reveal'))) {
             $clean_data['captions'] = $data['captions'];
         }
     }
     if (isset($data['aspect'])) {
         if (in_array($data['aspect'], array('none', 'landscape', 'portrait', 'square'))) {
             $clean_data['aspect'] = $data['aspect'];
         }
     }
     if (isset($data['background-image']['image-id'])) {
         $clean_data['background-image'] = ttfmake_sanitize_image_id($data['background-image']['image-id']);
     }
     if (isset($data['title'])) {
         $clean_data['title'] = $clean_data['label'] = apply_filters('title_save_pre', $data['title']);
     }
     if (isset($data['darken'])) {
         $clean_data['darken'] = 1;
     } else {
         $clean_data['darken'] = 0;
     }
     if (isset($data['background-color'])) {
         $clean_data['background-color'] = maybe_hash_hex_color($data['background-color']);
     }
     if (isset($data['background-style'])) {
         if (in_array($data['background-style'], array('tile', 'cover'))) {
             $clean_data['background-style'] = $data['background-style'];
         }
     }
     if (isset($data['gallery-item-order'])) {
         $clean_data['gallery-item-order'] = array_map(array('TTFMAKE_Builder_Save', 'clean_section_id'), explode(',', $data['gallery-item-order']));
     }
     if (isset($data['gallery-items']) && is_array($data['gallery-items'])) {
         foreach ($data['gallery-items'] as $id => $item) {
             if (isset($item['title'])) {
                 $clean_data['gallery-items'][$id]['title'] = apply_filters('title_save_pre', $item['title']);
             }
             if (isset($item['link'])) {
                 $clean_data['gallery-items'][$id]['link'] = esc_url_raw($item['link']);
             }
             if (isset($item['description'])) {
                 $clean_data['gallery-items'][$id]['description'] = sanitize_post_field('post_content', $item['description'], get_post() ? get_the_ID() : 0, 'db');
             }
             if (isset($item['image-id'])) {
                 $clean_data['gallery-items'][$id]['image-id'] = ttfmake_sanitize_image_id($item['image-id']);
             }
         }
     }
     return $clean_data;
 }
Example #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);
}
Example #3
0
File: base.php Project: 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;
        }
 /**
  * Clean the data being passed when saving the Banner layout.
  *
  * @param array $data Array of data inputs being passed.
  *
  * @return array Clean data.
  */
 public function save_banner($data)
 {
     $clean_data = array();
     $clean_data['title'] = $clean_data['label'] = isset($data['title']) ? apply_filters('title_save_pre', $data['title']) : '';
     $clean_data['hide-arrows'] = isset($data['hide-arrows']) && 1 === (int) $data['hide-arrows'] ? 1 : 0;
     $clean_data['hide-dots'] = isset($data['hide-dots']) && 1 === (int) $data['hide-dots'] ? 1 : 0;
     $clean_data['autoplay'] = isset($data['autoplay']) && 1 === (int) $data['autoplay'] ? 1 : 0;
     if (isset($data['transition']) && in_array($data['transition'], array('fade', 'scrollHorz', 'none'))) {
         $clean_data['transition'] = $data['transition'];
     }
     if (isset($data['delay'])) {
         $clean_data['delay'] = absint($data['delay']);
     }
     if (isset($data['height'])) {
         $clean_data['height'] = absint($data['height']);
     }
     if (isset($data['responsive']) && in_array($data['responsive'], array('aspect', 'balanced'))) {
         $clean_data['responsive'] = $data['responsive'];
     }
     if (isset($data['banner-slide-order'])) {
         $clean_data['banner-slide-order'] = array_map(array('TTFMAKE_Builder_Save', 'clean_section_id'), explode(',', $data['banner-slide-order']));
     }
     if (isset($data['banner-slides']) && is_array($data['banner-slides'])) {
         foreach ($data['banner-slides'] as $id => $slide) {
             if (isset($slide['content'])) {
                 $clean_data['banner-slides'][$id]['content'] = sanitize_post_field('post_content', $slide['content'], get_post() ? get_the_ID() : 0, 'db');
             }
             if (isset($slide['background-color'])) {
                 $clean_data['banner-slides'][$id]['background-color'] = maybe_hash_hex_color($slide['background-color']);
             }
             $clean_data['banner-slides'][$id]['darken'] = isset($slide['darken']) && 1 === (int) $slide['darken'] ? 1 : 0;
             if (isset($slide['image-id'])) {
                 $clean_data['banner-slides'][$id]['image-id'] = ttfmake_sanitize_image_id($slide['image-id']);
             }
             $clean_data['banner-slides'][$id]['alignment'] = isset($slide['alignment']) && in_array($slide['alignment'], array('none', 'left', 'right')) ? $slide['alignment'] : 'none';
             if (isset($slide['state'])) {
                 $clean_data['banner-slides'][$id]['state'] = in_array($slide['state'], array('open', 'closed')) ? $slide['state'] : 'open';
             }
             if (isset($slide['spine_slide_url'])) {
                 $clean_data['banner-slides'][$id]['slide-url'] = esc_url_raw($slide['spine_slide_url']);
             }
         }
     }
     if (isset($data['section-classes'])) {
         $clean_data['section-classes'] = $this->clean_classes($data['section-classes']);
     }
     if (isset($data['section-wrapper'])) {
         $clean_data['section-wrapper'] = $this->clean_classes($data['section-wrapper']);
     }
     if (isset($data['column-classes'])) {
         $clean_data['column-classes'] = $this->clean_classes($data['column-classes']);
     }
     if (isset($data['label'])) {
         $clean_data['label'] = sanitize_text_field($data['label']);
     }
     if (isset($data['background-img'])) {
         $clean_data['background-img'] = esc_url_raw($data['background-img']);
     }
     if (isset($data['background-mobile-img'])) {
         $clean_data['background-mobile-img'] = esc_url_raw($data['background-mobile-img']);
     }
     $clean_data = apply_filters('spine_builder_save_banner', $clean_data, $data);
     return $clean_data;
 }
Example #5
0
	<div class="ttfmake-titlediv">
		<input placeholder="<?php 
esc_attr_e('Enter link here', 'make');
?>
" type="text" name="<?php 
echo $section_name;
?>
[link]" class="ttfmake-link code widefat" value="<?php 
echo esc_url($link);
?>
" autocomplete="off" />
	</div>

	<?php 
ttfmake_get_builder_base()->add_uploader($section_name, ttfmake_sanitize_image_id($image_id));
?>

	<div class="ttfmake-titlediv">
		<div class="ttfmake-titlewrap">
			<input placeholder="<?php 
esc_attr_e('Enter title here', 'make');
?>
" type="text" name="<?php 
echo $section_name;
?>
[title]" class="ttfmake-title" value="<?php 
echo esc_attr(htmlspecialchars($title));
?>
" autocomplete="off" />
		</div>
    echo esc_attr($ttfmake_slide_id);
    ?>
" data-section-type="banner-slide">
<?php 
}
?>

	<div title="<?php 
esc_attr_e('Drag-and-drop this slide into place', 'make');
?>
" class="ttfmake-sortable-handle">
		<div class="sortable-background"></div>
	</div>

	<?php 
echo ttfmake_get_builder_base()->add_uploader($section_name, ttfmake_sanitize_image_id($image_id), __('Set banner image', 'make'));
?>

	<a href="#" class="configure-banner-slide-link ttfmake-banner-slide-configure ttfmake-overlay-open" title="<?php 
esc_attr_e('Configure slide', 'make');
?>
" data-overlay="#<?php 
echo $overlay_id;
?>
">
		<span>
			<?php 
_e('Configure slide', 'make');
?>
		</span>
	</a>
Example #7
0
</option>
					<option value="right"<?php 
selected('right', $alignment);
?>
><?php 
_e('Right', 'make');
?>
</option>
				</select>
			</div>

		</div>

		<div class="ttfmake-banner-slide-background-image-wrapper">
			<?php 
ttfmake_get_builder_base()->add_uploader($section_name, ttfmake_sanitize_image_id($image_id), array('add' => __('Set slide image', 'make'), 'remove' => __('Remove slide image', 'make'), 'title' => __('Slide image', 'make'), 'button' => __('Use as slide image', 'make')));
?>
		</div>

		<div class="clear"></div>

		<h2>
			<?php 
_e('Slide content overlay', 'make');
?>
		</h2>

		<?php 
$editor_settings = array('tinymce' => true, 'quicktags' => true, 'textarea_name' => $section_name . '[content]');
if (true === $ttfmake_is_js_template) {
    ?>
        /**
         * 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  array     $messages        Message to show.
         * @return void
         */
        public function add_uploader($section_name, $image_id = 0, $messages = array())
        {
            $image = ttfmake_get_image($image_id, 'large');
            $add_state = '' === $image ? 'ttfmake-show' : 'ttfmake-hide';
            $remove_state = '' === $image ? 'ttfmake-hide' : 'ttfmake-show';
            // Set default messages. Note that the theme textdomain is not used in some cases
            // because the strings are core i18ns
            $messages['add'] = empty($messages['add']) ? __('Set featured image', 'make') : $messages['add'];
            $messages['remove'] = empty($messages['remove']) ? __('Remove featured image', 'make') : $messages['remove'];
            $messages['title'] = empty($messages['title']) ? __('Featured Image', 'make') : $messages['title'];
            $messages['button'] = empty($messages['button']) ? __('Use as Featured Image', 'make') : $messages['button'];
            ?>
		<div class="ttfmake-uploader">
			<div class="ttfmake-media-uploader-placeholder ttfmake-media-uploader-add">
				<?php 
            if ('' !== $image) {
                ?>
					<?php 
                echo $image;
                ?>
				<?php 
            }
            ?>
			</div>
			<div class="ttfmake-media-link-wrap">
				<a href="#" class="ttfmake-media-uploader-add ttfmake-media-uploader-set-link <?php 
            echo $add_state;
            ?>
" data-title="<?php 
            echo esc_attr($messages['title']);
            ?>
" data-button-text="<?php 
            echo esc_attr($messages['button']);
            ?>
">
					<?php 
            echo $messages['add'];
            ?>
				</a>
				<a href="#" class="ttfmake-media-uploader-remove <?php 
            echo $remove_state;
            ?>
">
					<?php 
            echo $messages['remove'];
            ?>
				</a>
			</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 
        }
Example #9
0
File: text.php Project: fovoc/make
            echo $button['other-a-attributes'];
        }
        ?>
>
			<span>
				<?php 
        echo esc_html($button['label']);
        ?>
			</span>
		</a>
		<?php 
    }
    ?>

		<?php 
    echo ttfmake_get_builder_base()->add_uploader($column_name, ttfmake_sanitize_image_id($image_id), __('Set image', 'make'));
    ?>
		<?php 
    ttfmake_get_builder_base()->add_frame($section_id . '-' . $i, $column_name . '[content]', $content);
    ?>

		<?php 
    /**
     * Execute code after an individual text column is displayed.
     *
     * @since 1.2.3.
     *
     * @param array    $ttfmake_section_data    The data for the section.
     */
    do_action('make_section_text_after_column', $ttfmake_section_data, $i);
    ?>
Example #10
0
			<input placeholder="<?php 
esc_attr_e('Enter title here', 'make');
?>
" type="text" name="<?php 
echo $section_name;
?>
[title]" class="ttfmake-title ttfmake-section-header-title-input" value="<?php 
echo esc_attr(htmlspecialchars($title));
?>
" autocomplete="off" />
		</div>
	</div>

	<div class="ttfmake-gallery-background-image-wrapper">
		<?php 
ttfmake_get_builder_base()->add_uploader($section_name . '[background-image]', ttfmake_sanitize_image_id($background_image), array('add' => __('Set background image', 'make'), 'remove' => __('Remove background image', 'make'), 'title' => __('Background image', 'make'), 'button' => __('Use as Background Image', 'make')));
?>
	</div>

	<div class="ttfmake-gallery-background-options-wrapper">
		<h4><?php 
_e('Background image', 'make');
?>
</h4>
		<input id="<?php 
echo $section_name;
?>
[darken]" type="checkbox" name="<?php 
echo $section_name;
?>
[darken]" value="1"<?php