PluginProbe
MaxButtons – Create buttons / 7.13.3
MaxButtons – Create buttons v7.13.3
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.13.3, at assets/integrations/shortcake/shortcake.php

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