Skip to content

Commit 69f776f

Browse files
authored
Merge pull request #3 from wpfresher/release/1.1.0
Enhanced code editor supports
2 parents 3f80d23 + b0451d4 commit 69f776f

7 files changed

Lines changed: 107 additions & 28 deletions

File tree

includes/Admin/views/codes.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,22 @@
6767
<div class="insertcodes__aside aside__items">
6868
<div class="aside__item">
6969
<div class="aside__item__header">
70-
<h4><?php esc_html_e( 'Recommended Plugins', 'insert-codes' ); ?></h4>
70+
<h4><?php esc_html_e( 'Support & Rating', 'insert-codes' ); ?></h4>
7171
</div>
7272
<div class="aside__item__body">
7373
<ul>
74-
<li><a href="https://wordpress.org/plugins/autocomplete-orders-for-woocommerce/" target="_blank"><?php esc_html_e( 'Autocomplete Orders for WooCommerce', 'insert-codes' ); ?></a></li>
74+
<li>
75+
<p>
76+
<?php esc_html_e( 'If you need help, please visit the support forum.', 'insert-codes' ); ?>
77+
<a href="https://wordpress.org/support/plugin/insert-codes/" target="_blank"><?php esc_html_e( 'Get Support', 'insert-codes' ); ?></a>
78+
</p>
79+
</li>
80+
<li>
81+
<p>
82+
<?php esc_html_e( 'If you like the plugin, please rate it on WordPress.org.', 'insert-codes' ); ?>
83+
<a href="https://wordpress.org/plugins/insert-codes/" target="_blank"><?php esc_html_e( 'Give a Rating', 'insert-codes' ); ?></a>
84+
</p>
85+
</li>
7586
</ul>
7687
</div>
7788
</div>

includes/Admin/views/settings.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,22 @@
8686
<div class="insertcodes__aside aside__items">
8787
<div class="aside__item">
8888
<div class="aside__item__header">
89-
<h4><?php esc_html_e( 'Recommended Plugins', 'insert-codes' ); ?></h4>
89+
<h4><?php esc_html_e( 'Support & Rating', 'insert-codes' ); ?></h4>
9090
</div>
9191
<div class="aside__item__body">
9292
<ul>
93-
<li><a href="https://wordpress.org/plugins/autocomplete-orders-for-woocommerce/" target="_blank"><?php esc_html_e( 'Autocomplete Orders for WooCommerce', 'insert-codes' ); ?></a></li>
93+
<li>
94+
<p>
95+
<?php esc_html_e( 'If you need help, please visit the support forum.', 'insert-codes' ); ?>
96+
<a href="https://wordpress.org/support/plugin/insert-codes/" target="_blank"><?php esc_html_e( 'Get Support', 'insert-codes' ); ?></a>
97+
</p>
98+
</li>
99+
<li>
100+
<p>
101+
<?php esc_html_e( 'If you like the plugin, please rate it on WordPress.org.', 'insert-codes' ); ?>
102+
<a href="https://wordpress.org/plugins/insert-codes/" target="_blank"><?php esc_html_e( 'Give a Rating', 'insert-codes' ); ?></a>
103+
</p>
104+
</li>
94105
</ul>
95106
</div>
96107
</div>

includes/Frontend/Frontend.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function init() {
3333
add_action( 'wp_head', array( $this, 'insert_into_head' ), $header_priority );
3434
add_action( 'wp_body_open', array( $this, 'insert_into_body' ), $body_priority );
3535
add_action( 'wp_footer', array( $this, 'insert_into_footer' ), $footer_priority );
36+
add_filter( 'safe_style_css', array( $this, 'safe_styles' ) );
37+
add_filter( 'pre_kses', array( $this, 'normalize_entities' ), PHP_INT_MAX );
3638
}
3739

3840
/**
@@ -65,4 +67,31 @@ public function insert_into_body() {
6567
public function insert_into_footer() {
6668
echo wp_kses( get_option( 'insertcodes_footer' ), insertcodes_get_allowed_html() );
6769
}
70+
71+
/**
72+
* Add allowed styles.
73+
*
74+
* @param array $styles Allowed styles.
75+
*
76+
* @since 1.1.0
77+
* @return array
78+
*/
79+
public function safe_styles( $styles ) {
80+
$styles[] = 'display';
81+
$styles[] = 'visibility';
82+
83+
return $styles;
84+
}
85+
86+
/**
87+
* Normalize entities.
88+
*
89+
* @param string $content Content.
90+
*
91+
* @since 1.1.0
92+
* @return string
93+
*/
94+
public function normalize_entities( $content ) {
95+
return html_entity_decode( $content );
96+
}
6897
}

