【问题标题】:How to include mailchimp plugin with wordpress theme如何在 wordpress 主题中包含 mailchimp 插件
【发布时间】:2017-06-23 06:11:24
【问题描述】:

我正在开发 WordPress 主题,这个主题有电子邮件订阅小部件。所以我想在主题中包含 MailChimp 插件。该怎么做?

【问题讨论】:

    标签: wordpress wordpress-theming mailchimp


    【解决方案1】:

    对不起兄弟,你不能在你的主题中使用 mailchimp 插件作为嵌入式插件。但是您可以使用 TGM 插件激活文件将插件包含到您的主题中。从这里TGM plugin activation class 下载 TGM 类文件的副本,然后将 class-tgm-plugin-activation.php 文件复制到您的主题目录,并将以下代码添加到您主题的 functions.php 文件中..

    <?php
    
    require get_template_directory() . '/class-tgm-plugin-activation.php'; //add your file path where you put the file
    
    add_action( 'tgmpa_register', 'something_register_required_plugins' );
    
    function something_register_required_plugins() {
    
        $plugins = array(
    
            array(
                'name'      => 'Mailchimp',
                'slug'      => 'mailchimp',
                'required'  => true,
            ),
    
        );
    
        $config = array(
            'id'           => 'something',             // Unique ID for hashing notices for multiple instances of TGMPA.
            'default_path' => '',                      // Default absolute path to bundled plugins.
            'menu'         => 'tgmpa-install-plugins', // Menu slug.
            'parent_slug'  => 'themes.php',            // Parent menu slug.
            'capability'   => 'edit_theme_options',    // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
            'has_notices'  => true,                    // Show admin notices or not.
            'dismissable'  => true,                    // If false, a user cannot dismiss the nag message.
            'dismiss_msg'  => '',                      // If 'dismissable' is false, this message will be output at top of nag.
            'is_automatic' => false,                   // Automatically activate plugins after installation or not.
            'message'      => '',                      // Message to output right before the plugins table.
        );
    
        tgmpa( $plugins, $config );
    }
     ?>
    

    这会建议您的用户从 wordpress.org 存储库安装 mailchimp 插件

    【讨论】:

      猜你喜欢
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 2014-02-10
      • 2016-09-20
      • 2011-09-07
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      相关资源
      最近更新 更多