Skip to content

Commit

Permalink
Quick fix phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
rilwis committed Mar 4, 2024
1 parent eca2dc0 commit f1da942
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function parse(): void {
} elseif ( is_singular() ) {
$this->add_singular();
} elseif ( is_tax() || is_category() || is_tag() ) { // Taxonomy archive.
$term = get_queried_object();
$term = get_queried_object();
if ( $term ) {
$taxonomy = get_taxonomy( $term->taxonomy );
if ( ! empty( $taxonomy->object_type ) && 1 === count( $taxonomy->object_type ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Integrations/Bricks.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private function remove_elements( array $data ): array {
'wpgb-facet',
] );

return array_filter( $data, function( $element ) use ( $skipped_elements ) {
return array_filter( $data, function ( $element ) use ( $skipped_elements ) {
if ( in_array( $element['name'], $skipped_elements, true ) ) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Integrations/SenseiLMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public function skip_shortcodes( $shortcodes ) {
] );
return $shortcodes;
}
}
}
6 changes: 3 additions & 3 deletions src/Integrations/TranslatePress.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function setup() {

add_action( 'slim_seo_sitemap_post', [ $this, 'add_post_links' ] );
add_action( 'slim_seo_sitemap_term', [ $this, 'add_term_links' ] );
add_filter( 'wpseo_sitemap_url', [ $this, 'get_url' ], 0, 2 );
add_filter( 'wpseo_sitemap_url', [ $this, 'get_url' ], 0, 2 ); // phpcs:ignore
}

public function add_post_links( \WP_Post $post ): void {
Expand All @@ -32,7 +32,7 @@ private function add_links( string $url ): void {
* We have to use the Yoast SEO's filter name to make it work.
* This will be removed when TranslatePress adds support for Slim SEO's hooks.
*/
$url = apply_filters( 'wpseo_sitemap_url', $url, $language );
$url = apply_filters( 'wpseo_sitemap_url', $url, $language ); // phpcs:ignore

printf(
"\t\t<xhtml:link rel=\"alternate\" hreflang=\"%s\" href=\"%s\"/>\n",
Expand All @@ -54,6 +54,6 @@ private function get_languages(): array {
$trp_settings = $this->trp->get_component( 'settings' );
$settings = $trp_settings->get_settings();

return array_diff( $settings[ 'publish-languages' ], [ $settings[ 'default-language' ] ] );
return array_diff( $settings['publish-languages'], [ $settings['default-language'] ] );
}
}
2 changes: 1 addition & 1 deletion src/MetaTags/Settings/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function get_script_params(): array {
'description' => html_entity_decode( get_bloginfo( 'description' ), ENT_QUOTES, 'UTF-8' ),
],
'title' => [
'separator' => apply_filters( 'document_title_separator', '-' ),
'separator' => apply_filters( 'document_title_separator', '-' ), // phpcs:ignore
'parts' => apply_filters( 'slim_seo_title_parts', [ 'title', 'site' ], $this->object_type ),
],
];
Expand Down
2 changes: 1 addition & 1 deletion src/MetaTags/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function filter_title( $title ): string {

// Add a page number if necessary.
if ( $custom_title && ( $paged >= 2 || $page >= 2 ) ) {
$separator = apply_filters( 'document_title_separator', '-' );
$separator = apply_filters( 'document_title_separator', '-' ); // phpcs:ignore
// Translators: %s - Page number.
$custom_title .= " $separator " . sprintf( __( 'Page %s', 'slim-seo' ), max( $paged, $page ) );
}
Expand Down
7 changes: 5 additions & 2 deletions src/Migration/Sources/SEOPress.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ protected function get_post_noindex( $post_id ): int {

protected function before_migrate_term( $term_id ) {
add_filter( 'seopress_primary_category_list', '__return_empty_array' );
$term = get_term( $term_id );
$this->context = seopress_get_service( 'ContextPage' )->buildContextWithCurrentId( $term_id, [ 'type' => 'term', 'taxonomy' => $term->taxonomy ] )->getContext();
$term = get_term( $term_id );
$this->context = seopress_get_service( 'ContextPage' )->buildContextWithCurrentId( $term_id, [
'type' => 'term',
'taxonomy' => $term->taxonomy,
] )->getContext();
}

protected function get_term_title( $term_id ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Redirection/Api/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function register_routes() {

public function get_redirects(): array {
$redirects = $this->db_redirects->list();
$redirects = array_map( function( $index, $redirect ) {
$redirects = array_map( function ( $index, $redirect ) {
$redirect['id'] = $index;

return $redirect;
Expand Down
4 changes: 2 additions & 2 deletions src/Redirection/Database/Redirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function list(): array {
public function exists( string $url ): bool {
$url = Helper::normalize_url( $url );

return count( array_filter( $this->redirects, function( $redirect ) use ( $url ) {
return count( array_filter( $this->redirects, function ( $redirect ) use ( $url ) {
return $redirect['from'] === $url;
} ) ) > 0;
}
Expand All @@ -37,7 +37,7 @@ public function update( array $redirect ): string {
}

public function delete( array $ids ) {
$this->redirects = array_filter( $this->redirects, function( $id ) use ( $ids ) {
$this->redirects = array_filter( $this->redirects, function ( $id ) use ( $ids ) {
return ! in_array( $id, $ids, true );
}, ARRAY_FILTER_USE_KEY );

Expand Down
24 changes: 12 additions & 12 deletions src/Schema/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function output() {
$this->add_schemas();

$entities = apply_filters( 'slim_seo_schema_entities', $this->entities );
$entities = array_filter( $entities, function ($entity) {
$entities = array_filter( $entities, function ( $entity ) {
return $entity->is_active();
} );

$graph = array_map( function ($entity) {
$graph = array_map( function ( $entity ) {
return $entity->get_schema();
}, $entities );

Expand Down Expand Up @@ -101,8 +101,8 @@ private function add_logo_schema() {
$logo = new Types\ImageObject( 'logo', home_url( '/' ) );
$logo->image_id = $logo_id;

$this->entities[ 'organization' ]->add_reference( 'logo', $logo );
$this->entities[ 'organization' ]->add_reference( 'image', $logo );
$this->entities['organization']->add_reference( 'logo', $logo );
$this->entities['organization']->add_reference( 'image', $logo );
$this->add_entity( $logo );
}

Expand All @@ -111,23 +111,23 @@ private function add_thumbnail_schema() {
$thumbnail = new Types\ImageObject( 'thumbnail', get_permalink( $post ) );
$thumbnail->image_id = get_post_thumbnail_id( $post );

$this->entities[ 'webpage' ]->add_reference( 'primaryImageOfPage', $thumbnail );
$this->entities[ 'webpage' ]->add_reference( 'image', $thumbnail );
$this->entities['webpage']->add_reference( 'primaryImageOfPage', $thumbnail );
$this->entities['webpage']->add_reference( 'image', $thumbnail );
$this->add_entity( $thumbnail );
}

private function add_post_schemas() {
$post = get_queried_object();
$article = new Types\Article( null, get_permalink( $post ) );
$article->add_reference( 'isPartOf', $this->entities[ 'webpage' ] );
$article->add_reference( 'mainEntityOfPage', $this->entities[ 'webpage' ] );
$article->add_reference( 'isPartOf', $this->entities['webpage'] );
$article->add_reference( 'mainEntityOfPage', $this->entities['webpage'] );
$this->add_entity( $article );

if ( isset( $this->entities[ 'thumbnail' ] ) ) {
$article->add_reference( 'image', $this->entities[ 'thumbnail' ] );
if ( isset( $this->entities['thumbnail'] ) ) {
$article->add_reference( 'image', $this->entities['thumbnail'] );
}

$article->add_reference( 'publisher', $this->entities[ 'organization' ] );
$article->add_reference( 'publisher', $this->entities['organization'] );

$author = new Types\Person( 'author', get_author_posts_url( $post->post_author ) );
$author->user = get_userdata( $post->post_author );
Expand All @@ -143,7 +143,7 @@ private function add_post_schemas() {
private function add_author_schemas() {
$author = new Types\Person( 'author', get_author_posts_url( get_queried_object_id() ) );
$author->user = get_queried_object();
$author->add_reference( 'mainEntityOfPage', $this->entities[ 'webpage' ] );
$author->add_reference( 'mainEntityOfPage', $this->entities['webpage'] );

$this->add_entity( $author );
}
Expand Down
4 changes: 2 additions & 2 deletions src/Settings/MetaTags/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ private function get_default_title(): string {
'title' => $title,
];

$parts = array_map( function( string $part ) use ( $values ): string {
$parts = array_map( function ( string $part ) use ( $values ): string {
return $values[ $part ] ?? '';
}, $parts );

$separator = apply_filters( 'document_title_separator', '-' );
$separator = apply_filters( 'document_title_separator', '-' ); // phpcs:ignore
return implode( " $separator ", $parts );
}

Expand Down
2 changes: 1 addition & 1 deletion src/Settings/MetaTags/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function admin_init() {
$items = array_keys( array_filter( $this->get_post_types(), function ( $post_type_object ) {
return $post_type_object->has_archive;
} ) );
$items = array_map( function( $item ) {
$items = array_map( function ( $item ) {
return "{$item}_archive";
}, $items );

Expand Down
14 changes: 7 additions & 7 deletions src/Settings/sections/post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use SlimSEO\Helpers\Data;
use SlimSEO\Helpers\UI;

$post_types = $this->meta_tags_manager->get_post_types();
$option = get_option( 'slim_seo' );
$post_types = $this->meta_tags_manager->get_post_types(); // phpcs:ignore
$option = get_option( 'slim_seo' ); // phpcs:ignore
?>

<div class="ss-field">
Expand All @@ -13,7 +13,7 @@
<div class="ss-input">
<select id="ss-post-type-select">
<?php
foreach ( $post_types as $post_type_object ) {
foreach ( $post_types as $post_type_object ) { // phpcs:ignore
printf(
'<option value="%s">%s (%s)</option>',
esc_attr( $post_type_object->name ),
Expand All @@ -25,8 +25,8 @@
</select>
</div>
</div>
<?php foreach ( $post_types as $post_type => $post_type_object ) : ?>
<?php $data = $option[ $post_type ] ?? []; ?>
<?php foreach ( $post_types as $post_type => $post_type_object ) : //phpcs:ignore ?>
<?php $data = $option[ $post_type ] ?? []; // phpcs:ignore ?>
<div class="ss-post-type-settings ss-post-type-settings--<?= esc_attr( $post_type ) ?>">
<div class="ss-field">
<div class="ss-label">
Expand All @@ -43,9 +43,9 @@
<?php
if ( $post_type_object->has_archive ) {
// Translators: %s - post type singular name.
printf( '<h3>' . esc_html__( '%s archive page', 'slim-seo' ) . '</h3>', $post_type_object->labels->singular_name );
printf( '<h3>' . esc_html__( '%s archive page', 'slim-seo' ) . '</h3>', $post_type_object->labels->singular_name ); // phpcs:ignore

$archive_page = Data::get_post_type_archive_page( $post_type );
$archive_page = Data::get_post_type_archive_page( $post_type ); // phpcs:ignore
if ( $archive_page ) {
echo '<p>', wp_kses_post( sprintf(
// Translators: %1$s - link to the archive page, %2$s - page title, %3$s - post type slug.
Expand Down

0 comments on commit f1da942

Please sign in to comment.