PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
← All changes | includes/admin/shortcodes/class-shortcode-button.php +24 -17 2.3.14.16.9 View file →
@@ -57,10 +57,10 @@
57 57 * Ajax handler for shortcode
58 58 *
59 59 * @since 2.3.0
60 60 */
61 - public function ajax_handler(){
62 - add_action( "wp_ajax_give_shortcode", array( $this, 'shortcode_ajax' ) );
61 + public function ajax_handler() {
62 + add_action( 'wp_ajax_give_shortcode', array( $this, 'shortcode_ajax' ) );
63 63 }
64 64
65 65 /**
66 66 * Register any TinyMCE plugins
@@ -93,9 +93,9 @@
93 93 $direction = ( is_rtl() || isset( $_GET['d'] ) && 'rtl' === $_GET['d'] ) ? '.rtl' : '';
94 94
95 95 wp_enqueue_script(
96 96 'give_shortcode',
97 - GIVE_PLUGIN_URL . 'assets/dist/js/admin-shortcodes.js',
97 + GIVE_PLUGIN_URL . 'build/assets/dist/js/admin-shortcodes.js',
98 98 array( 'jquery' ),
99 99 GIVE_VERSION,
100 100 true
101 101 );
@@ -101,9 +101,9 @@
101 101 );
102 102
103 103 wp_enqueue_style(
104 104 'give-admin-shortcode-button-style',
105 - GIVE_PLUGIN_URL . 'assets/dist/css/admin-shortcode-button' . $direction . '.css',
105 + GIVE_PLUGIN_URL . 'build/assets/dist/css/admin-shortcode-button' . $direction . '.css',
106 106 array(),
107 107 GIVE_VERSION
108 108 );
109 109 }
@@ -163,9 +163,9 @@
163 163 if ( ! empty( $shortcodes ) ) {
164 164
165 165 // check current WP version
166 166 $img = ( version_compare( get_bloginfo( 'version' ), '3.5', '<' ) )
167 - ? '<img src="' . GIVE_PLUGIN_URL . 'assets/dist/images/give-media.png" />'
167 + ? '<img src="' . GIVE_PLUGIN_URL . 'build/assets/dist/images/give-media.png" />'
168 168 : '<span class="wp-media-buttons-icon" id="give-media-button" style="background-image: url(' . give_svg_icons( 'give_grey' ) . ');"></span>';
169 169
170 170 reset( $shortcodes );
171 171
@@ -175,9 +175,10 @@
175 175
176 176 printf(
177 177 '<button type="button" class="button sc-shortcode" data-shortcode="%s">%s</button>',
178 178 $shortcode,
179 - sprintf( '%s %s %s',
179 + sprintf(
180 + '%s %s %s',
180 181 $img,
181 182 __( 'Insert', 'give' ),
182 183 self::$shortcodes[ $shortcode ]['label']
183 184 )
@@ -188,9 +189,9 @@
188 189 '<button class="button sc-button" type="button">%s %s</button>' .
189 190 '<div class="sc-menu mce-menu">%s</div>' .
190 191 '</div>',
191 192 $img,
192 - __( 'Give Shortcodes', 'give' ),
193 + __( 'GiveWP Shortcodes', 'give' ),
193 194 implode( '', array_values( $shortcodes ) )
194 195 );
195 196 }
196 197 }
@@ -198,13 +199,18 @@
198 199
199 200 /**
200 201 * Load the shortcode dialog fields via AJAX
201 202 *
203 + * @todo: handle error
204 + *
202 205 * @return void
203 206 *
204 207 * @since 1.0
205 208 */
206 209 public function shortcode_ajax() {
210 + if ( ! current_user_can( 'edit_give_forms' ) ) {
211 + wp_die();
212 + }
207 213
208 214 $shortcode = isset( $_POST['shortcode'] ) ? $_POST['shortcode'] : false;
209 215 $response = false;
210 216
@@ -223,9 +229,8 @@
223 229 'shortcode' => $shortcode,
224 230 'title' => $data['title'],
225 231 );
226 232 } else {
227 - // todo: handle error
228 233 error_log( print_r( 'AJAX error!', 1 ) );
229 234 }
230 235
231 236 wp_send_json( $response );
@@ -241,15 +246,18 @@
241 246 */
242 247 private function is_add_button() {
243 248 global $pagenow;
244 249
245 - $shortcode_button_pages = apply_filters( 'give_shortcode_button_pages', array(
246 - 'post.php',
247 - 'page.php',
248 - 'post-new.php',
249 - 'post-edit.php',
250 - 'edit.php',
251 - ) );
250 + $shortcode_button_pages = apply_filters(
251 + 'give_shortcode_button_pages',
252 + array(
253 + 'post.php',
254 + 'page.php',
255 + 'post-new.php',
256 + 'post-edit.php',
257 + 'edit.php',
258 + )
259 + );
252 260
253 261 $exclude_post_types = array( 'give_forms' );
254 262
255 263 /* @var WP_Screen $current_screen */
@@ -265,9 +273,8 @@
265 273 * Fire the filter
266 274 * Use this filter to show Give Shortcode button on custom pages
267 275 *
268 276 * @since 1.0
269 - *
270 277 */
271 278 || ! apply_filters( 'give_shortcode_button_condition', true )
272 279 || empty( self::$shortcodes )
273 280 ) {
@@ -277,5 +284,5 @@
277 284 return true;
278 285 }
279 286 }
280 287
281 -new Give_Shortcode_Button;
288 +new Give_Shortcode_Button();