Skip to content

Commit

Permalink
Merge branch 'release/1.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
philipjohn committed Oct 17, 2018
2 parents ddfb1c6 + eb05841 commit e5dc952
Show file tree
Hide file tree
Showing 43 changed files with 14,105 additions and 428 deletions.
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ matrix:
env:
- SNIFF=1
- WP_VERSION=latest
# aliased to a recent hhvm version
- php: 'hhvm'
env: WP_VERSION=latest

allow_failures:
- php: 'hhvm'

before_script:
# Set up CodeSniffer
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.9.1

* Multiple coding standards fixes
* Removes unused debug code
* Fix rendering embeds upon entry updates
* Avoid null dereference in `get_user_data_for_json()`
* Improvements to code review process

props, [cain](https://github.com/cain), [GaryJones](https://github.com/GaryJones), [maevelander](https://github.com/maevelander), [paulschreiber](https://github.com/paulschreiber), [philipjohn](https://github.com/philipjohn), [rgllm](https://github.com/rgllm), [rogertheriault](https://github.com/rogertheriault)

## 1.9

* Round out polling timestamp for improved performance (#496)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Requires at least: 4.4
* Requires PHP: 5.6
* Tested up to: 4.9.8
* Stable tag: 1.9
* Stable tag: 1.9.1
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
2 changes: 1 addition & 1 deletion assets/app.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 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 All @@ -94,6 +94,6 @@ public function render( $name, $variables = array() ) {
* @return void
*/
public function load_part( $name, $variables = array() ) {
echo WPCOM_Liveblog_AMP::get_template( $name, $variables );
echo WPCOM_Liveblog_AMP::get_template( $name, $variables ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
26 changes: 14 additions & 12 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 @@ -103,7 +101,7 @@ public static function add_social_share_options() {
* @return void
*/
public static function print_styles() {
include dirname( __DIR__ ) . '/assets/amp.css';
echo esc_html( file_get_contents( dirname( __DIR__ ) . '/assets/amp.css' ) );
}

/**
Expand All @@ -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
Loading

0 comments on commit e5dc952

Please sign in to comment.