reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!

Home Page:http://redux.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to load custom extension

MorenoDD opened this issue · comments

Site Health Report

WordPress Version: 6.3.1
Server: nginx/1.16.0
PHP Version: 7.4.1
ReduxFramework Installed as Plugin

Steps to reproduce

The process for loading a custom extension is not clear.

Following the guide at https://devs.redux.io/guides/basics/using-extensions.html#loading-an-extension, you should load the extension using the following syntax:
Redux::load_extensions('OPT_NAME', 'RELATIVE_PATH_TO_DIRECTORY');

However, the load_extensions method only accepts a single parameter, as indicated here: https://devs.redux.io/configuration/api.html#available-methods
Redux::load_extensions($redux_framework)

In fact, using the syntax from the guide:

$opt_name = 'my-theme-options';

$theme = wp_get_theme();

$args = array(
    'opt_name'	=> $opt_name,
    'menu_icon' => '',
    'menu_type' => 'menu',
    'menu_title' => __('Theme Options', 'nope'),
    'page_title' => __('Theme Options', 'nope'),
    'page_slug' => $opt_name,
    'page_priority' => 4,
    'customizer' => false,
    'dev_mode' => false,
    'admin_bar' => false,
    'display_name' => $theme->get( 'Name' ),
    'display_version' => $theme->get( 'Version' ),
    'output' => false,
    'output_tag' => false
);
Redux::set_args( $opt_name, $args );

Redux::load_extensions($opt_name, dirname( __FILE__ ).'/extensions/my_extension');

results in an error.

Expected Behavior

Extension loaded successfully.

Actual Behavior

Get fatal error:

Fatal error: Uncaught TypeError: Argument 1 passed to Redux::get_extensions() must be of the type string, null given, called in /app/public/wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-api.php on line 231 and defined in /app/public/wp-content/plugins/redux-framework/redux-core/inc/classes/class-redux-api.php on line 1691

You're not showing YOUR code, nor are you including the system health report. This is required information. What extension are you trying to load, exactly?

Site Health Report added.

I'm trying to load the extension "my_extension".

Thanks.

Unfortunately, whoever wrote that help document did it incorrectly. I'll have to update it later.

Use

Redux::set_extensions( $opt_name, $path to extension_dir );