te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>php - load_plugin_textdomain Generates Notice in WordPress Multisite Only - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - load_plugin_textdomain Generates Notice in WordPress Multisite Only - Stack Overflow

programmeradmin1浏览0评论

My WordPress plugin is Network Only plugin and all my local tests on WordPress Multisite only, Since WordPress 6.7, I start to receive (Function _load_textdomain_just_in_time was called incorrectly) notice.

I moved the translation code from 'plugins_loaded' action to 'init' with very low priority but nothing help, finally, I created a single-site for test and I found that the plugin working properly without notices, and this notice only appears in WordPress Multisite.

I tried a lot and even moved the translation code from classes to the main .php file, but still generates that notice.

Because of the plugin working only in a certain site (determined by the user in a constant), I tried to check current blog using (get_current_blog_id) to ensure that the translation code triggered only in the correct site, But nothing help.

Here's my situation:

My Directories:

- pascalplugin
  -- languages
     -- pascalplugin-en_US.mo
     -- pascalplugin-en_US.po
     -- pascalplugin.pot
  -- pascalplugin.php

pascalplugin.php

/**
 * Plugin Name:         PascalPlugin
 * Version:             1.0.0
 * Domain Path:         /languages/
 * Text Domain:         pascalplugin
 * Tested up to:        6.7
 * Requires at least:   5.9
 * Requires PHP:        7.0
 * Network:             true
 */

if ( ! defined( 'ABSPATH' ) ) {
    die( 'You cannot access plugin\'s files directly' );
}

if( !defined('PASCALPLUGIN_TEXTDOMAIN') ) {
    define( 'PASCALPLUGIN_TEXTDOMAIN', 'pascalplugin' );
}

if (!defined('PASCALPLUGIN__FILE__')) {
    define( 'PASCALPLUGIN__FILE__', __FILE__ );
}

add_action('init', '__init_load_textdomain', 1);
function __init_load_textdomain() {
    $dir = wp_normalize_path(dirname(PASCALPLUGIN__FILE__));
    $basename = plugin_basename(PASCALPLUGIN__FILE__);
    $basepath = trailingslashit(dirname($basename));
    $lang_dir = trailingslashit($basepath . 'languages');

    // Echo working properly and output "pascalplugin/languages/"
    echo $lang_dir;

    load_plugin_textdomain(PASCALPLUGIN_TEXTDOMAIN, false, $lang_dir);
}

My WordPress plugin is Network Only plugin and all my local tests on WordPress Multisite only, Since WordPress 6.7, I start to receive (Function _load_textdomain_just_in_time was called incorrectly) notice.

I moved the translation code from 'plugins_loaded' action to 'init' with very low priority but nothing help, finally, I created a single-site for test and I found that the plugin working properly without notices, and this notice only appears in WordPress Multisite.

I tried a lot and even moved the translation code from classes to the main .php file, but still generates that notice.

Because of the plugin working only in a certain site (determined by the user in a constant), I tried to check current blog using (get_current_blog_id) to ensure that the translation code triggered only in the correct site, But nothing help.

Here's my situation:

My Directories:

- pascalplugin
  -- languages
     -- pascalplugin-en_US.mo
     -- pascalplugin-en_US.po
     -- pascalplugin.pot
  -- pascalplugin.php

pascalplugin.php

/**
 * Plugin Name:         PascalPlugin
 * Version:             1.0.0
 * Domain Path:         /languages/
 * Text Domain:         pascalplugin
 * Tested up to:        6.7
 * Requires at least:   5.9
 * Requires PHP:        7.0
 * Network:             true
 */

if ( ! defined( 'ABSPATH' ) ) {
    die( 'You cannot access plugin\'s files directly' );
}

if( !defined('PASCALPLUGIN_TEXTDOMAIN') ) {
    define( 'PASCALPLUGIN_TEXTDOMAIN', 'pascalplugin' );
}

if (!defined('PASCALPLUGIN__FILE__')) {
    define( 'PASCALPLUGIN__FILE__', __FILE__ );
}

add_action('init', '__init_load_textdomain', 1);
function __init_load_textdomain() {
    $dir = wp_normalize_path(dirname(PASCALPLUGIN__FILE__));
    $basename = plugin_basename(PASCALPLUGIN__FILE__);
    $basepath = trailingslashit(dirname($basename));
    $lang_dir = trailingslashit($basepath . 'languages');

    // Echo working properly and output "pascalplugin/languages/"
    echo $lang_dir;

    load_plugin_textdomain(PASCALPLUGIN_TEXTDOMAIN, false, $lang_dir);
}
Share Improve this question edited Feb 18 at 7:26 yivi 47.5k18 gold badges130 silver badges153 bronze badges asked Feb 17 at 17:43 Hady ShaltoutHady Shaltout 6321 gold badge9 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

This looks like a known issue and is undergoing active development

Internationalization improvements in 6.7

  • #62175 closed defect (bug) (duplicate) PHP Notice in WP 6.7: _load_textdomain_just_in_time was called incorrectly
  • #44937 closed enhancement (fixed) Add _doing_it_wrong to load_plugin_textdomain
发布评论

评论列表(0)

  1. 暂无评论