includes/functions.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
function insertcodes_get_allowed_html() {
1212
return array(
1313
'script' => array(
14-
'type' => array(),
15-
'src' => array(),
16-
'async' => array(),
17-
'defer' => array(),
14+
'type' => array(),
15+
'src' => array(),
16+
'async' => array(),
17+
'defer' => array(),
18+
'data-account' => array(),
19+
'data-user' => array(),
20+
'id' => array(),
1821
),
1922
'noscript' => array(
2023
'type' => array(),
@@ -30,6 +33,7 @@ function insertcodes_get_allowed_html() {
3033
'scrolling' => array(),
3134
'style' => array(),
3235
'class' => array(),
36+
'id' => array(),
3337
),
3438
'meta' => array(
3539
'name' => array(),
@@ -43,6 +47,9 @@ function insertcodes_get_allowed_html() {
4347
'title' => array(),
4448
'rel' => array(),
4549
'target' => array(),
50+
'class' => array(),
51+
'id' => array(),
52+
'style' => array(),
4653
),
4754
'br' => array(),
4855
'em' => array(),
@@ -51,10 +58,22 @@ function insertcodes_get_allowed_html() {
5158
'div' => array(
5259
'class' => array(),
5360
'id' => array(),
61+
'style' => array(),
5462
),
5563
'span' => array(
5664
'class' => array(),
5765
'id' => array(),
66+
'style' => array(),
67+
),
68+
'img' => array(
69+
'src' => array(),
70+
'alt' => array(),
71+
'title' => array(),
72+
'width' => array(),
73+
'height' => array(),
74+
'class' => array(),
75+
'id' => array(),
76+
'style' => array(),
5877
),
5978
);
6079
}

insert-codes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Insert Codes - Headers And Footers Code Snippet
44
* Plugin URI: https://urldev.com/plugins/insert-codes/
55
* Description: The "Insert Codes - Headers And Footers Code Snippet" plugin allows you to easily add custom code to the header, body, and footer sections of your WordPress website.
6-
* Version: 1.0.0
6+
* Version: 1.1.0
77
* Requires at least: 5.0
88
* Requires PHP: 7.4
99
* Author: UrlDev
@@ -41,7 +41,7 @@
4141
* @return Plugin plugin initialize class.
4242
*/
4343
function insertcodes() {
44-
return Plugin::create( __FILE__, '1.0.0' );
44+
return Plugin::create( __FILE__, '1.1.0' );
4545
}
4646

4747
// Initialize the plugin.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "insert-codes",
33
"title": "Insert Codes - Headers And Footers Code Snippet",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"description": "The \"Insert Codes - Headers And Footers Code Snippet\" plugin allows you to easily add custom code to the header, body, and footer sections of your WordPress website.",
66
"homepage": "https://urldev.com/plugins/insert-codes/",
77
"license": "GPL-2.0-or-later",

readme.txt

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
=== Insert Codes - Headers And Footers Code Snippet ===
22
Contributors: urldev
3-
Tags: insert codes, insert headers and footers, insert header, insert footer, code snippet
3+
Tags: code, code snippet, insert codes, header, footer
44
Requires at least: 5.0
55
Tested up to: 6.6
6-
Stable tag: 1.0.0
6+
Stable tag: 1.1.0
77
Requires PHP: 7.4
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -49,51 +49,54 @@ Install Insert Codes - Headers And Footers Code Snippet from the WordPress plugi
4949
4. Configure the settings and start using the plugin feature!
5050

5151
== Frequently Asked Questions ==
52-
= Q: How do I add a header script? =
52+
= How do I add a header script? =
5353
A: After activating the plugin, go to 'Settings' > 'Insert Codes', and you will find a field for 'Header Scripts'. Paste your code snippet there and save changes.
5454

55-
= Q: Can I add multiple scripts in each section? =
55+
= Can I add multiple scripts in each section? =
5656
A: Yes, you can add multiple scripts in each section. Just paste them one after the other.
5757

58-
= Q: Is it safe to add third-party scripts using this plugin? =
58+
= Is it safe to add third-party scripts using this plugin? =
5959
A: Yes, it is safe as long as you ensure the scripts are from trusted sources. The plugin itself securely inserts the code snippets into your site.
6060

61-
= Q: Will this plugin slow down my site? =
61+
= Will this plugin slow down my site? =
6262
A: The impact on performance is minimal as the plugin inserts the scripts directly into the respective sections of your site's HTML. However, excessive use of scripts can affect performance, so use them judiciously.
6363

64-
= Q: Can I add custom CSS using this plugin? =
64+
= Can I add custom CSS using this plugin? =
6565
A: Yes, you can add custom CSS to the header section using this plugin. Just paste your CSS code snippet in the 'Header Scripts' field.
6666

67-
= Q: Can I add Google Analytics tracking code using this plugin? =
67+
= Can I add Google Analytics tracking code using this plugin? =
6868
A: Yes, you can add Google Analytics tracking code to the header section using this plugin. Paste the tracking code snippet in the 'Header Scripts' field.
6969

70-
= Q: Can I add Facebook Pixel code using this plugin? =
70+
= Can I add Facebook Pixel code using this plugin? =
7171
A: Yes, you can add Facebook Pixel code to the header section using this plugin. Paste the Pixel code snippet in the 'Header Scripts' field.
7272

73-
= Q: Can I add custom scripts to the head section using this plugin? =
73+
= Can I add custom scripts to the head section using this plugin? =
7474
A: Yes, you can add custom scripts to the head section using this plugin. Paste your code snippet in the 'Header Scripts' field.
7575

76-
= Q: Can I add custom scripts to the body section using this plugin? =
76+
= Can I add custom scripts to the body section using this plugin? =
7777
A: Yes, you can add custom scripts to the body section using this plugin. Paste your code snippet in the 'Body Scripts' field.
7878

79-
= Q: Can I add custom scripts to the footer section using this plugin? =
79+
= Can I add custom scripts to the footer section using this plugin? =
8080
A: Yes, you can add custom scripts to the footer section using this plugin. Paste your code snippet in the 'Footer Scripts' field.
8181

82-
= Q: Can I add scripts to specific pages using this plugin? =
82+
= Can I add scripts to specific pages using this plugin? =
8383
A: Currently, the plugin does not support adding scripts to specific pages. The scripts added using this plugin will be displayed on all pages of your site.
8484

85-
= Q: Can I add scripts to specific posts using this plugin? =
85+
= Can I add scripts to specific posts using this plugin? =
8686
A: Currently, the plugin does not support adding scripts to specific posts. The scripts added using this plugin will be displayed on all posts of your site.
8787

88-
= Q: Can I add scripts to specific categories using this plugin? =
88+
= Can I add scripts to specific categories using this plugin? =
8989
A: Currently, the plugin does not support adding scripts to specific categories. The scripts added using this plugin will be displayed on all categories of your site.
9090

91-
= Q: Can I add scripts to specific tags using this plugin? =
91+
= Can I add scripts to specific tags using this plugin? =
9292
A: Currently, the plugin does not support adding scripts to specific tags. The scripts added using this plugin will be displayed on all tags of your site.
9393

94-
= Q: Can I add scripts to specific custom post types using this plugin? =
94+
= Can I add scripts to specific custom post types using this plugin? =
9595
A: Currently, the plugin does not support adding scripts to specific custom post types. The scripts added using this plugin will be displayed on all custom post types of your site.
9696

97+
= Can I add scripts to specific taxonomies using this plugin? =
98+
A: Currently, the plugin does not support adding scripts to specific taxonomies. The scripts added using this plugin will be displayed on all taxonomies of your site.
99+
97100
= Minimum requirements =
98101
* WordPress 5.0 or greater
99102
* PHP version 5.6 or greater
@@ -105,6 +108,12 @@ A: Currently, the plugin does not support adding scripts to specific custom post
105108
2. Settings Page: Easy and user-friendly admin panel to configure the header, body, and footer scripts options.
106109

107110
== Changelog ==
111+
= 1.1.0 (19 August 2024) =
112+
* Enhancement: Enhanced sanitization and validation of input fields.
113+
* Enhancement: Improved user interface and settings page.
114+
* Contact support: Add support & rating widget.
115+
* Fix: few known issues.
116+
108117
= 1.0.0 (19 June 2024) =
109118
* Initial release with support for adding header, body, and footer scripts.
110119

0 commit comments

Comments
 (0)