PluginProbe
Powerkit – Supercharge your WordPress Site / 3.1.0
Powerkit – Supercharge your WordPress Site v3.1.0
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.1.0, at modules/basic-elements/templates/progressbars.php

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