PATH:
home
/
lab2454c
/
fcxpro.com
/
wp-content
/
plugins
/
webon-core
/
inc
/
shortcodes
/
progress-bar
<?php if ( ! function_exists( 'webon_core_add_progress_bar_shortcode' ) ) { /** * Function that add shortcode into shortcodes list for registration * * @param array $shortcodes * * @return array */ function webon_core_add_progress_bar_shortcode( $shortcodes ) { $shortcodes[] = 'WebOnCoreProgressBarShortcode'; return $shortcodes; } add_filter( 'webon_core_filter_register_shortcodes', 'webon_core_add_progress_bar_shortcode' ); } if ( class_exists( 'WebOnCoreShortcode' ) ) { class WebOnCoreProgressBarShortcode extends WebOnCoreShortcode { public function map_shortcode() { $this->set_shortcode_path( WEBON_CORE_SHORTCODES_URL_PATH . '/progress-bar' ); $this->set_base( 'webon_core_progress_bar' ); $this->set_name( esc_html__( 'Progress Bar', 'webon-core' ) ); $this->set_description( esc_html__( 'Shortcode that displays progress bar with provided parameters', 'webon-core' ) ); $this->set_category( esc_html__( 'WebOn Core', 'webon-core' ) ); $this->set_scripts( array( 'progress-bar-line' => array( 'registered' => false, 'url' => WEBON_CORE_INC_URL_PATH . '/shortcodes/progress-bar/assets/js/plugins/jquery.lineProgressbar.js', 'dependency' => array( 'jquery' ) ), 'progress-bar-circle' => array( 'registered' => false, 'url' => WEBON_CORE_INC_URL_PATH . '/shortcodes/progress-bar/assets/js/plugins/progressbar.min.js', 'dependency' => array( 'jquery' ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'custom_class', 'title' => esc_html__( 'Custom Class', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'layout', 'title' => esc_html__( 'Layout', 'webon-core' ), 'options' => array( 'circle' => esc_html__( 'Circle', 'webon-core' ), 'semi-circle' => esc_html__( 'Semi Circle', 'webon-core' ), 'line' => esc_html__( 'Line', 'webon-core' ), 'custom' => esc_html__( 'Custom', 'webon-core' ) ), 'default_value' => 'circle' ) ); $this->set_option( array( 'field_type' => 'textarea_html', 'name' => 'custom_shape', 'title' => esc_html__( 'Custom Shape (SVG code)', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'custom', 'default_value' => '_self' ) ) ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'percentage_type', 'title' => esc_html__( 'Percentage Type', 'webon-core' ), 'options' => array( '' => esc_html__( 'Default', 'webon-core' ), 'floating' => esc_html__( 'Floating', 'webon-core' ), ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'line', 'default_value' => 'circle' ) ) ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'active_line_color', 'title' => esc_html__( 'Active Line Color', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'active_line_width', 'title' => esc_html__( 'Active Line Width', 'webon-core' ), 'description' => esc_html__( 'Enter width for active line without unit. Default value is 4 (1 is equal 3.59px for circle and custom type)', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'inactive_line_color', 'title' => esc_html__( 'Inactive Color', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'enable_inner_border', 'title' => esc_html__( 'Inner Border', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'no_yes', false ), 'description' => esc_html__( 'Enabling this option will display inner circle of 1px (Inactive Line Width option will not affect this line).', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'circle', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'inner_border_width_height', 'title' => esc_html__( 'Inner Border Width & Height', 'webon-core' ), 'description' => esc_html__( 'Enter width and height for inner border in %. Default value is 90%', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'circle', 'default_value' => 'circle' ) ) ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'inner_border_color', 'title' => esc_html__( 'Inner Border Color', 'webon-core' ), 'dependency' => array( 'show' => array( 'enable_inner_border' => array( 'values' => 'yes', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'enable_border_bottom', 'title' => esc_html__( 'Border Below', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'no_yes', false ), 'description' => esc_html__( 'Enabling this option will display border bottom of 1px.', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'line', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'border_bottom_color', 'title' => esc_html__( 'Border Color', 'webon-core' ), 'dependency' => array( 'show' => array( 'enable_border_bottom' => array( 'values' => 'yes', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'textual_content_right', 'title' => esc_html__( 'Textual Content Right', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'no_yes', false ), 'description' => esc_html__( 'Enabling this option will display textual content to the right side of progress bar.', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'circle', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'inactive_line_width', 'title' => esc_html__( 'Inactive Line Width', 'webon-core' ), 'description' => esc_html__( 'Enter width for inactive line without unit. Default value is 4 (1 is equal 3.59px for circle and custom type)', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'duration', 'title' => esc_html__( 'Animation Duration (ms)', 'webon-core' ), 'description' => esc_html__( 'Speed of progress animation in milliseconds. Default value is 1600.', 'webon-core' ), ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'number', 'title' => esc_html__( 'Percentage Number', 'webon-core' ), 'description' => esc_html__( 'Enter percentage number for progress bar', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'number_color', 'title' => esc_html__( 'Number Color', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title', 'title' => esc_html__( 'Title', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'select', 'name' => 'title_tag', 'title' => esc_html__( 'Title Tag', 'webon-core' ), 'options' => webon_core_get_select_type_options_pool( 'title_tag' ), 'default_value' => 'p' ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'title_color', 'title' => esc_html__( 'Title Color', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'title_margin', 'title' => esc_html__( 'Title Margin', 'webon-core' ), 'description' => esc_html__( 'If you selected a progress bar layout other than line this option corresponds to the margin top; in the event line layout type is selected, the option corresponds to the margin bottom.', 'webon-core' ) ) ); $this->set_option( array( 'field_type' => 'textarea', 'name' => 'text', 'title' => esc_html__( 'Text', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'circle', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'color', 'name' => 'text_color', 'title' => esc_html__( 'Text Color', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'circle', 'default_value' => '' ) ) ) ) ); $this->set_option( array( 'field_type' => 'text', 'name' => 'text_margin', 'title' => esc_html__( 'Text Margin Top', 'webon-core' ), 'dependency' => array( 'show' => array( 'layout' => array( 'values' => 'circle', 'default_value' => '' ) ) ) ) ); } public function load_assets() { $atts = $this->get_atts(); if ( $atts['layout'] == 'line' ) { wp_enqueue_script( 'progress-bar-line' ); } else { wp_enqueue_script( 'progress-bar-circle' ); } } public function render( $options, $content = null ) { parent::render( $options ); $atts = $this->get_atts(); $atts['holder_classes'] = $this->get_holder_classes( $atts ); $atts['title_styles'] = $this->get_title_styles( $atts ); $atts['text_styles'] = $this->get_text_styles( $atts ); $atts['inner_border_styles'] = $this->get_inner_border_styles( $atts ); $atts['border_styles'] = $this->get_border_bottom_styles( $atts ); $atts['data_attrs'] = $this->get_data_attrs( $atts ); return webon_core_get_template_part( 'shortcodes/progress-bar', 'templates/progress-bar', '', $atts ); } private function get_holder_classes( $atts ) { $holder_classes = $this->init_holder_classes(); $holder_classes[] = 'qodef-progress-bar'; $holder_classes[] = ! empty( $atts['layout'] ) ? 'qodef-layout--' . $atts['layout'] : ''; // $holder_classes[] = $atts['enable_inner_border'] === 'yes' && $atts['layout'] === 'circle'? 'qodef-inner-circle--enabled' : ''; $holder_classes[] = $atts['textual_content_right'] === 'yes' && $atts['layout'] === 'circle'? 'qodef-content--right' : ''; if ( $atts['layout'] === 'line' && ! empty( $atts['percentage_type'] ) ) { $holder_classes[] = 'qodef-percentage--' . $atts['percentage_type']; } return implode( ' ', $holder_classes ); } private function get_data_attrs( $atts ) { $data = array(); if ( ! empty( $atts['layout'] ) ) { $data['data-layout'] = $atts['layout']; } $data['data-active-line-color'] = ! empty( $atts['active_line_color'] ) ? $atts['active_line_color'] : '#000'; $data['data-active-line-width'] = ! empty( $atts['active_line_width'] ) ? intval( $atts['active_line_width'] ) : 4; $data['data-inactive-line-color'] = ! empty( $atts['inactive_line_color'] ) ? $atts['inactive_line_color'] : '#f5f5f5'; $data['data-inactive-line-width'] = ! empty( $atts['inactive_line_width'] ) ? intval( $atts['inactive_line_width'] ) : 4; $data['data-duration'] = ! empty( $atts['duration'] ) ? intval( $atts['duration'] ) : ''; $data['data-number'] = ! empty( $atts['number'] ) ? $atts['number'] : ''; $data['data-number-color'] = ! empty( $atts['number_color'] ) ? $atts['number_color'] : '#000'; $data['data-text-color'] = ! empty( $atts['number_color'] ) ? $atts['number_color'] : '#000'; return $data; } private function get_title_styles( $atts ) { $styles = array(); if ( $atts['title_margin'] !== '' ) { if ( $atts['layout'] === 'line' ) { $styles[] = 'margin-bottom: ' . intval( $atts['title_margin'] ) . 'px'; } else { $styles[] = 'margin-top: ' . intval( $atts['title_margin'] ) . 'px'; } } if ( ! empty( $atts['title_color'] ) ) { $styles[] = 'color: ' . $atts['title_color']; } return $styles; } private function get_text_styles( $atts ) { $styles = array(); if ( $atts['text_margin'] !== '' ) { if ( $atts['layout'] === 'circle' ) { $styles[] = 'margin-top: ' . intval( $atts['text_margin'] ) . 'px'; } } if ( ! empty( $atts['text_color'] ) ) { $styles[] = 'color: ' . $atts['text_color']; } return $styles; } private function get_inner_border_styles( $atts ) { $styles = array(); if ( $atts['enable_inner_border'] === 'yes' && ! empty( $atts['inner_border_color'] ) ) { $styles[] = 'border-color: ' . $atts['inner_border_color']; } if ( ! empty( $atts['inner_border_width_height'] ) ) { $styles[] = 'width: ' . $atts['inner_border_width_height']; $styles[] = 'height: ' . $atts['inner_border_width_height']; } return $styles; } private function get_border_bottom_styles( $atts ) { $styles = array(); if ( $atts['enable_border_bottom'] === 'yes' && ! empty( $atts['border_bottom_color'] ) ) { $styles[] = 'border-color: ' . $atts['border_bottom_color']; } return $styles; } } }
[+]
..
[-] progress-bar.php
[edit]
[+]
templates
[-] include.php
[edit]
[+]
assets
[-] progress-bar-elementor.php
[edit]