From 7cf3fb239af0673cd8592f76b6d027183ad2cac9 Mon Sep 17 00:00:00 2001 From: Yogesh Sambare <91533131+yssambare12@users.noreply.github.com> Date: Mon, 2 Feb 2026 09:43:12 +0530 Subject: [PATCH 1/2] chore: added woff file support --- .../includes/class-bsf-custom-fonts-menu.php | 21 ++- admin/dashboard/package-lock.json | 148 +++++++++++++----- 2 files changed, 130 insertions(+), 39 deletions(-) diff --git a/admin/dashboard/includes/class-bsf-custom-fonts-menu.php b/admin/dashboard/includes/class-bsf-custom-fonts-menu.php index f13926fe..8a9315bf 100644 --- a/admin/dashboard/includes/class-bsf-custom-fonts-menu.php +++ b/admin/dashboard/includes/class-bsf-custom-fonts-menu.php @@ -410,16 +410,33 @@ public function sanitize_svg( $original_content ) { * @return Array File data array containing 'ext', 'type', and */ public function update_mime_types( $defaults, $file, $filename ) { - if ( 'ttf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) { + $ext = pathinfo( $filename, PATHINFO_EXTENSION ); + + if ( 'woff2' === $ext ) { + $defaults['type'] = 'application/x-font-woff2'; + $defaults['ext'] = 'woff2'; + } + + if ( 'woff' === $ext ) { + $defaults['type'] = 'application/x-font-woff'; + $defaults['ext'] = 'woff'; + } + + if ( 'ttf' === $ext ) { $defaults['type'] = 'application/x-font-ttf'; $defaults['ext'] = 'ttf'; } - if ( 'otf' === pathinfo( $filename, PATHINFO_EXTENSION ) ) { + if ( 'otf' === $ext ) { $defaults['type'] = 'application/x-font-otf'; $defaults['ext'] = 'otf'; } + if ( 'eot' === $ext ) { + $defaults['type'] = 'application/vnd.ms-fontobject'; + $defaults['ext'] = 'eot'; + } + if ( 'svg' === pathinfo( $filename, PATHINFO_EXTENSION ) ) { // Perform SVG sanitization using the sanitize_svg function. $svg_content = file_get_contents( $file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents diff --git a/admin/dashboard/package-lock.json b/admin/dashboard/package-lock.json index ba9e617a..544b0b67 100644 --- a/admin/dashboard/package-lock.json +++ b/admin/dashboard/package-lock.json @@ -1640,6 +1640,40 @@ "strip-ansi": "^7.0.1" } }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -1649,6 +1683,23 @@ "ansi-regex": "^6.0.1" } }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + } + } + }, "wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -1659,6 +1710,60 @@ "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } } } }, @@ -3628,6 +3733,12 @@ "resolved": "https://registry.npmjs.org/@wordpress/prettier-config/-/prettier-config-1.4.0.tgz", "integrity": "sha512-uvrgUAhRnOvIysXjcXH9VDsrKLqH9r3BfdGoy+WFLSHFnTfdMhW7bdDQXl4F4UIUuefUwGi+ZvT/rChg9zoBkQ==", "dev": true + }, + "prettier": { + "version": "npm:wp-prettier@2.2.1-beta-1", + "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.2.1-beta-1.tgz", + "integrity": "sha512-+JHkqs9LC/JPp51yy1hzs3lQ7qeuWCwOcSzpQNeeY/G7oSpnF61vxt7hRh87zNRTr6ob2ndy0W8rVzhgrcA+Gw==", + "dev": true } } }, @@ -12612,12 +12723,6 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, - "prettier": { - "version": "npm:wp-prettier@2.2.1-beta-1", - "resolved": "https://registry.npmjs.org/wp-prettier/-/wp-prettier-2.2.1-beta-1.tgz", - "integrity": "sha512-+JHkqs9LC/JPp51yy1hzs3lQ7qeuWCwOcSzpQNeeY/G7oSpnF61vxt7hRh87zNRTr6ob2ndy0W8rVzhgrcA+Gw==", - "dev": true - }, "prettier-linter-helpers": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", @@ -14803,17 +14908,6 @@ "strip-ansi": "^6.0.1" } }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "string.prototype.includes": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/string.prototype.includes/-/string.prototype.includes-2.0.0.tgz", @@ -14904,15 +14998,6 @@ "ansi-regex": "^5.0.1" } }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, "strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -16930,17 +17015,6 @@ "strip-ansi": "^6.0.0" } }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", From ebf421efb5f8db9a5e617ca117d990733a724eda Mon Sep 17 00:00:00 2001 From: Yogesh Sambare <91533131+yssambare12@users.noreply.github.com> Date: Mon, 2 Feb 2026 09:47:49 +0530 Subject: [PATCH 2/2] doc: changelog added and version updated --- .distignore | 66 +- .gitignore | 71 +- Gruntfile.js | 408 +- README.md | 619 +- .../includes/class-bsf-custom-fonts-menu.php | 1208 +- admin/dashboard/package-lock.json | 34254 ++++++++-------- admin/dashboard/package.json | 106 +- admin/dashboard/tailwind.config.js | 107 +- custom-fonts.php | 184 +- package.json | 66 +- readme.txt | 619 +- 11 files changed, 18858 insertions(+), 18850 deletions(-) diff --git a/.distignore b/.distignore index 32390a4f..cf0413dd 100644 --- a/.distignore +++ b/.distignore @@ -1,33 +1,33 @@ -# A set of files you probably don't want in your WordPress.org distribution -.distignore -.editorconfig -.git -.gitignore -.gitlab-ci.yml -.travis.yml -.DS_Store -Thumbs.db -behat.yml -bin -circle.yml -composer.json -composer.lock -Gruntfile.js -package.json -package-lock.json -phpunit.xml -phpunit.xml.dist -multisite.xml -multisite.xml.dist -phpcs.xml -phpcs.xml.dist -README.md -wp-cli.local.yml -tests -vendor -node_modules -*.sql -*.tar.gz -*.zip -.github -.wordpress-org +# A set of files you probably don't want in your WordPress.org distribution +.distignore +.editorconfig +.git +.gitignore +.gitlab-ci.yml +.travis.yml +.DS_Store +Thumbs.db +behat.yml +bin +circle.yml +composer.json +composer.lock +Gruntfile.js +package.json +package-lock.json +phpunit.xml +phpunit.xml.dist +multisite.xml +multisite.xml.dist +phpcs.xml +phpcs.xml.dist +README.md +wp-cli.local.yml +tests +vendor +node_modules +*.sql +*.tar.gz +*.zip +.github +.wordpress-org diff --git a/.gitignore b/.gitignore index bec1e4cf..d8c9e775 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,36 @@ -# ignore PHPStorm extra directories -.idea/ - -# Leave node_modules from git -node_modules/ - -# sass cache -.sass-cache - -# map files -*.map - -# Skip package file from versoning -*.zip - -# ignore git inside subproject -admin/bsf-core/.git - -# ignore PHPCS report files -phpcs-summary.log -phpcs-full.log - -# Exclude OS specific files -.DS_Store - -# Exclude composer's directories -vendor/ - -# Exclude exported settings -borders-for-default-menu.json -defaults.json -no-toggle-border-fix.json - -# Large dist directory - Build files can be in MBs, let's not increase size of the git repo -admin/dashboard/assets/build/ +# ignore PHPStorm extra directories +.idea/ + +# Leave node_modules from git +node_modules/ + +# sass cache +.sass-cache + +# map files +*.map + +# Skip package file from versoning +*.zip + +# ignore git inside subproject +admin/bsf-core/.git + +# ignore PHPCS report files +phpcs-summary.log +phpcs-full.log + +# Exclude OS specific files +.DS_Store + +# Exclude composer's directories +vendor/ + +# Exclude exported settings +borders-for-default-menu.json +defaults.json +no-toggle-border-fix.json + +# Large dist directory - Build files can be in MBs, let's not increase size of the git repo +admin/dashboard/assets/build/ +config.bat diff --git a/Gruntfile.js b/Gruntfile.js index e31af978..b6a66710 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,204 +1,204 @@ -module.exports = function( grunt ) { - - 'use strict'; - var pkg = grunt.file.readJSON('package.json'); - var banner = '/**\n * <%= pkg.homepage %>\n * Copyright (c) <%= grunt.template.today("yyyy") %>\n * This file is generated automatically. Do not edit.\n */\n'; - // Project configuration - grunt.initConfig( { - - rtlcss: { - options: { - config: { - preserveComments: true, - greedy: true - }, - // generate source maps - map: false - }, - dist: { - files: [ - { - expand: true, - cwd: 'admin/dashboard/assets/build', - src: [ - '*.css', - '!*-rtl.css', - ], - dest: 'admin/dashboard/assets/build', - ext: '-rtl.css' - }, - ] - } - }, - - addtextdomain: { - options: { - textdomain: 'custom-fonts', - }, - update_all_domains: { - options: { - updateDomains: true - }, - src: [ '*.php', '**/*.php', '!node_modules/**', '!php-tests/**', '!bin/**' ] - } - }, - - wp_readme_to_markdown: { - your_target: { - files: { - 'README.md': 'readme.txt' - } - }, - }, - - makepot: { - target: { - options: { - domainPath: '/languages', - mainFile: 'custom-fonts.php', - potFilename: 'custom-fonts.pot', - potHeaders: { - poedit: true, - 'x-poedit-keywordslist': true - }, - type: 'wp-plugin', - updateTimestamp: true - } - } - }, - - clean: { - main: ["custom-fonts"], - zip: ["*.zip"] - }, - - copy: { - main: { - options: { - mode: true - }, - src: [ - '**', - '*.zip', - '!node_modules/**', - '!admin/dashboard/node_modules/**', - '!admin/dashboard/package.json', - '!admin/dashboard/package-lock.json', - '!admin/dashboard/postcss.config.js', - '!admin/dashboard/tailwind.config.js', - '!admin/dashboard/webpack.config.js', - '!.git/**', - '!.wordpress-org/**', - '!bin/**', - '!.gitlab-ci.yml', - '!bin/**', - '!tests/**', - '!phpunit.xml.dist', - '!*.sh', - '!*.map', - '!Gruntfile.js', - '!package.json', - '!.gitignore', - '!.distignore', - '!.editorconfig', - '!tailwind.config.js', - '!webpack.config.js', - '!postcss.config.js', - '!phpunit.xml', - '!README.md', - '!codesniffer.ruleset.xml', - '!vendor/**', - '!composer.json', - '!composer.lock', - '!package-lock.json', - '!phpcs.xml', - '!phpcs.xml.dist', - '!admin/dashboard/assets/src/**', - ], - dest: 'custom-fonts/' - } - }, - - compress: { - main: { - options: { - archive: 'custom-fonts-' + pkg.version + '.zip', - mode: 'zip' - }, - files: [ - { - src: [ - './custom-fonts/**' - ] - - } - ] - } - }, - - json2php: { - options: { - // Task-specific options go here. - compress: true, - cover: function (phpArrayString, destFilePath) { - return '\n * Copyright (c) <%= grunt.template.today("yyyy") %>\n * This file is generated automatically. Do not edit.\n */\n'; + // Project configuration + grunt.initConfig( { + + rtlcss: { + options: { + config: { + preserveComments: true, + greedy: true + }, + // generate source maps + map: false + }, + dist: { + files: [ + { + expand: true, + cwd: 'admin/dashboard/assets/build', + src: [ + '*.css', + '!*-rtl.css', + ], + dest: 'admin/dashboard/assets/build', + ext: '-rtl.css' + }, + ] + } + }, + + addtextdomain: { + options: { + textdomain: 'custom-fonts', + }, + update_all_domains: { + options: { + updateDomains: true + }, + src: [ '*.php', '**/*.php', '!node_modules/**', '!php-tests/**', '!bin/**' ] + } + }, + + wp_readme_to_markdown: { + your_target: { + files: { + 'README.md': 'readme.txt' + } + }, + }, + + makepot: { + target: { + options: { + domainPath: '/languages', + mainFile: 'custom-fonts.php', + potFilename: 'custom-fonts.pot', + potHeaders: { + poedit: true, + 'x-poedit-keywordslist': true + }, + type: 'wp-plugin', + updateTimestamp: true + } + } + }, + + clean: { + main: ["custom-fonts"], + zip: ["*.zip"] + }, + + copy: { + main: { + options: { + mode: true + }, + src: [ + '**', + '*.zip', + '!node_modules/**', + '!admin/dashboard/node_modules/**', + '!admin/dashboard/package.json', + '!admin/dashboard/package-lock.json', + '!admin/dashboard/postcss.config.js', + '!admin/dashboard/tailwind.config.js', + '!admin/dashboard/webpack.config.js', + '!.git/**', + '!.wordpress-org/**', + '!bin/**', + '!.gitlab-ci.yml', + '!bin/**', + '!tests/**', + '!phpunit.xml.dist', + '!*.sh', + '!*.map', + '!Gruntfile.js', + '!package.json', + '!.gitignore', + '!.distignore', + '!.editorconfig', + '!tailwind.config.js', + '!webpack.config.js', + '!postcss.config.js', + '!phpunit.xml', + '!README.md', + '!codesniffer.ruleset.xml', + '!vendor/**', + '!composer.json', + '!composer.lock', + '!package-lock.json', + '!phpcs.xml', + '!phpcs.xml.dist', + '!admin/dashboard/assets/src/**', + ], + dest: 'custom-fonts/' + } + }, + + compress: { + main: { + options: { + archive: 'custom-fonts-' + pkg.version + '.zip', + mode: 'zip' + }, + files: [ + { + src: [ + './custom-fonts/**' + ] + + } + ] + } + }, + + json2php: { + options: { + // Task-specific options go here. + compress: true, + cover: function (phpArrayString, destFilePath) { + return 'initialize_hooks(); - } - - /** - * Init Hooks. - * - * @since 2.0.0 - * @return void - */ - public function initialize_hooks() { - - add_action( 'admin_menu', array( $this, 'register_custom_fonts_menu' ) ); - add_action( 'admin_init', array( $this, 'settings_admin_scripts' ) ); - - add_filter( 'upload_mimes', array( $this, 'add_fonts_to_allowed_mimes' ) ); - add_filter( 'wp_check_filetype_and_ext', array( $this, 'update_mime_types' ), 10, 3 ); - } - - /** - * Register custom font menu - * - * @since 1.0.0 - */ - public function register_custom_fonts_menu() { - $title = apply_filters( 'bsf_custom_fonts_menu_title', _x( 'Custom Fonts', 'Menu title', 'custom-fonts' ) ); - add_theme_page( - $title, - $title, - 'edit_theme_options', - self::$plugin_slug, - array( $this, 'render_admin_dashboard' ) - ); - } - - /** - * Allowed mime types and file extensions - * - * @since 1.0.0 - * @param array $mimes Current array of mime types. - * @return array $mimes Updated array of mime types. - */ - public function add_fonts_to_allowed_mimes( $mimes ) { - $mimes['woff'] = 'application/x-font-woff'; - $mimes['woff2'] = 'application/x-font-woff2'; - $mimes['ttf'] = 'application/x-font-ttf'; - // Allow SVG with additional sanitization. - $mimes['svg'] = 'image/svg+xml'; - $mimes['eot'] = 'application/vnd.ms-fontobject'; - $mimes['otf'] = 'font/otf'; - - return $mimes; - } - - /** - * Sanitizes SVG Code string. - * - * @param string $original_content SVG code to sanitize. - * @return string - * @since x.x.x - * */ - public function sanitize_svg( $original_content ) { - - if ( ! $original_content ) { - return ''; - } - - // Define allowed tags and attributes. - $allowed_tags = array( - 'a', - 'circle', - 'clippath', - 'defs', - 'style', - 'desc', - 'ellipse', - 'fegaussianblur', - 'filter', - 'foreignobject', - 'g', - 'image', - 'line', - 'lineargradient', - 'marker', - 'mask', - 'metadata', - 'path', - 'pattern', - 'polygon', - 'polyline', - 'radialgradient', - 'rect', - 'stop', - 'svg', - 'switch', - 'symbol', - 'text', - 'textpath', - 'title', - 'tspan', - 'use', - ); - - $allowed_attributes = array( - 'class', - 'clip-path', - 'clip-rule', - 'fill', - 'fill-opacity', - 'fill-rule', - 'filter', - 'id', - 'mask', - 'opacity', - 'stroke', - 'stroke-dasharray', - 'stroke-dashoffset', - 'stroke-linecap', - 'stroke-linejoin', - 'stroke-miterlimit', - 'stroke-opacity', - 'stroke-width', - 'style', - 'systemlanguage', - 'transform', - 'href', - 'xlink:href', - 'xlink:title', - 'cx', - 'cy', - 'r', - 'requiredfeatures', - 'clippathunits', - 'type', - 'rx', - 'ry', - 'color-interpolation-filters', - 'stddeviation', - 'filterres', - 'filterunits', - 'height', - 'primitiveunits', - 'width', - 'x', - 'y', - 'font-size', - 'display', - 'font-family', - 'font-style', - 'font-weight', - 'text-anchor', - 'marker-end', - 'marker-mid', - 'marker-start', - 'x1', - 'x2', - 'y1', - 'y2', - 'gradienttransform', - 'gradientunits', - 'spreadmethod', - 'markerheight', - 'markerunits', - 'markerwidth', - 'orient', - 'preserveaspectratio', - 'refx', - 'refy', - 'viewbox', - 'maskcontentunits', - 'maskunits', - 'd', - 'patterncontentunits', - 'patterntransform', - 'patternunits', - 'points', - 'fx', - 'fy', - 'offset', - 'stop-color', - 'stop-opacity', - 'xmlns', - 'xmlns:se', - 'xmlns:xlink', - 'xml:space', - 'method', - 'spacing', - 'startoffset', - 'dx', - 'dy', - 'rotate', - 'textlength', - ); - - $is_encoded = false; - - $needle = "\x1f\x8b\x08"; - // phpcs:disable PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault.NotSet - if ( function_exists( 'mb_strpos' ) ) { - $is_encoded = 0 === mb_strpos( $original_content, $needle ); - } else { - $is_encoded = 0 === strpos( $original_content, $needle ); - } - // phpcs:enable PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault.NotSet - - // phpcs:disable WordPress.PHP.YodaConditions.NotYoda - if ( $is_encoded ) { - $original_content = gzdecode( $original_content ); - if ( $original_content === false ) { - return ''; - } - } - // phpcs:enable WordPress.PHP.YodaConditions.NotYoda - - // Strip php tags. - $content = preg_replace( '/<\?(=|php)(.+?)\?>/i', '', $original_content ); - $content = preg_replace( '/<\?(.*)\?>/Us', '', $content ); - $content = preg_replace( '/<\%(.*)\%>/Us', '', $content ); - - if ( ( false !== strpos( $content, '/Us', '', $content ); - $content = preg_replace( '/\/\*(.*)\*\//Us', '', $content ); - - if ( ( false !== strpos( $content, '/Us', '', $content ); + $content = preg_replace( '/\/\*(.*)\*\//Us', '', $content ); + + if ( ( false !== strpos( $content, '