config['self_closing'] = 'no';
$this->config['name'] = __('Code Block', 'avia_framework' );
$this->config['tab'] = __('Content Elements', 'avia_framework' );
$this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-codeblock.png";
$this->config['order'] = 1;
$this->config['target'] = 'avia-target-insert';
$this->config['shortcode'] = 'av_codeblock';
$this->config['tinyMCE'] = array('disable' => true);
$this->config['tooltip'] = __( 'Add text, shortcodes, HTML, CSS, JavaScript and non executeable codesnippets to your website (without any formatting or text optimization).', 'avia_framework' );
}
/**
* Popup Elements
*
* If this function is defined in a child class the element automatically gets an edit button, that, when pressed
* opens a modal window that allows to edit the element properties
*
* @return void
*/
public function popup_elements()
{
$this->elements = array(
array(
"type" => "tab_container", 'nodescription' => true
),
array(
"type" => "tab",
"name" => __("Content" , 'avia_framework'),
'nodescription' => true),
array(
"name" => __("Code Block Content. Add your own HTML/CSS/Javascript here", 'avia_framework'),
"desc" => __("Enter some text/code/shortcode. You can also add plugin shortcodes here. Adding theme shortcodes is supported now for many elements. Be carefull not to nest same named shortcodes because this is not supported by WordPress ([foo] [foo] [/foo] [/foo] will break layout !!! )", 'avia_framework'),
"id" => "content",
'container_class' =>"avia-element-fullwidth",
"type" => "textarea",
"std" => "",
),
array(
"name" => __("Code Wrapper Element", 'avia_framework' ),
"desc" => __("Wrap your code into a html tag (i.e. pre or code tag). Insert the tag without <>", 'avia_framework' ) ,
"id" => "wrapper_element",
"std" => '',
"type" => "input"),
array(
"name" => __("Code Wrapper Element Attributes", 'avia_framework' ),
"desc" => __("Enter one or more attribute values which should be applied to the wrapper element. Leave the field empty if no attributes are required.", 'avia_framework' ) ,
"id" => "wrapper_element_attributes",
"std" => '',
"required" => array('wrapper_element', 'not', ''),
"type" => "input"),
array(
"name" => __( "Action with codeblock", 'avia_framework' ),
"desc" => __( "Select if you want to execute codeblock or display it to the user only.", 'avia_framework' ),
"id" => "codeblock_type",
"type" => "select",
"std" => "",
"subtype" => array(
__( "Add codeblock to content", 'avia_framework' ) => '',
__( "Display codeblock as code snippet", 'avia_framework' ) => 'snippet'
)
),
array(
"name" => __("Escape HTML Code", 'avia_framework' ),
"desc" => __("WordPress will convert the html tags to readable text.", 'avia_framework' ) ,
"id" => "escape_html",
"std" => false,
"required" => array( 'codeblock_type', 'equals', '' ),
"type" => "checkbox"),
array(
"name" => __("Disable Shortcode Processing", 'avia_framework' ),
"desc" => __("Check if you want to disable the shortcode processing for this code block", 'avia_framework' ) ,
"id" => "deactivate_shortcode",
"std" => false,
"required" => array('escape_html', 'equals', '' ),
"type" => "checkbox"),
array(
"name" => __("Deactivate schema.org markup", 'avia_framework' ),
"desc" => __("Output the code without any additional wrapper elements. (not recommended)", 'avia_framework' ) ,
"id" => "deactivate_wrapper",
"std" => false,
"type" => "checkbox"),
array(
"type" => "close_div",
'nodescription' => true
),
array(
"type" => "tab",
"name" => __("Screen Options",'avia_framework' ),
'nodescription' => true
),
array(
"name" => __("Element Visibility",'avia_framework' ),
"desc" => __("Set the visibility for this element, based on the device screensize.", 'avia_framework' ),
"type" => "heading",
"description_class" => "av-builder-note av-neutral",
),
array(
"desc" => __("Hide on large screens (wider than 990px - eg: Desktop)", 'avia_framework'),
"id" => "av-desktop-hide",
"std" => "",
"container_class" => 'av-multi-checkbox',
"type" => "checkbox"),
array(
"desc" => __("Hide on medium sized screens (between 768px and 989px - eg: Tablet Landscape)", 'avia_framework'),
"id" => "av-medium-hide",
"std" => "",
"container_class" => 'av-multi-checkbox',
"type" => "checkbox"),
array(
"desc" => __("Hide on small screens (between 480px and 767px - eg: Tablet Portrait)", 'avia_framework'),
"id" => "av-small-hide",
"std" => "",
"container_class" => 'av-multi-checkbox',
"type" => "checkbox"),
array(
"desc" => __("Hide on very small screens (smaller than 479px - eg: Smartphone Portrait)", 'avia_framework'),
"id" => "av-mini-hide",
"std" => "",
"container_class" => 'av-multi-checkbox',
"type" => "checkbox"),
array(
"type" => "close_div",
'nodescription' => true
),
array(
"type" => "close_div",
'nodescription' => true
),
);
}
/**
* Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
* Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
* Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
*
*
* @param array $params this array holds the default values for $content and $args.
* @return $params the return array usually holds an innerHtml key that holds item specific markup.
*/
public function editor_element($params)
{
$params['innerHtml'] = "";
$params['innerHtml'].= "
' . trim( $content ) . '';
}
if(!empty($atts['wrapper_element'])) $content = "<{$atts['wrapper_element']} {$atts['wrapper_element_attributes']}>{$content}{$atts['wrapper_element']}>";
if(empty($atts['deactivate_wrapper']))
{
$output = '';
$markup = avia_markup_helper(array('context' => 'entry', 'echo' => false, 'custom_markup'=>$meta['custom_markup']));
$markup_text = avia_markup_helper(array('context' => 'entry_content', 'echo' => false, 'custom_markup'=>$meta['custom_markup']));
$output .= '