Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Don't load directly
- if (!defined('ABSPATH')) {
- die('-1');
- }
- if (!class_exists('res_aufklappbarer_text')) {
- class res_aufklappbarer_text extends aviaShortcodeTemplate
- {
- /**
- * Create the config array for the shortcode button
- */
- function shortcode_insert_button()
- {
- $this->config['version'] = '1.0';
- $this->config['self_closing'] = 'yes';
- $this->config['name'] = __('Aufklappbarer Text', 'avia_framework');
- $this->config['tab'] = __('Custom', 'avia_framework');
- $this->config['icon'] = AviaBuilder::$path['imagesURL'] . 'sc-text_block.png';
- $this->config['order'] = 93;
- $this->config['target'] = 'avia-target-insert';
- $this->config['shortcode'] = 'res_aufklappbarer_text';
- $this->config['modal_data'] = array('modal_class' => 'mediumscreen');
- $this->config['tooltip'] = __('', 'avia_framework');
- $this->config['preview'] = false;
- $this->config['disabling_allowed'] = true;
- $this->config['id_name'] = 'id';
- $this->config['id_show'] = 'yes';
- }
- function extra_assets()
- {
- wp_enqueue_script( 'res_aufklappbarer-text', get_stylesheet_directory_uri() . '/avia-shortcodes/aufklappbarer_text/aufklappbarer-text.js', array( 'jquery' ), false, true );
- }
- /**
- * 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
- */
- function popup_elements()
- {
- $this->elements = array(
- array(
- 'type' => 'tab_container',
- 'nodescription' => true
- ),
- array(
- 'type' => 'tab',
- 'name' => __('Content', 'avia_framework'),
- 'nodescription' => true
- ),
- array(
- 'type' => 'template',
- 'template_id' => $this->popup_key('content_faq')
- ),
- array(
- 'type' => 'tab_close',
- 'nodescription' => true
- ),
- array(
- 'type' => 'tab',
- 'name' => __('Advanced', 'avia_framework'),
- 'nodescription' => true
- ),
- array(
- 'type' => 'toggle_container',
- 'nodescription' => true
- ),
- array(
- 'type' => 'template',
- 'template_id' => $this->popup_key('layout_spacing')
- ),
- array(
- 'type' => 'template',
- 'template_id' => 'developer_options_toggle',
- 'args' => array('sc' => $this)
- ),
- array(
- 'type' => 'toggle_container_close',
- 'nodescription' => true
- ),
- array(
- 'type' => 'tab_close',
- 'nodescription' => true
- ),
- array(
- 'type' => 'tab_container_close',
- 'nodescription' => true
- )
- );
- }
- /**
- * Create and register templates for easier maintainance
- *
- * @since 4.6.4
- */
- protected function register_dynamic_templates()
- {
- /**
- * Content Tab
- * ===========
- */
- $c = array(
- array(
- 'name' => __('Immer sichtbarer Text', 'avia_framework'),
- 'desc' => __('Enter some content for this textblock', 'avia_framework'),
- 'id' => 'visible_text',
- 'type' => 'tiny_mce',
- 'std' => __('', 'avia_framework'),
- 'tmpl_set_default' => false
- ),
- array(
- 'name' => __('Eingeklappter Text', 'avia_framework'),
- 'desc' => __('Enter some content for this textblock', 'avia_framework'),
- 'id' => 'hidden_text',
- 'type' => 'tiny_mce',
- 'std' => __('', 'avia_framework'),
- 'tmpl_set_default' => false
- ),
- );
- AviaPopupTemplates()->register_dynamic_template($this->popup_key('content_faq'), $c);
- $c = array(
- array(
- 'name' => __('Custom top and bottom margin', 'avia_framework'),
- 'desc' => __('If checked allows you to set a custom top and bottom margin. Otherwise the margin is calculated by the theme based on surrounding elements', 'avia_framework'),
- 'id' => 'margin',
- 'type' => 'checkbox',
- 'std' => '',
- 'lockable' => true,
- ),
- array(
- 'name' => __('Custom top and bottom margin', 'avia_framework'),
- 'desc' => __('Set a custom top or bottom margin. Both pixel and % based values are accepted. eg: 30px, 5%', 'avia_framework'),
- 'id' => 'custom_margin',
- 'type' => 'multi_input',
- 'sync' => true,
- 'std' => '0px',
- 'lockable' => true,
- 'required' => array('margin', 'not', ''),
- 'multi' => array(
- 'top' => __('Margin-Top', 'avia_framework'),
- 'bottom' => __('Margin-Bottom', 'avia_framework'),
- )
- )
- );
- $template = array(
- array(
- 'type' => 'template',
- 'template_id' => 'toggle',
- 'title' => __('Spacing', 'avia_framework'),
- 'content' => $c
- ),
- );
- AviaPopupTemplates()->register_dynamic_template($this->popup_key('layout_spacing'), $template);
- }
- /**
- * 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.
- */
- function editor_element($params)
- {
- $params = parent::editor_element($params);
- $params['content'] = null; //remove to allow content elements
- return $params;
- }
- /**
- * Frontend Shortcode Handler
- *
- * @param array $atts array of attributes
- * @param string $content text within enclosing form of shortcode element
- * @param string $shortcodename the shortcode found, when == callback name
- * @return string $output returns the modified html string
- */
- function shortcode_handler($atts, $content = '', $shortcodename = '', $meta = '')
- {
- extract($atts);
- /* custom margin */
- if (!empty($atts['margin'])) {
- $explode_custom_margin = explode(',', $atts['custom_margin']);
- if (count($explode_custom_margin) > 1) {
- $atts['margin-top'] = $explode_custom_margin['0'];
- $atts['margin-bottom'] = $explode_custom_margin['1'];
- } else {
- $atts['margin-top'] = $atts['custom_margin'];
- $atts['margin-bottom'] = $atts['custom_margin'];
- }
- }
- $custom_margin_style = '';
- $custom_margin_style .= AviaHelper::style_string($atts, 'margin-top');
- $custom_margin_style .= AviaHelper::style_string($atts, 'margin-bottom');
- $output = "";
- $output .= "<div class='res_aufklappbarer_text'>";
- $output .= "<div class='res_aufklappbarer_text__vissible'>";
- $output .= ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($visible_text));
- $output .= "</div>";
- if ( $hidden_text ) {
- $output .= "<div class='res_aufklappbarer_text__hidden'>";
- $output .= ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($hidden_text));
- $output .= "</div>";
- $output .= "<a class='res_aufklappbarer_text__btn avia-button avia-size-medium avia-color-dark' href='#'>Mehr lesen</a>";
- }
- $output .= "</div>";
- return $output;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment