2014-03-07 57 views
2

如何在主题WordPress中包含Redux Framework?如何在主题中包含Redux Framework

此代码不起作用:

<?php 
    if (!class_exists('ReduxFramework') && file_exists(dirname(__FILE__) . '/ReduxFramework/ReduxCore/framework.php')) { 
    require_once(dirname(__FILE__) . '/ReduxFramework/ReduxCore/framework.php'); 
    } 
    if (!isset($redux_demo) && file_exists(dirname(__FILE__) . '/ReduxFramework/sample/sample-config.php')) { 
    require_once(dirname(__FILE__) . '/ReduxFramework/sample/sample-config.php'); 
    } 
?> 
+0

你按照指示在这里:https://github.com/ReduxFramework/redux-framework/wiki/Embedding-Redux-into-Your-Theme-or-Plugin 或正确地调整你的路你上面显示的代码? – AndyWarren

+0

好问题。在文档中没有清楚地列出:http://docs.reduxframework.com/redux-framework/getting-started/ –

回答

1

对于我的作品:

// load the theme's framework 
if (!class_exists('ReduxFramework') && file_exists(dirname(__FILE__) . '/framework/ReduxCore/framework.php')) { 
require_once(dirname(__FILE__) . '/framework/ReduxCore/framework.php'); 
} 

// load the theme's options 
if (!isset($redux_owd) && file_exists(dirname(__FILE__) . '/framework/sample/sample-config.php')) { 
require_once(dirname(__FILE__) . '/framework/sample/sample-config.php'); 
} 

我有文件夹的框架年底他我有ReduxCore结束样本文件夹...检查代码.. Photo

2

扰流警报,在Redux的主要开发在这里。您可以使用Redux Generator获取管理文件夹并绕过一些痛苦。

http://generate.reduxframework.com

毕竟,这是一个免费服务。 :)

+0

Redux确实需要更清晰的文档。他们假设你知道任何刚刚开始使用Redux的人都知道的事情。 '只下载管理文件夹部分。这将为您提供一个文件夹,您可以放置​​在主题或插件中,并包含〜/ admin/admin-init.php来启动它。“好的,太好了。现在你能告诉我在哪里包含admin-init.php吗? – Gavin

+0

你见过... http://docs.reduxframework.com?可能是所有WordPress框架中最完整的文档? :) – Dovy

+0

@Dovy - 它确实是一个很好的框架,并且它对大多数部分都有很好的记录。但是缺少一些非常重要的部分,例如[如何在自己的插件中嵌入框架](https://docs.reduxframework.com/core/advanced/embed/)(针对开发人员)。授予 - 这很容易理解 - 但仍然 - 对于初学者开发者来说可能会有所帮助。 –

1

使用这种在functions.php的

// this will deactive demo mode of reduxframework plugin and will not display and addvertisement 

if (! function_exists('redux_disable_dev_mode_plugin')) { 
     function redux_disable_dev_mode_plugin($redux) { 
      if ($redux->args['opt_name'] != 'redux_demo') { 
       $redux->args['dev_mode'] = false; 
      } 
     } 

     add_action('redux/construct', 'redux_disable_dev_mode_plugin'); 
    } 

// add sample config to overwrite reduxcore/framework.php 

if (!isset($redux_demo)){ 
    require_once(dirname(__FILE__) . '/sample-config.php'); 
} 

要安装该插件reduxframework你需要TGM插件

,你会从这里得到TGM插件 - >http://tgmpluginactivation.com/

包括TGM插件在你的主题功能或复制和过去tgm-init.php在functions.php中的代码,不要忘了class-tgm-plugin-activation.php。

示例 - >安装终极版框架插件

$plugins = array(// add below code to add redux framework plugin 

     array(
      'name'    => 'Redux Framework', // The plugin name. 
      'slug'    => 'redux-framework-master', // The plugin slug (typically the folder name). 
      'required'   => true, // If false, the plugin is only 'recommended' instead of required. 
      'external_url'  => 'https://wordpress.org/plugins/redux-framework', // If set, overrides default API URL and points to an external URL. 
      'source'    => get_stylesheet_directory() . '/plugins/redux-framework-master.zip', 
      'force_activation' => true, 
      'force_deactivation' => true,  
     ), 
); 

force_activation - >真,将激活reduxframework当你的主题将积极。

'force_deactivation'=> true,将在您的主题无效时停用reduxframework。

您可以在主题文件夹中添加reduxframework,但是当您通过wordpress主题检查主题时,您会收到很多错误。

我已经开发了一个主题,下载并检查它会帮助你很多。 http://www.nxcreation.com/alpha-nx-one/

0

在该链接http://tgmpluginactivation.com/download/生成插件激活文件(“class-tgm-plugin-activation。PHP”包括文件到你的主题文件夹)下载的zip文件

在该文件中‘插件数组的数组’

添加代码

// add below code to add redux framework plugin 

$plugins = array( 
    array(
     'name'    => 'Redux Framework', // The plugin name. 
     'slug'    => 'redux-framework', // The plugin slug (typically the folder name). 
     'required'   => false, 
     'version'   => '3.6.1', 
     'external_url'  => 'https://wordpress.org/plugins/redux-framework', 
     'source'    => 'repo', 
     'force_activation' => false, 
     'force_deactivation' => false,  
    ), 
); 

在此使用了插件路径

'source'=>'repo',

1

试试这些步骤希望能帮到

步骤1Download Redux framework

步骤2:提取/解压下载的终极版框架文件。

步骤3:复制ReduxCore从提取/解压缩文件的文件夹到您的活动主题目录。

步骤4:在叫你的当前活动的主题目录中创建新文件夹功能

步骤5:下载框架文件样本的config.php从样品目录复制到你的主题功能文件夹

第6步:将此复制的文件从sample-config.php重命名为admin-config.php

第7步:将此代码复制粘贴到您的functions.php文件的底部。

if(!class_exists('ReduxFramework')){ 
    require_once(dirname(__FILE__) . '/ReduxCore/Framework.php'); 
} 

if(!isset($redux_demo)){ 
    require_once(dirname(__FILE__) . '/functions/admin-config.php'); 
} 

步骤8:就是这样。现在,您可以在主题中看到主题选项。 此外,您可以根据您的要求定制您的/functions/admin-config.php文件。

Reference link

0

简单方法包括在wordpress主题终极版框架。

// Including Redux Framework 
    require_once (dirname(__FILE__) . '/redux/redux-framework.php'); 
    if (class_exists('Redux')) { 
     require_once (dirname(__FILE__) . '/redux/sample/barebones-config.php'); 
    } 
相关问题