redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Guide for creating extensions

Open wpinsite opened this issue 12 years ago • 3 comments

Hi Dovi,

Love the framework. Just wondering if there is any example code for creating extensions for version 3.3.

  1. I have created an extension, saved it in the "redux-extensions/extensions" folder.
  2. I have called the "loader" & "framework" in my "functions.php" file like this.

require get_template_directory().'/admin/redux-extensions/extensions-init.php'; require get_template_directory().'/admin/admin-init.php';

I copied the field class "textarea" as an example extension. I renamed it to "example.php"

Here is the extension:

if ( ! class_exists( 'ReduxFramework_example' ) ) { class ReduxFramework_example {

        function __construct( $field = array(), $value = '', $parent ) {
            $this->parent = $parent;
            $this->field  = $field;
            $this->value  = $value;
        }

        function render() {

            $this->field['placeholder'] = isset( $this->field['placeholder'] ) ? $this->field['placeholder'] : "";
            $this->field['rows']        = isset( $this->field['rows'] ) ? $this->field['rows'] : 6;

            ?>
            <textarea name="<?php echo $this->field['name'] . $this->field['name_suffix']; ?>"
                      id="<?php echo $this->field['id']; ?>-textarea"
                      placeholder="<?php echo esc_attr( $this->field['placeholder'] ); ?>"
                      class="large-text <?php echo $this->field['class']; ?>"
                      rows="<?php echo $this->field['rows']; ?>"><?php echo $this->value; ?></textarea>
        <?php
        }
    }
}

When I try and add the new field to my config file I cannot get the field to render.

array( 'id' => 'global_test', 'type' => 'example', 'title' => __('Test field', 'bizstream'), 'desc' => __('text', 'bizstream'),

                ),

Any help on getting the extension to load would be greatly appreciated.

Thanks

wpinsite avatar Sep 18 '14 10:09 wpinsite

Rather than spending a day attempting to debug your install, try using our builder, and install your extension from that: http://build.reduxframework.com

kprovance avatar Sep 18 '14 14:09 kprovance

And use our extension boilerplate as a starting point: https://github.com/ReduxFramework/extension-boilerplate

dovy avatar Sep 18 '14 18:09 dovy

Thanks guys. Got it sorted using the boilerplate.

wpinsite avatar Sep 18 '14 22:09 wpinsite