Skip to content

Commit

Permalink
Fix lint error.
Browse files Browse the repository at this point in the history
  • Loading branch information
fumikito committed Sep 28, 2021
1 parent e0de970 commit 803b7e7
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 44 deletions.
13 changes: 4 additions & 9 deletions assets/js/post-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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( {
Expand Down Expand Up @@ -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' );
}
Expand Down Expand Up @@ -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 ) {
Expand All @@ -185,7 +180,7 @@ class SeriesChooser extends Component {
);
} else if ( loading ) {
result.push(
<p className="description">{ __( 'Loading...', 'taro-series' ) }</p>
<p className="description">{ __( 'Loading', 'taro-series' ) }</p>
);
} else {
result.push(
Expand Down
14 changes: 6 additions & 8 deletions assets/js/series-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -108,7 +108,7 @@ class Articles extends Component {
loading: false,
posts: res.posts,
} );
} ).catch( ( res ) => {
} ).catch( () => {
this.setState( {
loading: false,
posts: [],
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -200,7 +198,7 @@ class Articles extends Component {
{ loading && (
<>
<Spinner />
<p className="description">{ __( 'Loading...', 'taro-series' ) }</p>
<p className="description">{ __( 'Loading', 'taro-series' ) }</p>
</>
) }

Expand Down Expand Up @@ -246,7 +244,7 @@ class Articles extends Component {
{ loading && <Spinner /> }
{ ( 0 < results.length ) ? (
<>
<p>{ sprintf( __( 'Found posts: %d', 'taro-series' ), resultCount ) }</p>
<p>{ /* translators: %d is post count. */ sprintf( __( 'Found posts: %d', 'taro-series' ), resultCount ) }</p>
<ol style={ { borderTop: '1px solid #eee' } }>
{ results.map( ( post ) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion assets/scss/toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
border-top: 1px solid currentColor;
}

&.current{
&.current {
position: relative;
&::before {
content: "";
Expand Down
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions src/Tarosky/Series/Controller/Rewrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]',
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/Tarosky/Series/Customizer/ArchiveLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/Tarosky/Series/Customizer/IndexLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
10 changes: 5 additions & 5 deletions src/Tarosky/Series/Customizer/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
] );
}

Expand Down
8 changes: 4 additions & 4 deletions src/Tarosky/Series/Customizer/OrderBy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
] );
}

Expand Down
6 changes: 3 additions & 3 deletions src/Tarosky/Series/Customizer/PostIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
] );
}

Expand Down
6 changes: 3 additions & 3 deletions src/Tarosky/Series/Customizer/ScheduledPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
] );
}

Expand All @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/Tarosky/Series/Customizer/SeriesIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
] );
}

Expand Down
4 changes: 2 additions & 2 deletions src/Tarosky/Series/Customizer/StyleLoading.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ),
] );
}

Expand Down
1 change: 1 addition & 0 deletions src/Tarosky/Series/Customizer/TocTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/Tarosky/Series/Pattern/CustomizerPattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract protected function id();
protected function get_setting() {
return [
'type' => 'option',
'transport' => 'refresh'
'transport' => 'refresh',
];
}

Expand Down
2 changes: 1 addition & 1 deletion template-parts/series/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ol>
<?php if ( $query->found_posts > $query->post_count && $args['link'] ) : ?>
<p class="taro-series-toc-link">
<a class="taro-series-toc-link-button" href="<?php echo esc_attr( $args['link'] ) ?>">
<a class="taro-series-toc-link-button" href="<?php echo esc_attr( $args['link'] ); ?>">
<?php echo esc_html( $args['link_label'] ); ?>
</a>
</p>
Expand Down

0 comments on commit 803b7e7

Please sign in to comment.