[wp-trac] [WordPress Trac] #62519: _doing_it_wrong misplaced in the _load_textdomain_just_in_time() function

WordPress Trac noreply at wordpress.org
Mon Nov 25 08:05:50 UTC 2024


#62519: _doing_it_wrong misplaced in the _load_textdomain_just_in_time() function
-----------------------------+-------------------------
 Reporter:  babelhalsupport  |       Owner:  (none)
     Type:  defect (bug)     |      Status:  closed
 Priority:  normal           |   Milestone:
Component:  I18N             |     Version:  6.7
 Severity:  normal           |  Resolution:  worksforme
 Keywords:  has-patch        |     Focuses:
-----------------------------+-------------------------

Comment (by babelhalsupport):

 **bh-meeting.php**
 {{{#!php
 <?php
 /**
  * Plugin Name: BH - Ülések modul
  * Description: Admin felület az ülések kezelésére
  * Version: 2023.12.04
  * Author: Bábelhal Webstudio Kft.
  * Author URI: https://babelhal.hu
  * Text Domain: bh_meeting
  */

 [...]

 define( 'BH_CPT_MEETING', 'meeting' );

 $cpt_args =
 [
         BH_CPT_MEETING =>
         [
                 'public'             => true,
                 'publicly_queryable' => true,
                 'show_ui'            => true,
                 'show_in_menu'       => true,
                 'query_var'          => true,
                 'capabilities'       => array(
 [...]
                 ),
                 'has_archive'        => false,
                 'hierarchical'       => false,
                 'menu_position'      => 30,
                 'supports'           => [ 'title', 'editor' ],
                 'menu_icon'          => 'dashicons-groups',
                 'labels'             =>
                 [
                         'name'               => __( 'Seats', 'bh_meeting'
 ),
                         'singular_name'      => __( 'Seat', 'bh_meeting'
 ),
                         'menu_name'          => __( 'Seats', 'bh_meeting'
 ),
 [...]
                 ]
         ]
 ];

 $params =
 [
         'plugin_name'      => plugin_basename( dirname( __FILE__, 1 ) ),
         'plugin_path'      => plugin_dir_path( __FILE__ ),
         'plugin_url'       => plugin_dir_url( __FILE__ ),
         'post_type'        => BH_CPT_MEETING,
         'cpt_args'         => $cpt_args,
 ];
 $instance = new Babelhal\Plugins\BhMeeting\BhMeeting( $params );
 }}}


 ----


 **BhMeeting.php**
 {{{#!php
 <?php
 class BhMeeting extends BhPluginBase
 {
         public function __construct( $params ) {
                 parent::__construct( $params );
 [...]
         }
 [...]
 }
 }}}



 ----


 **BhPluginBase.php**
 {{{#!php
 <?php
 abstract class BhPluginBase
 {
         public function __construct( $params ) {
                 $this->plugin_name      = $params['plugin_name'];
                 $this->plugin_path      = $params['plugin_path'];
                 $this->plugin_url       = $params['plugin_url'];
                 $this->post_type        = $params['post_type'];
                 $this->cpt_args         = ( isset( $params['cpt_args'] ) ?
 $params['cpt_args'] : [] );
 [...]
                 add_action( 'init', array( $this, 'load_plugin_textdomain'
 ) );
 [...]
                 add_action( 'init', array( $this,
 'register_custom_post_types' ) );
 [...]
         }
 [...]
 }
 }}}

 **Some explanation**
 We tried to translate the name of the custom post, the menu and related
 text.
 But we did this before calling ''load_plugin_textdomain()''.
 I think this should trigger a **doing_it_wrong**.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62519#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list