From d3f9b2e14d4c8a665558ca4847e65b27f47066b7 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Tue, 26 Sep 2023 14:43:29 +0300 Subject: [PATCH 01/13] Added i18n to CPTs --- functions.php | 28 ++++++++++++++++- inc/includes/localization.php | 2 +- inc/includes/post-type.php | 30 ++++++++++++++++++- inc/includes/theme-setup.php | 50 ++++++++++++++++++++++++++----- inc/post-types/your-post-type.php | 32 ++++++++++---------- 5 files changed, 117 insertions(+), 25 deletions(-) diff --git a/functions.php b/functions.php index 893e4529..2e634d5a 100644 --- a/functions.php +++ b/functions.php @@ -22,6 +22,7 @@ // We need to have some defaults as comments or empties so let's allow this: // phpcs:disable Squiz.Commenting.InlineComment.SpacingBefore, WordPress.Arrays.ArrayDeclarationSpacing.SpaceInEmptyArray + /** * Theme settings */ @@ -98,6 +99,7 @@ */ 'post_types' => [ // 'Your_Post_Type', + 'Question', ], /** @@ -178,7 +180,9 @@ ], // If you want to use classic editor somewhere, define it here - 'use_classic_editor' => [], + 'use_classic_editor' => [ + 'question' + ], // Add your own settings and use them wherever you need, for example THEME_SETTINGS['my_custom_setting'] 'my_custom_setting' => true, @@ -199,3 +203,25 @@ // Run theme setup add_action( 'after_setup_theme', __NAMESPACE__ . '\theme_setup' ); add_action( 'after_setup_theme', __NAMESPACE__ . '\build_theme_support' ); + +/* + * First: we register the taxonomies and post types after setup theme + * If air-helper loads (for translations), we unregister the original taxonomies and post types + * and reregister them with the translated ones. + * + * This allows the slugs translations to work before the translations are available, + * and for the label translations to work if they are available. + */ +add_action( 'after_setup_theme', __NAMESPACE__ . '\build_taxonomies' ); +add_action( 'after_setup_theme', __NAMESPACE__ . '\build_post_types' ); + +add_action( 'air_helper_activated', __NAMESPACE__ . '\rebuild_taxonomies' ); +add_action( 'air_helper_activated', __NAMESPACE__ . '\rebuild_post_types' ); + +/** + * Show plugins and other menus for everyone + */ +add_action( 'init', function() { + remove_filter( 'air_helper_helper_remove_admin_menu_links', 'air_helper_maybe_remove_plugins_from_admin_menu' ); + add_filter( 'air_helper_disable_views_author', '__return_false' ); +} ); diff --git a/inc/includes/localization.php b/inc/includes/localization.php index ec377e56..dacccc7f 100644 --- a/inc/includes/localization.php +++ b/inc/includes/localization.php @@ -23,7 +23,7 @@ // $strings[ "Accessibility: {$key}" ] = $value; // } - return $strings; + return apply_filters("air_light_translations", $strings); } ); function get_default_localization_strings( $language = 'en' ) { diff --git a/inc/includes/post-type.php b/inc/includes/post-type.php index 7b46205f..09ab4077 100644 --- a/inc/includes/post-type.php +++ b/inc/includes/post-type.php @@ -31,9 +31,17 @@ abstract class Post_Type { */ public $slug; + /** + * Translations used in labels + * + * @var array(string) + */ + public $translations; + public function __construct( $slug ) { $this->slug = $slug; + $this->translations = []; } @@ -55,7 +63,8 @@ abstract protected function register(); * of failure. */ public function register_wp_post_type( $slug, $args ) { - if ( $args['pll_translatable'] ) { + // Register PolyLang translatable only if it's private + if ( $args['pll_translatable'] && false === $args['public'] ) { add_filter( 'pll_get_post_types', function( $cpts ) use ( $slug ) { $cpts[ $slug ] = $slug; @@ -63,7 +72,26 @@ public function register_wp_post_type( $slug, $args ) { }, 9, 2 ); } + $this->register_translations(); return register_post_type( $slug, $args ); } + // Wrapper for ask__ + public function ask__( $key, $value ) { + $pllKey = "{$key}: {$value}"; + $this->translations[ $pllKey ] = $value; + if ( function_exists("ask__") ) { + return ask__( $pllKey ); + } + + return $value; + } + + private function register_translations() { + $translations = $this->translations; + + add_filter( 'air_light_translations', function($strings) use($translations) { + return array_merge( $translations, $strings ); + }, 10, 2 ); + } } diff --git a/inc/includes/theme-setup.php b/inc/includes/theme-setup.php index 7a215a5d..e7b30a2e 100644 --- a/inc/includes/theme-setup.php +++ b/inc/includes/theme-setup.php @@ -31,10 +31,6 @@ function theme_setup() { if ( ! isset( $content_width ) ) { $content_width = THEME_SETTINGS['content_width']; } - - // Run the rest of the setup - build_taxonomies(); - build_post_types(); } /** @@ -54,7 +50,10 @@ function build_taxonomies() { if ( ! file_exists( $file_path ) ) { return new \WP_Error( 'invalid-taxonomy', __( 'The taxonomy class file does not exist.', 'air-light' ), $classname ); } - require $file_path; + // Get the class file, only try to require if not already imported + if ( ! class_exists( $classname ) ) { + require $file_path; + } if ( ! class_exists( $classname ) ) { return new \WP_Error( 'invalid-taxonomy', __( 'The taxonomy you attempting to create does not have a class to instance. Possible problems: your configuration does not match the class file name; the class file name does not exist.', 'air-light' ), $classname ); @@ -82,8 +81,10 @@ function build_post_types() { if ( ! file_exists( $file_path ) ) { return new \WP_Error( 'invalid-cpt', __( 'The custom post type class file does not exist.', 'air-light' ), $classname ); } - // Get the class file - require $file_path; + // Get the class file, only try to require if not already imported + if ( ! class_exists( $classname ) ) { + require $file_path; + } if ( ! class_exists( $classname ) ) { return new \WP_Error( 'invalid-cpt', __( 'The custom post type you attempting to create does not have a class to instance. Possible problems: your configuration does not match the class file name; the class file name does not exist.', 'air-light' ), $classname ); @@ -94,6 +95,41 @@ function build_post_types() { } } +/** + * Rebuild taxonomies + */ +function rebuild_taxonomies() { + if ( ! is_array( THEME_SETTINGS['taxonomies'] ) || ! THEME_SETTINGS['taxonomies'] ) { + return; + } + + foreach ( THEME_SETTINGS['taxonomies'] as $name => $post_types ) { + $slug = strtolower( $name ); + + unregister_taxonomy( $slug ); + } + + build_taxonomies(); +} + +/** + * Rebuild custom post types + */ +function rebuild_post_types() { + if ( ! is_array( THEME_SETTINGS['post_types'] ) || ! THEME_SETTINGS['post_types'] ) { + return; + } + + foreach ( THEME_SETTINGS['post_types'] as $name ) { + $slug = strtolower( $name ); + + unregister_post_type( $slug ); + } + + build_post_types(); +} + + /** * Build theme support */ diff --git a/inc/post-types/your-post-type.php b/inc/post-types/your-post-type.php index 4468d686..e3acf515 100644 --- a/inc/post-types/your-post-type.php +++ b/inc/post-types/your-post-type.php @@ -16,23 +16,25 @@ class Your_Post_Type extends Post_Type { public function register() { - // Modify all the i18ized strings here. $generated_labels = [ - 'menu_name' => __( 'Your Post Type', 'air-light' ), - 'name' => _x( 'Your Post Types', 'post type general name', 'air-light' ), - 'singular_name' => _x( 'Your Post Type', 'post type singular name', 'air-light' ), - 'name_admin_bar' => _x( 'Your Post Type', 'add new on admin bar', 'air-light' ), - 'add_new' => _x( 'Add New', 'thing', 'air-light' ), - 'add_new_item' => __( 'Add New Your Post Type', 'air-light' ), - 'new_item' => __( 'New Your Post Type', 'air-light' ), - 'edit_item' => __( 'Edit Your Post Type', 'air-light' ), - 'view_item' => __( 'View Your Post Type', 'air-light' ), - 'all_items' => __( 'All Your Post Types', 'air-light' ), - 'search_items' => __( 'Search Your Post Types', 'air-light' ), - 'parent_item_colon' => __( 'Parent Your Post Types:', 'air-light' ), - 'not_found' => __( 'No your post types found.', 'air-light' ), - 'not_found_in_trash' => __( 'No your post types found in Trash.', 'air-light' ), + // The Post_Type ask__ function wraps the air-helper ask__, and automatically registers the keys to Polylang! + // self::ask__( 'Key', 'Default value' ) + // -> Key: Default value => 'Default value' + 'menu_name' => self::ask__( 'Your Post Type', 'Your Post Type' ), + 'name' => self::ask__( 'Your Post Type', 'Your Post Types' ), + 'singular_name' => self::ask__( 'Your Post Type', 'Your Post Type' ), + 'name_admin_bar' => self::ask__( 'Your Post Type', 'Your Post Type' ), + 'add_new' => self::ask__( 'Your Post Type', 'Add New' ), + 'add_new_item' => self::ask__( 'Your Post Type', 'Add New Your Post Type' ), + 'new_item' => self::ask__( 'Your Post Type', 'New Your Post Type' ), + 'edit_item' => self::ask__( 'Your Post Type', 'Edit Your Post Type' ), + 'view_item' => self::ask__( 'Your Post Type', 'View Your Post Type' ), + 'all_items' => self::ask__( 'Your Post Type', 'All Your Post Types' ), + 'search_items' => self::ask__( 'Your Post Type', 'Search Your Post Types' ), + 'parent_item_colon' => self::ask__( 'Your Post Type', 'Parent Your Post Types:' ), + 'not_found' => self::ask__( 'Your Post Type', 'No your post types found.' ), + 'not_found_in_trash' => self::ask__( 'Your Post Type', 'No your post types found in Trash.' ), ]; // Definition of the post type arguments. For full list see: From 9361e4400f450b21e59e61f0769e57c7c3ad82ca Mon Sep 17 00:00:00 2001 From: raikasdev Date: Tue, 26 Sep 2023 14:46:54 +0300 Subject: [PATCH 02/13] Added i18n support for taxonomies --- inc/includes/taxonomy.php | 27 +++++++++++++++++++++++++++ inc/taxonomies/your-taxonomy.php | 28 ++++++++++++++-------------- 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index 37fa5861..00a9918b 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -22,9 +22,17 @@ abstract class Taxonomy { */ protected $slug; + /** + * Translations used in labels + * + * @var array(string) + */ + public $translations; + public function __construct( $slug ) { $this->slug = $slug; + $this->translations = []; } /** @@ -65,6 +73,7 @@ protected function register_wp_taxonomy( $slug, $object_types, $args ) { } ); } + $this->register_translations(); register_taxonomy( $slug, $object_types_slugs, $args ); // Note from the Codex: "Better be safe than sorry when registering @@ -85,4 +94,22 @@ protected function register_wp_taxonomy( $slug, $object_types, $args ) { return $registered_object_types; } + // Wrapper for ask__ + public function ask__( $key, $value ) { + $pllKey = "{$key}: {$value}"; + $this->translations[ $pllKey ] = $value; + if ( function_exists("ask__") ) { + return ask__( $pllKey ); + } + + return $value; + } + + private function register_translations() { + $translations = $this->translations; + + add_filter( 'air_light_translations', function($strings) use($translations) { + return array_merge( $translations, $strings ); + }, 10, 2 ); + } } diff --git a/inc/taxonomies/your-taxonomy.php b/inc/taxonomies/your-taxonomy.php index 193dffeb..07c02d14 100644 --- a/inc/taxonomies/your-taxonomy.php +++ b/inc/taxonomies/your-taxonomy.php @@ -22,20 +22,20 @@ class Your_Taxonomy extends Taxonomy { public function register( array $post_types = [] ) { // Taxonomy labels. $labels = [ - 'name' => _x( 'Your Taxonomies', 'Taxonomy plural name', 'air-light' ), - 'singular_name' => _x( 'Your Taxonomy', 'Taxonomy singular name', 'air-light' ), - 'search_items' => __( 'Search Your Taxonomies', 'air-light' ), - 'popular_items' => __( 'Popular Your Taxonomies', 'air-light' ), - 'all_items' => __( 'All Your Taxonomies', 'air-light' ), - 'parent_item' => __( 'Parent Your Taxonomy', 'air-light' ), - 'parent_item_colon' => __( 'Parent Your Taxonomy', 'air-light' ), - 'edit_item' => __( 'Edit Your Taxonomy', 'air-light' ), - 'update_item' => __( 'Update Your Taxonomy', 'air-light' ), - 'add_new_item' => __( 'Add New Your Taxonomy', 'air-light' ), - 'new_item_name' => __( 'New Your Taxonomy', 'air-light' ), - 'add_or_remove_items' => __( 'Add or remove Your Taxonomies', 'air-light' ), - 'choose_from_most_used' => __( 'Choose from most used Taxonomies', 'air-light' ), - 'menu_name' => __( 'Your Taxonomy', 'air-light' ), + 'name' => self::ask__( 'Your Taxonomy', 'Taxonomy plural name' ), + 'singular_name' => self::ask__( 'Your Taxonomy', 'Taxonomy singular name' ), + 'search_items' => self::ask__( 'Your Taxonomy', 'Search Your Taxonomies' ), + 'popular_items' => self::ask__( 'Your Taxonomy', 'Popular Your Taxonomies' ), + 'all_items' => self::ask__( 'Your Taxonomy', 'All Your Taxonomies' ), + 'parent_item' => self::ask__( 'Your Taxonomy', 'Parent Your Taxonomy' ), + 'parent_item_colon' => self::ask__( 'Your Taxonomy', 'Parent Your Taxonomy' ), + 'edit_item' => self::ask__( 'Your Taxonomy', 'Edit Your Taxonomy' ), + 'update_item' => self::ask__( 'Your Taxonomy', 'Update Your Taxonomy' ), + 'add_new_item' => self::ask__( 'Your Taxonomy', 'Add New Your Taxonomy' ), + 'new_item_name' => self::ask__( 'Your Taxonomy', 'New Your Taxonomy' ), + 'add_or_remove_items' => self::ask__( 'Your Taxonomy', 'Add or remove Your Taxonomies' ), + 'choose_from_most_used' => self::ask__( 'Your Taxonomy', 'Choose from most used Taxonomies' ), + 'menu_name' => self::ask__( 'Your Taxonomy', 'Your Taxonomy' ), ]; $args = [ From 4f6cc3877b87c8c515eb4deaae4d759e380f5726 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Tue, 26 Sep 2023 14:47:47 +0300 Subject: [PATCH 03/13] Removed demo data from testing --- functions.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/functions.php b/functions.php index 2e634d5a..44981536 100644 --- a/functions.php +++ b/functions.php @@ -99,7 +99,6 @@ */ 'post_types' => [ // 'Your_Post_Type', - 'Question', ], /** @@ -180,9 +179,7 @@ ], // If you want to use classic editor somewhere, define it here - 'use_classic_editor' => [ - 'question' - ], + 'use_classic_editor' => [], // Add your own settings and use them wherever you need, for example THEME_SETTINGS['my_custom_setting'] 'my_custom_setting' => true, @@ -217,11 +214,3 @@ add_action( 'air_helper_activated', __NAMESPACE__ . '\rebuild_taxonomies' ); add_action( 'air_helper_activated', __NAMESPACE__ . '\rebuild_post_types' ); - -/** - * Show plugins and other menus for everyone - */ -add_action( 'init', function() { - remove_filter( 'air_helper_helper_remove_admin_menu_links', 'air_helper_maybe_remove_plugins_from_admin_menu' ); - add_filter( 'air_helper_disable_views_author', '__return_false' ); -} ); From fc20831cdfd4940ce446ff528b3dc24fa331c594 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Tue, 26 Sep 2023 14:49:08 +0300 Subject: [PATCH 04/13] Taxonomy PLL hook only when private --- functions.php | 1 - inc/includes/taxonomy.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 44981536..38e1f3e7 100644 --- a/functions.php +++ b/functions.php @@ -22,7 +22,6 @@ // We need to have some defaults as comments or empties so let's allow this: // phpcs:disable Squiz.Commenting.InlineComment.SpacingBefore, WordPress.Arrays.ArrayDeclarationSpacing.SpaceInEmptyArray - /** * Theme settings */ diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index 00a9918b..69a23e0d 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -66,7 +66,7 @@ protected function register_wp_taxonomy( $slug, $object_types, $args ) { } }, $object_types ); - if ( $args['pll_translatable'] ) { + if ( $args['pll_translatable'] && false === $args['public'] ) { add_filter( 'pll_get_taxonomies', function( $cpts ) use ( $slug ) { $cpts[ $slug ] = $slug; return $cpts; From 91ae0482d84f2566b76699b8f8429e944fdfc944 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Tue, 26 Sep 2023 14:58:53 +0300 Subject: [PATCH 05/13] Renamed air-helper action to be consistent with WP --- functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions.php b/functions.php index 38e1f3e7..d61432fd 100644 --- a/functions.php +++ b/functions.php @@ -211,5 +211,5 @@ add_action( 'after_setup_theme', __NAMESPACE__ . '\build_taxonomies' ); add_action( 'after_setup_theme', __NAMESPACE__ . '\build_post_types' ); -add_action( 'air_helper_activated', __NAMESPACE__ . '\rebuild_taxonomies' ); -add_action( 'air_helper_activated', __NAMESPACE__ . '\rebuild_post_types' ); +add_action( 'after_air_helper_init', __NAMESPACE__ . '\rebuild_taxonomies' ); +add_action( 'after_air_helper_init', __NAMESPACE__ . '\rebuild_post_types' ); From 0b1e403cf69df025e666358121bbba316f416464 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 15:46:23 +0300 Subject: [PATCH 06/13] PHPCS style fixes --- functions.php | 2 +- inc/includes/localization.php | 2 +- inc/includes/post-type.php | 10 +++++----- phpcs.xml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/functions.php b/functions.php index d61432fd..c27fa764 100644 --- a/functions.php +++ b/functions.php @@ -204,7 +204,7 @@ * First: we register the taxonomies and post types after setup theme * If air-helper loads (for translations), we unregister the original taxonomies and post types * and reregister them with the translated ones. - * + * * This allows the slugs translations to work before the translations are available, * and for the label translations to work if they are available. */ diff --git a/inc/includes/localization.php b/inc/includes/localization.php index dacccc7f..305535b7 100644 --- a/inc/includes/localization.php +++ b/inc/includes/localization.php @@ -23,7 +23,7 @@ // $strings[ "Accessibility: {$key}" ] = $value; // } - return apply_filters("air_light_translations", $strings); + return apply_filters( 'air_light_translations', $strings ); } ); function get_default_localization_strings( $language = 'en' ) { diff --git a/inc/includes/post-type.php b/inc/includes/post-type.php index 09ab4077..95e01285 100644 --- a/inc/includes/post-type.php +++ b/inc/includes/post-type.php @@ -33,7 +33,7 @@ abstract class Post_Type { /** * Translations used in labels - * + * * @var array(string) */ public $translations; @@ -78,10 +78,10 @@ public function register_wp_post_type( $slug, $args ) { // Wrapper for ask__ public function ask__( $key, $value ) { - $pllKey = "{$key}: {$value}"; - $this->translations[ $pllKey ] = $value; - if ( function_exists("ask__") ) { - return ask__( $pllKey ); + $pll_key = "{$key}: {$value}"; + $this->translations[ $pll_key ] = $value; + if ( function_exists( "ask__" ) ) { + return ask__( $pll_key ); } return $value; diff --git a/phpcs.xml b/phpcs.xml index 9d45a21d..a633889b 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -29,7 +29,7 @@ - + From 81b9b6eda6b4e65edb3fa3cb7867c2685c8c2405 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 16:58:51 +0300 Subject: [PATCH 07/13] Restore old PHPCS rule --- phpcs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpcs.xml b/phpcs.xml index a633889b..9d45a21d 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -29,7 +29,7 @@ - + From 47f88fa53c90fc3668c875a3d78d62633651a81f Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 17:04:37 +0300 Subject: [PATCH 08/13] Fix PHPCS errors --- inc/includes/post-type.php | 4 ++-- inc/includes/taxonomy.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/includes/post-type.php b/inc/includes/post-type.php index 95e01285..5106f6c1 100644 --- a/inc/includes/post-type.php +++ b/inc/includes/post-type.php @@ -80,7 +80,7 @@ public function register_wp_post_type( $slug, $args ) { public function ask__( $key, $value ) { $pll_key = "{$key}: {$value}"; $this->translations[ $pll_key ] = $value; - if ( function_exists( "ask__" ) ) { + if ( function_exists( 'ask__' ) ) { return ask__( $pll_key ); } @@ -90,7 +90,7 @@ public function ask__( $key, $value ) { private function register_translations() { $translations = $this->translations; - add_filter( 'air_light_translations', function($strings) use($translations) { + add_filter( 'air_light_translations', function( $strings ) use( $translations ) { return array_merge( $translations, $strings ); }, 10, 2 ); } diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index 69a23e0d..cef1eeec 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -96,10 +96,10 @@ protected function register_wp_taxonomy( $slug, $object_types, $args ) { // Wrapper for ask__ public function ask__( $key, $value ) { - $pllKey = "{$key}: {$value}"; - $this->translations[ $pllKey ] = $value; - if ( function_exists("ask__") ) { - return ask__( $pllKey ); + $pll_key = "{$key}: {$value}"; + $this->translations[ $pll_key ] = $value; + if ( function_exists( 'ask__' ) ) { + return ask__( $pll_key ); } return $value; @@ -108,7 +108,7 @@ public function ask__( $key, $value ) { private function register_translations() { $translations = $this->translations; - add_filter( 'air_light_translations', function($strings) use($translations) { + add_filter( 'air_light_translations', function( $strings ) use( $translations ) { return array_merge( $translations, $strings ); }, 10, 2 ); } From 190acd65768273bc51bbfb4a3cb2f8ac87098241 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 17:10:56 +0300 Subject: [PATCH 09/13] PHPCS fixes --- inc/includes/post-type.php | 2 +- inc/includes/taxonomy.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/includes/post-type.php b/inc/includes/post-type.php index 5106f6c1..8b929ef8 100644 --- a/inc/includes/post-type.php +++ b/inc/includes/post-type.php @@ -90,7 +90,7 @@ public function ask__( $key, $value ) { private function register_translations() { $translations = $this->translations; - add_filter( 'air_light_translations', function( $strings ) use( $translations ) { + add_filter( 'air_light_translations', function ( $strings ) use ( $translations ) { return array_merge( $translations, $strings ); }, 10, 2 ); } diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index cef1eeec..fc5d16ce 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -23,10 +23,10 @@ abstract class Taxonomy { protected $slug; /** - * Translations used in labels - * - * @var array(string) - */ + * Translations used in labels + * + * @var array(string) + */ public $translations; @@ -109,7 +109,7 @@ private function register_translations() { $translations = $this->translations; add_filter( 'air_light_translations', function( $strings ) use( $translations ) { - return array_merge( $translations, $strings ); + return array_merge ( $translations, $strings ); }, 10, 2 ); } } From 637845b4709241fb7b14e9c75b8129912b611dcf Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 17:13:08 +0300 Subject: [PATCH 10/13] PHPCS fixes --- inc/includes/taxonomy.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index fc5d16ce..94e11165 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -23,10 +23,10 @@ abstract class Taxonomy { protected $slug; /** - * Translations used in labels - * - * @var array(string) - */ + * Translations used in labels + * + * @var array + */ public $translations; @@ -108,8 +108,8 @@ public function ask__( $key, $value ) { private function register_translations() { $translations = $this->translations; - add_filter( 'air_light_translations', function( $strings ) use( $translations ) { - return array_merge ( $translations, $strings ); + add_filter( 'air_light_translations', function ( $strings ) use( $translations ) { + return array_merge( $translations, $strings ); }, 10, 2 ); } } From d2f43d0a20f5c1f6a48b386fe3e6170556874bc5 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 17:14:41 +0300 Subject: [PATCH 11/13] PHPCS fixes --- inc/includes/taxonomy.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index 94e11165..9a9c604b 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -23,10 +23,10 @@ abstract class Taxonomy { protected $slug; /** - * Translations used in labels - * - * @var array - */ + * Translations used in labels + * + * @var array + */ public $translations; From 4a396505b196e79a65908a42fa9f52b5a4eec466 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 17:16:33 +0300 Subject: [PATCH 12/13] PHPCS fixes --- inc/includes/taxonomy.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index 9a9c604b..6b2e2db6 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -23,10 +23,10 @@ abstract class Taxonomy { protected $slug; /** - * Translations used in labels - * - * @var array - */ + * Translations used in labels + * + * @var array + */ public $translations; @@ -108,7 +108,7 @@ public function ask__( $key, $value ) { private function register_translations() { $translations = $this->translations; - add_filter( 'air_light_translations', function ( $strings ) use( $translations ) { + add_filter ( 'air_light_translations', function ( $strings ) use( $translations ) { return array_merge( $translations, $strings ); }, 10, 2 ); } From 317cf1487c8c4aa454a19ca8efb82c7c86296f86 Mon Sep 17 00:00:00 2001 From: raikasdev Date: Wed, 27 Sep 2023 17:18:56 +0300 Subject: [PATCH 13/13] Try to fix PHPCS problems --- inc/includes/taxonomy.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/includes/taxonomy.php b/inc/includes/taxonomy.php index 6b2e2db6..ce76a4ac 100644 --- a/inc/includes/taxonomy.php +++ b/inc/includes/taxonomy.php @@ -23,10 +23,10 @@ abstract class Taxonomy { protected $slug; /** - * Translations used in labels - * - * @var array - */ + * Translations used in labels + * + * @var array(string) + */ public $translations; @@ -108,7 +108,7 @@ public function ask__( $key, $value ) { private function register_translations() { $translations = $this->translations; - add_filter ( 'air_light_translations', function ( $strings ) use( $translations ) { + add_filter( 'air_light_translations', function ( $strings ) use ( $translations ) { return array_merge( $translations, $strings ); }, 10, 2 ); }