Adding Builder Element in Plugin
-
Topic
-
I’m trying to add a builder element from a plugin like so:
function jma_flip_code($atts, $content = null){ extract( shortcode_atts( array( 'back' => '', 'class' => '' ), $atts ) ); $x = '<div class="' . $class . ' jma-hover jma-flip-panel">'; $x .= '<div class="side front">'; $x .= '<div class="inner">'; $x .= do_shortcode($content); $x .= '</div><!--inner-->'; $x .= '</div><!--front-->'; $x .= '<div class="side back">'; $x .= '<div class="inner">'; $x .= do_shortcode($back); $x .= '</div><!--inner-->'; $x .= '</div><!--back-->'; $x .= '</div><!--jma-flip-panel-->'; return $x; } add_shortcode('jma_flip_shortcode','jma_flip_code'); function jma_add_flip_panel(){ if ( ! defined('TB_FRAMEWORK_VERSION') ) { return; } $options = array( array( 'name' => 'Class', 'desc' => 'An optional class for the wrapping div.', 'id' => 'class', 'type' => 'text' ), array( 'name' => 'Front', 'desc' => 'Content for the front of the panel.', 'id' => 'front', 'type' => 'editor' ), array( 'name' => 'Back', 'desc' => 'Content for the back of the panel.', 'id' => 'back', 'type' => 'editor' ) ); themeblvd_add_builder_element( 'flip_panel', 'Flip Panel', 'none', $options, 'display_flip_panel' ); } add_action('after_setup_theme', 'jma_add_flip_panel'); function display_flip_panel( $id, $options, $location = '') { $atts['class'] = $options['class']; $atts['back'] = $options['back']; echo jma_flip_code($atts, $option['front']); }
The element displays in the page editor as expected, but when I update the page it doesn’t hold the value (editors in my ‘flip panel’ go blank). I think I need to be on ‘after_theme_setup’, but maybe there is a better hook. If I don’t set a default value for $location I get a warning when the page is displayed.
thx,
John
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.