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 for 1.9.1-dev #486

Merged
merged 60 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
abaf98b
remove commented-out code
Jun 7, 2018
8ba1baa
fix indentation
Jun 7, 2018
e6888fa
templates: fix indentation
Jun 7, 2018
8ee4ef9
templates: escape output
Jun 7, 2018
cfbc80c
templates: fix spacing around :/;
Jun 7, 2018
3177f41
classes: PHPCBF spacing fixes
Jun 7, 2018
a230106
fix spelling of constructor method
Jun 7, 2018
1d60b54
fix yoda condition
Jun 7, 2018
2ed1caf
Merge branch 'master' into fix/phpcs
paulschreiber Jun 7, 2018
6d20b8d
Merge remote-tracking branch 'upstream/master' into fix/phpcs
Aug 3, 2018
7c6e25b
update composer.json with new phpcs/vipcs versions
Aug 3, 2018
379ddbd
add package-lock.json
Aug 3, 2018
a820435
add phpcs.xml
Aug 3, 2018
2f89a60
PHPCBF fixes
Aug 3, 2018
0485e97
PHPCS fixes
Aug 3, 2018
268daa4
update composer.json dependencies to use require-dev
paulschreiber Aug 7, 2018
0ca4449
phpcs.xml: remove trailing spaces from <rule/>
paulschreiber Aug 7, 2018
5767fb0
rename phpcs.xml to phpcs.xml.dist
paulschreiber Aug 7, 2018
14a4a9e
rename liveblog ruleset, per #486
paulschreiber Aug 7, 2018
15df6b2
update arguments, per #486
paulschreiber Aug 7, 2018
3cb354e
add VIPCS to travis configuration
paulschreiber Aug 9, 2018
f5aa5da
update phpcs.xml file with new ruleset names
paulschreiber Aug 9, 2018
5f4df54
use WordPress as main ruleset
paulschreiber Aug 13, 2018
a9e2c6c
use WordPress-Extra ruleset, not WordPress
paulschreiber Aug 14, 2018
1d5c891
Update the description to use the new "Vision" statement.
philipjohn Sep 28, 2018
3304f5c
Merge branch 'fix/phpcs' into fix/phpcs19
paulschreiber Sep 28, 2018
c518452
PHPCBF automatic fixes
paulschreiber Sep 28, 2018
957e027
update phpcs.xml to only check .php files
paulschreiber Sep 28, 2018
fdec543
use wp_strip_all_tags() instead of strip_tags()
paulschreiber Sep 28, 2018
01dbcd3
use Yoda condition
paulschreiber Sep 28, 2018
595fc00
amp: correctly escape attributes
paulschreiber Sep 28, 2018
1824a09
remove extra whitespace
paulschreiber Sep 28, 2018
fdb2a5f
remove unsued loop indexes
paulschreiber Sep 28, 2018
d4ef949
remove unsued variables
paulschreiber Sep 28, 2018
dd60f39
ignore unused variable warning
paulschreiber Sep 28, 2018
d3b9a49
use wp_json_encode() instead of json_encode()
paulschreiber Sep 28, 2018
f691036
adding missing parameters to get_liveblog_metadata() method signature
paulschreiber Sep 28, 2018
a05b0ea
define missing $entries_for_json variable
paulschreiber Sep 28, 2018
efc8a5d
Merge pull request #534 from Automattic/add/vision
philipjohn Oct 10, 2018
b848b9c
fix spelling error
Oct 12, 2018
9bd7f68
rework missing $entries_for_json fix
Oct 12, 2018
e49e6d9
simplify $index++ call
Oct 12, 2018
4302b8e
Merge remote-tracking branch 'upstream/master' into fix/phpcs
Oct 12, 2018
45487b4
add missing parameters to WPCOM_Liveblog::get_liveblog_metadata() call
Oct 15, 2018
493636f
use tabs for composer.json
Oct 16, 2018
a5eb3f4
update vipwpcs to 0.3.x
Oct 16, 2018
155f0a8
specify which PHPCS rules are being ignored
Oct 16, 2018
5e5deac
correctly escape data-param-url
Oct 16, 2018
333fa60
suppress warning for A8C_PROXIED_REQUEST
Oct 16, 2018
9ea949a
whitespace fixes
Oct 16, 2018
c40f38a
silence IncludingFile errors
Oct 16, 2018
02aa5cd
remove @return void comment
Oct 16, 2018
3d19db4
use Yoda condition for equality check
Oct 16, 2018
8eb2c5c
suppress superglobal warning
Oct 16, 2018
4059896
specify which PHPCS rules are being ignored
Oct 16, 2018
4ff5fa6
remove @return void comment
Oct 16, 2018
b76f50b
suppress wp_is_mobile() warning
Oct 16, 2018
c7926a6
remove unused variables
Oct 16, 2018
6ad73dd
remove global which conflict with parameter
Oct 16, 2018
40d4c27
Merge branch 'release/1.9.1' into fix/phpcs
philipjohn Oct 16, 2018
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ before_script:
- 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_DIR; fi
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/Automattic/VIP-Coding-Standards.git $SNIFFS_DIR; fi
# Install PHP Compatibility sniffs.
- if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_DIR/PHPCompatibility; fi
# Set install path for PHPCS sniffs.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[![Build Status](https://travis-ci.org/Automattic/liveblog.svg?branch=master)](https://travis-ci.org/Automattic/liveblog)

