PluginProbe
Snippet Shortcodes / 4.2.2
Snippet Shortcodes v4.2.2
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
← All changes | includes/pages/page.edit.php +63 -128 5.24.2.2 View file →
@@ -18,22 +18,14 @@
18 18
19 19 // Load
20 20 $shortcode = ( false === empty( $_GET['id'] ) ) ?
21 21 sh_cd_db_shortcodes_by_id( (int) $_GET['id'] ) :
22 - sh_cd_get_values_from_post( [ 'id', 'slug', 'previous_slug', 'data', 'disabled', 'multisite', 'editor' ] );
22 + sh_cd_get_values_from_post( [ 'id', 'slug', 'previous_slug', 'data', 'disabled', 'multisite' ] );
23 23
24 - $shortcode = apply_filters( 'sh-cd-shortcode-new', $shortcode, $action );
25 -
26 24 $shortcode['data'] = stripslashes( $shortcode['data'] );
27 25
28 - $current_editor = ( false === empty( $_GET[ 'editor' ] ) ) ? $_GET[ 'editor' ] : $shortcode[ 'editor' ];
29 -
30 - if ( true === empty( $current_editor ) ) {
31 - $current_editor = sh_cd_default_editor_get();
32 - }
33 -?>
34 -<form method="post" action="<?php echo sh_cd_link_your_shortcodes() . '&action=save'; ?>" class="sh-cd-form">
35 -
26 + ?>
27 +
36 28 <div class="wrap">
37 29 <div id="icon-options-general" class="icon32"></div>
38 30 <div id="poststuff">
39 31 <div id="post-body" class="metabox-holder columns-3">
@@ -38,20 +30,20 @@
38 30 <div id="poststuff">
39 31 <div id="post-body" class="metabox-holder columns-3">
40 32 <div id="post-body-content">
41 33 <div class="meta-box-sortables ui-sortable">
42 - <div class="postbox sh-cd-postbox-edit-slug">
43 - <h3 class="postbox-header">
44 - <span>
45 - <?php echo __( 'Slug', SH_CD_SLUG ); ?>
46 - </span>
47 - </h3>
34 + <div class="postbox">
35 + <div class="postbox-header">
36 + <h2 class="hndle"><span><?php echo __( 'Add / Edit a shortcode', SH_CD_SLUG ); ?></span></h2>
37 + </div>
48 38 <div style="padding: 0px 15px 0px 15px">
49 39 <?php
50 40
51 41 if ( true === $save_result ) :
52 42
53 - printf('<p>%1$s.<a href="%2$s">%3$s</a>.</p>',
43 + printf('<p>%1$s.
44 + <a href="%2$s">%3$s</a>.
45 + </p>',
54 46 __( 'Your shortcode has been saved successfully', SH_CD_SLUG ),
55 47 sh_cd_link_your_shortcodes(),
56 48 __( 'Return to all shortcodes', SH_CD_SLUG )
57 49 );
@@ -56,126 +48,69 @@
56 48 __( 'Return to all shortcodes', SH_CD_SLUG )
57 49 );
58 50
59 51 else:
60 -
61 52 ?>
53 + <form method="post" action="<?php echo sh_cd_link_your_shortcodes() . '&action=save'; ?>">
54 + <input type="hidden" id="id" name="id" value="<?php echo esc_attr( $shortcode['id'] ); ?>" />
55 + <?php wp_nonce_field( 'save-shortcode' ); ?>
56 +
57 + <div class="sh-cd-button-row sh-cd-border-bottom">
58 + <a class="comment-submit button" href="<?php echo sh_cd_link_your_shortcodes(); ?>"><?php echo __( 'Cancel', SH_CD_SLUG ); ?></a>
59 + <input name="submit_button" type="submit" value="Save Shortcode" class="comment-submit button button-primary">
60 + </div>
61 + <h4><?php echo __( 'Slug', SH_CD_SLUG ); ?></h4>
62 + <p><small><?php echo __( 'Specify the unique identifier for this shortcode', SH_CD_SLUG ); ?>.</small></p>
63 + <input type="text" required class="regular-text" size="100" id="slug" name="slug"
64 + placeholder="Slug"
65 + value="<?php echo esc_attr( $shortcode['slug'] )?>" />
66 + <?php
62 67
63 - <input type="hidden" id="id" name="id" value="<?php echo esc_attr( $shortcode['id'] ); ?>" />
64 - <?php wp_nonce_field( 'save-shortcode' ); ?>
65 -
66 - <div class="sh-cd-row">
67 - <?php if ( true === sh_cd_is_premium() || 'add' === $action ) : ?>
68 - <input type="text" required class="regular-text sh-cd-slug-validation" size="100" id="slug" name="slug"
69 - placeholder="Enter a name for your shortcode" title="Only letters, numbers, dashes and underscores are allowed."
70 - value="<?php echo esc_attr( $shortcode['slug'] )?>" />
71 - <?php endif; ?>
72 -
73 - <?php $previous_slug = ( false === empty( $shortcode['previous_slug'] ) ) ? $shortcode['previous_slug'] : $shortcode['slug']; ?>
74 - <input type="hidden" id="previous_slug" name="previous_slug" value="<?php echo esc_attr( $previous_slug )?>" />
68 + $previous_slug = ( false === empty( $shortcode['previous_slug'] ) ) ? $shortcode['previous_slug'] : $shortcode['slug'];
75 69
76 - <p class="sh-cd-shortcode-slug">
77 - <?php
78 - $default_slug = ( 'add' === $action ) ? 'enter-a-name-for-your-shortcode' : $previous_slug;
79 70 ?>
80 - <?php echo __( 'Shortcode:', SH_CD_SLUG ); ?><span id="sh-cd-test-shortcode-slug">[<?php echo SH_CD_SHORTCODE; ?> slug="<span id="sh-cd-shortcode-slug-preview"><?php echo esc_html( $default_slug ); ?></span>"]</span>
81 - <i class="far fa-copy sh-cd-copy-trigger <?php if ( 'add' === $action ): ?>sh-cd-hide<?php endif; ?>" data-clipboard-text="[<?php echo SH_CD_SHORTCODE; ?> slug=&quot;<?php echo esc_html( $default_slug ); ?>&quot;]"></i>
82 - </p>
83 - </div>
71 + <input type="hidden" id="previous_slug" name="previous_slug" value="<?php echo esc_attr( $previous_slug )?>" />
72 +
73 + <h4><?php echo __( 'Shortcode Content', SH_CD_SLUG ); ?></h4>
74 + <p><small><?php echo __( 'Specify the text, HTML, media, data, etc that should be rendered wherever the shortcode is placed.', SH_CD_SLUG ); ?></small></p>
75 + <?php wp_editor( $shortcode['data'], 'data', [ 'textarea_name' => 'data' ] ); ?>
76 +
77 + <h4><?php echo __( 'Disable?', SH_CD_SLUG ); ?></h4>
78 + <p><?php echo __( 'If disabled, nothing will be rendered where the shortcode has been placed.', SH_CD_SLUG ); ?></p>
79 + <select id="disabled" name="disabled">
80 + <option value="0" <?php selected( $shortcode['disabled'], 0 ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option>
81 + <option value="1" <?php selected( $shortcode['disabled'], 1 ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option>
82 + </select>
83 +
84 + <h4><?php echo __( 'Global?', SH_CD_SLUG ); ?></h4>
85 +
86 + <p><?php echo __( 'Can this be used by all sites within your multi-site? If Yes, your shortcode will be promoted so it can be used across your entire multi site. Please note, shortcode slugs are not unique across a multi site. Therefore, if you have two Global shortcodes with the same slug, the shortcode created or updated most recently shall be the one rendered. It is best practice to give all Global shortcodes a unique slug. A Global shortcode with always be displayed before a local shortcode with the same slug. Upon saving, it may take a Global shortcode upto 30 seconds to update across all your sites.', SH_CD_SLUG ); ?></p>
87 + <select id="multisite" name="multisite" <?php if ( false === SH_CD_IS_PREMIUM ) { echo 'disabled="disabled"'; } ?>>
88 + <option value="0" <?php selected( $shortcode['multisite'], 0 ); ?>><?php echo __( 'No', SH_CD_SLUG ); ?></option>
89 + <option value="1" <?php selected( $shortcode['multisite'], 1 ); ?>><?php echo __( 'Yes', SH_CD_SLUG ); ?></option>
90 + </select>
91 + <?php if ( false === SH_CD_IS_PREMIUM ) : ?>
92 + <p>
93 + <i class="far fa-credit-card"></i>
94 + <a href="<?php echo sh_cd_license_upgrade_link(); ?>">
95 + <?php echo __( 'Multi site support is for Premium users. Upgrade now.', SH_CD_SLUG ); ?>
96 + </a>
97 + </p>
98 + <?php endif; ?>
99 +
100 + <div class="sh-cd-button-row sh-cd-border-top">
101 + <a class="comment-submit button" href="<?php echo sh_cd_link_your_shortcodes(); ?>"><?php echo __( 'Cancel', SH_CD_SLUG ); ?></a>
102 + <input name="submit_button" type="submit" value="Save Shortcode" class="comment-submit button button-primary">
103 + </div>
104 + </form>
105 + <?php endif; ?>
84 106 </div>
85 107 </div>
86 - <div class="postbox sh-cd-postbox-edit-content">
87 - <h3 class="postbox-header">
88 - <span>
89 - <?php echo __( 'Content', SH_CD_SLUG ); ?>
90 - </span>
91 - <?php sh_cd_editor_change_button( $current_editor ); ?>
92 - </h3>
93 - <div class="sh-cd-postbox-content">
94 - <?php
95 - if ( 'code' !== $current_editor ) {
96 - wp_editor( $shortcode['data'], 'data', [ 'textarea_name' => 'data' ] );
97 - } else {
98 - printf( ' <textarea id="sh-cd-code-editor" name="data">%s</textarea>
99 - <script>
100 - jQuery( document ).ready(function ($) {
101 - wp.codeEditor.initialize($("#sh-cd-code-editor"), cm_settings);
102 - });
103 - </script>', $shortcode['data'] );
104 - }
105 -
106 - $premium_icon = sh_cd_display_premium_star();
107 -
108 - ?>
109 - <input type="hidden" id="editor" name="editor" value="<?php echo esc_attr( $current_editor ); ?>" />
110 - </div>
111 - </div>
112 - <div class="postbox sh-cd-postbox-edit-content">
113 - <h3 class="postbox-header">
114 - <span>
115 - <?php echo __( 'Options', SH_CD_SLUG ); ?>
116 - </span>
117 - </h3>
118 - <div class="sh-cd-postbox-content">
119 - <?php
120 - if ( false === apply_filters( 'sh-cd-premium-plugin-likely-to-add-edit-options', false ) ) {
121 - sh_cd_marketing_page_edit_additional_options();
122 - } else {
123 - do_action( 'sh-cd-page-edit', $shortcode ); // Allow Premium plugin to add additional fields
124 - }
125 - ?>
126 - </div>
127 - </div>
128 - <div class="sh-cd-button-row">
129 - <a class="comment-submit button" href="<?php echo sh_cd_link_your_shortcodes(); ?>"><?php echo __( 'Cancel', SH_CD_SLUG ); ?></a>
130 - <input name="submit_button" type="submit" value="Save Shortcode" class="comment-submit button button-primary sh-cd-button">
131 108 </div>
132 - <?php endif; ?>
133 - </div>
134 - </div>
135 - </div>
109 + </div>
110 + </div>
111 + <br class="clear">
136 112 </div>
137 113 </div>
138 -</form>
139 114 <?php
140 115 }
141 116
142 - /**
143 - * Button for toggling editor
144 - *
145 - * @return void
146 - */
147 - function sh_cd_editor_change_button( $current_editor = null ) {
148 -
149 - if ( true === empty( $current_editor ) ) {
150 - $current_editor = sh_cd_default_editor_get();
151 - }
152 -
153 - $editor = ( 'tinymce' === $current_editor ) ? 'code' : 'tinymce';
154 - $text = ( 'tinymce' === $current_editor ) ? __( 'Change to HTML Editor', SH_CD_SLUG ) : __( 'Change to WordPress Editor', SH_CD_SLUG );
155 - $icon = ( 'tinymce' === $current_editor ) ? 'fa-solid fa-code' : 'fa-brands fa-wordpress';
156 -
157 - $url = add_query_arg( [ 'editor' => $editor ], sh_cd_get_current_url() );
158 -
159 - echo sprintf( '<a type="button" class="button sh-cd-button sh-cd-button-editor-select sh-cd-button-%2$s" href="%1$s" data-new-editor="%2$s"><i class="%3$s"></i> %4$s</a>',
160 - esc_url( $url ),
161 - $editor,
162 - esc_html( $icon ),
163 - esc_html( $text ));
164 - }
165 -
166 -/**
167 - * If using code editor, load the code editor
168 - */
169 -add_action( 'admin_enqueue_scripts', function() {
170 -
171 - if ( false === sh_cd_is_snippet_shortcodes_admin_page() ) {
172 - return;
173 - }
174 -
175 - // Types found here: https://docs.classicpress.net/reference/functions/wp_enqueue_code_editor/
176 - $cm_settings['codeEditor'] = wp_enqueue_code_editor( [ 'type' => 'text/html' ] );
177 - wp_localize_script( 'jquery', 'cm_settings', $cm_settings) ;
178 -
179 - wp_enqueue_script( 'wp-theme-plugin-editor' );
180 - wp_enqueue_style( 'wp-codemirror' );
181 -});