name = esc_html__( 'Bar Counter', 'et_builder' ); $this->plural = esc_html__( 'Bar Counters', 'et_builder' ); $this->slug = 'et_pb_counter'; $this->vb_support = 'on'; $this->type = 'child'; $this->child_title_var = 'content'; $this->advanced_setting_title_text = esc_html__( 'New Bar Counter', 'et_builder' ); $this->settings_text = esc_html__( 'Bar Counter Settings', 'et_builder' ); $this->main_css_element = '%%order_class%%'; $this->advanced_fields = array( 'borders' => array( 'default' => array( 'css' => array( 'main' => array( 'border_radii' => "{$this->main_css_element} span.et_pb_counter_container, {$this->main_css_element} span.et_pb_counter_amount", 'border_styles' => "{$this->main_css_element} span.et_pb_counter_container", ), ), ), ), 'box_shadow' => array( 'default' => array( 'css' => array( 'main' => '%%order_class%% span.et_pb_counter_container', 'overlay' => 'inset', ), ), ), 'fonts' => array( 'title' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'css' => array( 'main' => ".et_pb_counters {$this->main_css_element} .et_pb_counter_title", ), ), 'percent' => array( 'label' => esc_html__( 'Percentage', 'et_builder' ), 'css' => array( 'main' => ".et_pb_counters {$this->main_css_element} .et_pb_counter_amount_number", 'text_align' => ".et_pb_counters {$this->main_css_element} .et_pb_counter_amount", ), ), ), 'background' => array( 'use_background_color' => 'fields_only', 'css' => array( 'main' => ".et_pb_counters li{$this->main_css_element} .et_pb_counter_container", ), ), 'margin_padding' => array( 'css' => array( 'margin' => ".et_pb_counters {$this->main_css_element}", 'padding' => ".et_pb_counters {$this->main_css_element} .et_pb_counter_amount", ), ), 'max_width' => array( 'css' => array( 'module_alignment' => ".et_pb_counters {$this->main_css_element}", ), ), 'text' => array( 'css' => array( 'text_orientation' => '%%order_class%% .et_pb_counter_title, %%order_class%% .et_pb_counter_amount', ), ), 'button' => false, ); $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'main_content' => esc_html__( 'Text', 'et_builder' ), ), ), 'advanced' => array( 'toggles' => array( 'bar' => esc_html__( 'Bar Counter', 'et_builder' ), ), ), ); $this->custom_css_fields = array( 'counter_title' => array( 'label' => esc_html__( 'Counter Title', 'et_builder' ), 'selector' => '.et_pb_counter_title', ), 'counter_container' => array( 'label' => esc_html__( 'Counter Container', 'et_builder' ), 'selector' => '.et_pb_counter_container', ), 'counter_amount' => array( 'label' => esc_html__( 'Counter Amount', 'et_builder' ), 'selector' => '.et_pb_counter_amount', ), ); } function get_fields() { $fields = array( 'content' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'Input a title for your bar.', 'et_builder' ), 'toggle_slug' => 'main_content', 'dynamic_content' => 'text', ), 'percent' => array( 'label' => esc_html__( 'Percent', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'Define a percentage for this bar.', 'et_builder' ), 'toggle_slug' => 'main_content', 'default_on_front' => '0', ), 'bar_background_color' => array( 'label' => esc_html__( 'Bar Background Color', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'hover' => 'tabs', 'tab_slug' => 'advanced', 'toggle_slug' => 'bar', ), ); return $fields; } public function get_transition_fields_css_props() { $fields = parent::get_transition_fields_css_props(); $fields['background_layout'] = array( 'color' => '%%order_class%% .et_pb_counter_title' ); $fields['bar_background_color'] = array( 'background-color' => '%%order_class%% .et_pb_counter_amount' ); return $fields; } function get_parallax_image_background( $base_name = 'background' ) { global $et_pb_counters_settings; // Parallax setting is only derived from parent if bar counter item has no background $use_counter_value = '' !== $this->props['background_color'] || 'on' === $this->props['use_background_color_gradient'] || '' !== $this->props['background_image'] || '' !== $this->props['background_video_mp4'] || '' !== $this->props['background_video_webm']; $background_image = $use_counter_value ? $this->props['background_image'] : $et_pb_counters_settings['background_image']; $parallax = $use_counter_value ? $this->props['parallax'] : $et_pb_counters_settings['parallax']; $parallax_method = $use_counter_value ? $this->props['parallax_method'] : $et_pb_counters_settings['parallax_method']; $parallax_background = ''; if ( '' !== $background_image && 'on' == $parallax ) { $parallax_classname = array( 'et_parallax_bg' ); if ( 'off' === $parallax_method ) { $parallax_classname[] = 'et_pb_parallax_css'; } $parallax_background = sprintf( '
', esc_attr( implode( ' ', $parallax_classname ) ), esc_attr( $background_image ) ); } return $parallax_background; } function video_background( $args = array(), $base_name = 'background' ) { global $et_pb_counters_settings; $use_counter_value = '' !== $this->props['background_color'] || 'on' === $this->props['use_background_color_gradient'] || '' !== $this->props['background_image'] || '' !== $this->props['background_video_mp4'] || '' !== $this->props['background_video_webm']; $background_video_mp4 = $use_counter_value && isset( $this->props['background_video_mp4'] ) ? $this->props['background_video_mp4'] : $et_pb_counters_settings['background_video_mp4']; $background_video_webm = $use_counter_value && isset( $this->props['background_video_webm'] ) ? $this->props['background_video_webm'] : $et_pb_counters_settings['background_video_webm']; $background_video_width = $use_counter_value && isset( $this->props['background_video_width'] ) ? $this->props['background_video_width'] : $et_pb_counters_settings['background_video_width']; $background_video_height = $use_counter_value && isset( $this->props['background_video_height'] ) ? $this->props['background_video_height'] : $et_pb_counters_settings['background_video_height']; if ( ! empty( $args ) ) { $background_video = self::get_video_background( $args ); $allow_player_pause = isset( $args['allow_player_pause'] ) ? $args['allow_player_pause' ] : 'off'; $pause_outside_viewport = isset( $args['background_video_pause_outside_viewport'] ) ? $args['background_video_pause_outside_viewport'] : 'on'; } else { $background_video = self::get_video_background( array( 'background_video_mp4' => $background_video_mp4, 'background_video_webm' => $background_video_webm, 'background_video_width' => $background_video_width, 'background_video_height' => $background_video_height, ) ); $allow_player_pause = $use_counter_value ? $this->props['allow_player_pause'] : $et_pb_counters_settings['allow_player_pause']; $pause_outside_viewport = $use_counter_value ? $this->props['background_video_pause_outside_viewport'] : $et_pb_counters_settings['background_video_pause_outside_viewport']; } $video_background = ''; if ( $background_video ) { $video_background = sprintf( '