diff --git a/includes/Admin/views/codes.php b/includes/Admin/views/codes.php index 3e7a57b..5261418 100644 --- a/includes/Admin/views/codes.php +++ b/includes/Admin/views/codes.php @@ -67,11 +67,22 @@
-

+

    -
  • +
  • +

    + + +

    +
  • +
  • +

    + + +

    +
diff --git a/includes/Admin/views/settings.php b/includes/Admin/views/settings.php index 2484e96..69a92f9 100644 --- a/includes/Admin/views/settings.php +++ b/includes/Admin/views/settings.php @@ -86,11 +86,22 @@
-

+

    -
  • +
  • +

    + + +

    +
  • +
  • +

    + + +

    +
diff --git a/includes/Frontend/Frontend.php b/includes/Frontend/Frontend.php index 3a79bd9..2b1dc76 100644 --- a/includes/Frontend/Frontend.php +++ b/includes/Frontend/Frontend.php @@ -33,6 +33,8 @@ public function init() { add_action( 'wp_head', array( $this, 'insert_into_head' ), $header_priority ); add_action( 'wp_body_open', array( $this, 'insert_into_body' ), $body_priority ); add_action( 'wp_footer', array( $this, 'insert_into_footer' ), $footer_priority ); + add_filter( 'safe_style_css', array( $this, 'safe_styles' ) ); + add_filter( 'pre_kses', array( $this, 'normalize_entities' ), PHP_INT_MAX ); } /** @@ -65,4 +67,31 @@ public function insert_into_body() { public function insert_into_footer() { echo wp_kses( get_option( 'insertcodes_footer' ), insertcodes_get_allowed_html() ); } + + /** + * Add allowed styles. + * + * @param array $styles Allowed styles. + * + * @since 1.1.0 + * @return array + */ + public function safe_styles( $styles ) { + $styles[] = 'display'; + $styles[] = 'visibility'; + + return $styles; + } + + /** + * Normalize entities. + * + * @param string $content Content. + * + * @since 1.1.0 + * @return string + */ + public function normalize_entities( $content ) { + return html_entity_decode( $content ); + } } diff --git a/includes/functions.php b/includes/functions.php index 96dfae1..a7f95da 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -11,10 +11,13 @@ function insertcodes_get_allowed_html() { return array( 'script' => array( - 'type' => array(), - 'src' => array(), - 'async' => array(), - 'defer' => array(), + 'type' => array(), + 'src' => array(), + 'async' => array(), + 'defer' => array(), + 'data-account' => array(), + 'data-user' => array(), + 'id' => array(), ), 'noscript' => array( 'type' => array(), @@ -30,6 +33,7 @@ function insertcodes_get_allowed_html() { 'scrolling' => array(), 'style' => array(), 'class' => array(), + 'id' => array(), ), 'meta' => array( 'name' => array(), @@ -43,6 +47,9 @@ function insertcodes_get_allowed_html() { 'title' => array(), 'rel' => array(), 'target' => array(), + 'class' => array(), + 'id' => array(), + 'style' => array(), ), 'br' => array(), 'em' => array(), @@ -51,10 +58,22 @@ function insertcodes_get_allowed_html() { 'div' => array( 'class' => array(), 'id' => array(), + 'style' => array(), ), 'span' => array( 'class' => array(), 'id' => array(), + 'style' => array(), + ), + 'img' => array( + 'src' => array(), + 'alt' => array(), + 'title' => array(), + 'width' => array(), + 'height' => array(), + 'class' => array(), + 'id' => array(), + 'style' => array(), ), ); } diff --git a/insert-codes.php b/insert-codes.php index 3a3f742..46dd157 100644 --- a/insert-codes.php +++ b/insert-codes.php @@ -3,7 +3,7 @@ * Plugin Name: Insert Codes - Headers And Footers Code Snippet * Plugin URI: https://urldev.com/plugins/insert-codes/ * 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. - * Version: 1.0.0 + * Version: 1.1.0 * Requires at least: 5.0 * Requires PHP: 7.4 * Author: UrlDev @@ -41,7 +41,7 @@ * @return Plugin plugin initialize class. */ function insertcodes() { - return Plugin::create( __FILE__, '1.0.0' ); + return Plugin::create( __FILE__, '1.1.0' ); } // Initialize the plugin. diff --git a/package.json b/package.json index 59f6800..295ff4b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "insert-codes", "title": "Insert Codes - Headers And Footers Code Snippet", - "version": "1.0.0", + "version": "1.1.0", "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.", "homepage": "https://urldev.com/plugins/insert-codes/", "license": "GPL-2.0-or-later", diff --git a/readme.txt b/readme.txt index 4504362..8b252ff 100644 --- a/readme.txt +++ b/readme.txt @@ -1,9 +1,9 @@ === Insert Codes - Headers And Footers Code Snippet === Contributors: urldev -Tags: insert codes, insert headers and footers, insert header, insert footer, code snippet +Tags: code, code snippet, insert codes, header, footer Requires at least: 5.0 Tested up to: 6.6 -Stable tag: 1.0.0 +Stable tag: 1.1.0 Requires PHP: 7.4 License: GPLv2 or later 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 4. Configure the settings and start using the plugin feature! == Frequently Asked Questions == -= Q: How do I add a header script? = += How do I add a header script? = 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. -= Q: Can I add multiple scripts in each section? = += Can I add multiple scripts in each section? = A: Yes, you can add multiple scripts in each section. Just paste them one after the other. -= Q: Is it safe to add third-party scripts using this plugin? = += Is it safe to add third-party scripts using this plugin? = 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. -= Q: Will this plugin slow down my site? = += Will this plugin slow down my site? = 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. -= Q: Can I add custom CSS using this plugin? = += Can I add custom CSS using this plugin? = 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. -= Q: Can I add Google Analytics tracking code using this plugin? = += Can I add Google Analytics tracking code using this plugin? = 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. -= Q: Can I add Facebook Pixel code using this plugin? = += Can I add Facebook Pixel code using this plugin? = 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. -= Q: Can I add custom scripts to the head section using this plugin? = += Can I add custom scripts to the head section using this plugin? = A: Yes, you can add custom scripts to the head section using this plugin. Paste your code snippet in the 'Header Scripts' field. -= Q: Can I add custom scripts to the body section using this plugin? = += Can I add custom scripts to the body section using this plugin? = A: Yes, you can add custom scripts to the body section using this plugin. Paste your code snippet in the 'Body Scripts' field. -= Q: Can I add custom scripts to the footer section using this plugin? = += Can I add custom scripts to the footer section using this plugin? = A: Yes, you can add custom scripts to the footer section using this plugin. Paste your code snippet in the 'Footer Scripts' field. -= Q: Can I add scripts to specific pages using this plugin? = += Can I add scripts to specific pages using this plugin? = 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. -= Q: Can I add scripts to specific posts using this plugin? = += Can I add scripts to specific posts using this plugin? = 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. -= Q: Can I add scripts to specific categories using this plugin? = += Can I add scripts to specific categories using this plugin? = 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. -= Q: Can I add scripts to specific tags using this plugin? = += Can I add scripts to specific tags using this plugin? = 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. -= Q: Can I add scripts to specific custom post types using this plugin? = += Can I add scripts to specific custom post types using this plugin? = 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. += Can I add scripts to specific taxonomies using this plugin? = +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. + = Minimum requirements = * WordPress 5.0 or greater * PHP version 5.6 or greater @@ -105,6 +108,12 @@ A: Currently, the plugin does not support adding scripts to specific custom post 2. Settings Page: Easy and user-friendly admin panel to configure the header, body, and footer scripts options. == Changelog == += 1.1.0 (19 August 2024) = +* Enhancement: Enhanced sanitization and validation of input fields. +* Enhancement: Improved user interface and settings page. +* Contact support: Add support & rating widget. +* Fix: few known issues. + = 1.0.0 (19 June 2024) = * Initial release with support for adding header, body, and footer scripts.