2014-03-07 53 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'); 
    } 
相關問題