PluginProbe
PixCodes / 2.3.8
PixCodes v2.3.8
2.3.9 trunk 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8
pixcodes / shortcodes / WpGradeShortcode_Button.php

WpGradeShortcode_Button.php in PixCodes 2.3.8, at shortcodes/WpGradeShortcode_Button.php

98 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 die( '-1' );
5 }
6
7 class WpGradeShortcode_Button extends WpGradeShortcode {
8
9 public function __construct( $settings = array() ) {
10 $this->self_closed = false;
11 $this->name = esc_html__( 'Button', 'pixcodes' );
12 $this->code = 'button';
13 $this->icon = 'icon-bookmark';
14 $this->direct = false;
15 $this->one_line = true;
16
17 $this->params = array(
18 'label' => array(
19 'type' => 'text',
20 'name' => esc_html__( 'Label Text', 'pixcodes' ),
21 'admin_class' => 'span6',
22 'is_content' => true,
23 ),
24 'link' => array(
25 'type' => 'text',
26 'name' => esc_html__( 'Link URL', 'pixcodes' ),
27 'admin_class' => 'span5 push1'
28 ),
29 'size' => array(
30 'type' => 'select',
31 'name' => esc_html__( 'Button Size', 'pixcodes' ),
32 'options' => array(
33 '' => esc_html__( '-- Select Size --', 'pixcodes' ),
34 'small' => esc_html__( 'Small', 'pixcodes' ),
35 'large' => esc_html__( 'Large', 'pixcodes' ),
36 'huge' => esc_html__( 'Huge', 'pixcodes' )
37 ),
38 'admin_class' => 'span6'
39 ),
40 'text_size' => array(
41 'type' => 'select',
42 'name' => esc_html__( 'Text Size', 'pixcodes' ),
43 'options' => array(
44 '' => esc_html__( '-- Select Size --', 'pixcodes' ),
45 'gamma' => esc_html__( 'Small', 'pixcodes' ),
46 'beta' => esc_html__( 'Large', 'pixcodes' ),
47 'alpha' => esc_html__( 'Huge', 'pixcodes' )
48 ),
49 'admin_class' => 'span5 push1'
50 ),
51 'class' => array(
52 'type' => 'text',
53 'name' => esc_html__( 'Class', 'pixcodes' ),
54 'admin_class' => 'span3'
55 ),
56 'id' => array(
57 'type' => 'text',
58 'name' => esc_html__( 'ID', 'pixcodes' ),
59 'admin_class' => 'span2 push1'
60 ),
61 'newtab' => array(
62 'type' => 'switch',
63 'name' => esc_html__( 'Open in a new tab?', 'pixcodes' ),
64 'admin_class' => 'span5 push2'
65 ),
66 );
67
68 // allow the theme or other plugins to "hook" into this shortcode's params
69 $this->params = apply_filters( 'pixcodes_filter_params_for_' . strtolower( $this->name ), $this->params );
70
71 add_shortcode( 'button', array( $this, 'add_shortcode' ) );
72 }
73
74 public function add_shortcode( $atts, $content ) {
75 //create an array with only the registered params - dynamic since we filter them and have no way of knowing for sure
76 $extract_params = array();
77 if ( isset( $this->params ) ) {
78 foreach ( $this->params as $key => $value ) {
79 $extract_params[ $key ] = '';
80 }
81 }
82 extract( shortcode_atts( $extract_params, $atts ) );
83
84 /**
85 * Template localization between plugin and theme
86 */
87 $located = locate_template( "templates/shortcodes/{$this->code}.php", false, false );
88 if ( ! $located ) {
89 $located = dirname( __FILE__ ) . '/templates/' . $this->code . '.php';
90 }
91 // load it
92 ob_start();
93 require $located;
94
95 return ob_get_clean();
96 }
97 }
98