Skip to content
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

PHPCS fixes #3

Merged
merged 5 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Travis CI configuration file for Hogan.
# @link https://travis-ci.org/

# Ditch sudo and use containers.
# @link https://docs.travis-ci.com/user/migrating-from-legacy/#Why-migrate-to-container-based-infrastructure%3F
# @link https://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure
sudo: false
dist: trusty

# Declare project language.
# @link https://about.travis-ci.org/docs/user/languages/php/
language: php

# Declare versions of PHP to use. Use one decimal max.
# @link https://docs.travis-ci.com/user/build-configuration/
matrix:
fast_finish: true

include:
# aliased to a recent 7.0.x version
- php: '7.0'
env:
- SNIFF="1"
# aliased to a recent 7.2.x version
- php: '7.2'
env:
- SNIFF="1"

# Use this to prepare your build for testing.
# Failures in this section will result in build status 'errored'.
before_script:
- export PHPCS_DIR=/tmp/phpcs
- export SNIFFS_WPCS_DIR=/tmp/sniffs_wpcs
- export SNIFFS_PHPCOMPATIBILITY_DIR=/tmp/sniffs_phpcompataibility
# Install CodeSniffer for WordPress Coding Standards checks.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi
# Install WordPress Coding Standards.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_WPCS_DIR; fi
# Install PHP Compatibility.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_PHPCOMPATIBILITY_DIR; fi
# Set install path for PHPCS sniffs.
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs --config-set installed_paths $SNIFFS_WPCS_DIR,$SNIFFS_PHPCOMPATIBILITY_DIR; fi
# After CodeSniffer install you should refresh your path.
- if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi

# Run test script commands.
# Default is specific to project language.
# All commands must exit with code 0 on success. Anything else is considered failure.
script:
# Search for PHP syntax errors.
- find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
# WordPress Coding Standards.
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
# @link https://pear.php.net/package/PHP_CodeSniffer/
# Uses a custom ruleset based on WordPress.
- if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs -p -s -v . --standard=./phpcs.xml --extensions=php --runtime-set testVersion $TRAVIS_PHP_VERSION; fi

