Guide for creating extensions
Hi Dovi,
Love the framework. Just wondering if there is any example code for creating extensions for version 3.3.
- I have created an extension, saved it in the "redux-extensions/extensions" folder.
- 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
Rather than spending a day attempting to debug your install, try using our builder, and install your extension from that: http://build.reduxframework.com
And use our extension boilerplate as a starting point: https://github.com/ReduxFramework/extension-boilerplate
Thanks guys. Got it sorted using the boilerplate.