PluginProbe
MaxButtons – Create buttons / 7.1.2
MaxButtons – Create buttons v7.1.2
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / assets / integrations / shortcake / shortcake.php

shortcake.php in MaxButtons – Create buttons 7.1.2, at assets/integrations/shortcake/shortcake.php

138 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MaxButtons;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 class mbCake
6 {
7
8 public static function init()
9 {
10 add_action('register_shortcode_ui', array(maxUtils::namespaceit('mbCake'), 'register'));
11 add_action('init', array(maxUtils::namespaceit('mbCake'), 'initField'));
12 add_action('shortcode_ui_after_do_shortcode', array(maxUtils::namespaceit('mbCake'), 'shortcode'));
13
14 // Load FA within TinyMCE
15 add_action('admin_enqueue_scripts', array(maxUtils::namespaceit('mbCake'), 'editor_styles')) ;
16
17 }
18
19 public static function initField()
20 {
21 require_once('class-field-maxbutton.php');
22
23 Shortcake_Field_MaxButton::get_instance();
24
25 }
26
27 public static function shortcode($shortcode)
28 {
29
30 if (strpos ($shortcode, 'maxbutton') === false)
31 return; // not our shorts
32
33
34 // style controls the output - if set to something else assume css is there.
35 if (strpos ( $shortcode, 'style') === false)
36 {
37 preg_match('/id=?("|\'|)([0-9]+)/i', $shortcode, $match);
38 if (count($match) == 0)
39 return; // happens when adding new button from shortcake
40
41 $button_id = $match[2];
42
43 $button = MB()->getClass('button');
44 $button->set($button_id);
45
46 $button->parse_button();
47 $button->parse_css('preview');
48 $button->display_css();
49 }
50 }
51
52 public static function editor_styles()
53 {
54 $fa_url = apply_filters("mb_fa_url", MB()->get_plugin_url() . 'assets/libraries/font-awesome/css/font-awesome.min.css');
55 if ($fa_url != false && $fa_url != '')
56 {
57 add_editor_style($fa_url);
58 }
59 }
60
61 public static function register()
62 {
63
64 shortcode_ui_register_for_shortcode( 'maxbutton',
65 array(
66 /*
67 * How the shortcode should be labeled in the UI. Required argument.
68 */
69 'label' => esc_html__( 'MaxButtons', 'maxbuttons' ),
70 /*
71 * Include an icon with your shortcode. Optional.
72 * Use a dashicon, or full URL to image.
73 */
74 'listItemImage' => '<img src="' . MB()->get_plugin_url() . 'assets/integrations/shortcake/assets/banner.png">',
75 //'dashicons-editor-quote',
76 /*
77 * Limit this shortcode UI to specific posts. Optional.
78 */
79 //'post_type' => array( 'post' ),
80
81 /*
82 * Register UI for the "inner content" of the shortcode. Optional.
83 * If no UI is registered for the inner content, then any inner content
84 * data present will be backed up during editing.
85 */
86 /*
87 * Register UI for attributes of the shortcode. Optional.
88 *
89 * If no UI is registered for an attribute, then the attribute will
90 * not be editable through Shortcake's UI. However, the value of any
91 * unregistered attributes will be preserved when editing.
92 *
93 * Each array must include 'attr', 'type', and 'label'.
94 * 'attr' should be the name of the attribute.
95 * 'type' options include: text, checkbox, textarea, radio, select, email,
96 * url, number, and date, post_select, attachment, color.
97 * Use 'meta' to add arbitrary attributes to the HTML of the field.
98 * Use 'encode' to encode attribute data. Requires customization to callback to decode.
99 * Depending on 'type', additional arguments may be available.
100 */
101 'attrs' => array(
102
103 array(
104 'label' => esc_html__( 'Button', 'maxbuttons' ),
105 'attr' => 'id',
106 'type' => 'MaxButton',
107 'nonce' => wp_create_nonce('maxajax'),
108 'meta' => array('select' => __("Select a button","maxbuttons")),
109
110 ),
111 array(
112 'label' => esc_html__( 'Custom URL [optional]', 'maxbuttons' ),
113 'attr' => 'url',
114 'type' => 'url',
115 'encode' => true,
116 'meta' => array(
117 'placeholder' => esc_html__( 'http://', '' ),
118 'data-test' => 1,
119 ),
120 ),
121 array(
122 'label' => esc_html__( 'Custom Text [optional]', 'maxbuttons' ),
123 'attr' => 'text',
124 'type' => 'text',
125 'query' => array( 'post_type' => 'page' ),
126
127 ),
128 ),
129 )
130 );
131
132
133 }
134
135 }
136
137 mbCake::init();
138