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, '