aqua-page-builder
aqua-page-builder copied to clipboard
Unable to add custom block to a layout
Hi, Firstly, i want to say thanks to you because i like a lot your plugin, i'm using it with a themifycloud open theme and i'm very delighted with its functioning. Currently, i have the need of a custom block, i have already added it to the list of available blocks but i'm having problems when adding to a layout.
When i click save, my custom block is not added to the template i'm using. Do you have any idea of how to solve it? Thanks in advance.
Could you put the code here?
Sure, thanks.
My Custom Block (et-how-we-do-it.php)
'How we do it?', 'size' => 'span6', ); //create the block parent::__construct('oe_how_we_do_it_block', $block_options); } function form($instance) { $defaults = array( 'text' => '', 'font_size' => '18', 'margin_top' => '10', 'margin_bottom' => '10', 'duration' => '900', 'delay' => '0', 'animation' => '', 'align' => '' ); $instance = wp_parse_args($instance, $defaults); extract($instance); global $include_animation ; $text_align = array( 'center' => 'Center', 'left' => 'Left', 'right' => 'Right', ); ?> <p class="description">
<label for="<?php echo $this->get_field_id('margin_top') ?>">
<?php _e('Margin top', 'themifycloud'); ?>
<?php echo aq_field_input('margin_top', $block_id, $margin_top, 'min', 'number') ?> px
</label> -
<label for="<?php echo $this->get_field_id('margin_bottom') ?>">
<?php _e('Margin bottom', 'themifycloud'); ?>
<?php echo aq_field_input('margin_bottom', $block_id, $margin_bottom, 'min', 'number') ?> px
</label> -
<label for="<?php echo $this->get_field_id('font_size') ?>">
<?php _e('Font-size (Ex : 18px)', 'themifycloud'); ?>
<?php echo aq_field_input('font_size', $block_id, $font_size, 'min', 'number') ?> px
</label> -
</p>
<p class="description">
<label for="<?php echo $this->get_field_id('align') ?>">
<?php _e('Text align', 'themifycloud'); ?><br/>
<?php echo aq_field_select('align', $block_id, $text_align , $align) ?>
</label>
</p>
<div class="sortable-body">
<p class="description">
<label for="<?php echo $this->get_field_id('animation') ?>">
<?php _e('Animation style', 'themifycloud'); ?><br/>
<?php echo aq_field_select('animation', $block_id, $include_animation , $animation) ?>
</label>
</p>
<p class="description">
<label for="<?php echo $this->get_field_id('duration') ?>">
<?php _e('Duration for Animation (Ex : 900ms)', 'themifycloud'); ?>
<?php echo aq_field_input('duration', $block_id, $duration, 'min', 'number') ?> ms
</label> -
<label for="<?php echo $this->get_field_id('delay') ?>">
<?php _e('Time Delay (Ex : 900ms)', 'themifycloud'); ?>
<?php echo aq_field_input('delay', $block_id, $delay, 'min', 'number') ?> ms
</label>
</p>
</div>
<p class="description">
<label for="<?php echo $this->get_field_id('text') ?>">
<?php _e('Content', 'themifycloud'); ?>
<?php echo aq_field_textarea('text', $block_id, $text, $size = 'full') ?>
</label>
</p>
<?php
}
function block($instance) {
extract($instance);
$output='';
$animation_effect ='';
$duration_effect ='';
if($animation) $animation_effect = 'animated '.$animation.'';
if($duration && $animation != '') $duration_effect = '-webkit-animation-duration: '.$duration.'ms; -moz-animation-duration: '.$duration.'ms; -o-animation-duration: '.$duration.'ms;animation-duration: '.$duration.'ms; animation-delay:'.$delay.'ms; -webkit-animation-delay:'.$delay.'ms; -moz-animation-delay:'.$delay.'ms;-o-animation-delay:'.$delay.'ms;';
$output .= '<div class="animation-wrapper">';
$output .= do_shortcode(htmlspecialchars_decode('<p class="'.$animation_effect.'" style="font-size:'.$font_size.'px;margin-top:'.$margin_top.'px;margin-bottom:'.$margin_bottom.'px; text-align:'.$align.'; '.$duration_effect.'">'.$text.'</p>'));
$output .= '</div>';
echo $output;
}
function before_block($instance) {
extract($instance);
echo '<div class="'.$size.'">';
}
function after_block($instance) {
extract($instance);
echo '</div>';
}
}
aq_register_block('OE_How_We_Do_It');
endif;
## The section where i add the custom block to available blocks (block-init.php)
...
/*\* Define Directory Location Constants*/
if (!defined('themifycloud_DIR')) define('themifycloud_DIR', trailingslashit(get_template_directory()));
if (!defined('themifycloud_LIB_BLOCK_DIR')) define('themifycloud_LIB_BLOCK_DIR', themifycloud_DIR . trailingslashit('plugins/pagebuilder/blocks'));
/*\* Define URI Location Constants */
if (!defined('themifycloud_URI')) define('themifycloud_URI', trailingslashit(get_template_directory_uri()));
if (!defined('themifycloud_LIB_URI')) define('themifycloud_LIB_URI', themifycloud_URI . trailingslashit('plugins/pagebuilder/blocks'));
/*\* Include custom custom block */
include_once(themifycloud_LIB_BLOCK_DIR . 'et-home-text-slider.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-about-block.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-team-block.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-service-1-block.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-portfolio-block.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-text.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-client-block.php');
include_once(themifycloud_LIB_BLOCK_DIR . 'et-how-we-do-it.php');