PluginProbe
MaxButtons – Create buttons / 6.23
MaxButtons – Create buttons v6.23
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 6.23, at assets/integrations/shortcake/shortcake.php

137 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
9 public static function init()
10 {
11 add_action('register_shortcode_ui', array(maxUtils::namespaceit('mbCake'), 'register'));
12 add_action('init', array(maxUtils::namespaceit('mbCake'), 'initField'));
13 add_action('shortcode_ui_after_do_shortcode', array(maxUtils::namespaceit('mbCake'), 'shortcode'));
14
15 // Load FA within TinyMCE
16 add_action('admin_enqueue_scripts', array(maxUtils::namespaceit('mbCake'), 'editor_styles')) ;
17
18 }
19
20 public static function initField()
21 {
22 require_once('class-field-maxbutton.php');
23
24 Shortcake_Field_MaxButton::get_instance();
25
26 }
27
28 public static function shortcode($shortcode)
29 {
30
31 if (strpos ($shortcode, 'maxbutton') === false)
32 return; // not our shorts
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 = new maxButton();
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 'meta' => array('select' => __("Select a button","maxbuttons")),
108
109 ),
110 array(
111 'label' => esc_html__( 'Custom URL [optional]', 'maxbuttons' ),
112 'attr' => 'url',
113 'type' => 'url',
114 'encode' => true,
115 'meta' => array(
116 'placeholder' => esc_html__( 'http://', '' ),
117 'data-test' => 1,
118 ),
119 ),
120 array(
121 'label' => esc_html__( 'Custom Text [optional]', 'maxbuttons' ),
122 'attr' => 'text',
123 'type' => 'text',
124 'query' => array( 'post_type' => 'page' ),
125
126 ),
127 ),
128 )
129 );
130
131
132 }
133
134 }
135
136 mbCake::init();
137