Skip to content

Commit

Permalink
Fix phpcs errors raised by latest WP CS using phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
thelovekesh committed Sep 3, 2023
1 parent baebb51 commit 5499f6f
Show file tree
Hide file tree
Showing 105 changed files with 326 additions and 364 deletions.
2 changes: 1 addition & 1 deletion amp.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

define( 'AMP__FILE__', __FILE__ );
define( 'AMP__DIR__', dirname( __FILE__ ) );
define( 'AMP__DIR__', __DIR__ );
define( 'AMP__VERSION', '2.4.3-alpha' );

/**
Expand Down
2 changes: 1 addition & 1 deletion back-compat/templates-v0-3/style.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
.amp-wp-content, .amp-wp-title-bar div {
<?php $content_max_width = absint( $this->get( 'content_max_width' ) ); ?>
<?php if ( $content_max_width > 0 ) : ?>
max-width: <?php echo sprintf( '%dpx', $content_max_width ); ?>;
max-width: <?php printf( '%dpx', $content_max_width ); ?>;
margin: 0 auto;
<?php endif; ?>
}
Expand Down
2 changes: 1 addition & 1 deletion bin/add-test-widgets-to-sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ function amp_create_widget( $widget ) {
$number = max( array_keys( $widgets ) );
$number = max( 1, $number );
}
$number++;
++$number;
$widgets[ $number ] = $settings;
update_option( $option_key, $widgets );
}
Expand Down
4 changes: 2 additions & 2 deletions bin/verify-version-consistency.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

$versions = [];

$readme_md = file_get_contents( dirname( __FILE__ ) . '/../README.md' );
$readme_md = file_get_contents( __DIR__ . '/../README.md' );
if ( ! preg_match( '/\*\*Stable tag:\*\*\s+(?P<version>\S+)/i', $readme_md, $matches ) ) {
echo "Could not find stable tag in readme\n";
exit( 1 );
}
$versions['README.md#stable-tag'] = $matches['version'];

$plugin_file = file_get_contents( dirname( __FILE__ ) . '/../amp.php' );
$plugin_file = file_get_contents( __DIR__ . '/../amp.php' );
if ( ! preg_match( '/\*\s*Version:\s*(?P<version>\d+\.\d+(?:.\d+)?(-\w+)?)/', $plugin_file, $matches ) ) {
echo "Could not find version in readme metadata\n";
exit( 1 );
Expand Down
2 changes: 1 addition & 1 deletion docs/src/Cli/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __invoke( $args, $assoc_args ) {
foreach ( $iterator as $file ) {
if ( unlink( $file ) ) {
WP_CLI::line( "Cleaned: $file" );
$cleaned_count++;
++$cleaned_count;
} else {
WP_CLI::warning( "Failed to clean: $file" );
}
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-amp-admin-pointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function enqueue() {

add_action(
'admin_print_footer_scripts',
function() {
function () {
$this->print_js();
}
);
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/class-amp-admin-pointers.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function get_pointers() {
'position' => [
'align' => 'middle',
],
'active_callback' => static function() {
'active_callback' => static function () {
return version_compare( strtok( AMP__VERSION, '-' ), '1.1', '<' );
},
]
Expand Down
2 changes: 1 addition & 1 deletion includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static function () use ( $old_version ) {

add_action(
'rest_api_init',
static function() {
static function () {
$reader_themes = new ReaderThemes();

$reader_theme_controller = new AMP_Reader_Theme_REST_Controller( $reader_themes );
Expand Down
1 change: 0 additions & 1 deletion includes/class-amp-comment-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function start_el( &$output, $comment, $depth = 0, $args = [], $id = 0 )
}

$output .= $new_tag . substr( ltrim( $new_out ), strlen( $tag ) );

}

/**
Expand Down
6 changes: 3 additions & 3 deletions includes/class-amp-service-worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static function add_cdn_script_caching( $service_workers ) {
// Add AMP scripts to runtime cache which will then get stale-while-revalidate strategy.
$service_workers->register(
'amp-cdn-runtime-caching',
static function() {
static function () {
$urls = AMP_Service_Worker::get_precached_script_cdn_urls();
if ( empty( $urls ) ) {
return '';
Expand Down Expand Up @@ -356,8 +356,8 @@ public static function handle_service_worker_iframe_install() {
// Die in a way that can be unit tested.
add_filter(
'wp_die_handler',
static function() {
return static function() {
static function () {
return static function () {
die();
};
},
Expand Down
18 changes: 9 additions & 9 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public static function finish_init() {

add_filter(
'template_include',
static function() {
static function () {
return AMP__DIR__ . '/includes/templates/reader-template-loader.php';
},
PHP_INT_MAX
Expand Down Expand Up @@ -859,21 +859,21 @@ public static function add_hooks() {
// Prevent MediaElement.js scripts/styles from being enqueued.
add_filter(
'wp_video_shortcode_library',
static function() {
static function () {
return 'amp';
}
);
add_filter(
'wp_audio_shortcode_library',
static function() {
static function () {
return 'amp';
}
);

// Don't show loading indicator on custom logo since it makes most sense for larger images.
add_filter(
'get_custom_logo',
static function( $html ) {
static function ( $html ) {
return preg_replace( '/(?<=<img\s)/', ' data-amp-noloading="" ', $html );
},
1
Expand All @@ -900,7 +900,7 @@ static function( $html ) {
add_filter( 'get_header_image_tag', [ __CLASS__, 'amend_header_image_with_video_header' ], PHP_INT_MAX );
add_action(
'wp_print_footer_scripts',
static function() {
static function () {
wp_dequeue_script( 'wp-custom-header' );
},
0
Expand Down Expand Up @@ -1243,14 +1243,14 @@ public static function init_admin_bar() {
// Emulate customize support script in PHP, to assume Customizer.
add_action(
'admin_bar_menu',
static function() {
static function () {
remove_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' );
},
41
);
add_filter(
'body_class',
static function( $body_classes ) {
static function ( $body_classes ) {
return array_merge(
array_diff(
$body_classes,
Expand Down Expand Up @@ -1570,7 +1570,7 @@ public static function ensure_required_markup( Document $dom, $script_handles =
$extension_specs[ $extension_name ]['bento']['version']
)
);
$bento_extension_count++;
++$bento_extension_count;
}
}

Expand Down Expand Up @@ -2132,7 +2132,7 @@ public static function prepare_response( $response, $args = [] ) {

if ( count( $errors ) > 0 ) {
$error_messages = array_map(
static function( Optimizer\Error $error ) {
static function ( Optimizer\Error $error ) {
return ' - ' . $error->getCode() . ': ' . $error->getMessage();
},
iterator_to_array( $errors )
Expand Down
8 changes: 4 additions & 4 deletions includes/embeds/class-amp-core-block-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function filter_rendered_block( $block_content, $block ) {
*/
public function ampify_categories_block( $block_content ) {
static $block_id = 0;
$block_id++;
++$block_id;

$form_id = "wp-block-categories-dropdown-{$block_id}-form";

Expand Down Expand Up @@ -186,7 +186,7 @@ public function ampify_archives_block( $block_content ) {

// Eliminate use of uniqid(). Core should be using wp_unique_id() here.
static $block_id = 0;
$block_id++;
++$block_id;
$block_content = preg_replace( '/(?<="wp-block-archives-)\w+(?=")/', $block_id, $block_content );

// Replace onchange with on attribute.
Expand Down Expand Up @@ -339,7 +339,7 @@ public function ampify_navigation_block( $block_content, $block ) {
add_action( 'wp_print_footer_scripts', [ $this, 'dequeue_block_navigation_view_script' ], 0 );
}

$this->navigation_block_count++;
++$this->navigation_block_count;
$modal_state_property = "modal_{$this->navigation_block_count}_expanded";

// Set `aria-expanded` value of submenus whenever AMP state changes.
Expand Down Expand Up @@ -487,7 +487,7 @@ private function process_categories_widgets( Document $dom ) {
continue; // @codeCoverageIgnore
}

$this->category_widget_count++;
++$this->category_widget_count;
$id = sprintf( 'amp-wp-widget-categories-%d', $this->category_widget_count );

$form->setAttribute( 'id', $id );
Expand Down
1 change: 0 additions & 1 deletion includes/embeds/class-amp-gfycat-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ public function filter_embed_oembed_html( $return, $url, $attr ) {
return $return;
}
}

1 change: 0 additions & 1 deletion includes/embeds/class-amp-issuu-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ public function filter_embed_oembed_html( $return, $url, $attr ) {
return $return;
}
}

