PluginProbe
Powerkit – Supercharge your WordPress Site / 3.0.4
Powerkit – Supercharge your WordPress Site v3.0.4
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / basic-elements / templates / progressbars.php

progressbars.php in Powerkit – Supercharge your WordPress Site 3.0.4, at modules/basic-elements/templates/progressbars.php

117 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode Progress Bars config
4 *
5 * @package Powerkit
6 * @subpackage Templates
7 */
8
9 /**
10 * Progress Bars
11 */
12 add_action( 'init', function () {
13 powerkit_basic_shortcodes_register( array(
14 'name' => 'progressbars',
15 'title' => esc_html__( 'Progress Bars', 'powerkit' ),
16 'priority' => 60,
17 'base' => 'powerkit_progressbar',
18 'autoregister' => true,
19 'fields' => array(
20 array(
21 'type' => 'section',
22 'label' => esc_html__( 'Options', 'powerkit' ),
23 ),
24 array(
25 'type' => 'input',
26 'name' => 'value',
27 'label' => esc_html__( 'Value', 'powerkit' ),
28 'default' => '25',
29 'suffix' => ' %',
30 'desc' => '(0-100)',
31 ),
32 array(
33 'type' => 'section',
34 'label' => esc_html__( 'Style', 'powerkit' ),
35 ),
36 array(
37 'type' => 'input',
38 'name' => 'height',
39 'label' => esc_html__( 'Height (thickness)', 'powerkit' ),
40 'default' => '20',
41 'suffix' => ' px',
42 ),
43 array(
44 'type' => 'radio',
45 'name' => 'color',
46 'label' => esc_html__( 'Color', 'powerkit' ),
47 'style' => 'vertical',
48 'default' => 'primary',
49 'options' => array(
50 'primary' => esc_html__( 'Primary', 'powerkit' ),
51 'secondary' => esc_html__( 'Secondary', 'powerkit' ),
52 'success' => esc_html__( 'Success', 'powerkit' ),
53 'info' => esc_html__( 'Info', 'powerkit' ),
54 'warning' => esc_html__( 'Warning', 'powerkit' ),
55 'danger' => esc_html__( 'Danger', 'powerkit' ),
56 ),
57 ),
58 array(
59 'type' => 'checkbox',
60 'name' => 'display_value',
61 'label' => esc_html__( 'Display value', 'powerkit' ),
62 'default' => false,
63 ),
64 array(
65 'type' => 'checkbox',
66 'name' => 'striped',
67 'label' => esc_html__( 'Striped', 'powerkit' ),
68 'default' => false,
69 ),
70 array(
71 'type' => 'checkbox',
72 'name' => 'animated',
73 'label' => esc_html__( 'Animated', 'powerkit' ),
74 'default' => false,
75 ),
76 ),
77 ) );
78 });
79
80 /**
81 * Progress Bar Shortcode
82 *
83 * @param array $output Shortcode HTML.
84 * @param array $atts User defined attributes in shortcode tag.
85 * @param string $content Shorcode tag content.
86 * @return string Shortcode result HTML.
87 */
88 function powerkit_basic_shortcodes_progressbar( $output, $atts, $content ) {
89
90 // Value.
91 $atts['value'] = $atts['value'] > 100 ? 100 : $atts['value'];
92
93 // Display value.
94 $display_value = ( 'true' === $atts['display_value'] ) ? $atts['value'] . '%' : '';
95
96 // Striped and animated.
97 $class = 'pk-progress-bar';
98 $class .= ( 'true' === $atts['striped'] ) ? ' pk-progress-bar-striped' : '';
99 $class .= ( 'true' === $atts['animated'] ) ? ' pk-progress-bar-animated' : '';
100
101 // Color.
102 $class .= sprintf( ' pk-bg-%s', $atts['color'] );
103
104 $output = sprintf(
105 '<div class="pk-progress" style="height: %2$spx;">
106 <div class="%s" role="progressbar" style="width: %3$s%%;" aria-valuenow="%3$s" aria-valuemin="0" aria-valuemax="100">%4$s</div>
107 </div>',
108 $class,
109 $atts['height'],
110 $atts['value'],
111 $display_value
112 );
113
114 return $output;
115 }
116 add_filter( 'powerkit_progressbar_shortcode', 'powerkit_basic_shortcodes_progressbar', 10, 3 );
117