doushan3511 2018-06-16 12:48
浏览 32
已采纳

无法将自定义wordpress模块​​迁移到新服务器

I need to migrate a WordPress site to a live server. I've done this numerous times and everything went fine except the custom modules I made for the theme I had to use (Divi) don't work. I am using this guide to load the custom modules. For example what I get on my local development server is: enter image description here

And what I'm getting on the live server after migrating is: enter image description here

The only difference I could think of is that the live server is using PHP7 and my local one is using PHP5. Could this be the problem? Here's the code I use in my child theme's functions.php:

/*================================================
# LOAD CUSTOM MODULES
================================================*/
function Custom_Modules(){
 if(class_exists("ET_Builder_Module")){
 include("/custom-modules/custom-latest-case-studies.php");
 include("/custom-modules/custom-latest-resources.php");
 include("/custom-modules/custom-resources-page.php");
 include("/custom-modules/custom-blog-page.php");
 include("/custom-modules/custom-portfolio-big.php");
 include("/custom-modules/custom-portfolio-small-1.php");
 include("/custom-modules/custom-portfolio-small-2.php");
 }
}

function Prep_Custom_Modules(){
 global $pagenow;

$is_admin = is_admin();
 $action_hook = $is_admin ? 'wp_loaded' : 'wp';
 $required_admin_pages = array( 'edit.php', 'post.php', 'post-new.php', 'admin.php', 'customize.php', 'edit-tags.php', 'admin-ajax.php', 'export.php' ); // list of admin pages where we need to load builder files
 $specific_filter_pages = array( 'edit.php', 'admin.php', 'edit-tags.php' );
 $is_edit_library_page = 'edit.php' === $pagenow && isset( $_GET['post_type'] ) && 'et_pb_layout' === $_GET['post_type'];
 $is_role_editor_page = 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'et_divi_role_editor' === $_GET['page'];
 $is_import_page = 'admin.php' === $pagenow && isset( $_GET['import'] ) && 'wordpress' === $_GET['import']; 
 $is_edit_layout_category_page = 'edit-tags.php' === $pagenow && isset( $_GET['taxonomy'] ) && 'layout_category' === $_GET['taxonomy'];

if ( ! $is_admin || ( $is_admin && in_array( $pagenow, $required_admin_pages ) && ( ! in_array( $pagenow, $specific_filter_pages ) || $is_edit_library_page || $is_role_editor_page || $is_edit_layout_category_page || $is_import_page ) ) ) {
 add_action($action_hook, 'Custom_Modules', 9789);
 }
}
Prep_Custom_Modules();
  • 写回答

1条回答 默认 最新

  • dsf4354353452 2018-06-25 15:14
    关注

    The problem was in the brackets at the import lines. PHP7 doesn't like them:

    /*================================================
    # LOAD CUSTOM MODULES
    ================================================*/
    function Custom_Modules(){
     if(class_exists("ET_Builder_Module")){
     include "custom-modules/custom-latest-case-studies.php";
     include "custom-modules/custom-latest-resources.php";
     include "custom-modules/custom-resources-page.php";
     include "custom-modules/custom-blog-page.php";
     include "custom-modules/custom-portfolio-big.php";
     include "custom-modules/custom-portfolio-small-1.php";
     include "custom-modules/custom-portfolio-small-2.php";
     }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 xshell无法连接提示ssh服务器拒绝密码
  • ¥15 AT89C52单片机C语言关于串口通信的位操作
  • ¥20 需要步骤截图(标签-服务器|关键词-map)
  • ¥50 gki vendor hook
  • ¥15 灰狼算法和蚁群算法如何结合
  • ¥15 这是一个利用ESP32自带按键和LED控制的录像代码,编译过程出现问题,请解决并且指出错误,指导如何处理 ,协助完成代码并上传代码
  • ¥20 stm32f103,hal库 hal_usart_receive函数接收不到数据。
  • ¥20 求结果和代码,sas利用OPTEX程序和D-efficiency生成正交集
  • ¥50 adb连接不到手机是怎么回事?
  • ¥20 抓取数据时发生错误: get_mooncake_data() missing 1 required positional argument: 'driver'的问题,怎么改出正确的爬虫代码?