PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.2.7
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.2.7
2.7.7 2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 All 28 releases
← All changes | includes/class.helpers.php +32 -154 2.4.22.2.7 View file →
@@ -135,9 +135,9 @@
135 135 if ( ! empty( $available_tags ) ) {
136 136 $available_tags = array_map( 'trim', explode( ',', $available_tags ) );
137 137 $available_tags = array_unique( $available_tags );
138 138 } else {
139 - if ( $snippet_type !== 'text' && $snippet_type !== 'advert' ) {
139 + if ( $snippet_type !== 'text' ) {
140 140 $available_tags = [ 'id', 'title' ];
141 141 } else {
142 142 $available_tags = [ 'id' ];
143 143 }
@@ -185,9 +185,9 @@
185 185 global $post;
186 186
187 187 $_post = $post;
188 188
189 - $snippet_type = WINP_Plugin::app()->request->get( 'winp_item', WINP_SNIPPET_TYPE_PHP, 'sanitize_key' );
189 + $snippet_type = WINP_Plugin::app()->request->get( 'winp_item', WINP_SNIPPET_TYPE_PHP, true );
190 190 $get_post = WINP_Plugin::app()->request->get( 'post', '' );
191 191
192 192 if ( empty( $post_id ) && ! empty( $get_post ) && ! is_array( $get_post ) ) {
193 193 $post_id = esc_attr( $get_post );
@@ -233,10 +233,10 @@
233 233 return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0;
234 234 }
235 235
236 236 /**
237 + * @since 2.1.0
237 238 * @return bool
238 - * @since 2.1.0
239 239 */
240 240 public static function doing_ajax() {
241 241 if ( function_exists( 'wp_doing_ajax' ) ) {
242 242 return wp_doing_ajax();
@@ -245,10 +245,10 @@
245 245 return defined( 'DOING_AJAX' ) && DOING_AJAX;
246 246 }
247 247
248 248 /**
249 + * @since 2.1.0
249 250 * @return bool
250 - * @since 2.1.0
251 251 */
252 252 public static function doing_cron() {
253 253 if ( function_exists( 'wp_doing_cron' ) ) {
254 254 return wp_doing_cron();
@@ -263,14 +263,14 @@
263 263 *
264 264 * If the migration was an error, we need to reliably get the
265 265 * snippet code if the post_content cell is empty.
266 266 *
267 + * @author Alexander Kovalev <alex.kovalevv@gmail.com>
268 + * @since 2.2.1
269 + *
267 270 * @param WP_Post $post
268 271 *
269 272 * @return string snippet code
270 - * @author Alexander Kovalev <alex.kovalevv@gmail.com>
271 - * @since 2.2.1
272 - *
273 273 */
274 274 public static function get_snippet_code( $post ) {
275 275 if ( empty( $post->post_content ) ) {
276 276 return WINP_Helper::getMetaOption( $post->ID, 'snippet_code' );
@@ -281,11 +281,11 @@
281 281
282 282 /**
283 283 * Get meta option
284 284 *
285 - * @param int $post_id
285 + * @param int $post_id
286 286 * @param string $option_name
287 - * @param mixed $default
287 + * @param mixed $default
288 288 *
289 289 * @return mixed|array
290 290 */
291 291 public static function getMetaOption( $post_id, $option_name, $default = null ) {
@@ -306,11 +306,11 @@
306 306
307 307 /**
308 308 * Udpdate meta option
309 309 *
310 - * @param int $post_id
310 + * @param int $post_id
311 311 * @param string $option_name
312 - * @param mixed $option_value
312 + * @param mixed $option_value
313 313 *
314 314 * @return bool|int
315 315 */
316 316 public static function updateMetaOption( $post_id, $option_name, $option_value ) {
@@ -321,9 +321,9 @@
321 321
322 322 /**
323 323 * Remove meta option
324 324 *
325 - * @param int $post_id
325 + * @param int $post_id
326 326 * @param string $option_name
327 327 *
328 328 * @return bool|int
329 329 */
@@ -390,17 +390,15 @@
390 390 update_option( WINP_Plugin::app()->getOptionName( 'code_editor_highlight_selection_matches' ), 0 );
391 391
392 392 $posts = [
393 393 [
394 - 'post_title' => __( 'Simple universal snippet: Google analytics tracking', 'insert-php' ),
395 - 'post_name' => 'simple-universal-snippet',
396 - 'post_content' => self::get_simple_universal_snippet(),
394 + 'post_title' => __( 'Simple php snippet: Disable emojis', 'insert-php' ),
395 + 'post_name' => 'simple-php-snippet',
396 + 'post_content' => self::get_simple_php_snippet(),
397 397 'meta' => [
398 - 'type' => WINP_SNIPPET_TYPE_UNIVERSAL,
399 - 'description' => __( 'Google analytics tracking code will be added to all pages before the &lt;/head&gt; tag. Please remember to set the Tracking ID before activating the snippet.' ),
400 - 'filters' => 'a:1:{i:0;O:8:"stdClass":2:{s:10:"conditions";a:1:{i:0;O:8:"stdClass":2:{s:4:"type";s:5:"scope";s:10:"conditions";a:1:{i:0;O:8:"stdClass":4:{s:5:"param";s:18:"location-some-page";s:8:"operator";s:6:"equals";s:4:"type";s:6:"select";s:5:"value";s:8:"base_web";}}}}s:4:"type";s:6:"showif";}}',
401 - 'tags' => [ 'universal', 'tracking' ],
402 - 'priority' => 10
398 + 'type' => WINP_SNIPPET_TYPE_PHP,
399 + 'description' => __( 'Emojis are little icons used to express ideas or emotions. While these icons are fun and all, are they really necessary for your WordPress site? This snippet to disable emojis on your site to make it faster.', 'insert-php' ),
400 + 'tags' => [ 'php', 'disable features' ]
403 401 ]
404 402 ],
405 403 [
406 404 'post_title' => __( 'Simple text snippet: What is Lorem Ipsum?', 'insert-php' ),
@@ -409,35 +407,22 @@
409 407 'meta' => [
410 408 'type' => WINP_SNIPPET_TYPE_TEXT,
411 409 'description' => __( 'This ordinary maintenance text. With this snippet, you can fill your pages with meaningless English text.', 'insert-php' ),
412 410 'filters' => 'a:1:{i:0;O:8:"stdClass":2:{s:10:"conditions";a:2:{i:0;O:8:"stdClass":2:{s:4:"type";s:5:"scope";s:10:"conditions";a:1:{i:0;O:8:"stdClass":4:{s:5:"param";s:18:"location-some-page";s:8:"operator";s:6:"equals";s:4:"type";s:6:"select";s:5:"value";s:9:"base_sing";}}}i:1;O:8:"stdClass":2:{s:4:"type";s:5:"scope";s:10:"conditions";a:2:{i:0;O:8:"stdClass":4:{s:5:"param";s:18:"location-post-type";s:8:"operator";s:6:"equals";s:4:"type";s:6:"select";s:5:"value";s:4:"post";}i:1;O:8:"stdClass":4:{s:5:"param";s:18:"location-post-type";s:8:"operator";s:6:"equals";s:4:"type";s:6:"select";s:5:"value";s:4:"page";}}}}s:4:"type";s:6:"showif";}}',
413 - 'tags' => [ 'text', 'lorem ipsum' ],
414 - 'priority' => 20
411 + 'tags' => [ 'text', 'lorem ipsum' ]
415 412 ]
416 413 ],
417 414 [
418 - 'post_title' => __( 'Simple php snippet: Disable emojis', 'insert-php' ),
419 - 'post_name' => 'simple-php-snippet',
420 - 'post_content' => self::get_simple_php_snippet(),
415 + 'post_title' => __( 'Simple universal snippet: Google analytics tracking', 'insert-php' ),
416 + 'post_name' => 'simple-universal-snippet',
417 + 'post_content' => self::get_simple_universal_snippet(),
421 418 'meta' => [
422 - 'type' => WINP_SNIPPET_TYPE_PHP,
423 - 'description' => __( 'Emojis are little icons used to express ideas or emotions. While these icons are fun and all, are they really necessary for your WordPress site? This snippet to disable emojis on your site to make it faster.', 'insert-php' ),
424 - 'tags' => [ 'php', 'disable features' ],
425 - 'priority' => 30
426 - ]
427 - ],
428 - [
429 - 'post_title' => __( 'Add Facebook Pixel to the Order success page', 'insert-php' ),
430 - 'post_name' => 'simple-uni-snippet-for-woocommerce',
431 - 'post_content' => self::get_woo_snippet(),
432 - 'meta' => [
433 419 'type' => WINP_SNIPPET_TYPE_UNIVERSAL,
434 - 'description' => __( 'Add Facebook Pixel to the Order success page.', 'insert-php' ),
435 - 'filters' => 'a:1:{i:0;O:8:"stdClass":2:{s:10:"conditions";a:1:{i:0;O:8:"stdClass":2:{s:4:"type";s:5:"scope";s:10:"conditions";a:1:{i:0;O:8:"stdClass":4:{s:5:"param";s:18:"location-some-page";s:8:"operator";s:6:"equals";s:4:"type";s:6:"select";s:5:"value";s:16:"woo_checkout_pay";}}}}s:4:"type";s:6:"showif";}}',
436 - 'tags' => [ 'woocommerce' ],
437 - 'priority' => 40
420 + 'description' => __( 'Google analytics tracking code will be added to all pages before the &lt;/head&gt; tag. Please remember to set the Tracking ID before activating the snippet.' ),
421 + 'filters' => 'a:1:{i:0;O:8:"stdClass":2:{s:10:"conditions";a:1:{i:0;O:8:"stdClass":2:{s:4:"type";s:5:"scope";s:10:"conditions";a:1:{i:0;O:8:"stdClass":4:{s:5:"param";s:18:"location-some-page";s:8:"operator";s:6:"equals";s:4:"type";s:6:"select";s:5:"value";s:8:"base_web";}}}}s:4:"type";s:6:"showif";}}',
422 + 'tags' => [ 'universal', 'tracking' ]
438 423 ]
439 - ],
424 + ]
440 425 ];
441 426
442 427 foreach ( $posts as $post ) {
443 428 // '@' here is to hide unexpected output while plugin activation
@@ -480,12 +465,8 @@
480 465 }
481 466
482 467 wp_set_post_terms( $post_id, $post['meta']['tags'], WINP_SNIPPETS_TAXONOMY, true );
483 468 }
484 -
485 - if ( isset( $post['meta']['priority'] ) ) {
486 - WINP_Helper::updateMetaOption( $post_id, 'snippet_priority', $post['meta']['priority'] );
487 - }
488 469 }
489 470 }
490 471
491 472 update_option( WINP_Plugin::app()->getOptionName( 'demo_snippets_created' ), 1 );
@@ -555,34 +536,8 @@
555 536 return $output;
556 537 }
557 538
558 539 /**
559 - * Returns an example of the content of a woocommerce snippet.
560 - *
561 - * @return string
562 - */
563 - protected static function get_woo_snippet() {
564 - $output = <<<SCRIPT
565 -<script type="text/javascript">
566 - var pixel_id = ''; // Add you FB pixel ID!
567 - !function (f, b, e, v, n, t, s) {
568 - if (f.fbq) return; n = f.fbq = function () {
569 - n.callMethod ?
570 - n.callMethod.apply(n, arguments) : n.queue.push(arguments)
571 - }; if (!f._fbq) f._fbq = n;
572 - n.push = n; n.loaded = !0; n.version = '2.0'; n.queue = []; t = b.createElement(e); t.async = !0;
573 - t.src = v; s = b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t, s)
574 - }(window,document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
575 -
576 - fbq('init', pixel_id);
577 - fbq('track', 'PageView');
578 -</script>
579 -SCRIPT;
580 -
581 - return $output;
582 - }
583 -
584 - /**
585 540 * Wrapper for register shortcode
586 541 *
587 542 * @param $name
588 543 * @param $obj
@@ -596,20 +551,20 @@
596 551 *
597 552 * @return string
598 553 */
599 554 public static function get_factory_class() {
600 - return "factory-bootstrap-450 factory-fontawesome-000";
555 + return "factory-bootstrap-420 factory-fontawesome-000";
601 556 }
602 557
603 558 /**
604 - * Wrapper for Wbcr_FactoryForms447_OptionsValueProvider object
559 + * Wrapper for Wbcr_FactoryForms417_OptionsValueProvider object
605 560 *
606 561 * @param $plugin
607 562 *
608 - * @return Wbcr_FactoryForms447_OptionsValueProvider
563 + * @return Wbcr_FactoryForms417_OptionsValueProvider
609 564 */
610 565 public static function get_options_value_provider( $plugin ) {
611 - return new Wbcr_FactoryForms447_OptionsValueProvider( $plugin );
566 + return new Wbcr_FactoryForms417_OptionsValueProvider( $plugin );
612 567 }
613 568
614 569 /**
615 570 * Wrapper for get factory form object
@@ -616,12 +571,12 @@
616 571 *
617 572 * @param $options
618 573 * @param $plugin
619 574 *
620 - * @return Wbcr_FactoryForms447_Form
575 + * @return Wbcr_FactoryForms417_Form
621 576 */
622 577 public static function get_factory_form( $options, $plugin ) {
623 - return new Wbcr_FactoryForms447_Form( $options, $plugin );
578 + return new Wbcr_FactoryForms417_Form( $options, $plugin );
624 579 }
625 580
626 581 /**
627 582 * Wrapper for register factory metaboxes
@@ -721,82 +676,5 @@
721 676 prune_super_cache( $cache_path, true );
722 677 }
723 678 }
724 679 }
725 -
726 - /**
727 - * @param $post WP_Post
728 - *
729 - * @return string
730 - * @since 2.4.0
731 - *
732 - */
733 - public static function get_where_use_text( $post ) {
734 - global $winp_snippets_locations;
735 - $snippet_scope = self::getMetaOption( $post->ID, 'snippet_scope' );
736 - $result = "";
737 -
738 - if ( $snippet_scope == 'evrywhere' ) {
739 - $result = __( 'Run everywhere', 'insert-php' );
740 - } else if ( $snippet_scope == 'auto' ) {
741 - $items = $winp_snippets_locations->getList();
742 -
743 - $snippet_location = self::getMetaOption( $post->ID, 'snippet_location', '' );
744 -
745 - if ( ! empty( $snippet_location ) ) {
746 - $text = $items[ $snippet_location ][0] ?? '';
747 - } else {
748 - $text = __( 'Everywhere', 'insert-php' );
749 - }
750 -
751 - $result = esc_html( $text );
752 - } else {
753 - $result = self::get_shortcode_text( $post );
754 - }
755 -
756 - return $result;
757 - }
758 -
759 - /**
760 - * @param $post WP_Post
761 - *
762 - * @return string
763 - */
764 - public static function get_shortcode_text( $post ) {
765 - $snippet_type = self::get_snippet_type( $post->ID );
766 - $snippet_type = ( $snippet_type == WINP_SNIPPET_TYPE_UNIVERSAL ? '' : $snippet_type . '_' );
767 -
768 - return esc_html( apply_filters( 'wbcr/inp/viewtable/where_use', '[wbcr_' . $snippet_type . 'snippet id="' . $post->ID . '"]', $post->ID ) );
769 - }
770 -
771 - /**
772 - * @param $post WP_Post
773 - *
774 - * @return int
775 - */
776 - public static function get_next_snippet_priority() {
777 - global $wpdb;
778 -
779 - $max_priority = $wpdb->get_var( "
780 - SELECT MAX(CAST(meta_value AS UNSIGNED))
781 - FROM {$wpdb->postmeta}
782 - WHERE meta_key = '" . WINP_Plugin::app()->getPrefix() . "snippet_priority'" );
783 -
784 - if ( is_null( $max_priority ) ) {
785 - $max_priority = 0;
786 - } else {
787 - $max_priority = (int) $max_priority;
788 - }
789 -
790 - return $max_priority + 10;
791 - }
792 -
793 - /**
794 - * @return bool
795 - *
796 - * @since 2.4.0
797 - */
798 - public static function is_woo_active() {
799 - return is_plugin_active( 'woocommerce/woocommerce.php' );
800 - }
801 -
802 680 }