Quick and simple blogging for following fast-paced events.
Empowers website owners to provide rich and engaging live event coverage to a large, distributed audience.

## Description

Expand Down
6 changes: 3 additions & 3 deletions classes/class-wpcom-liveblog-amp-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WPCOM_Liveblog_AMP_Template {
*
* @return void
*/
public function __contrust() {
public function __construct() {
$this->theme_template_path = apply_filters( 'liveblog_amp_theme_template_path', $this->theme_template_path );
$this->plugin_template_path = apply_filters( 'liveblog_amp_plugin_template_path', $this->plugin_template_path );
}
Expand Down Expand Up @@ -75,14 +75,14 @@ public function render( $name, $variables = array() ) {
$path = $plugin;
}

if ( $path === false ) {
if ( false === $path ) {
return 'Template Not Found: ' . $name;
}

$this->data = $variables;

ob_start();
include $path;
include $path; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.IncludingFile
return ob_get_clean();
}

Expand Down
24 changes: 13 additions & 11 deletions classes/class-wpcom-liveblog-amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public static function load() {

/**
* AMP Setup by removing and adding new hooks.
*
* @return void
*/
public static function setup() {
// If we're not on an AMP page then bail.
Expand Down Expand Up @@ -112,7 +110,7 @@ public static function print_styles() {
* @return void
*/
public static function enqueue_styles() {
wp_enqueue_style( 'liveblog', plugin_dir_url( __DIR__ ) . 'assets/amp.css' );
wp_enqueue_style( 'liveblog', plugin_dir_url( __DIR__ ) . 'assets/amp.css', array(), WPCOM_Liveblog::VERSION );
}


Expand All @@ -138,7 +136,7 @@ public static function social_meta_tags() {

$entry = self::get_entry( $request->id, $post->ID );
$title = WPCOM_Liveblog_Entry::get_entry_title( $entry );
$description = strip_tags( $entry->content );
$description = wp_strip_all_tags( $entry->content );
$url = self::build_single_entry_permalink( amp_get_permalink( $post->ID ), $entry->id );
$image = self::get_entry_image( $entry );

Expand Down Expand Up @@ -191,7 +189,7 @@ public static function append_liveblog_to_metadata( $metadata, $post ) {
/**
* This filter is documented in liveblog.php
*/
$metadata = WPCOM_Liveblog::get_liveblog_metadata();
$metadata = WPCOM_Liveblog::get_liveblog_metadata( $metadata, $post );
}

return $metadata;
Expand Down Expand Up @@ -262,7 +260,8 @@ public static function build_single_entry( $entries, $request, $post_id ) {
}

$rendered = self::get_template(
'entry', array(
'entry',
array(
'single' => true,
'id' => $entry->id,
'content' => $entry->content,
Expand Down Expand Up @@ -315,7 +314,8 @@ public static function get_entry( $id, $post_id, $entries = false ) {
*/
public static function build_entries_feed( $entries, $request, $post_id ) {
$rendered = self::get_template(
'feed', array(
'feed',
array(
'entries' => self::filter_entries( $entries['entries'], $post_id ),
'post_id' => $post_id,
'page' => $entries['page'],
Expand Down Expand Up @@ -395,7 +395,7 @@ public static function get_pagination_links( $request, $pages, $post_id ) {

$links['prev'] = false;
if ( $request->page > 1 ) {
$keep_postion = ( (int) $request->page === 2 ) ? false : $request->last;
$keep_postion = ( 2 === (int) $request->page ) ? false : $request->last;
$links['prev'] = self::build_paged_permalink( $permalink, $request->page - 1, $keep_postion );
}

Expand All @@ -420,7 +420,8 @@ public static function build_paged_permalink( $permalink, $page, $last ) {
array(
'liveblog_page' => $page,
'liveblog_last' => $last,
), $permalink
),
$permalink
);
}

Expand All @@ -435,7 +436,8 @@ public static function build_single_entry_permalink( $permalink, $id ) {
return add_query_arg(
array(
'liveblog_id' => $id,
), $permalink
),
$permalink
);
}

Expand All @@ -458,6 +460,6 @@ public static function get_template( $name, $variables = array() ) {
*/
public static function is_amp_polling() {
// phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
return isset( $_GET[ self::AMP_UPDATE_QUERY_VAR ] );
return isset( $_GET[ self::AMP_UPDATE_QUERY_VAR ] ); // phpcs:ignore WordPress.VIP.SuperGlobalInputUsage.AccessDetected
}
}
2 changes: 1 addition & 1 deletion classes/class-wpcom-liveblog-cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function execute_auto_archive_housekeeping() {
array(
'order' => 'ASC',
'orderby' => 'ID',
'meta_key' => 'liveblog',
'meta_key' => 'liveblog', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
)
);

Expand Down
2 changes: 1 addition & 1 deletion classes/class-wpcom-liveblog-entry-embed-sdks.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static function enqueue() {
}

foreach ( self::$sdks as $name => $url ) {
wp_enqueue_script( $name, esc_url( $url ), false );
wp_enqueue_script( $name, esc_url( $url ), array(), WPCOM_Liveblog::VERSION, false );
}
}

Expand Down
4 changes: 2 additions & 2 deletions classes/class-wpcom-liveblog-entry-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function shortcode( $attr, $url = '', $comment = null ) {
$handlers = array_replace_recursive( $GLOBALS['wp_embed']->handlers, $this->handlers );
}
ksort( $handlers );
foreach ( $handlers as $priority => $handlers ) {
foreach ( $handlers as $id => $handler ) {
foreach ( $handlers as $handlers ) {
foreach ( $handlers as $handler ) {
if ( preg_match( $handler['regex'], $url, $matches ) && is_callable( $handler['callback'] ) ) {
$return = call_user_func( $handler['callback'], $matches, $attr, $url, $rawattr );
if ( false !== $return ) {
Expand Down
8 changes: 5 additions & 3 deletions classes/class-wpcom-liveblog-entry-extend-feature-authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function load() {
// generated author html back to the
// raw input format (e.g @author).
$this->revert_regex = implode(
'', array(
'',
array(
preg_quote( '<a href="', '~' ),
'[^"]+',
preg_quote( '" class="liveblog-author ', '~' ),
Expand Down Expand Up @@ -87,7 +88,8 @@ public function get_config( $config ) {
// config, after first allowing other plugins,
// themes, etc. to modify it as required
$config[] = apply_filters(
'liveblog_author_config', array(
'liveblog_author_config',
array(
'type' => 'ajax',
'cache' => 1000 * 60 * 30,
'url' => esc_url( $endpoint_url ),
Expand Down Expand Up @@ -198,7 +200,7 @@ public function add_author_class_to_entry( $classes, $class, $comment_id ) {
if ( WPCOM_Liveblog::KEY === $comment->comment_type ) {

// Grab all the prefixed classes applied.
preg_match_all( '/(?<!\w)' . preg_quote( $this->class_prefix ) . '\w+/', $comment->comment_content, $authors );
preg_match_all( '/(?<!\w)' . preg_quote( $this->class_prefix, '/' ) . '\w+/', $comment->comment_content, $authors );

// Append the first class to the classes array.
$classes = array_merge( $classes, $authors[0] );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function load() {
// generated author html back to the
// raw input format (e.g /key).
$this->revert_regex = implode(
'', array(
'',
array(
preg_quote( '<span class="liveblog-command ', '~' ),
preg_quote( $this->class_prefix_local, '~' ),
'([^"]+)',
Expand Down Expand Up @@ -103,7 +104,8 @@ public function get_config( $config ) {
// config, after first allowing other plugins,
// themes, etc. to modify it as required
$config[] = apply_filters(
'liveblog_command_config', array(
'liveblog_command_config',
array(
'trigger' => '/',
'data' => $this->get_commands(),
'displayKey' => false,
Expand Down
11 changes: 7 additions & 4 deletions classes/class-wpcom-liveblog-entry-extend-feature-emojis.php
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ public function load() {
// generated emoji html back to the
// raw input format (e.g :poop:).
$this->revert_regex = implode(
'', array(
'',
array(
preg_quote( '<img src="', '~' ),
preg_quote( $this->emoji_cdn, '~' ),
'[^"]+',
Expand Down Expand Up @@ -952,7 +953,8 @@ public function get_config( $config ) {
// config, after first allowing other plugins,
// themes, etc. to modify it as required
$config[] = apply_filters(
'liveblog_emoji_config', array(
'liveblog_emoji_config',
array(
'type' => 'static',
'data' => $emojis,
'search' => 'key',
Expand Down Expand Up @@ -984,7 +986,8 @@ public function map_emoji( $val, $key ) {
// Then pass it into a filter to allow plugins,
// themes, etc. to customise the output.
return apply_filters(
'liveblog_emoji_map', array(
'liveblog_emoji_map',
array(
'key' => $key,
'name' => $key,
'image' => strtolower( $val ),
Expand Down Expand Up @@ -1093,7 +1096,7 @@ public function add_emoji_class_to_entry( $classes, $class, $comment_id ) {
if ( WPCOM_Liveblog::KEY === $comment->comment_type ) {

// Grab all the prefixed classes applied.
preg_match_all( '/(?<!\w)' . preg_quote( $this->class_prefix ) . '\w+/', $comment->comment_content, $emojis );
preg_match_all( '/(?<!\w)' . preg_quote( $this->class_prefix, '/' ) . '\w+/', $comment->comment_content, $emojis );

// Append the first class to the classes array.
$classes = array_merge( $classes, $emojis[0] );
Expand Down
12 changes: 7 additions & 5 deletions classes/class-wpcom-liveblog-entry-extend-feature-hashtags.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function load() {
// generated hashtag html back to the
// raw input format (e.g #hashtag).
$this->revert_regex = implode(
'', array(
'',
array(
preg_quote( '<span class="liveblog-hash ', '~' ),
preg_quote( $this->class_prefix, '~' ),
'([^"]+)',
Expand Down Expand Up @@ -87,7 +88,8 @@ public function get_config( $config ) {
// config, after first allowing other plugins,
// themes, etc. to modify it as required
$config[] = apply_filters(
'liveblog_hashtag_config', array(
'liveblog_hashtag_config',
array(
'type' => 'ajax',
'cache' => 1000 * 60,
'regex' => '#([\w\d\-]*)$',
Expand Down Expand Up @@ -142,7 +144,7 @@ public function preg_replace_callback( $match ) {

// If it doesn't exist, then make it.
if ( ! get_term_by( 'slug', $hashtag, self::$taxonomy ) ) {
$error = wp_insert_term( $hashtag, self::$taxonomy );
wp_insert_term( $hashtag, self::$taxonomy );
}

// Replace the #hashtag content with a styled
Expand Down Expand Up @@ -180,7 +182,7 @@ public function add_term_class_to_entry( $classes, $class, $comment_id ) {
if ( WPCOM_Liveblog::KEY === $comment->comment_type ) {

// Grab all the prefixed classes applied.
preg_match_all( '/(?<!\w)' . preg_quote( $this->class_prefix ) . '(\w\-?)+/', $comment->comment_content, $terms );
preg_match_all( '/(?<!\w)' . preg_quote( $this->class_prefix, '/' ) . '(\w\-?)+/', $comment->comment_content, $terms );

// Append the first class to the classes array.
$classes = array_merge( $classes, $terms[0] );
Expand Down Expand Up @@ -259,7 +261,7 @@ public function remove_name_search( $clauses ) {
// Remove the where clause's section about the name.
$clauses['where'] = preg_replace(
array(
'~\\(\\(.*(?=' . preg_quote( "(t.slug LIKE '" ) . ')~',
'~\\(\\(.*(?=' . preg_quote( "(t.slug LIKE '", '~' ) . ')~',
'~(%\'\\))\\)~',
),
'($1',
Expand Down
22 changes: 11 additions & 11 deletions classes/class-wpcom-liveblog-entry-key-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ public static function render_key_template( $entry, $object ) {
// Get the entry content
$content = $object->get_content();

// Use the currently set template.
$template = self::get_current_template( $post_id );

// Set if key event
$entry['key_event'] = self::is_key_event( $entry['id'] );

Expand Down Expand Up @@ -219,7 +216,8 @@ public static function add_admin_options( $extra_fields, $post_id ) {

// Add the custom template fields to the editor.
$extra_fields[] = WPCOM_Liveblog::get_template_part(
'liveblog-key-admin.php', array(
'liveblog-key-admin.php',
array(
'current_key_template' => get_post_meta( $post_id, self::META_KEY_TEMPLATE, true ),
'current_key_format' => get_post_meta( $post_id, self::META_KEY_FORMAT, true ),
'current_key_limit' => get_post_meta( $post_id, self::META_KEY_LIMIT, true ),
Expand Down Expand Up @@ -307,7 +305,7 @@ public static function format_content_first_sentence( $content ) {
$content = preg_replace( '/(.*?[?!.](?=\s|$)).*/', '\\1', $content );

// Strip it of all non-accepted tags.
$content = strip_tags( $content, '<strong></strong><em></em><span></span><img>' );
$content = wp_strip_all_tags( $content, '<strong></strong><em></em><span></span><img>' );

return $content;
}
Expand All @@ -328,7 +326,7 @@ public static function format_content_first_linebreak( $content ) {
$content = explode( '<br />', $content );

// Strip it of all non-accepted tags.
$content = strip_tags( $content[0], '<strong></strong><em></em><span></span><img>' );
$content = wp_strip_all_tags( $content[0], '<strong></strong><em></em><span></span><img>' );

return $content;
}
Expand All @@ -350,13 +348,14 @@ public static function shortcode( $atts ) {
$atts = shortcode_atts(
array(
'title' => 'Key Events',
), $atts
),
$atts
);

// The args to pass into the entry query.
$args = array(
'meta_key' => self::META_KEY,
'meta_value' => self::META_VALUE,
'meta_key' => self::META_KEY, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
'meta_value' => self::META_VALUE, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value
);

$limit = get_post_meta( $post->ID, self::META_KEY_LIMIT, true );
Expand All @@ -378,7 +377,8 @@ public static function shortcode( $atts ) {

// Render the actual template.
return WPCOM_Liveblog::get_template_part(
'liveblog-key-events.php', array(
'liveblog-key-events.php',
array(
'entries' => $entries,
'title' => $atts['title'],
'template' => $template[0],
Expand All @@ -398,7 +398,7 @@ public static function all() {
$query = new WPCOM_Liveblog_Entry_Query( WPCOM_Liveblog::$post_id, WPCOM_Liveblog::KEY );
$key_events = $query->get(
array(
'meta_query' => array(
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
array(
'key' => self::META_KEY,
'value' => self::META_VALUE,
Expand Down
3 changes: 1 addition & 2 deletions classes/class-wpcom-liveblog-entry-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
class WPCOM_Liveblog_Entry_Query {

public function __construct( $post_id, $key ) {
global $wp_version;
$this->post_id = $post_id;
$this->key = $key;
}
Expand Down Expand Up @@ -44,7 +43,7 @@ public function get_all_edits( $args = array() ) {
$defaults = array(
'orderby' => 'comment_date_gmt',
'order' => 'ASC',
'meta_key' => 'liveblog_replaces',
'meta_key' => 'liveblog_replaces', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
'status' => 'liveblog',
);

Expand Down
Loading