-
Notifications
You must be signed in to change notification settings - Fork 0
Add starter child theme WPCS compliant #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 3 commits
b00f247
c341ce5
957d522
14361c2
ca74908
00b1d1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| PROJECT_TYPE=theme | ||
| WPCS_STANDARD=phpcs.xml.dist | ||
| PATH_EXCLUDES_PATTERN='^(.*/)?(vendor|node_modules)/.*' | ||
| DEV_LIB_SKIP=yuicompressor,codeception,grunt,jshint,phpunit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # This file is for unifying the coding style for different editors and IDEs | ||
| # editorconfig.org | ||
|
|
||
| # WordPress Coding Standards | ||
| # https://make.wordpress.org/core/handbook/coding-standards/ | ||
|
|
||
| root = true | ||
|
|
||
| [*] | ||
| charset = utf-8 | ||
| end_of_line = lf | ||
| insert_final_newline = true | ||
| trim_trailing_whitespace = true | ||
| indent_style = tab | ||
|
|
||
| [{.jshintrc,*.json,*.yml}] | ||
| indent_style = space | ||
| indent_size = 2 | ||
|
|
||
| [{*.txt,wp-config-sample.php}] | ||
| end_of_line = crlf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| *.DS_Store | ||
| composer.lock | ||
| /node_modules/ | ||
| /vendor/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| language: php | ||
| sudo: false | ||
|
|
||
| cache: | ||
| directories: | ||
| node_modules | ||
| vendor | ||
|
|
||
| addons: | ||
| apt: | ||
| packages: | ||
| - libxml2-utils | ||
|
|
||
| matrix: | ||
| include: | ||
| - php: '5.6' | ||
| - php: '7.0' | ||
| - php: '7.1' | ||
| - php: '7.2' | ||
|
|
||
| install: | ||
| - composer install | ||
| - export DEV_LIB_PATH=vendor/xwp/wp-dev-lib | ||
| - source $DEV_LIB_PATH/travis.install.sh | ||
|
|
||
| script: | ||
| - source $DEV_LIB_PATH/travis.script.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| { | ||
| "name": "beans/beans-child", | ||
| "description": "Beans theme starter child theme.", | ||
| "type": "wordpress-theme", | ||
| "license": "GPL-2.0+", | ||
| "homepage": "http://www.getbeans.io/", | ||
| "support": { | ||
| "issues": "https://github.com/Getbeans/Beans-Starter-Child-Theme/issues", | ||
| "source": "https://github.com/Getbeans/Beans-Starter-Child-Theme" | ||
| }, | ||
| "prefer-stable": true, | ||
| "repositories": [ | ||
| { | ||
| "type": "package", | ||
| "package": { | ||
| "name": "xwp/wp-dev-lib", | ||
| "version": "1.0.1", | ||
| "source": { | ||
| "url": "https://github.com/xwp/wp-dev-lib.git", | ||
| "type": "git", | ||
| "reference": "master" | ||
| } | ||
| } | ||
| } | ||
| ], | ||
| "require-dev": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3", | ||
| "sirbrillig/phpcs-variable-analysis": "^2.0", | ||
| "wp-coding-standards/wpcs": "^0.14.0", | ||
| "xwp/wp-dev-lib": "^1.0.1" | ||
| }, | ||
| "scripts": { | ||
| "install-codestandards": [ | ||
| "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run" | ||
| ], | ||
| "phpcs-src": "\"vendor/bin/phpcs\"", | ||
| "phpcs-tests": "\"vendor/bin/phpcs\" --runtime-set testVersion 5.6 tests/phpunit/", | ||
| "phpcs": [ | ||
| "@phpcs-src", | ||
| "@phpcs-tests" | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <?php | ||
| /** | ||
| * Beans Child | ||
| * | ||
| * @package Beans\StarterChildTheme | ||
| */ | ||
|
|
||
| namespace Beans\StarterChildTheme; | ||
|
|
||
| // Include Beans. Do not remove the line below. | ||
| require_once get_template_directory() . '/lib/init.php'; | ||
|
|
||
| /** | ||
| * Enqueue LESS and CSS style to the UIkit compiler. | ||
| * | ||
| * IMPORTANT: The function below enqueue both the style.less and style.css to the UIkit compiler. Remove one of the | ||
| * two enqueuer according to your needs | ||
| * | ||
| * To make sure the compiler re-compile your LESS or CSS on the fly (on page reload), make sure to enable development | ||
| * mode via the Admin->Appearance->Settings option. | ||
| */ | ||
| add_action( 'beans_uikit_enqueue_scripts', function() { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a fan of using closures as the hooked callback. Why? Our code provides an example of how to build code. And in some cases a closure is fine. But in most others it is not because it cannot be unhooked. Here, one could argue that this callback will never be unhooked. But in many other cases, you may build a plugin that needs to unhook another part of your theme. If you use a closure, that is no longer possible, well unless we use Choices:Option 1Use the standard function as the callback. Option 2Use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thinking behind is that Child Theme are not meant to be extendable to a certain extent, but I am definitely in a agreement that it can be the case sometimes. I think using |
||
| // To remove if you are using style.css only. | ||
| beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.less', 'less' ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why call
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because one of the too calls below are meant to be removed. Either users choose LESS or CSS but not enqueue both. Then users will most likely leave the function assigned to the variable unnecessary. |
||
|
|
||
| // To remove if you are using style.less only. | ||
| beans_compiler_add_fragment( 'uikit', get_stylesheet_directory_uri() . '/style.css', 'less' ); | ||
| } ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0"?> | ||
| <ruleset name="Beans Child"> | ||
| <description>The code standard for Beans Child.</description> | ||
|
|
||
| <file>.</file> | ||
|
|
||
| <!-- Ignore these directories --> | ||
| <exclude-pattern>node_modules/*</exclude-pattern> | ||
| <exclude-pattern>*/vendor/*</exclude-pattern> | ||
|
|
||
| <!-- PHP only. We'll use other validators for JS, CSS, etc. --> | ||
| <arg name="extensions" value="php"/> | ||
|
|
||
| <!-- WordPress Rules --> | ||
| <rule ref="WordPress"> | ||
| <exclude name="WordPress.VIP"/> | ||
|
|
||
| <!-- Exclude until v2 as this applies after WP 4.4 with upgrades in PHP 5.3 --> | ||
| <exclude name="WordPress.WP.AlternativeFunctions.parse_url_parse_url"/> | ||
| <exclude name="PEAR.NamingConventions.ValidClassName.StartWithCapital"/> | ||
| </rule> | ||
|
|
||
| <rule ref="WordPress.Files.FileName"> | ||
| <properties> | ||
| <property name="is_theme" value="true"/> | ||
| <property name="strict_class_file_names" value="false"/> | ||
| </properties> | ||
| <exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/> | ||
| </rule> | ||
|
|
||
| <rule ref="WordPress.WP.I18n"> | ||
| <properties> | ||
| <property name="text_domain" type="array" value="beans-child" /> | ||
| </properties> | ||
| </rule> | ||
| </ruleset> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd" | ||
| bootstrap="tests/phpunit/unit/bootstrap.php" | ||
| backupGlobals="false" | ||
| colors="true" | ||
| beStrictAboutCoversAnnotation="true" | ||
| beStrictAboutOutputDuringTests="true" | ||
| beStrictAboutTestsThatDoNotTestAnything="true" | ||
| beStrictAboutTodoAnnotatedTests="true" | ||
| convertErrorsToExceptions="true" | ||
| convertNoticesToExceptions="true" | ||
| convertWarningsToExceptions="true" | ||
| verbose="true"> | ||
|
|
||
| <testsuites> | ||
| <testsuite name="unit"> | ||
| <directory suffix=".php">./tests/phpunit/unit/</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <filter> | ||
| <whitelist processUncoveredFilesFromWhitelist="true"> | ||
| <directory suffix=".php">.</directory> | ||
| </whitelist> | ||
| </filter> | ||
| </phpunit> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| /* | ||
| Theme Name: Beans child | ||
| Description: Starter Child Theme for the Beans Theme. | ||
| Author: Beans | ||
| Author URI: http://www.getbeans.io | ||
| Template: tm-beans | ||
| Version: 1.0.0 | ||
| Text Domain: beans-child | ||
| License: GNU General Public License v2 or later | ||
| License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /* | ||
| * In this file, you may style your site using CSS or LESS as well as overwrite UIkit LESS variables. | ||
| * Make sure to enable development mode via the Admin->Appearance->Settings option while working on your website. LESS will then be processed on the fly. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest that we set up this
composer.jsonwith the same dependencies and scripts as in Beans. It would then give a developer the environment, s/he needs to start building a theme and writing tests.We could think of the child theme as the starting development environment for a new theme.