Esempio n. 1
0
 /**
  * Generate Setting HTML for each shortcode
  *
  * @global object $Wr_Pb
  * @param string $shortcode The current shortcode
  * @param array $params The shortcode content
  * @param string $el_title Title of shortcode
  * @param bool $no_tab
  *
  * @return string
  */
 public static function shortcode_modal_settings($shortcode, $params, $el_title = '', $no_tab = false)
 {
     $html = '';
     // get shortcode class
     $class = WR_Pb_Helper_Shortcode::get_shortcode_class($shortcode);
     if (class_exists($class)) {
         global $Wr_Pb;
         $settings_html = '';
         $elements = $Wr_Pb->get_elements();
         $instance = isset($elements['element'][strtolower($class)]) ? $elements['element'][strtolower($class)] : null;
         if (!is_object($instance)) {
             $instance = new $class();
         }
         $instance->init_element();
         $has_preview = false;
         // Generate default params if they were not posted.
         if (empty($params)) {
             $params = $instance->config['shortcode_structure'];
         }
         if (!empty($params)) {
             $params = str_replace('#_EDITTED', '', $params);
             $extract_params = WR_Pb_Helper_Shortcode::extract_params($params, $shortcode);
             // if have sub-shortcode, extract sub shortcodes content
             if (!empty($instance->config['has_subshortcode'])) {
                 $sub_sc_data = WR_Pb_Helper_Shortcode::extract_sub_shortcode($params, true);
                 $sub_sc_data = apply_filters('wr_pb_sub_items_filter', $sub_sc_data, $shortcode, isset($_COOKIE['wr_pb_data_for_modal']) ? $_COOKIE['wr_pb_data_for_modal'] : '');
                 $extract_params['sub_items_content'] = $sub_sc_data;
             }
             // Set auto title for the subitem if have
             $extract_title = isset($el_title) && $el_title != __('(Untitled)', WR_PBL) ? $el_title : '';
             // MODIFY $instance->items
             WR_Pb_Helper_Shortcode::generate_shortcode_params($instance->items, NULL, $extract_params, TRUE, FALSE, $extract_title, $has_preview);
             // if have sub-shortcode, re-generate shortcode structure
             if (!empty($instance->config['has_subshortcode'])) {
                 $instance->shortcode_data();
             }
         }
         // get Modal setting box
         $settings = $instance->items;
         $settings_html .= WR_Pb_Objects_Modal::get_shortcode_modal_settings($settings, $shortcode, $extract_params, $params, $has_preview, $no_tab);
         // Add preview
         if ($has_preview) {
             $settings_html .= WR_Pb_Helper_Shortcode::render_parameter('preview');
         }
         $html = balanceTags($settings_html);
     }
     return $html;
 }
Esempio n. 2
0
            $exp = str_replace('____', '(.*? )', $exp);
            $form = preg_replace('/' . $exp . '/', '$1', $form);
            // tab and content generate
            $tabs = array();
            foreach (array('content', 'styling') as $i => $tab) {
                $active = $i++ == 0 ? 'active' : '';
                $data_['href'] = "#{$tab}";
                $data_['data-toggle'] = 'tab';
                $content_ = ucfirst($tab);
                $tabs[] = "<li class='{$active}'>" . WR_Pb_Objects_Modal::tab_settings('a', $data_, $content_) . '</li>';
            }
            // content
            $contents = array();
            $contents[] = "<div class='tab-pane active' id='content'><form id='wr-widget-form'>{$form}</form></div>";
            $contents[] = "<div class='tab-pane' id='styling'>" . WR_Pb_Helper_Shortcode::render_parameter('preview') . '</div>';
            $output = WR_Pb_Objects_Modal::setting_tab_html($shortcode, $tabs, $contents, array(), '', array());
            echo balanceTags($output);
        }
    }
    ?>
			<div id="modalAction" class="wr-pb-setting-tab"></div>
		</div>
		<textarea class="hidden" id="shortcode_content">
		<?php 
    echo esc_attr($params);
    ?>
		</textarea>
		<textarea class="hidden" id="wr_share_data"></textarea>
		<textarea class="hidden" id="wr_merge_data"></textarea>
		<textarea class="hidden" id="wr_extract_data"></textarea>
		<input type="hidden" id="wr_previewing" value="0" />
Esempio n. 3
0
 /**
  * Get settings HTML modal from shortcode content
  *
  * @return html
  */
 function get_settings_html()
 {
     if (!isset($_POST[WR_NONCE]) || !wp_verify_nonce($_POST[WR_NONCE], WR_NONCE)) {
         return;
     }
     $shortcode = $_POST['shortcode'];
     $shortcode_data = $_POST['data'];
     $sub_el_settings = WR_Pb_Objects_Modal::shortcode_modal_settings($shortcode, stripslashes($shortcode_data), '', true);
     printf("<div class='sub-element-settings form' style='display: none'>%s</div>", balanceTags($sub_el_settings));
     exit;
 }
Esempio n. 4
0
 /**
  * Print Setting HTML of Pricing Item
  */
 function _modal_footer($shortcode)
 {
     $pricing_item = new WR_Item_Pricing_Table();
     if ($shortcode == $this->config['shortcode']) {
         // Create instance of sub shortcode
         $instance = new $pricing_item->config['has_subshortcode']();
         $instance->init_element();
         // Get modal settings html
         $settings_html = WR_Pb_Objects_Modal::get_shortcode_modal_settings($instance->items, $instance->config['shortcode']);
         // Print html as template script
         printf("<script type='text/html' id='tmpl-wr-pb-hidden-setting'>\n%s\n</script>\n", balanceTags($settings_html));
     }
 }