1 change: 0 additions & 1 deletion includes/embeds/class-amp-meetup-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,3 @@ public function filter_embed_oembed_html( $cache, $url ) {
return $cache;
}
}

4 changes: 2 additions & 2 deletions includes/embeds/class-amp-playlist-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function audio_playlist( $data ) {
if ( ! isset( $data['tracks'] ) ) {
return '';
}
self::$playlist_id++;
++self::$playlist_id;
$container_id = 'wpPlaylist' . self::$playlist_id . 'Carousel';
$state_id = 'wpPlaylist' . self::$playlist_id;
$amp_state = [
Expand Down Expand Up @@ -207,7 +207,7 @@ public function video_playlist( $data ) {
if ( ! isset( $data['tracks'][0]['src'] ) ) {
return '';
}
self::$playlist_id++;
++self::$playlist_id;
$state_id = 'wpPlaylist' . self::$playlist_id;
$amp_state = [
'selectedIndex' => 0,
Expand Down
1 change: 0 additions & 1 deletion includes/embeds/class-amp-reddit-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ public function render( $args ) {
);
}
}

2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-bento-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function sanitize() {
$script->parentNode->removeChild( $script );
} else {
ValidationExemption::mark_node_as_px_verified( $script );
$non_amp_scripts_retained++;
++$non_amp_scripts_retained;
}
}

Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-block-uniqid-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static function ( $class_name_prefix ) {
$replaced_count = 0;
foreach ( $elements as $element ) {
if ( $this->transform_element_with_class_attribute( $element ) ) {
$replaced_count++;
++$replaced_count;
}
}

Expand Down
26 changes: 13 additions & 13 deletions includes/sanitizers/class-amp-core-theme-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public static function add_twentyseventeen_attachment_image_attributes( $args =
*/
add_filter(
'get_custom_logo',
static function( $html ) {
static function ( $html ) {
$src = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
if ( ! $src ) {
return $html;
Expand Down Expand Up @@ -659,7 +659,7 @@ public function prevent_sanitize_in_customizer_preview( $xpaths = [] ) {
public static function dequeue_scripts( $handles = [] ) {
add_action(
'wp_enqueue_scripts',
static function() use ( $handles ) {
static function () use ( $handles ) {
foreach ( $handles as $handle ) {
wp_dequeue_script( $handle );
}
Expand Down Expand Up @@ -798,7 +798,7 @@ public static function add_has_header_video_body_class( $args = [] ) {

add_filter(
'body_class',
static function( $body_classes ) use ( $args ) {
static function ( $body_classes ) use ( $args ) {
if ( has_header_video() ) {
$body_classes[] = $args['class_name'];
}
Expand Down Expand Up @@ -832,7 +832,7 @@ public static function add_twentytwenty_masthead_styles( $args = [] ) {
// @todo This was introduced in <https://github.com/ampproject/amp-wp/commit/e1c7462> but it doesn't seem to have any effect.
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
ob_start();
?>
<style>
Expand Down Expand Up @@ -868,7 +868,7 @@ public static function add_twentytwenty_custom_logo_fix( $args = [] ) {
$method = __METHOD__;
add_filter(
'get_custom_logo',
static function( $html ) use ( $method ) {
static function ( $html ) use ( $method ) {
// Pattern sourced from AMP_Base_Embed_Handler::match_element_attributes().
$pattern = sprintf(
'/<img%s/',
Expand Down Expand Up @@ -936,7 +936,7 @@ public static function add_img_display_block_fix( $args = [] ) {
// that any subsequent style rules for images will continue to override.
add_action(
'wp_print_styles',
static function() use ( $method ) {
static function () use ( $method ) {
printf(
'<style data-src="%s">%s</style>',
esc_attr( $method ),
Expand All @@ -957,7 +957,7 @@ static function() use ( $method ) {
public static function add_twentyseventeen_masthead_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
$is_front_page_layout = ( is_front_page() && 'posts' !== get_option( 'show_on_front' ) ) || ( is_home() && is_front_page() );
ob_start();
?>
Expand Down Expand Up @@ -1124,7 +1124,7 @@ public function add_twentyseventeen_sticky_nav_menu() {
public static function add_nav_menu_styles( $args = [] ) {
add_action(
'wp_enqueue_scripts',
static function() use ( $args ) {
static function () use ( $args ) {
ob_start();
?>
<style>
Expand Down Expand Up @@ -1441,7 +1441,7 @@ public static function adjust_twentynineteen_images() {
// Make sure the featured image gets responsive layout.
add_filter(
'wp_get_attachment_image_attributes',
static function( $attributes ) {
static function ( $attributes ) {
if ( preg_match( '/(^|\s)(attachment-post-thumbnail)(\s|$)/', $attributes['class'] ) ) {
$attributes['data-amp-layout'] = 'responsive';
}
Expand All @@ -1458,7 +1458,7 @@ static function( $attributes ) {
public static function add_twentyfourteen_masthead_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
ob_start();
?>
<style>
Expand Down Expand Up @@ -1841,7 +1841,7 @@ public function wrap_modal_in_lightbox( $args = [] ) {

$modal_content_node = $modal_content_node->removeChild( $children[0] );

$strip_wrapper_levels--;
--$strip_wrapper_levels;
}

$amp_lightbox->appendChild( $modal_content_node );
Expand Down Expand Up @@ -2030,7 +2030,7 @@ public function add_twentytwenty_toggles() {
public static function amend_twentytwentyone_dark_mode_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
$theme_style_handle = 'twenty-twenty-one-style';
$dark_mode_style_handle = 'tt1-dark-mode';

Expand Down Expand Up @@ -2070,7 +2070,7 @@ static function() {
public static function amend_twentytwentyone_styles() {
add_action(
'wp_enqueue_scripts',
static function() {
static function () {
$style_handle = 'twenty-twenty-one-style';

// Bail if the stylesheet is not enqueued.
Expand Down
Loading

0 comments on commit 5499f6f

Please sign in to comment.