PluginProbe
Powerkit – Supercharge your WordPress Site / 2.9.2
Powerkit – Supercharge your WordPress Site v2.9.2
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 / buttons.php

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

133 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Shortcode Buttons config
4 *
5 * @package Powerkit
6 * @subpackage Templates
7 */
8
9 /**
10 * Buttons
11 */
12 powerkit_basic_shortcodes_register( array(
13 'name' => 'buttons',
14 'title' => esc_html__( 'Buttons', 'powerkit' ),
15 'priority' => 20,
16 'base' => 'powerkit_button',
17 'autoregister' => true,
18 'fields' => array(
19 array(
20 'type' => 'section',
21 'label' => esc_html__( 'Style Options', 'powerkit' ),
22 ),
23 array(
24 'type' => 'radio',
25 'name' => 'size',
26 'label' => esc_html__( 'Size', 'powerkit' ),
27 'style' => 'horizontal',
28 'default' => 'md',
29 'options' => array(
30 'sm' => esc_html__( 'Small', 'powerkit' ),
31 'md' => esc_html__( 'Default', 'powerkit' ),
32 'lg' => esc_html__( 'Large', 'powerkit' ),
33 ),
34 ),
35 array(
36 'type' => 'radio',
37 'name' => 'style',
38 'label' => esc_html__( 'Style', 'powerkit' ),
39 'style' => 'vertical',
40 'default' => 'primary',
41 'options' => array(
42 'primary' => esc_html__( 'Primary', 'powerkit' ),
43 'secondary' => esc_html__( 'Secondary', 'powerkit' ),
44 'success' => esc_html__( 'Success', 'powerkit' ),
45 'info' => esc_html__( 'Info', 'powerkit' ),
46 'warning' => esc_html__( 'Warning', 'powerkit' ),
47 'danger' => esc_html__( 'Danger', 'powerkit' ),
48 'link' => esc_html__( 'Link', 'powerkit' ),
49 ),
50 ),
51 array(
52 'type' => 'checkbox',
53 'name' => 'block',
54 'label' => esc_html__( 'Block', 'powerkit' ),
55 'default' => false,
56 ),
57 array(
58 'type' => 'section',
59 'label' => esc_html__( 'Link Options', 'powerkit' ),
60 ),
61 array(
62 'type' => 'input',
63 'name' => 'url',
64 'label' => esc_html__( 'URL', 'powerkit' ),
65 'default' => 'http://',
66 ),
67 array(
68 'type' => 'radio',
69 'name' => 'target',
70 'label' => esc_html__( 'Link target', 'powerkit' ),
71 'style' => 'vertical',
72 'default' => '_self',
73 'options' => array(
74 '_self' => esc_html__( 'Open in same window', 'powerkit' ),
75 '_blank' => esc_html__( 'Open in new window/tab', 'powerkit' ),
76 ),
77 ),
78 array(
79 'type' => 'content',
80 'name' => 'title',
81 'label' => esc_html__( 'Title', 'powerkit' ),
82 'default' => 'Button',
83 'attrs' => array(
84 'class' => 'widefat',
85 'rows' => 6,
86 ),
87 ),
88 array(
89 'type' => 'checkbox',
90 'name' => 'nofollow',
91 'label' => esc_html__( 'Apply "nofollow" attribute', 'powerkit' ),
92 'default' => false,
93 ),
94 ),
95 ) );
96
97
98 /**
99 * Button Shortcode
100 *
101 * @param array $output Shortcode HTML.
102 * @param array $atts User defined attributes in shortcode tag.
103 * @param string $content Shorcode tag content.
104 * @return string Shortcode result HTML.
105 */
106 function powerkit_basic_shortcodes_button( $output, $atts, $content ) {
107 $block = ( 'true' === $atts['block'] ) ? ' pk-button-block' : '';
108
109 if ( isset( $atts['title'] ) && $atts['title'] ) {
110 $title = $atts['title'];
111 }
112
113 if ( $content ) {
114 $title = $content;
115 }
116
117 $output = sprintf(
118 '<a class="pk-button pk-button-%s pk-button-%s%s pk-font-primary" href="%s" target="%s" %s>
119 %s
120 </a>',
121 esc_attr( $atts['size'] ),
122 esc_attr( $atts['style'] ),
123 esc_attr( $block ),
124 esc_url( $atts['url'] ),
125 esc_attr( $atts['target'] ),
126 ( ( 'true' === $atts['nofollow'] ) ? 'rel="nofollow"' : '' ),
127 wp_kses( $title, 'post' )
128 );
129
130 return $output;
131 }
132 add_filter( 'powerkit_button_shortcode', 'powerkit_basic_shortcodes_button', 10, 3 );
133