# Receive notifications for build results.
# @link https://docs.travis-ci.com/user/notifications/#Email-notifications
notifications:
email: false
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## master
#### :boom: Breaking Change
* [#2](https://github.com/DekodeInteraktiv/hogan-banner/pull/2) Heading classname changed from `.heading .alpha` to `.hogan-heading`
* [#1](https://github.com/DekodeInteraktiv/hogan-banner/pull/1) Button classname changed from `.button` to `.hogan-button`

### :house: Internal
* [#3](https://github.com/DekodeInteraktiv/hogan-banner/pull/3) Added Travis-CI config
* [#2](https://github.com/DekodeInteraktiv/hogan-banner/pull/2) Late escaping
* [#2](https://github.com/DekodeInteraktiv/hogan-banner/pull/2) Use core heading component on heading
* [#1](https://github.com/DekodeInteraktiv/hogan-banner/pull/1) Use core button component to print out call to action button

## 1.0.5
#### :nail_care: Enhancement
* Added filters

### :house: Internal
* Text content is no longer required
26 changes: 11 additions & 15 deletions class-banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package Hogan
*/

declare( strict_types=1 );
declare( strict_types = 1 );

namespace Dekode\Hogan;

Expand Down Expand Up @@ -57,10 +57,6 @@ class Banner extends Module {
*/
public $call_to_action = null;

/**************/
/***SETTINGS***/
/**************/

/**
* Image size for one column or span both columns
*
Expand Down Expand Up @@ -140,7 +136,7 @@ public function get_fields(): array {
'mime_types' => '',
];

// Merge $args from filter with $defaults
// Merge $args from filter with $defaults.
$constraints_args = wp_parse_args( apply_filters( 'hogan/module/banner/image/constraints', [] ), $constraints_defaults );

$fields = [
Expand Down Expand Up @@ -214,7 +210,7 @@ public function get_fields(): array {
'name' => 'image_size',
'label' => __( 'Image Size', 'hogan-banner' ),
'value' => is_array( $image_size_choices ) && ! empty( $image_size_choices ) ? reset( $image_size_choices ) : null,
// Use the first key in the choices array (default = square)
// Use the first key in the choices array (default = square).
'instructions' => __( 'Choose image size', 'hogan-banner' ),
'choices' => $image_size_choices,
'layout' => 'horizontal',
Expand All @@ -226,12 +222,12 @@ public function get_fields(): array {
'name' => 'text_position_square',
'label' => __( 'Text Position', 'hogan-banner' ),
'value' => is_array( $text_position_choices_square ) && ! empty( $text_position_choices_square ) ? reset( $text_position_choices_square ) : null,
// Use the first key in the choices array (default = left)
// Use the first key in the choices array (default = left).
'instructions' => __( 'Choose text position', 'hogan-banner' ),
'choices' => $text_position_choices_square,
'layout' => 'horizontal',
'return_format' => 'value',
'conditional_logic' => [ //FIXME: Will not work if choice for text position is changed with filter
'conditional_logic' => [ // Will not work if choice for text position is changed with filter.
[
[
'field' => $this->field_key . '_image_size',
Expand All @@ -247,12 +243,12 @@ public function get_fields(): array {
'name' => 'text_position_large',
'label' => __( 'Text Position', 'hogan-banner' ),
'value' => is_array( $text_position_choices_large ) && ! empty( $text_position_choices_large ) ? reset( $text_position_choices_large ) : null,
// Use the first key in the choices array (default = left)
// Use the first key in the choices array (default = left).
'instructions' => __( 'Choose text position', 'hogan-banner' ),
'choices' => $text_position_choices_large,
'layout' => 'horizontal',
'return_format' => 'value',
'conditional_logic' => [ //FIXME: Will not work if choice for text position is changed with filter
'conditional_logic' => [ // Will not work if choice for text position is changed with filter.
[
[
'field' => $this->field_key . '_image_size',
Expand All @@ -268,12 +264,12 @@ public function get_fields(): array {
'name' => 'background_color',
'label' => __( 'Background Color', 'hogan-banner' ),
'value' => is_array( $background_color_choices ) && ! empty( $background_color_choices ) ? reset( $background_color_choices ) : null,
// Use the first key in the choices array (default = light)
// Use the first key in the choices array (default = light).
'instructions' => __( 'Choose background color for the text field', 'hogan-banner' ),
'choices' => $background_color_choices,
'layout' => 'horizontal',
'return_format' => 'value',
'conditional_logic' => [ //FIXME: Will not work if choice for image size is changed with filter
'conditional_logic' => [ // Will not work if choice for image size is changed with filter.
[
[
'field' => $this->field_key . '_image_size',
Expand All @@ -289,7 +285,7 @@ public function get_fields(): array {
'label' => __( 'Overlay Opacity', 'hogan-banner' ),
'name' => 'overlay_opacity',
'instructions' => __( 'Choose opacity value for overlay behind text', 'hogan-banner' ),
'conditional_logic' => [ //FIXME: Will not work if choice for image size is changed with filter
'conditional_logic' => [ // Will not work if choice for image size is changed with filter.
[
[
'field' => $this->field_key . '_image_size',
Expand All @@ -312,7 +308,7 @@ public function get_fields(): array {
* Map raw fields from acf to object variable.
*
* @param array $raw_content Content values.
* @param int $counter Module location in page layout.
* @param int $counter Module location in page layout.
*
* @return void
*/
Expand Down
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
<rule ref="WordPress-Docs" />
<rule ref="WordPress-Extra" />
<rule ref="WordPress-VIP" />
<rule ref="PHPCompatibility" />
</ruleset>