Shortcode Widget - Version 1.5.3

Version Description

  • Strict PHPCS ruleset adherence.
  • More documentation in widget class.
  • Testing with WordPress 5.6
Download this release

Release Info

Developer gagan0123
Plugin Icon 128x128 Shortcode Widget
Version 1.5.3
Comparing to
See all releases

Code changes from version 1.5.2 to 1.5.3

includes/class-shortcode-widget.php CHANGED
@@ -52,18 +52,33 @@ if ( ! class_exists( 'Shortcode_Widget' ) ) {
52
  * @return void
53
  */
54
  public function widget( $args, $instance ) {
 
 
 
 
55
  /** This filter is documented in wp-includes/default-widgets.php */
56
- $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );
57
 
58
  /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
 
59
  $text = do_shortcode( apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance, $this ) );
 
 
 
60
  echo $args['before_widget'];
61
  if ( ! empty( $title ) ) {
 
 
62
  echo $args['before_title'] . $title . $args['after_title'];
63
  }
64
  ?>
 
 
 
65
  <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
66
  <?php
 
 
67
  echo $args['after_widget'];
68
  }
69
 
@@ -81,14 +96,24 @@ if ( ! class_exists( 'Shortcode_Widget' ) ) {
81
  * @return array|false Settings to save or bool false to cancel saving.
82
  */
83
  public function update( $new_instance, $old_instance ) {
84
- $instance = $old_instance;
85
- $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
 
 
 
 
 
 
 
 
 
86
  if ( current_user_can( 'unfiltered_html' ) ) {
87
  $instance['text'] = $new_instance['text'];
88
  } else {
89
- $instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed.
90
  }
91
  $instance['filter'] = ! empty( $new_instance['filter'] );
 
92
  return $instance;
93
  }
94
 
52
  * @return void
53
  */
54
  public function widget( $args, $instance ) {
55
+ $title = ! empty( $instance['title'] ) ? $instance['title'] : '';
56
+
57
+ $instance['filter'] = ! empty( $instance['filter'] );
58
+
59
  /** This filter is documented in wp-includes/default-widgets.php */
60
+ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
61
 
62
  /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
63
+ // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
64
  $text = do_shortcode( apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance, $this ) );
65
+
66
+ // We need $args['before_widget'] value as it is, so no escaping it.
67
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
68
  echo $args['before_widget'];
69
  if ( ! empty( $title ) ) {
70
+ // We need $args['before_title'] and $args['after_title'] values as they are, so no escaping it.
71
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
72
  echo $args['before_title'] . $title . $args['after_title'];
73
  }
74
  ?>
75
+ <?php
76
+ // We need $instance['filter'] value as it is, so no escaping it.
77
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
78
  <div class="textwidget"><?php echo ! empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div>
79
  <?php
80
+ // We need $args['after_widget'] value as it is, so no escaping it.
81
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
82
  echo $args['after_widget'];
83
  }
84
 
96
  * @return array|false Settings to save or bool false to cancel saving.
97
  */
98
  public function update( $new_instance, $old_instance ) {
99
+ $new_instance = wp_parse_args(
100
+ $new_instance,
101
+ array(
102
+ 'title' => '',
103
+ 'text' => '',
104
+ 'filter' => false,
105
+ )
106
+ );
107
+ $instance = $old_instance;
108
+
109
+ $instance['title'] = sanitize_text_field( $new_instance['title'] );
110
  if ( current_user_can( 'unfiltered_html' ) ) {
111
  $instance['text'] = $new_instance['text'];
112
  } else {
113
+ $instance['text'] = wp_kses_post( $new_instance['text'] );
114
  }
115
  $instance['filter'] = ! empty( $new_instance['filter'] );
116
+
117
  return $instance;
118
  }
119
 
languages/shortcode-widget.pot CHANGED
@@ -1,18 +1,18 @@
1
- # Copyright (C) 2019 Gagan Deep Singh
2
  # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Shortcode Widget 1.5.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shortcode-widget\n"
7
- "POT-Creation-Date: 2019-02-21 10:52:37+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
  "Poedit: \n"
