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 +21 -133 2.3.102.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 */
@@ -396,10 +396,9 @@
396 396 'post_content' => self::get_simple_php_snippet(),
397 397 'meta' => [
398 398 'type' => WINP_SNIPPET_TYPE_PHP,
399 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' ],
401 - 'priority' => 30
400 + 'tags' => [ 'php', 'disable features' ]
402 401 ]
403 402 ],
404 403 [
405 404 'post_title' => __( 'Simple text snippet: What is Lorem Ipsum?', 'insert-php' ),
@@ -408,10 +407,9 @@
408 407 'meta' => [
409 408 'type' => WINP_SNIPPET_TYPE_TEXT,
410 409 'description' => __( 'This ordinary maintenance text. With this snippet, you can fill your pages with meaningless English text.', 'insert-php' ),
411 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";}}',
412 - 'tags' => [ 'text', 'lorem ipsum' ],
413 - 'priority' => 20
411 + 'tags' => [ 'text', 'lorem ipsum' ]
414 412 ]
415 413 ],
416 414 [
417 415 'post_title' => __( 'Simple universal snippet: Google analytics tracking', 'insert-php' ),
@@ -420,10 +418,9 @@
420 418 'meta' => [
421 419 'type' => WINP_SNIPPET_TYPE_UNIVERSAL,
422 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.' ),
423 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";}}',
424 - 'tags' => [ 'universal', 'tracking' ],
425 - 'priority' => 10
422 + 'tags' => [ 'universal', 'tracking' ]
426 423 ]
427 424 ]
428 425 ];
429 426
@@ -468,12 +465,8 @@
468 465 }
469 466
470 467 wp_set_post_terms( $post_id, $post['meta']['tags'], WINP_SNIPPETS_TAXONOMY, true );
471 468 }
472 -
473 - if ( isset( $post['meta']['priority'] ) ) {
474 - WINP_Helper::updateMetaOption( $post_id, 'snippet_priority', $post['meta']['priority'] );
475 - }
476 469 }
477 470 }
478 471
479 472 update_option( WINP_Plugin::app()->getOptionName( 'demo_snippets_created' ), 1 );
@@ -558,20 +551,20 @@
558 551 *
559 552 * @return string
560 553 */
561 554 public static function get_factory_class() {
562 - return "factory-bootstrap-433 factory-fontawesome-000";
555 + return "factory-bootstrap-420 factory-fontawesome-000";
563 556 }
564 557
565 558 /**
566 - * Wrapper for Wbcr_FactoryForms430_OptionsValueProvider object
559 + * Wrapper for Wbcr_FactoryForms417_OptionsValueProvider object
567 560 *
568 561 * @param $plugin
569 562 *
570 - * @return Wbcr_FactoryForms430_OptionsValueProvider
563 + * @return Wbcr_FactoryForms417_OptionsValueProvider
571 564 */
572 565 public static function get_options_value_provider( $plugin ) {
573 - return new Wbcr_FactoryForms430_OptionsValueProvider( $plugin );
566 + return new Wbcr_FactoryForms417_OptionsValueProvider( $plugin );
574 567 }
575 568
576 569 /**
577 570 * Wrapper for get factory form object
@@ -578,12 +571,12 @@
578 571 *
579 572 * @param $options
580 573 * @param $plugin
581 574 *
582 - * @return Wbcr_FactoryForms430_Form
575 + * @return Wbcr_FactoryForms417_Form
583 576 */
584 577 public static function get_factory_form( $options, $plugin ) {
585 - return new Wbcr_FactoryForms430_Form( $options, $plugin );
578 + return new Wbcr_FactoryForms417_Form( $options, $plugin );
586 579 }
587 580
588 581 /**
589 582 * Wrapper for register factory metaboxes
@@ -682,111 +675,6 @@
682 675 prune_super_cache( $cache_path . 'supercache/', true );
683 676 prune_super_cache( $cache_path, true );
684 677 }
685 678 }
686 - }
687 -
688 - /**
689 - * @since 2.4.0
690 - *
691 - * @param $post WP_Post
692 - *
693 - * @return string
694 - */
695 - public static function get_where_use_text( $post ) {
696 - $snippet_scope = self::getMetaOption( $post->ID, 'snippet_scope' );
697 - $result = "";
698 -
699 - if ( $snippet_scope == 'evrywhere' ) {
700 - $result = __( 'Run everywhere', 'insert-php' );
701 - } else if ( $snippet_scope == 'auto' ) {
702 - $items = [
703 - WINP_SNIPPET_AUTO_HEADER => __( 'Header', 'insert-php' ),
704 - WINP_SNIPPET_AUTO_FOOTER => __( 'Footer', 'insert-php' ),
705 - WINP_SNIPPET_AUTO_BEFORE_POST => __( 'Insert Before Post', 'insert-php' ),
706 - WINP_SNIPPET_AUTO_BEFORE_CONTENT => __( 'Insert Before Content', 'insert-php' ),
707 - WINP_SNIPPET_AUTO_BEFORE_PARAGRAPH => __( 'Insert Before Paragraph', 'insert-php' ),
708 - WINP_SNIPPET_AUTO_AFTER_PARAGRAPH => __( 'Insert After Paragraph', 'insert-php' ),
709 - WINP_SNIPPET_AUTO_AFTER_CONTENT => __( 'Insert After Content', 'insert-php' ),
710 - WINP_SNIPPET_AUTO_AFTER_POST => __( 'Insert After Post', 'insert-php' ),
711 - WINP_SNIPPET_AUTO_BEFORE_EXCERPT => __( 'Insert Before Excerpt', 'insert-php' ),
712 - WINP_SNIPPET_AUTO_AFTER_EXCERPT => __( 'Insert After Excerpt', 'insert-php' ),
713 - WINP_SNIPPET_AUTO_BETWEEN_POSTS => __( 'Between Posts', 'insert-php' ),
714 - WINP_SNIPPET_AUTO_BEFORE_POSTS => __( 'Before post', 'insert-php' ),
715 - WINP_SNIPPET_AUTO_AFTER_POSTS => __( 'After post', 'insert-php' ),
716 - ];
717 -
718 - $snippet_location = self::getMetaOption( $post->ID, 'snippet_location', '' );
719 -
720 - switch ( $snippet_location ) {
721 - case WINP_SNIPPET_AUTO_HEADER:
722 - case WINP_SNIPPET_AUTO_FOOTER:
723 - $text = __( 'Everywhere', 'insert-php' ) . '[' . $items[ $snippet_location ] . ']';
724 - break;
725 -
726 - case WINP_SNIPPET_AUTO_BEFORE_POST:
727 - case WINP_SNIPPET_AUTO_BEFORE_CONTENT:
728 - case WINP_SNIPPET_AUTO_BEFORE_PARAGRAPH:
729 - case WINP_SNIPPET_AUTO_AFTER_PARAGRAPH:
730 - case WINP_SNIPPET_AUTO_AFTER_CONTENT:
731 - case WINP_SNIPPET_AUTO_AFTER_POST:
732 - $text = __( 'Posts, Pages, Custom post types', 'insert-php' ) . '[' . $items[ $snippet_location ] . ']';
733 - break;
734 -
735 - case WINP_SNIPPET_AUTO_BEFORE_EXCERPT:
736 - case WINP_SNIPPET_AUTO_AFTER_EXCERPT:
737 - case WINP_SNIPPET_AUTO_BETWEEN_POSTS:
738 - case WINP_SNIPPET_AUTO_BEFORE_POSTS:
739 - case WINP_SNIPPET_AUTO_AFTER_POSTS:
740 - $text = __( 'Categories, Archives, Tags, Taxonomies', 'insert-php' ) . '[' . $items[ $snippet_location ] . ']';
741 - break;
742 -
743 - default:
744 - $text = __( 'Everywhere', 'insert-php' );
745 - }
746 -
747 - $result = __( 'Automatic insertion', 'insert-php' ) . ': ' . esc_html( $text );
748 - } else {
749 - $result = self::get_shortcode_text( $post );
750 - }
751 -
752 - return $result;
753 - }
754 -
755 - /**
756 - * @since 2.4.0
757 - *
758 - * @param $post WP_Post
759 - *
760 - * @return string
761 - */
762 - public static function get_shortcode_text( $post ) {
763 - $snippet_type = self::get_snippet_type( $post->ID );
764 - $snippet_type = ( $snippet_type == WINP_SNIPPET_TYPE_UNIVERSAL ? '' : $snippet_type . '_' );
765 -
766 - return esc_html( apply_filters( 'wbcr/inp/viewtable/where_use', '[wbcr_' . $snippet_type . 'snippet id="' . $post->ID . '"]', $post->ID ) );
767 - }
768 -
769 - /**
770 - * @since 2.4.0
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 679 }
792 680 }