Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class splitImageTextDouble extends ET_Builder_Module {
- function init() {
- $this->name = esc_html__( 'Split Image Text Double', 'et_builder' );
- $this->slug = 'insightdesign_split_image_text_double';
- $this->vb_support = 'on';
- $this->main_css_element = '%%order_class%%.insightdesign_split_image_text_double';
- $this->settings_modal_toggles = array(
- 'general' => array(
- 'toggles' => array(
- 'main_content' => esc_html__( 'Text', 'et_builder' ),
- 'image' => esc_html__( 'Image', 'et_builder' ),
- ),
- ),
- 'advanced' => array(
- 'toggles' => array(
- 'image' => esc_html__( 'Image', 'et_builder' ),
- 'text' => array(
- 'title' => esc_html__( 'Text', 'et_builder' ),
- 'priority' => 49,
- ),
- 'color' => esc_html__( 'Color', 'et_builder' ),
- ),
- ),
- 'custom_css' => array(
- 'toggles' => array(
- 'animation' => array(
- 'title' => esc_html__( 'Animation', 'et_builder' ),
- 'priority' => 90,
- ),
- ),
- ),
- );
- $this->advanced_fields = array(
- 'background' => array(
- 'settings' => array(
- 'color' => 'alpha',
- ),
- ),
- 'image' => array(
- 'css' => array(
- 'main' => '%%order_class%% .et_insightdesign_split_image',
- ),
- ),
- 'button' => false,
- );
- }
- function get_fields() {
- $fields = array(
- 'sit_title_1' => array(
- 'label' => esc_html__( 'Title 1', 'et_builder' ),
- 'type' => 'text',
- 'option_category' => 'basic_option',
- 'description' => esc_html__( 'Input the title of the section', 'et_builder' ),
- 'toggle_slug' => 'main_content',
- ),
- 'sit_title_2' => array(
- 'label' => esc_html__( 'Title 2', 'et_builder' ),
- 'type' => 'text',
- 'option_category' => 'basic_option',
- 'description' => esc_html__( 'Input the title of the section', 'et_builder' ),
- 'toggle_slug' => 'main_content',
- ),
- 'sit_date_1' => array(
- 'label' => esc_html__( 'Date to display 1', 'et_builder' ),
- 'type' => 'text',
- 'option_category' => 'basic_option',
- 'description' => esc_html__( 'Input the date for your module here.', 'et_builder' ),
- 'toggle_slug' => 'main_content',
- ),
- 'sit_date_2' => array(
- 'label' => esc_html__( 'Date to display 2', 'et_builder' ),
- 'type' => 'text',
- 'option_category' => 'basic_option',
- 'description' => esc_html__( 'Input the date for your module here.', 'et_builder' ),
- 'toggle_slug' => 'main_content',
- ),
- 'sit_link_1' => array(
- 'label' => esc_html__( 'Link 1', 'et_builder' ),
- 'type' => 'text',
- 'option_category' => 'basic_option',
- 'description' => esc_html__( "What URL does this module link to?", 'et_builder' ),
- 'toggle_slug' => 'main_content',
- ),
- 'sit_link_2' => array(
- 'label' => esc_html__( 'Link 2', 'et_builder' ),
- 'type' => 'text',
- 'option_category' => 'basic_option',
- 'description' => esc_html__( "What URL does this module link to?", 'et_builder' ),
- 'toggle_slug' => 'main_content',
- ),
- 'sit_image_1' => array(
- 'label' => esc_html__( 'Image URL 1', 'et_builder' ),
- 'type' => 'upload',
- 'option_category' => 'basic_option',
- 'upload_button_text' => esc_attr__( 'Upload an image', 'et_builder' ),
- 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ),
- 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ),
- 'description' => esc_html__( 'Upload your desired image, or type in the URL to the image you would like to display.', 'et_builder' ),
- 'toggle_slug' => 'image',
- 'affects' => array('sit_color_1',),
- ),
- 'sit_image_2' => array(
- 'label' => esc_html__( 'Image URL 2', 'et_builder' ),
- 'type' => 'upload',
- 'option_category' => 'basic_option',
- 'upload_button_text' => esc_attr__( 'Upload an image', 'et_builder' ),
- 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ),
- 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ),
- 'description' => esc_html__( 'Upload your desired image, or type in the URL to the image you would like to display.', 'et_builder' ),
- 'toggle_slug' => 'image',
- 'affects' => array('sit_color_2',),
- ),
- 'sit_color_1' => array(
- 'default' => et_builder_accent_color(),
- 'label' => esc_html__( 'Text Background Color 1', 'et_builder' ),
- 'type' => 'color-alpha',
- 'description' => esc_html__( 'This will adjust the background color to the text.', 'et_builder' ),
- 'depends_show_if' => 'on',
- 'toggle_slug' => 'main_content',
- ),
- 'sit_color_2' => array(
- 'default' => et_builder_accent_color(),
- 'label' => esc_html__( 'Text Background Color 2', 'et_builder' ),
- 'type' => 'color-alpha',
- 'description' => esc_html__( 'This will adjust the background color to the text.', 'et_builder' ),
- 'depends_show_if' => 'on',
- 'toggle_slug' => 'main_content',
- ),
- );
- return $fields;
- }
- function render( $attrs, $content = null, $render_slug ) {
- $link_1 = $this->props['sit_link_1'];
- $link_2 = $this->props['sit_link_2'];
- $title_1 = $this->props['sit_title_1'];
- $title_2 = $this->props['sit_title_2'];
- $date_1 = $this->props['sit_date_1'];
- $date_2 = $this->props['sit_date_2'];
- $image_1 = $this->props['sit_image_1'];
- $image_2 = $this->props['sit_image_2'];
- $color_1 = $this->props['sit_color_1'];
- $color_2 = $this->props['sit_color_2'];
- // Added for backward compatibility
- if ( empty( $animation ) ) {
- $animation = 'top';
- }
- $output = sprintf(
- '<style>
- .split-double {width: 50%%; float: left; position: relative;}
- @media (max-width: 600px) {
- .split-double {width: 100%%; float: none;}
- }
- </style>
- <div class="split-double" style="background: url(%4$s) center center no-repeat; background-size:cover; height: 340px;">
- <div class="splitIT-text" style="position: absolute; bottom: 0; background-color: %5$s; width: 100%%; padding: 1em 4em; height: 100px;">
- <h3 style="font-size: 14px; padding-bottom: 5px; text-align: center;"><a href="%1$s" style="color: white;">%2$s</a></h3>
- <p style="font-size: 12px; text-align: center;"><a href="%1$s" style="color: white;">%3$s</a></p>
- </div>
- </div>
- <div class="split-double" style="background: url(%9$s) center center no-repeat; background-size:cover; height: 340px;">
- <div class="splitIT-text" style="position: absolute; bottom: 0; background-color: %10$s; width: 100%%; padding: 1em 4em; height: 100px;">
- <h3 style="font-size: 14px; padding-bottom: 5px; text-align: center;"><a href="%6$s" style="color: white;">%7$s</a></h3>
- <p style="font-size: 12px; text-align: center;"><a href="%6$s" style="color: white;">%8$s</a></p>
- </div>
- </div>',
- $link_1,
- $title_1,
- $date_1,
- $image_1,
- $color_1,
- $link_2,
- $title_2,
- $date_2,
- $image_2,
- $color_2
- );
- return $output;
- }
- }
- new splitImageTextDouble;
Advertisement
Add Comment
Please, Sign In to add comment