From 803b7e7bd77d5e9e09313dd97b2334462b60f88f Mon Sep 17 00:00:00 2001 From: fumikito Date: Tue, 28 Sep 2021 17:27:20 +0900 Subject: [PATCH] Fix lint error. --- assets/js/post-editor.js | 13 ++++--------- assets/js/series-editor.js | 14 ++++++-------- assets/scss/toc.scss | 2 +- includes/functions.php | 2 +- src/Tarosky/Series/Controller/Rewrite.php | 4 ++-- src/Tarosky/Series/Customizer/ArchiveLink.php | 1 + src/Tarosky/Series/Customizer/IndexLimit.php | 2 +- src/Tarosky/Series/Customizer/Order.php | 10 +++++----- src/Tarosky/Series/Customizer/OrderBy.php | 8 ++++---- src/Tarosky/Series/Customizer/PostIndex.php | 6 +++--- src/Tarosky/Series/Customizer/ScheduledPosts.php | 6 +++--- src/Tarosky/Series/Customizer/SeriesIndex.php | 6 +++--- src/Tarosky/Series/Customizer/StyleLoading.php | 4 ++-- src/Tarosky/Series/Customizer/TocTitle.php | 1 + src/Tarosky/Series/Pattern/CustomizerPattern.php | 2 +- template-parts/series/list.php | 2 +- 16 files changed, 39 insertions(+), 44 deletions(-) diff --git a/assets/js/post-editor.js b/assets/js/post-editor.js index b46badc..1e1bd13 100644 --- a/assets/js/post-editor.js +++ b/assets/js/post-editor.js @@ -11,10 +11,6 @@ const { Spinner, RadioControl, TextControl, Button } = wp.components; const { __ } = wp.i18n; const { apiFetch } = wp; -const postCaches = {}; - - - class SeriesRender extends Component { constructor(prop) { @@ -40,7 +36,7 @@ class SeriesRender extends Component { if ( this.fetching ) { return; // Do nothing. } - const { postId, postType } = this.props; + const { postId } = this.props; this.fetching = true; if ( postId ) { this.setState( { @@ -77,14 +73,13 @@ class SeriesRender extends Component { render() { const { loading, post } = this.state; const { onChange } = this.props; - const objects = []; let link = false; let title = ''; if ( post ) { link = post.edit_link; title = post.title; } else if ( 0 < this.props.postId ) { - title = __( 'Loading...', 'taro-series' ); + title = __( 'Loading…', 'taro-series' ); } else { title = __( 'Not Set', 'taro-series' ); } @@ -159,7 +154,7 @@ class SeriesChooser extends Component { } render() { - const { postId, onChange } = this.props; + const { onChange } = this.props; const { loading, posts, s } = this.state; const result = []; if ( loading ) { @@ -185,7 +180,7 @@ class SeriesChooser extends Component { ); } else if ( loading ) { result.push( -

{ __( 'Loading...', 'taro-series' ) }

+

{ __( 'Loading…', 'taro-series' ) }

); } else { result.push( diff --git a/assets/js/series-editor.js b/assets/js/series-editor.js index 80edf33..397778f 100644 --- a/assets/js/series-editor.js +++ b/assets/js/series-editor.js @@ -7,7 +7,7 @@ */ const { Component, render } = wp.element; -const { __ } = wp.i18n; +const { __, sprintf } = wp.i18n; const { Spinner, Button, Modal, TextControl } = wp.components; const { apiFetch } = wp; const { dispatch } = wp.data; @@ -108,7 +108,7 @@ class Articles extends Component { loading: false, posts: res.posts, } ); - } ).catch( ( res ) => { + } ).catch( () => { this.setState( { loading: false, posts: [], @@ -125,7 +125,6 @@ class Articles extends Component { path: `taro-series/v1/series/${this.props.seriesId}?s=${this.state.term}`, method: 'get', } ).then( ( res ) => { - console.log( res ); this.setState( { loading: false, resultCount: res.total, @@ -149,9 +148,8 @@ class Articles extends Component { posts.sort( ( a, b ) => { if ( a.date === b.date ) { return 0; - } else { - return a.date < b.date ? -1 : 1; } + return a.date < b.date ? -1 : 1; } ) this.setState( { posts @@ -163,7 +161,7 @@ class Articles extends Component { apiFetch( { path: `taro-series/v1/series/${this.props.seriesId}?post_id=${postId}`, method: 'delete', - } ).then( ( response ) => { + } ).then( () => { // Successfully removed. this.setState( { loading: false, @@ -200,7 +198,7 @@ class Articles extends Component { { loading && ( <> -

{ __( 'Loading...', 'taro-series' ) }

+

{ __( 'Loading…', 'taro-series' ) }

) } @@ -246,7 +244,7 @@ class Articles extends Component { { loading && } { ( 0 < results.length ) ? ( <> -

{ sprintf( __( 'Found posts: %d', 'taro-series' ), resultCount ) }

+

{ /* translators: %d is post count. */ sprintf( __( 'Found posts: %d', 'taro-series' ), resultCount ) }

    { results.map( ( post ) => { return ( diff --git a/assets/scss/toc.scss b/assets/scss/toc.scss index 5f74c88..d4394d7 100644 --- a/assets/scss/toc.scss +++ b/assets/scss/toc.scss @@ -29,7 +29,7 @@ border-top: 1px solid currentColor; } - &.current{ + &.current { position: relative; &::before { content: "◁"; diff --git a/includes/functions.php b/includes/functions.php index f824c25..91c4c56 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -179,7 +179,7 @@ function taro_series_finish_at( $post = null ) { */ function taro_series_query_args( $series_id, $args = [] ) { $posts_per_page = \Tarosky\Series\Customizer\IndexLimit::posts_per_page(); - $args = array_merge( [ + $args = array_merge( [ 'post_type' => taro_series_post_types(), 'post_status' => \Tarosky\Series\Customizer\ScheduledPosts::post_statuses(), 'orderby' => \Tarosky\Series\Customizer\OrderBy::order_by(), diff --git a/src/Tarosky/Series/Controller/Rewrite.php b/src/Tarosky/Series/Controller/Rewrite.php index c16cc05..596767b 100644 --- a/src/Tarosky/Series/Controller/Rewrite.php +++ b/src/Tarosky/Series/Controller/Rewrite.php @@ -38,7 +38,7 @@ public function query_vars( $vars ) { * @param string[] $rules */ public function rewrite_rules( $rules ) { - $preg = '^' . ltrim( taro_series_prefix(),'/' ) . '/([^/]+)'; + $preg = '^' . ltrim( taro_series_prefix(), '/' ) . '/([^/]+)'; return array_merge( [ $preg . '/page/(\d+)/?' => 'index.php?series_in=$matches[1]&paged=$matches[2]', $preg . '/?' => 'index.php?series_in=$matches[1]', @@ -63,7 +63,7 @@ public function pre_get_posts( $wp_query ) { $series_id = $series->ID; } // Set meta query. - $meta_query = $wp_query->get( 'meta_query' ) ?: []; + $meta_query = $wp_query->get( 'meta_query' ) ?: []; $meta_query[] = [ 'key' => taro_series_meta_key(), 'value' => $series_id, diff --git a/src/Tarosky/Series/Customizer/ArchiveLink.php b/src/Tarosky/Series/Customizer/ArchiveLink.php index cdf94cc..0ccd89d 100644 --- a/src/Tarosky/Series/Customizer/ArchiveLink.php +++ b/src/Tarosky/Series/Customizer/ArchiveLink.php @@ -36,6 +36,7 @@ protected function controller_args() { return array_merge( parent::controller_args(), [ 'type' => 'text', 'label' => __( 'Archive Link Label', 'taro-series' ), + // translators: %s is a placeholder. 'description' => __( 'If you limit the amount of articles in TOC, a link to archive will be displayed. %s will be replaced with series title.', 'taro-series' ), 'input_attrs' => [ 'placeholder' => $this->default_title(), diff --git a/src/Tarosky/Series/Customizer/IndexLimit.php b/src/Tarosky/Series/Customizer/IndexLimit.php index aa4fb3c..1d1adc3 100644 --- a/src/Tarosky/Series/Customizer/IndexLimit.php +++ b/src/Tarosky/Series/Customizer/IndexLimit.php @@ -24,7 +24,7 @@ protected function id() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'type' => 'number', + 'type' => 'number', 'label' => __( 'Max Articles in Index', 'taro-series' ), 'description' => __( '0 means all articles. If more than 0, the amount of articles in index will be limited.', 'taro-series' ), 'input_attrs' => [ diff --git a/src/Tarosky/Series/Customizer/Order.php b/src/Tarosky/Series/Customizer/Order.php index e2f459e..a07fd44 100644 --- a/src/Tarosky/Series/Customizer/Order.php +++ b/src/Tarosky/Series/Customizer/Order.php @@ -24,13 +24,13 @@ protected function id() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'type' => 'select', - 'label' => __( 'Order', 'taro-series' ), - 'choices' => [ - '' => __( 'DESC', 'taro-series' ), + 'type' => 'select', + 'label' => __( 'Order', 'taro-series' ), + 'choices' => [ + '' => __( 'DESC', 'taro-series' ), 'ASC' => __( 'ASC', 'taro-series' ), ], - 'default' => '', + 'default' => '', ] ); } diff --git a/src/Tarosky/Series/Customizer/OrderBy.php b/src/Tarosky/Series/Customizer/OrderBy.php index bc4f92e..daad37f 100644 --- a/src/Tarosky/Series/Customizer/OrderBy.php +++ b/src/Tarosky/Series/Customizer/OrderBy.php @@ -24,15 +24,15 @@ protected function id() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'type' => 'select', - 'label' => __( 'Order By', 'taro-series' ), - 'choices' => [ + 'type' => 'select', + 'label' => __( 'Order By', 'taro-series' ), + 'choices' => [ '' => __( 'Published Date', 'taro-series' ), 'menu_order' => __( 'Page Order', 'taro-series' ), 'name' => __( 'Post Slug', 'taro-series' ), 'rand' => __( 'Random', 'taro-series' ), ], - 'default' => '', + 'default' => '', ] ); } diff --git a/src/Tarosky/Series/Customizer/PostIndex.php b/src/Tarosky/Series/Customizer/PostIndex.php index acc7aa4..559b8f5 100644 --- a/src/Tarosky/Series/Customizer/PostIndex.php +++ b/src/Tarosky/Series/Customizer/PostIndex.php @@ -31,9 +31,9 @@ protected function register_hooks() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'label' => __( 'Display TOC in Article Pages', 'taro-series' ), - 'type' => 'checkbox', - 'description' => __( 'If checked, TOC of the series will be displayed in each articles in series.', 'taro-series' ), + 'label' => __( 'Display TOC in Article Pages', 'taro-series' ), + 'type' => 'checkbox', + 'description' => __( 'If checked, TOC of the series will be displayed in each articles in series.', 'taro-series' ), ] ); } diff --git a/src/Tarosky/Series/Customizer/ScheduledPosts.php b/src/Tarosky/Series/Customizer/ScheduledPosts.php index b9a3f77..cee4d50 100644 --- a/src/Tarosky/Series/Customizer/ScheduledPosts.php +++ b/src/Tarosky/Series/Customizer/ScheduledPosts.php @@ -24,8 +24,8 @@ protected function id() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'type' => 'checkbox', - 'label' => __( 'Include scheduled posts', 'taro-series' ), + 'type' => 'checkbox', + 'label' => __( 'Include scheduled posts', 'taro-series' ), ] ); } @@ -35,7 +35,7 @@ protected function controller_args() { * @return string[] */ public static function post_statuses() { - $scheduled = (bool) self::get(); + $scheduled = (bool) self::get(); $post_status = [ 'publish' ]; if ( $scheduled ) { $post_status[] = 'future'; diff --git a/src/Tarosky/Series/Customizer/SeriesIndex.php b/src/Tarosky/Series/Customizer/SeriesIndex.php index 081627c..a3bfe45 100644 --- a/src/Tarosky/Series/Customizer/SeriesIndex.php +++ b/src/Tarosky/Series/Customizer/SeriesIndex.php @@ -32,9 +32,9 @@ protected function register_hooks() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'label' => __( 'Display TOC in Series Page', 'taro-series' ), - 'type' => 'checkbox', - 'description' => __( 'If checked, TOC of the series will be displayed in series single page.', 'taro-series' ), + 'label' => __( 'Display TOC in Series Page', 'taro-series' ), + 'type' => 'checkbox', + 'description' => __( 'If checked, TOC of the series will be displayed in series single page.', 'taro-series' ), ] ); } diff --git a/src/Tarosky/Series/Customizer/StyleLoading.php b/src/Tarosky/Series/Customizer/StyleLoading.php index 039f9a4..00bbb05 100644 --- a/src/Tarosky/Series/Customizer/StyleLoading.php +++ b/src/Tarosky/Series/Customizer/StyleLoading.php @@ -24,8 +24,8 @@ protected function id() { */ protected function controller_args() { return array_merge( parent::controller_args(), [ - 'type' => 'checkbox', - 'label' => __( 'Do not load TOC stylesheet', 'taro-series' ), + 'type' => 'checkbox', + 'label' => __( 'Do not load TOC stylesheet', 'taro-series' ), ] ); } diff --git a/src/Tarosky/Series/Customizer/TocTitle.php b/src/Tarosky/Series/Customizer/TocTitle.php index 8583d1e..8d4f841 100644 --- a/src/Tarosky/Series/Customizer/TocTitle.php +++ b/src/Tarosky/Series/Customizer/TocTitle.php @@ -36,6 +36,7 @@ protected function controller_args() { return array_merge( parent::controller_args(), [ 'type' => 'text', 'label' => __( 'Toc Title', 'taro-series' ), + // translators: %s is series title. 'description' => __( '%s will be replaced with series title. %0 means no TOC title.', 'taro-series' ), 'input_attrs' => [ 'placeholder' => $this->default_title(), diff --git a/src/Tarosky/Series/Pattern/CustomizerPattern.php b/src/Tarosky/Series/Pattern/CustomizerPattern.php index 329c79b..67ef86c 100644 --- a/src/Tarosky/Series/Pattern/CustomizerPattern.php +++ b/src/Tarosky/Series/Pattern/CustomizerPattern.php @@ -32,7 +32,7 @@ abstract protected function id(); protected function get_setting() { return [ 'type' => 'option', - 'transport' => 'refresh' + 'transport' => 'refresh', ]; } diff --git a/template-parts/series/list.php b/template-parts/series/list.php index 0fa89d5..98be1cd 100644 --- a/template-parts/series/list.php +++ b/template-parts/series/list.php @@ -34,7 +34,7 @@
found_posts > $query->post_count && $args['link'] ) : ?>