insightdes

TeamMemberEnhanced.php

Aug 1st, 2018
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.05 KB | None | 0 0
  1. <?php
  2.  
  3. class Strategic_Board_Member extends ET_Builder_Module {
  4.     function init() {
  5.         $this->name       = esc_html__( 'Board Member', 'et_builder' );
  6.         $this->slug       = 'sit_board_member';
  7.         $this->vb_support = 'on';
  8.  
  9.         $this->main_css_element = '%%order_class%%.sit_board_member';
  10.  
  11.         $this->settings_modal_toggles = array(
  12.             'general'  => array(
  13.                 'toggles' => array(
  14.                     'main_content' => esc_html__( 'Text', 'et_builder' ),
  15.                     'image'        => esc_html__( 'Image', 'et_builder' ),
  16.                 ),
  17.             ),
  18.             'advanced' => array(
  19.                 'toggles' => array(
  20.                     'icon'  => esc_html__( 'Icon', 'et_builder' ),
  21.                     'image' => esc_html__( 'Image', 'et_builder' ),
  22.                     'text'  => array(
  23.                         'title'    => esc_html__( 'Text', 'et_builder' ),
  24.                         'priority' => 49,
  25.                     ),
  26.                 ),
  27.             ),
  28.             'custom_css' => array(
  29.                 'toggles' => array(
  30.                     'animation' => array(
  31.                         'title'    => esc_html__( 'Animation', 'et_builder' ),
  32.                         'priority' => 90,
  33.                     ),
  34.                 ),
  35.             ),
  36.         );
  37.  
  38.         $this->advanced_fields = array(
  39.             'fonts'                 => array(
  40.                 'header' => array(
  41.                     'label'    => esc_html__( 'Title', 'et_builder' ),
  42.                     'css'      => array(
  43.                         'main'      => "{$this->main_css_element} h4, {$this->main_css_element} h1.et_pb_module_header, {$this->main_css_element} h2.et_pb_module_header, {$this->main_css_element} h3.et_pb_module_header, {$this->main_css_element} h5.et_pb_module_header, {$this->main_css_element} h6.et_pb_module_header",
  44.                         'important' => 'plugin_only',
  45.                     ),
  46.                     'header_level' => array(
  47.                         'default' => 'h4',
  48.                     ),
  49.                 ),
  50.                 'body'   => array(
  51.                     'label'    => esc_html__( 'Body', 'et_builder' ),
  52.                     'css'      => array(
  53.                         'main' => "{$this->main_css_element} *",
  54.                     ),
  55.                 ),
  56.             ),
  57.             'background'            => array(
  58.                 'settings' => array(
  59.                     'color' => 'alpha',
  60.                 ),
  61.             ),
  62.             'borders'               => array(
  63.                 'default' => array(),
  64.                 'image' => array(
  65.                     'css'          => array(
  66.                         'main' => array(
  67.                             'border_radii'  => "{$this->main_css_element} .sit_board_member_image",
  68.                             'border_styles' => "{$this->main_css_element} .sit_board_member_image",
  69.                         ),
  70.                     ),
  71.                     'label_prefix' => esc_html__( 'Image', 'et_builder' ),
  72.                     'tab_slug'     => 'advanced',
  73.                     'toggle_slug'  => 'image',
  74.                 ),
  75.             ),
  76.             'box_shadow'            => array(
  77.                 'default' => array(),
  78.                 'image'   => array(
  79.                     'label'           => esc_html__( 'Image Box Shadow', 'et_builder' ),
  80.                     'option_category' => 'layout',
  81.                     'tab_slug'        => 'advanced',
  82.                     'toggle_slug'     => 'image',
  83.                     'css'          => array(
  84.                         'main'         => '%%order_class%% .sit_board_member_image',
  85.                         'custom_style' => true,
  86.                     ),
  87.                     'default_on_fronts'  => array(
  88.                         'color'    => '',
  89.                         'position' => '',
  90.                     ),
  91.                 ),
  92.             ),
  93.             'margin_padding' => array(
  94.                 'css' => array(
  95.                     'important' => 'all',
  96.                 ),
  97.             ),
  98.             'max_width'             => array(
  99.                 'css' => array(
  100.                     'module_alignment' => '%%order_class%%.sit_board_member.et_pb_module',
  101.                 ),
  102.             ),
  103.             'text'                  => array(
  104.                 'use_background_layout' => true,
  105.                 'options' => array(
  106.                     'background_layout' => array(
  107.                         'default' => 'light',
  108.                     ),
  109.                 ),
  110.             ),
  111.             'filters'               => array(
  112.                 'css' => array(
  113.                     'main' => '%%order_class%%',
  114.                 ),
  115.                 'child_filters_target' => array(
  116.                     'tab_slug' => 'advanced',
  117.                     'toggle_slug' => 'image',
  118.                 ),
  119.             ),
  120.             'image'                 => array(
  121.                 'css' => array(
  122.                     'main' => '%%order_class%% .sit_board_member_image',
  123.                 ),
  124.             ),
  125.             'button'                => false,
  126.         );
  127.  
  128.         $this->custom_css_fields = array(
  129.             'member_image' => array(
  130.                 'label'    => esc_html__( 'Member Image', 'et_builder' ),
  131.                 'selector' => '.sit_board_member_image',
  132.             ),
  133.             'member_description' => array(
  134.                 'label'    => esc_html__( 'Member Description', 'et_builder' ),
  135.                 'selector' => '.sit_board_member_description',
  136.             ), 
  137.             'title' => array(
  138.                 'label'    => esc_html__( 'Title', 'et_builder' ),
  139.                 'selector' => '.sit_board_member_description h4',
  140.             ),
  141.             'member_position' => array(
  142.                 'label'    => esc_html__( 'Member Position', 'et_builder' ),
  143.                 'selector' => '.et_pb_member_position',
  144.             ),
  145.             'member_social_links' => array(
  146.                 'label'    => esc_html__( 'Member Social Links', 'et_builder' ),
  147.                 'selector' => '.et_pb_member_social_links',
  148.             ),
  149.         );
  150.  
  151.         $this->help_videos = array(
  152.             array(
  153.                 'id'   => esc_html( 'rrKmaQ0n7Hw' ),
  154.                 'name' => esc_html__( 'An introduction to the Person module', 'et_builder' ),
  155.             ),
  156.         );
  157.     }
  158.  
  159.     function get_fields() {
  160.         $fields = array(
  161.             'name' => array(
  162.                 'label'           => esc_html__( 'Name', 'et_builder' ),
  163.                 'type'            => 'text',
  164.                 'option_category' => 'basic_option',
  165.                 'description'     => esc_html__( 'Input the name of the person', 'et_builder' ),
  166.                 'toggle_slug'     => 'main_content',
  167.             ),
  168.             'position' => array(
  169.                 'label'           => esc_html__( 'Position', 'et_builder' ),
  170.                 'type'            => 'text',
  171.                 'option_category' => 'basic_option',
  172.                 'description'     => esc_html__( "Input the person's position.", 'et_builder' ),
  173.                 'toggle_slug'     => 'main_content',
  174.             ),
  175.             'image_url' => array(
  176.                 'label'              => esc_html__( 'Image URL', 'et_builder' ),
  177.                 'type'               => 'upload',
  178.                 'option_category'    => 'basic_option',
  179.                 'upload_button_text' => esc_attr__( 'Upload an image', 'et_builder' ),
  180.                 'choose_text'        => esc_attr__( 'Choose an Image', 'et_builder' ),
  181.                 'update_text'        => esc_attr__( 'Set As Image', 'et_builder' ),
  182.                 'description'        => esc_html__( 'Upload your desired image, or type in the URL to the image you would like to display.', 'et_builder' ),
  183.                 'toggle_slug'        => 'image',
  184.             ),
  185.             'facebook_url' => array(
  186.                 'label'           => esc_html__( 'Facebook Profile Url', 'et_builder' ),
  187.                 'type'            => 'text',
  188.                 'option_category' => 'basic_option',
  189.                 'description'     => esc_html__( 'Input Facebook Profile Url.', 'et_builder' ),
  190.                 'toggle_slug'     => 'main_content',
  191.             ),
  192.             'twitter_url' => array(
  193.                 'label'           => esc_html__( 'Twitter Profile Url', 'et_builder' ),
  194.                 'type'            => 'text',
  195.                 'option_category' => 'basic_option',
  196.                 'description'     => esc_html__( 'Input Twitter Profile Url', 'et_builder' ),
  197.                 'toggle_slug'     => 'main_content',
  198.             ),
  199.             'google_url' => array(
  200.                 'label'           => esc_html__( 'Google+ Profile Url', 'et_builder' ),
  201.                 'type'            => 'text',
  202.                 'option_category' => 'basic_option',
  203.                 'description'     => esc_html__( 'Input Google+ Profile Url', 'et_builder' ),
  204.                 'toggle_slug'     => 'main_content',
  205.             ),
  206.             'linkedin_url' => array(
  207.                 'label'           => esc_html__( 'LinkedIn Profile Url', 'et_builder' ),
  208.                 'type'            => 'text',
  209.                 'option_category' => 'basic_option',
  210.                 'description'     => esc_html__( 'Input LinkedIn Profile Url', 'et_builder' ),
  211.                 'toggle_slug'     => 'main_content',
  212.             ),
  213.             'content' => array(
  214.                 'label'           => esc_html__( 'Description (top)', 'et_builder' ),
  215.                 'type'            => 'tiny_mce',
  216.                 'option_category' => 'basic_option',
  217.                 'description'     => esc_html__( 'Input the upper text content for your module here.', 'et_builder' ),
  218.                 'toggle_slug'     => 'main_content',
  219.             ),
  220.             'content_bottom' => array(
  221.                 'label'           => esc_html__( 'Description (bottom)', 'et_builder' ),
  222.                 'type'            => 'tiny_mce',
  223.                 'option_category' => 'basic_option',
  224.                 'description'     => esc_html__( 'Input the bottom text content for your module here.', 'et_builder' ),
  225.                 'toggle_slug'     => 'main_content',
  226.             ),         
  227.             'icon_color' => array(
  228.                 'label'             => esc_html__( 'Icon Color', 'et_builder' ),
  229.                 'type'              => 'color-alpha',
  230.                 'custom_color'      => true,
  231.                 'tab_slug'          => 'advanced',
  232.                 'toggle_slug'       => 'icon',
  233.             ),
  234.             'icon_hover_color' => array(
  235.                 'label'             => esc_html__( 'Icon Hover Color', 'et_builder' ),
  236.                 'type'              => 'color-alpha',
  237.                 'custom_color'      => true,
  238.                 'tab_slug'          => 'advanced',
  239.                 'toggle_slug'       => 'icon',
  240.             ),
  241.         );
  242.  
  243.         return $fields;
  244.     }
  245.  
  246.     function render( $attrs, $content = null, $render_slug ) {
  247.         $name              = $this->props['name'];
  248.         $position          = $this->props['position'];
  249.         $content_bottom    = $this->props['content_bottom'];
  250.         $image_url         = $this->props['image_url'];
  251.         $animation         = $this->props['animation'];
  252.         $facebook_url      = $this->props['facebook_url'];
  253.         $twitter_url       = $this->props['twitter_url'];
  254.         $google_url        = $this->props['google_url'];
  255.         $linkedin_url      = $this->props['linkedin_url'];
  256.         $background_layout = $this->props['background_layout'];
  257.         $icon_color        = $this->props['icon_color'];
  258.         $icon_hover_color  = $this->props['icon_hover_color'];
  259.         $header_level      = $this->props['header_level'];
  260.  
  261.         $image = $social_links = '';
  262.  
  263.         if ( '' !== $icon_color ) {
  264.             ET_Builder_Element::set_style( $render_slug, array(
  265.                 'selector'    => '%%order_class%% .et_pb_member_social_links a',
  266.                 'declaration' => sprintf(
  267.                     'color: %1$s !important;',
  268.                     esc_html( $icon_color )
  269.                 ),
  270.             ) );
  271.         }
  272.  
  273.         if ( '' !== $icon_hover_color ) {
  274.             ET_Builder_Element::set_style( $render_slug, array(
  275.                 'selector'    => '%%order_class%% .et_pb_member_social_links a:hover',
  276.                 'declaration' => sprintf(
  277.                     'color: %1$s !important;',
  278.                     esc_html( $icon_hover_color )
  279.                 ),
  280.             ) );
  281.         }
  282.  
  283.         if ( '' !== $facebook_url ) {
  284.             $social_links .= sprintf(
  285.                 '<li><a href="%1$s" class="et_pb_font_icon et_pb_facebook_icon"><span>%2$s</span></a></li>',
  286.                 esc_url( $facebook_url ),
  287.                 esc_html__( 'Facebook', 'et_builder' )
  288.             );
  289.         }
  290.  
  291.         if ( '' !== $twitter_url ) {
  292.             $social_links .= sprintf(
  293.                 '<li><a href="%1$s" class="et_pb_font_icon et_pb_twitter_icon"><span>%2$s</span></a></li>',
  294.                 esc_url( $twitter_url ),
  295.                 esc_html__( 'Twitter', 'et_builder' )
  296.             );
  297.         }
  298.  
  299.         if ( '' !== $google_url ) {
  300.             $social_links .= sprintf(
  301.                 '<li><a href="%1$s" class="et_pb_font_icon et_pb_google_icon"><span>%2$s</span></a></li>',
  302.                 esc_url( $google_url ),
  303.                 esc_html__( 'Google+', 'et_builder' )
  304.             );
  305.         }
  306.  
  307.         if ( '' !== $linkedin_url ) {
  308.             $social_links .= sprintf(
  309.                 '<li><a href="%1$s" class="et_pb_font_icon et_pb_linkedin_icon"><span>%2$s</span></a></li>',
  310.                 esc_url( $linkedin_url ),
  311.                 esc_html__( 'LinkedIn', 'et_builder' )
  312.             );
  313.         }
  314.  
  315.         if ( '' !== $social_links ) {
  316.             $social_links = sprintf( '<ul class="et_pb_member_social_links">%1$s</ul>', $social_links );
  317.         }
  318.  
  319.         // Added for backward compatibility
  320.         if ( empty( $animation ) ) {
  321.             $animation = 'top';
  322.         }
  323.  
  324.         if ( '' !== $image_url ) {
  325.             // Images: Add CSS Filters and Mix Blend Mode rules (if set)
  326.             if ( array_key_exists( 'image', $this->advanced_fields ) && array_key_exists( 'css', $this->advanced_fields['image'] ) ) {
  327.                 $generate_css_filters_image = $this->generate_css_filters(
  328.                     $render_slug,
  329.                     'child_',
  330.                     self::$data_utils->array_get( $this->advanced_fields['image']['css'], 'main', '%%order_class%%' )
  331.                 );
  332.             }
  333.  
  334.             $image_pathinfo = pathinfo( $image_url );
  335.             $is_image_svg   = isset( $image_pathinfo['extension'] ) ? 'svg' === $image_pathinfo['extension'] : false;
  336.  
  337.             $image = sprintf(
  338.                 '<div class="sit_board_member_image et-waypoint%3$s%4$s%5$s">
  339.                     <img src="%1$s" alt="%2$s" />
  340.                 </div>',
  341.                 esc_attr( $image_url ),
  342.                 esc_attr( $name ),
  343.                 esc_attr( " et_pb_animation_{$animation}" ),
  344.                 $generate_css_filters_image,
  345.                 $is_image_svg ? esc_attr( " et-svg" ) : ''
  346.             );
  347.         }
  348.  
  349.         $video_background = $this->video_background();
  350.         $parallax_image_background = $this->get_parallax_image_background();
  351.  
  352.         // Module classnames
  353.         $this->add_classname( array(
  354.             "et_pb_bg_layout_{$background_layout}",
  355.             'clearfix',
  356.             $this->get_text_orientation_classname()
  357.         ) );
  358.  
  359.         if ( '' === $image ) {
  360.             $this->add_classname( 'sit_board_member_no_image' );
  361.         }
  362.  
  363.         $output = sprintf(
  364.             '<div%3$s class="%4$s">
  365.                 %9$s
  366.                 %8$s
  367.                 %2$s
  368.                 <div class="sit_board_member_description">
  369.                     %5$s
  370.                     %6$s
  371.                     %1$s
  372.                     <img class="toggle" src="' . get_stylesheet_directory_uri() . '/images/up-arrow-circle-30.png" />
  373.                     <div class="sit_board_member_description_bottom">
  374.                         %8$s
  375.                     </div>
  376.                     %7$s
  377.                 </div> <!-- .sit_board_member_description -->
  378.             </div> <!-- .sit_board_member -->',
  379.             $this->content,
  380.             ( '' !== $image ? $image : '' ),
  381.             $this->module_id(),
  382.             $this->module_classname( $render_slug ),
  383.             ( '' !== $name ? sprintf( '<%1$s class="et_pb_module_header">%2$s</%1$s>', et_pb_process_header_level( $header_level, 'h4' ), esc_html( $name ) ) : '' ),
  384.             ( '' !== $position ? sprintf( '<p class="et_pb_member_position">%1$s</p>', esc_html( $position ) ) : '' ),
  385.             $social_links,
  386.             $video_background,
  387.             $parallax_image_background,
  388.             $content_bottom
  389.         );
  390.  
  391.         return $output;
  392.     }
  393. }
  394.  
  395. new Strategic_Board_Member;
Advertisement
Add Comment
Please, Sign In to add comment