月度归档:2022年02月

wordpress的missed schedule错误

基于remi的安装源,创建出容器和wordpress开发环境,在运行wordpress是存在差别的。具体差别描述如下:

  • 容器模式下,文章发布是直接进入发布计划任务里,由wp_cron执行,且最终一定会出现missed schedule。
  • 非容器模式,文章发布是真正的发布,只有在指定具体时间时,发布按钮会自动转为【计划发布】,此时才真正进入计划发布流程。

曾深入对比这两个环境差异包括环境变量或某些参数等,最终无法定位出具体原因。
故最终只能使用官方的容器。

wordpress的中英文的多语言站点

假如中英文的表前缀分别为cn_和en_,其站点目录也分别为cn和en,假设帐号初始化是以cn_前缀创建的,则其它语言则只需要克隆cn的数据库即可。

第一步:将cn目录复制一份改为en。

第二步:修改wp_config.php文件,使其共享相同的用户数据表ayd_users和ayd_usermeta。

define('WP_TEMP_DIR',ABSPATH.'wp-content/tmp');
define("FS_METHOD","direct");
define("FS_CHMOD_DIR",0777);
define("FS_CHMOD_FILE",0777);

define('CUSTOM_USER_TABLE', 'ayd_users');
define('CUSTOM_USER_META_TABLE', 'ayd_usermeta');

第三步:在ayd_usermeta表中复制相关前缀表项,需要复制的表前项有:

en_capabilities
en_user_level
en_user-settings
en_user-settings-time
en_dashboard_quick_press_last_post_id
en_persisted_preferences

第四步:复制cn_xxx的数据表,并改名为en_xxx。

第五步:修改en_options表中的原cn_user_roles字段,并改为en_user_roles。

此时,应该完成的新的英文版创建了,然后就可以打开这个子站进行相关的编辑了。

——————————————–

1.其登录后台的权限关键代码在【wp-admin/includes/menu.php】中,如下所示:

wordpress是支持多语言站点,但如果希望多站点实现单点登录的话,需要修改如下几项。

// 不同的语言的站点均配置相同的用户表。
define('CUSTOM_USER_TABLE', 'ayd_users'); 
define('CUSTOM_USER_META_TABLE', 'ayd_usermeta');

共享的用户表,ayd_usermeta表需要添加管理员权限,否则是无法登录后台的。其字段格式是以表前缀开头的,如下:

$table_prefix . _capabilities和 $table_prefix ._user_level,假如$table_prefix是cn,则如下内容为【key, value】
cn_capabilities = a:1:{s:13:"administrator";b:1;}
cn_user_level = 10
如果还有另外其个项也顺便修改它,如:cn_user-settings / cn_user-settings-time

如果在登录后台时,仍然报错,则可能是表前缀是由其它前缀修改过来的,此时仍需要修改【$table_prefix .option】表的cn_user_roles,如下所示:

cn_user_roles的值如下:
a:5:{s:13:"administrator";a:2:{s:4:"name";s:13:"Administrator";s:12:"capabilities";a:65:{s:13:"switch_themes";b:1;s:11:"edit_themes";b:1;s:16:"activate_plugins";b:1;s:12:"edit_plugins";b:1;s:10:"edit_users";b:1;s:10:"edit_files";b:1;s:14:"manage_options";b:1;s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:6:"import";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:8:"level_10";b:1;s:7:"level_9";b:1;s:7:"level_8";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;s:12:"delete_users";b:1;s:12:"create_users";b:1;s:17:"unfiltered_upload";b:1;s:14:"edit_dashboard";b:1;s:14:"update_plugins";b:1;s:14:"delete_plugins";b:1;s:15:"install_plugins";b:1;s:13:"update_themes";b:1;s:14:"install_themes";b:1;s:11:"update_core";b:1;s:10:"list_users";b:1;s:12:"remove_users";b:1;s:13:"promote_users";b:1;s:18:"edit_theme_options";b:1;s:13:"delete_themes";b:1;s:6:"export";b:1;s:11:"smartslider";b:1;s:18:"smartslider_config";b:1;s:16:"smartslider_edit";b:1;s:18:"smartslider_delete";b:1;}}s:6:"editor";a:2:{s:4:"name";s:6:"Editor";s:12:"capabilities";a:34:{s:17:"moderate_comments";b:1;s:17:"manage_categories";b:1;s:12:"manage_links";b:1;s:12:"upload_files";b:1;s:15:"unfiltered_html";b:1;s:10:"edit_posts";b:1;s:17:"edit_others_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:10:"edit_pages";b:1;s:4:"read";b:1;s:7:"level_7";b:1;s:7:"level_6";b:1;s:7:"level_5";b:1;s:7:"level_4";b:1;s:7:"level_3";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:17:"edit_others_pages";b:1;s:20:"edit_published_pages";b:1;s:13:"publish_pages";b:1;s:12:"delete_pages";b:1;s:19:"delete_others_pages";b:1;s:22:"delete_published_pages";b:1;s:12:"delete_posts";b:1;s:19:"delete_others_posts";b:1;s:22:"delete_published_posts";b:1;s:20:"delete_private_posts";b:1;s:18:"edit_private_posts";b:1;s:18:"read_private_posts";b:1;s:20:"delete_private_pages";b:1;s:18:"edit_private_pages";b:1;s:18:"read_private_pages";b:1;}}s:6:"author";a:2:{s:4:"name";s:6:"Author";s:12:"capabilities";a:10:{s:12:"upload_files";b:1;s:10:"edit_posts";b:1;s:20:"edit_published_posts";b:1;s:13:"publish_posts";b:1;s:4:"read";b:1;s:7:"level_2";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;s:22:"delete_published_posts";b:1;}}s:11:"contributor";a:2:{s:4:"name";s:11:"Contributor";s:12:"capabilities";a:5:{s:10:"edit_posts";b:1;s:4:"read";b:1;s:7:"level_1";b:1;s:7:"level_0";b:1;s:12:"delete_posts";b:1;}}s:10:"subscriber";a:2:{s:4:"name";s:10:"Subscriber";s:12:"capabilities";a:2:{s:4:"read";b:1;s:7:"level_0";b:1;}}}

WordPress安装主题等提示FTP问题

wordpress为了安全考虑,故意留下来的。
需要在wp_config.php的文件中添加如下代码,即可:

define('WP_TEMP_DIR',ABSPATH.'wp-content/tmp');
define("FS_METHOD","direct");
define("FS_CHMOD_DIR",0777);
define("FS_CHMOD_FILE",0777);

xdebug的nginx配置

修改请求的Cookie信息。如下:
proxy_set_header Cookie “$http_cookie; XDEBUG_SESSION=PHPSTROM”;

完整的一份配置

server {
     listen 80;  #from https port to http port .
     location / {
         proxy_pass   http://127.0.0.1:8080/;
         proxy_set_header Cookie "$http_cookie; XDEBUG_SESSION=PHPSTROM";
         proxy_set_header Host $host;
     }
}

server {
    listen 8080;
    location ~ \.php$ {     
        fastcgi_pass   127.0.0.1:9090;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}