Skip to content

Commit

Permalink
AN-152 Version bump to v1.4.4, upgrade Travis and phpcs (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinfodness authored May 3, 2019
1 parent 84cfcd4 commit 03009e7
Show file tree
Hide file tree
Showing 21 changed files with 251 additions and 142 deletions.
82 changes: 50 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Tell Travis to use new container-based infrastructure
sudo: false
# Travis CI (MIT License) configuration file for Publish to Apple News
# @link https://travis-ci.org/

# Xenial image has PHP versions 5.6,7.1,7.2 pre-installed
dist: xenial

# Xenial does not start mysql by default
services:
- mysql
- memcached

# Declare project language.
# @link http://about.travis-ci.org/docs/user/languages/php/
Expand All @@ -10,23 +18,29 @@ branches:
only:
- master

cache:
directories:
- $HOME/.composer/cache
- ./vendor
- node_modules

# Git clone depth.
git:
depth: 1

matrix:
fast_finish: true
include:
- php: 5.6
- php: 7.2
env: WP_VERSION=latest PHP_LINT=1 WP_PHPCS=1
- php: 7.1
env: WP_VERSION=latest PHP_LINT=1
- php: 7.0
env: WP_VERSION=latest PHP_LINT=1
- php: 7.1
- php: 5.6
env: WP_VERSION=latest PHP_LINT=1
- php: 7.2
env: WP_VERSION=latest PHP_LINT=1 WP_PHPCS=1
- php: 7.2
env: WP_VERSION=nightly
fast_finish: true

# Use this to prepare your build for testing.
# e.g. copy database configurations, environment variables, etc.
Expand Down Expand Up @@ -55,37 +69,41 @@ before_script:

# Install Composer dependencies.
- composer install
- export PATH=$PATH:`pwd`/vendor/bin/
- phpenv rehash

# For debugging.
- which phpunit
- phpunit --version
- which phpcs
- phpcs --version
- pwd
- echo $PATH
# Set up phpcs.
- |
if [[ "$WP_PHPCS" == "1" ]] ; then
composer global require automattic/vipwpcs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/automattic/vipwpcs
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.
#
# Only need to run this once per PHP version.
- if [[ "$PHP_LINT" == "1" ]]; then find . -type "f" -iname "*.php" -not -path "./vendor/*" | xargs -L "1" php -l; fi

# WordPress Coding Standards.
#
# These are the same across PHP and WordPress, so we need to run them only once.
#
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
- if [[ "$WP_PHPCS" == "1" ]]; then phpcs -v; fi

# Test the plugin's unit tests
- phpunit
- phpunit -c multisite.xml
# Search for PHP syntax errors.
#
# Only need to run this once per PHP version.
- |
if [[ "$PHP_LINT" == "1" ]] ; then
find . -type "f" -iname "*.php" -not -path "./vendor/*" | xargs -L "1" php -l
fi
# WordPress Coding Standards.
#
# These are the same across PHP and WordPress, so we need to run them only once.
#
# @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
- |
if [[ "$WP_PHPCS" == "1" ]] ; then
phpcs
fi
# Run the plugin's unit tests, both in single and multisite.
- |
if [[ ! -z "$WP_VERSION" ]] ; then
phpunit
WP_MULTISITE=1 phpunit
fi
# Receive notifications for build results.
# @link http://docs.travis-ci.com/user/notifications/#Email-notifications
Expand Down
3 changes: 2 additions & 1 deletion admin/class-admin-apple-async.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function async_push( $post_id, $user_id ) {
// translators: token is the post title.
__( 'Article %s is no longer published and cannot be pushed to Apple News.', 'apple-news' ),
$post->post_title
), $user_id
),
$user_id
);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion admin/class-admin-apple-index-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,9 @@ public function setup_assets( $hook ) {

// Localize strings.
wp_localize_script(
$this->plugin_slug . '_export_table_js', 'apple_news_export_table', array(
$this->plugin_slug . '_export_table_js',
'apple_news_export_table',
array(
'reset_confirmation' => __( "Are you sure you want to reset status? Please only proceed if you're certain the post is stuck or this could reset in duplicate posts in Apple News.", 'apple-news' ),
'delete_confirmation' => __( 'Are you sure you want to delete this post from Apple News?', 'apple-news' ),
)
Expand Down
4 changes: 3 additions & 1 deletion admin/class-admin-apple-meta-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ public function register_assets( $hook ) {

// Localize the JS file for meta boxes.
wp_localize_script(
$this->plugin_slug . '_meta_boxes_js', 'apple_news_meta_boxes', array(
$this->plugin_slug . '_meta_boxes_js',
'apple_news_meta_boxes',
array(
'publish_action' => self::PUBLISH_ACTION,
)
);
Expand Down
19 changes: 13 additions & 6 deletions admin/class-admin-apple-news-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,15 @@ public function column_title( $item ) {

// Return the row action HTML.
return apply_filters(
'apple_news_column_title', sprintf(
'apple_news_column_title',
sprintf(
'%1$s <span>(id:%2$s)</span> %3$s',
esc_html( $item->post_title ),
absint( $item->ID ),
$this->row_actions( $actions ) // Can't be escaped but all elements are fully escaped above.
), $item, $actions
),
$item,
$actions
);
}

Expand All @@ -245,7 +248,8 @@ public function column_title( $item ) {
*/
public function get_columns() {
return apply_filters(
'apple_news_export_list_columns', array(
'apple_news_export_list_columns',
array(
'cb' => '<input type="checkbox">',
'title' => __( 'Title', 'apple-news' ),
'updated_at' => __( 'Last updated at', 'apple-news' ),
Expand Down Expand Up @@ -286,7 +290,8 @@ public function column_cb( $item ) {
*/
public function get_bulk_actions() {
return apply_filters(
'apple_news_bulk_actions', array(
'apple_news_bulk_actions',
array(
Admin_Apple_Index_Page::namespace_action( 'push' ) => __( 'Publish', 'apple-news' ),
)
);
Expand Down Expand Up @@ -402,7 +407,8 @@ public function prepare_items() {
$total_items = $query->found_posts;
$this->set_pagination_args(
apply_filters(
'apple_news_export_table_pagination_args', array(
'apple_news_export_table_pagination_args',
array(
'total_items' => $total_items,
'per_page' => $this->per_page,
'total_pages' => ceil( $total_items / $this->per_page ),
Expand Down Expand Up @@ -496,7 +502,8 @@ protected function get_search_filter() {
protected function publish_status_filter_field() {
// Add available statuses.
$publish_statuses = apply_filters(
'apple_news_publish_statuses', array(
'apple_news_publish_statuses',
array(
'' => __( 'Show All Statuses', 'apple-news' ),
'published' => __( 'Published', 'apple-news' ),
'not_published' => __( 'Not Published', 'apple-news' ),
Expand Down
14 changes: 10 additions & 4 deletions admin/class-admin-apple-themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,12 @@ public function page_themes_render() {
*/
public function register_assets( $hook ) {
if ( ! in_array(
$hook, array(
$hook,
array(
'apple-news_page_apple-news-themes',
'admin_page_apple-news-theme-edit',
), true
),
true
) ) {
return;
}
Expand All @@ -336,7 +338,9 @@ public function register_assets( $hook ) {
);

wp_localize_script(
'apple-news-themes-js', 'appleNewsThemes', array(
'apple-news-themes-js',
'appleNewsThemes',
array(
'deleteWarning' => __( 'Are you sure you want to delete the theme', 'apple-news' ),
'noNameError' => __( 'Please enter a name for the new theme.', 'apple-news' ),
'tooLongError' => __( 'Theme names must be 45 characters or less.', 'apple-news' ),
Expand Down Expand Up @@ -381,7 +385,9 @@ public function register_assets( $hook ) {
);

wp_localize_script(
'apple-news-theme-edit-js', 'appleNewsThemeEdit', array(
'apple-news-theme-edit-js',
'appleNewsThemeEdit',
array(
'fontNotice' => __( 'Font preview is only available on macOS', 'apple-news' ),
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ public function __construct( $page ) {

// Build the post types to display.
$post_types = apply_filters(
'apple_news_post_types', get_post_types(
'apple_news_post_types',
get_post_types(
array(
'public' => true,
'show_ui' => true,
), 'objects'
),
'objects'
)
);

Expand Down
2 changes: 1 addition & 1 deletion apple-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Publish to Apple News
* Plugin URI: http://github.com/alleyinteractive/apple-news
* Description: Export and sync posts to Apple format.
* Version: 1.4.3
* Version: 1.4.4
* Author: Alley Interactive
* Author URI: https://www.alleyinteractive.com
* Text Domain: apple-news
Expand Down
9 changes: 1 addition & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
"composer/installers": "~1.0"
},
"require-dev": {
"phpspec/prophecy": "~1.0",
"squizlabs/php_codesniffer": "3.*",
"wp-coding-standards/wpcs": "^1.0.0",
"automattic/vipwpcs": "^0.2.4"
},
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths $PWD/vendor/wp-coding-standards/wpcs,$PWD/vendor/automattic/vipwpcs",
"post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths $PWD/vendor/wp-coding-standards/wpcs,$PWD/vendor/automattic/vipwpcs"
"phpspec/prophecy": "~1.0"
}
}
3 changes: 2 additions & 1 deletion includes/apple-exporter/builders/class-component-layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public function set_anchor_layout_for( $component ) {

// Finally, register the layout.
$this->register_layout(
$layout_name, array(
$layout_name,
array(
'columnStart' => $col_start,
'columnSpan' => $col_span,
)
Expand Down
6 changes: 4 additions & 2 deletions includes/apple-exporter/builders/class-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ protected function build() {
$theme = \Apple_Exporter\Theme::get_used();

return apply_filters(
'apple_news_layout', array(
'apple_news_layout',
array(
'columns' => intval( $theme->get_layout_columns() ),
'width' => intval( $theme->get_value( 'layout_width' ) ),
'margin' => intval( $theme->get_value( 'layout_margin' ) ), // Defaults to 100.
'gutter' => intval( $theme->get_value( 'layout_gutter' ) ), // Defaults to 20.
), $this->content_id()
),
$this->content_id()
);
}

Expand Down
9 changes: 6 additions & 3 deletions includes/apple-exporter/builders/class-text-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ private function add_html_styles() {

// Add style for <code> tags.
$this->register_style(
'default-tag-code', array(
'default-tag-code',
array(
'fontName' => $theme->get_value( 'monospaced_font' ),
'fontSize' => intval( $theme->get_value( 'monospaced_size' ) ),
'tracking' => intval( $theme->get_value( 'monospaced_tracking' ) ) / 100,
Expand All @@ -106,7 +107,8 @@ private function add_html_styles() {

// Add style for <pre> tags.
$this->register_style(
'default-tag-pre', array(
'default-tag-pre',
array(
'textAlignment' => 'left',
'fontName' => $theme->get_value( 'monospaced_font' ),
'fontSize' => intval( $theme->get_value( 'monospaced_size' ) ),
Expand All @@ -120,7 +122,8 @@ private function add_html_styles() {

// Add style for <samp> tags.
$this->register_style(
'default-tag-samp', array(
'default-tag-samp',
array(
'fontName' => $theme->get_value( 'monospaced_font' ),
'fontSize' => intval( $theme->get_value( 'monospaced_size' ) ),
'tracking' => intval( $theme->get_value( 'monospaced_tracking' ) ) / 100,
Expand Down
8 changes: 4 additions & 4 deletions includes/apple-exporter/class-exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class Exporter {
* @access public
*/
public function __construct( $content, $workspace = null, $settings = null ) {
$this->content = $content;
$this->workspace = $workspace ?: new Workspace( $this->content_id() );
$this->settings = $settings ?: new Settings();
$this->builders = array();
$this->content = $content;
$this->workspace = $workspace ?: new Workspace( $this->content_id() );
$this->settings = $settings ?: new Settings();
$this->builders = array();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public function tiled_gallery() {
* builtin handling for the default WP galleries.
*/
add_filter(
'jetpack_tiled_gallery_types', function() {
'jetpack_tiled_gallery_types',
function() {
return array();
}
);
Expand Down
5 changes: 3 additions & 2 deletions includes/apple-push-api/request/class-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public function __construct( $credentials, $debug = false, $mime_builder = null

// Set the default WordPress HTTP API args.
$this->default_args = apply_filters(
'apple_news_request_args', array(
'apple_news_request_args',
array(
'reject_unsafe_urls' => true,
'timeout' => 5,
)
Expand Down Expand Up @@ -246,7 +247,7 @@ private function parse_response( $response, $json = true, $type = 'post', $meta
*
* See https://developer.wordpress.org/reference/functions/wp_mail/ for documentation and examples.
*
* @since x.x.x
* @since 1.4.4
*
* @param string|array $headers Optional. Additional headers.
*/
Expand Down
Loading

0 comments on commit 03009e7

Please sign in to comment.