PluginProbe
Snippet Shortcodes / 4.0
Snippet Shortcodes v4.0
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/hooks.php +16 -79 5.1.54.0 View file →
@@ -8,9 +8,9 @@
8 8 function sh_cd_build_admin_menu() {
9 9
10 10 $allowed_viewer = sh_cd_permission_role();
11 11
12 - add_menu_page( SH_CD_PLUGIN_NAME, SH_CD_PLUGIN_NAME, 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_pages_your_shortcodes', 'dashicons-snippet-shortcodes' );
12 + add_menu_page( SH_CD_PLUGIN_NAME, SH_CD_PLUGIN_NAME, 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_pages_your_shortcodes', 'dashicons-editor-kitchensink' );
13 13
14 14 // Hide duplicated sub menu (wee hack!)
15 15 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', '', '', 'manage_options', 'sh-cd-shortcode-variables-main-menu', 'sh_cd_pages_your_shortcodes');
16 16
@@ -19,14 +19,11 @@
19 19 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', __( 'Premade Shortcodes', SH_CD_SLUG ), __( 'Premade shortcodes', SH_CD_SLUG ), $allowed_viewer, 'sh-cd-shortcode-variables-sub-premade', 'sh_cd_premade_shortcodes_page');
20 20
21 21 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', __( 'Import shortcodes', SH_CD_SLUG ), __( 'Import shortcodes', SH_CD_SLUG ), 'manage_options', 'sh-cd-import', 'sh_cd_admin_page_import' );
22 22
23 - if( false === sh_cd_is_premium_plugin_activated() ) {
24 - add_submenu_page( 'sh-cd-shortcode-variables-main-menu', '<i class="fa-solid fa-star"></i> ' . __( 'Upgrade to Premium', SH_CD_SLUG ), '<i class="fa-solid fa-star"></i> ' . __( 'Get Premium', SH_CD_SLUG ), 'manage_options', 'sh-cd-shortcode-variables-upgrade', 'sh_cd_page_upgrade');
25 - }
26 -
27 - do_action( 'sh-cd-admin-menu-upgrade' );
28 -
23 + $menu_text = ( true === SH_CD_IS_PREMIUM ) ? __( 'Your License', SH_CD_SLUG ) : __( 'Upgrade to Premium', SH_CD_SLUG );
24 +
25 + add_submenu_page( 'sh-cd-shortcode-variables-main-menu', $menu_text, $menu_text, 'manage_options', 'sh-cd-shortcode-variables-license', 'sh_cd_advertise_pro');
29 26 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', __( 'Settings', SH_CD_SLUG ), __( 'Settings', SH_CD_SLUG ), 'manage_options', 'sh-cd-settings', 'sh_cd_settings_page_generic' );
30 27 add_submenu_page( 'sh-cd-shortcode-variables-main-menu', __( 'Help', SH_CD_SLUG ), __( 'Help', SH_CD_SLUG ), 'manage_options', 'sh-cd-help', 'sh_cd_help_page' );
31 28 }
32 29 add_action( 'admin_menu', 'sh_cd_build_admin_menu' );
@@ -34,38 +31,12 @@
34 31 /**
35 32 * Enqueue relevant CSS / JS
36 33 */
37 34 function sh_cd_enqueue_scripts() {
35 + wp_enqueue_style( 'sh-cd', plugins_url( '../assets/css/sh-cd.css', __FILE__ ), [], SH_CD_PLUGIN_VERSION ) ;
36 + wp_enqueue_style('fontawesome', 'https://use.fontawesome.com/releases/v5.7.2/css/all.css', [], SH_CD_PLUGIN_VERSION);
37 + wp_enqueue_script( 'sh-cd', plugins_url( '../assets/js/sh-cd.js', __FILE__ ), [ 'jquery' ], SH_CD_PLUGIN_VERSION, true );
38 38
39 - wp_enqueue_style( 'sh-cd-dashicon', plugins_url( '../assets/css/sh-cd-dashicon.css', __FILE__ ), [], SH_CD_PLUGIN_VERSION );
40 -
41 - // Allow marketing.js on any page so admin's can dismiss admin notices anywhere
42 - wp_enqueue_script( 'sh-cd-marketing', plugins_url( '../assets/js/marketing.js', __FILE__ ), [ 'jquery' ], SH_CD_PLUGIN_VERSION, true );
43 -
44 - if ( ! sh_cd_is_snippet_shortcodes_admin_page() ) {
45 - return;
46 - }
47 -
48 - $main_js_dependencies = [ 'jquery', 'sh-cd-clipboard' ];
49 -
50 - // Tooltips
51 - if ( sh_cd_tooltips_is_enabled() ) {
52 - wp_enqueue_script( 'sh-cd-tooltip', plugins_url( '../assets/zerbratooltips/zebra_tooltips.min.js', __FILE__ ), [ ], SH_CD_PLUGIN_VERSION );
53 - wp_enqueue_style( 'sh-cd-tooltip', plugins_url( '../assets/zerbratooltips/zebra_tooltips.min.css', __FILE__ ), [], SH_CD_PLUGIN_VERSION ) ;
54 -
55 - $main_js_dependencies[] = 'sh-cd-tooltip';
56 - }
57 -
58 - // CSS
59 - wp_enqueue_style( 'sh-cd', plugins_url( '../assets/css/sh-cd.css', __FILE__ ), [ 'sh-cd-dashicon' ], SH_CD_PLUGIN_VERSION );
60 - wp_enqueue_style( 'sh-cd-fontawesome', plugins_url( '../assets/fontawesome/css/fontawesome.min.css', __FILE__ ), [], SH_CD_PLUGIN_VERSION );
61 - wp_enqueue_style( 'sh-cd-fontawesome-solid', plugins_url( '../assets/fontawesome/css/solid.min.css', __FILE__ ), [ 'sh-cd-fontawesome' ], SH_CD_PLUGIN_VERSION );
62 - wp_enqueue_style( 'sh-cd-fontawesome-regular', plugins_url( '../assets/fontawesome/css/regular.min.css', __FILE__ ), [ 'sh-cd-fontawesome' ], SH_CD_PLUGIN_VERSION );
63 - wp_enqueue_style( 'sh-cd-fontawesome-brands', plugins_url( '../assets/fontawesome/css/brands.min.css', __FILE__ ), [ 'sh-cd-fontawesome' ], SH_CD_PLUGIN_VERSION );
64 -
65 - // JS
66 - wp_enqueue_script( 'sh-cd-clipboard', plugins_url( '../assets/js/clipboard.min.js', __FILE__ ), [], SH_CD_PLUGIN_VERSION, true );
67 - wp_enqueue_script( 'sh-cd', plugins_url( '../assets/js/sh-cd.js', __FILE__ ), $main_js_dependencies, SH_CD_PLUGIN_VERSION, true );
68 39 wp_localize_script( 'sh-cd', 'sh_cd', sh_cd_js_config() );
69 40
70 41 }
71 42 add_action( 'admin_enqueue_scripts', 'sh_cd_enqueue_scripts' );
@@ -70,46 +41,20 @@
70 41 }
71 42 add_action( 'admin_enqueue_scripts', 'sh_cd_enqueue_scripts' );
72 43
73 44 /**
74 - * Determine if we are on a Snippet Shortcodes admin page
75 - *
76 - * @return bool
77 - */
78 -function sh_cd_is_snippet_shortcodes_admin_page() {
79 -
80 - if ( true === empty( $_GET['page' ] ) ) {
81 - return false;
82 - }
83 -
84 - $known_admin_pages = apply_filters( 'sh-cd-admin-pages', [ 'sh-cd-shortcode-variables-main-menu',
85 - 'sh-cd-shortcode-variables-your-shortcodes',
86 - 'sh-cd-shortcode-variables-sub-premade',
87 - 'sh-cd-import',
88 - 'sh-cd-shortcode-variables-upgrade',
89 - 'sh-cd-settings',
90 - 'sh-cd-help' ] );
91 -
92 - return in_array( $_GET['page'], $known_admin_pages );
93 -}
94 -
95 -/**
96 45 * Config for JS
97 46 * @return array
98 47 */
99 48 function sh_cd_js_config() {
100 - return [ 'editor' => sh_cd_default_editor_get(),
101 - 'page' => false === empty( $_GET['page'] ) ? $_GET['page'] : '',
102 - 'action' => false === empty( $_GET['action'] ) ? $_GET['action'] : '',
49 + return [
103 50 'security' => wp_create_nonce( 'sh-cd-security' ),
104 - 'premium' => sh_cd_is_premium(),
51 + 'premium' => SH_CD_IS_PREMIUM,
105 52 'text-delete-confirm' => __( 'Are you sure you wish to delete this shortcode?', SH_CD_SLUG ),
106 53 'text-add' => __( 'Add', SH_CD_SLUG ),
107 54 'text-save' => __( 'Save', SH_CD_SLUG ),
108 55 'text-saved' => __( 'Saved!', SH_CD_SLUG ),
109 - 'text-editor-change' => __( 'Changing the editor will cause any unsaved changes to be lost. Please ensure you have saved your shortcode before proceeding.', SH_CD_SLUG ),
110 - 'text-error' => __( 'Unfortunately something went wrong!', SH_CD_SLUG ),
111 - 'tooltips-enabled' => sh_cd_tooltips_is_enabled() ? 'yes' : 'no',
56 + 'text-error' => __( 'Unfortunately something went wrong!', SH_CD_SLUG )
112 57 ];
113 58 }
114 59
115 60 /**
@@ -122,8 +67,10 @@
122 67 sh_cd_create_database_table();
123 68
124 69 sh_cd_create_database_table_multisite();
125 70
71 + sh_cd_cron_licence_check();
72 +
126 73 do_action( 'sh-cd-upgrade' );
127 74 }
128 75 }
129 76 add_action('admin_init', 'sh_cd_upgrade');
@@ -133,16 +80,14 @@
133 80 Ajax handler for toggling disable status of a shortcode
134 81 **/
135 82 function sh_cd_ajax_toggle_status() {
136 83
137 - if ( false === sh_cd_is_premium() ) {
84 + if ( false === SH_CD_IS_PREMIUM ) {
138 85 wp_send_json( 'not-premium' );
139 86 }
140 87
141 88 check_ajax_referer( 'sh-cd-security', 'security' );
142 89
143 - sh_cd_permission_check();
144 -
145 90 $id = ( false === empty( $_POST['id'] ) ) ? (int) $_POST['id'] : NULL;
146 91
147 92 if ( false === empty( $id ) ) {
148 93
@@ -161,10 +106,8 @@
161 106 function sh_cd_ajax_delete_shortcode() {
162 107
163 108 check_ajax_referer( 'sh-cd-security', 'security' );
164 109
165 - sh_cd_permission_check();
166 -
167 110 $id = ( false === empty( $_POST['id'] ) ) ? (int) $_POST['id'] : NULL;
168 111
169 112 if ( false === empty( $id ) ) {
170 113
@@ -181,16 +124,14 @@
181 124 Ajax handler for toggling disable status of a shortcode
182 125 **/
183 126 function sh_cd_ajax_toggle_multisite() {
184 127
185 - if ( false === sh_cd_is_multisite_enabled() ) {
128 + if ( false === SH_CD_IS_PREMIUM ) {
186 129 wp_send_json( 'not-premium' );
187 130 }
188 131
189 132 check_ajax_referer( 'sh-cd-security', 'security' );
190 133
191 - sh_cd_permission_check();
192 -
193 134 $id = ( false === empty( $_POST['id'] ) ) ? (int) $_POST['id'] : NULL;
194 135
195 136 if ( false === empty( $id ) ) {
196 137
@@ -207,16 +148,14 @@
207 148 Ajax handler for saving shortcode inline
208 149 **/
209 150 function sh_cd_ajax_update_shortcode() {
210 151
211 - if ( false === sh_cd_is_premium() ) {
152 + if ( false === SH_CD_IS_PREMIUM ) {
212 153 wp_send_json( 'not-premium' );
213 154 }
214 155
215 156 check_ajax_referer( 'sh-cd-security', 'security' );
216 157
217 - sh_cd_permission_check();
218 -
219 158 $id = ( false === empty( $_POST['id'] ) ) ? (int) $_POST['id'] : NULL;
220 159 $content = ( false === empty( $_POST['content'] ) ) ? $_POST['content'] : '';
221 160
222 161 if ( false === empty( $id ) ) {
@@ -234,15 +173,13 @@
234 173 Ajax handler for adding shortcode inline
235 174 **/
236 175 function sh_cd_ajax_add_shortcode() {
237 176
238 - if ( false === sh_cd_is_premium() ) {
177 + if ( false === SH_CD_IS_PREMIUM ) {
239 178 wp_send_json( 'not-premium' );
240 179 }
241 180
242 181 check_ajax_referer( 'sh-cd-security', 'security' );
243 -
244 - sh_cd_permission_check();
245 182
246 183 if( true === empty( $_POST['slug'] ) ) {
247 184 wp_send_json( [ 'id' => 0, 'ok' => 0, 'error_message' => __( 'Error: Please specify a "Slug".', SH_CD_SLUG ) ] );
248 185 }