15
- "X-Generator: grunt-wp-i18n1.0.0\n"
16
 
17
  #: includes/class-shortcode-widget-plugin.php:122
18
  msgid "It works"
@@ -26,15 +26,15 @@ msgstr ""
26
  msgid "Shortcode Widget"
27
  msgstr ""
28
 
29
- #: includes/class-shortcode-widget.php:115
30
  msgid "Title:"
31
  msgstr ""
32
 
33
- #: includes/class-shortcode-widget.php:118
34
  msgid "Content:"
35
  msgstr ""
36
 
37
- #: includes/class-shortcode-widget.php:121
38
  msgid "Automatically add paragraphs"
39
  msgstr ""
40
 
1
+ # Copyright (C) 2021 Gagan Deep Singh
2
  # This file is distributed under the GPLv2.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Shortcode Widget 1.5.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/shortcode-widget\n"
7
+ "POT-Creation-Date: 2021-01-03 08:40:49+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2021-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
  "Poedit: \n"
15
+ "X-Generator: grunt-wp-i18n 1.0.3\n"
16
 
17
  #: includes/class-shortcode-widget-plugin.php:122
18
  msgid "It works"
26
  msgid "Shortcode Widget"
27
  msgstr ""
28
 
29
+ #: includes/class-shortcode-widget.php:140
30
  msgid "Title:"
31
  msgstr ""
32
 
33
+ #: includes/class-shortcode-widget.php:143
34
  msgid "Content:"
35
  msgstr ""
36
 
37
+ #: includes/class-shortcode-widget.php:146
38
  msgid "Automatically add paragraphs"
39
  msgstr ""
40
 
readme.txt CHANGED
@@ -4,8 +4,8 @@ Donate Link: https://PayPal.me/gagan0123
4
  Tags: Shortcode, Widget
5
  Requires at least: 3.3
6
  Requires PHP: 5.6
7
- Tested up to: 5.1
8
- Stable tag: 1.5.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -30,6 +30,11 @@ To test the widget you can add the widget and use the shortcode "[shortcode_widg
30
 
31
  == Changelog ==
32
 
 
 
 
 
 
33
  = 1.5.2 =
34
  * Some PHPCS corrections, making code adhering to WordPress coding standards.
35
  * Replaced strip_tags function with wp_strip_all_tags.
@@ -68,4 +73,4 @@ To test the widget you can add the widget and use the shortcode "[shortcode_widg
68
  * Added translation support.
69
 
70
  = 0.1 =
71
- * Added the shortcode widget.
4
  Tags: Shortcode, Widget
5
  Requires at least: 3.3
6
  Requires PHP: 5.6
7
+ Tested up to: 5.9
8
+ Stable tag: 1.5.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
30
 
31
  == Changelog ==
32
 
33
+ = 1.5.3 =
34
+ * Strict PHPCS ruleset adherence.
35
+ * More documentation in widget class.
36
+ * Testing with WordPress 5.6
37
+
38
  = 1.5.2 =
39
  * Some PHPCS corrections, making code adhering to WordPress coding standards.
40
  * Replaced strip_tags function with wp_strip_all_tags.
73
  * Added translation support.
74
 
75
  = 0.1 =
76
+ * Added the shortcode widget.
shortcode-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Shortcode Widget
4
  * Plugin URI: https://wordpress.org/plugins/shortcode-widget/
5
  * Description: Adds a text-like widget that allows you to write shortcode in it. (Just whats missing in the default text widget)
6
- * Version: 1.5.2
7
  * Author: Gagan Deep Singh
8
  * Author URI: https://gagan0123.com
9
  * License: GPLv2
3
  * Plugin Name: Shortcode Widget
4
  * Plugin URI: https://wordpress.org/plugins/shortcode-widget/
5
  * Description: Adds a text-like widget that allows you to write shortcode in it. (Just whats missing in the default text widget)
6
+ * Version: 1.5.3
7
  * Author: Gagan Deep Singh
8
  * Author URI: https://gagan0123.com
9
  * License: GPLv2