首页 > 解决方案 > 我如何将登录模式从主题库更改为其他插件 wordpress

问题描述

这是我的主题登录我想将其更改为其他插件而不影响主题我需要帮助

> <?php if(get_theme_mod('header_login_btn', true ) &&
> !is_user_logged_in()){ 
>                                           $header_login_btn_text = get_theme_mod('header_login_btn_text', 'Login');
>                                           $header_reg_btn_text = get_theme_mod('header_reg_btn_text', 'Sign Up');
>                                           ?>
>                                       <div class="skillate-header-login d-inline-block ml-4">
>                                           <div class="header-login-wrap">
>                                               <a data-toggle="modal" href="#modal-login">
>                                                   <?php echo esc_html($header_login_btn_text); ?>
>                                               </a>
>                                               <a data-toggle="modal" href="#modal-registration">
>                                                   <?php echo esc_html($header_reg_btn_text); ?>
>                                               </a>
>                                           </div>
>                                       </div>
>                                       <?php } ?>

标签: wordpressauthenticationwordpress-themingcustom-wordpress-pageslogin-script

解决方案


制作插件很简单。使用此代码,创建一个名为的文件夹whatever-name-you-want并创建一个名为whatever-name-you-want.php. 在该文件中添加此代码。您可以更改注释代码中的名称。

然后转到管理部分中的插件,然后单击激活魔术插件或您所称的任何名称。

/**
 * Plugin Name: Magic Plugin
 * Description: Magic Plugin performs magic. 
 * Plugin URI: http://example.com/magic-plugin
 * Version: 2.3
 * Author: Mr. Magic 
 * Author URI: http://example.com/
 * Text Domain: magic-plugin 
 * 
 * @package Magic Plugin
 */

if(get_theme_mod('header_login_btn', true ) && !is_user_logged_in()){ 
    $header_login_btn_text = get_theme_mod('header_login_btn_text', 'Login');
    $header_reg_btn_text = get_theme_mod('header_reg_btn_text', 'Sign Up');
    ?>
    <div class="skillate-header-login d-inline-block ml-4">
        <div class="header-login-wrap">
            <a data-toggle="modal" href="#modal-login">
                <?php echo esc_html($header_login_btn_text); ?>
            </a>
            <a data-toggle="modal" href="#modal-registration">
                <?php echo esc_html($header_reg_btn_text); ?>
            </a>
        </div>
    </div>
<?php 
} 

推荐阅读