Skip to content

Commit fc8299a

Browse files
committed
HelpHub: Defer post type and taxonomy registration to init to avoid early translation loading.
Move instantiation of post types and taxonomy out of the constructor and into a new method hooked to init, preventing _load_textdomain_just_in_time warnings from WordPress 6.7. git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14761 74240141-8908-4e6f-9713-ba540dce6ec7
1 parent 723baed commit fc8299a

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

wordpress.org/public_html/wp-content/plugins/support-helphub/inc/helphub-post-types/classes/class-helphub-post-types.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,24 @@ public function __construct() {
126126
require_once( dirname( __FILE__ ) . '/class-helphub-post-types-post-type.php' );
127127
require_once( dirname( __FILE__ ) . '/class-helphub-post-types-taxonomy.php' );
128128

129+
register_activation_hook( __FILE__, array( $this, 'install' ) );
130+
131+
// Delay post type and taxonomy registration until init to avoid loading translations too early.
132+
add_action( 'init', array( $this, 'register_post_types_and_taxonomies' ), 0 );
133+
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
134+
add_action( 'pre_get_posts', array( $this, 'fix_archive_category' ) );
135+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
136+
} // End __construct()
137+
138+
/**
139+
* Register post types and taxonomies.
140+
*
141+
* Hooked to init to avoid loading translations too early.
142+
*
143+
* @access public
144+
* @since 1.0.0
145+
*/
146+
public function register_post_types_and_taxonomies() {
129147
$this->post_types['post'] = new HelpHub_Post_Types_Post_Type(
130148
'post',
131149
__( 'Post', 'wporg-forums' ),
@@ -161,18 +179,9 @@ public function __construct() {
161179
'wordpress-versions'
162180
);
163181

164-
/* Post Types - End */
165-
166-
// Register an example taxonomy. To register more taxonomies, duplicate this line.
167182
$this->taxonomies['helphub_category'] = new HelpHub_Post_Types_Taxonomy( array( 'post', 'helphub_article' ), 'category', __( 'Category', 'wporg-forums' ), __( 'Categories', 'wporg-forums' ) );
168183
$this->taxonomies['helphub_major_release'] = new HelpHub_Post_Types_Taxonomy( 'helphub_version', 'helphub_major_release', __( 'Major Release', 'wporg-forums' ), __( 'Major Releases', 'wporg-forums' ) );
169-
170-
register_activation_hook( __FILE__, array( $this, 'install' ) );
171-
172-
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
173-
add_action( 'pre_get_posts', array( $this, 'fix_archive_category' ) );
174-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) );
175-
} // End __construct()
184+
}
176185

177186
/**
178187
* Main HelpHub_Post_Types Instance

0 commit comments

Comments
 (0)