Esempio n. 1
0
 /**
  * Localize for js files
  */
 public static function wr_localize()
 {
     WR_Megamenu_Init_Assets::localize('wr-mm', 'Wr_Megamenu_Translate', WR_Megamenu_Helpers_Functions::js_translation());
     WR_Megamenu_Init_Assets::localize('wr-mm', 'Wr_Megamenu_Ajax', WR_Megamenu_Helpers_Functions::localize_js());
     WR_Megamenu_Init_Assets::localize('wr-mm-handleelement', 'Wr_Megamenu_Translate', WR_Megamenu_Helpers_Functions::js_translation());
     //WR_Megamenu_Init_Assets::localize( 'wr-mm-handleelement', 'Wr_Megamenu_Js_Html', WR_Megamenu_Helpers_Shortcode::$item_html_template );
     WR_Megamenu_Init_Assets::localize('wr-mm-handleelement', 'Wr_Megamenu_Ajax', WR_Megamenu_Helpers_Functions::localize_js());
     WR_Megamenu_Init_Assets::localize('wr-mm-layout', 'Wr_Megamenu_Translate', WR_Megamenu_Helpers_Functions::js_translation());
     WR_Megamenu_Init_Assets::localize('wr-mm-widget', 'Wr_Megamenu_Preview_Html', WR_Megamenu_Helpers_Functions::get_element_item_html(array('element_wrapper' => 'div', 'modal_title' => '', 'element_type' => 'data-el-type="element"', 'name' => 'Widget Element Setting', 'shortcode' => 'WR_SHORTCODE_CONTENT', 'shortcode_data' => 'WR_SHORTCODE_DATA', 'content_class' => 'wr-mm-element', 'content' => 'Widget Element Setting')));
 }
Esempio n. 2
0
 /**
  * DEFINE html structure of shortcode in MegaMenu area
  *
  * @param string $content
  * @param string $shortcode_data: string stores params (which is modified default value) of shortcode
  * @param string $el_title: Element Title used to identifying elements in WR MegaMenu
  * Ex:  param-tag=h6&param-text=Your+heading&param-font=custom&param-font-family=arial
  * @return string
  */
 public function element_in_megamenu($content = '', $shortcode_data = '', $el_title = '', $index = '')
 {
     $shortcode = $this->config['shortcode'];
     $is_sub_element = isset($this->config['sub_element']) ? true : false;
     $parent_shortcode = $is_sub_element ? str_replace('wr_item_', '', $shortcode) : $shortcode;
     $type = !empty($this->config['el_type']) ? $this->config['el_type'] : 'widget';
     // Empty content if this is not sub element
     if (!$is_sub_element) {
         $content = '';
     }
     $exception = isset($this->config['exception']) ? $this->config['exception'] : array();
     $content = isset($exception['default_content']) ? $exception['default_content'] : $content;
     $modal_title = '';
     // if is widget
     if ($type == 'widget') {
         global $wr_megamenu_widgets;
         if (isset($wr_megamenu_widgets[$shortcode]) && is_array($wr_megamenu_widgets[$shortcode]) && isset($wr_megamenu_widgets[$shortcode]['identity_name'])) {
             $modal_title = $wr_megamenu_widgets[$shortcode]['identity_name'];
             $content = $this->config['exception']['data-modal-title'] = $modal_title;
         }
     }
     // if content is still empty, Generate it
     if (empty($content)) {
         if (!$is_sub_element) {
             $content = ucfirst(str_replace('wr_', '', $shortcode));
         } else {
             if (isset($exception['item_text'])) {
                 if (!empty($exception['item_text'])) {
                     $content = WR_Megamenu_Helpers_Placeholder::add_placeholder($exception['item_text'] . ' %s', 'index');
                 }
             } else {
                 $content = WR_Megamenu_Helpers_Placeholder::add_placeholder(__(ucfirst($parent_shortcode), WR_MEGAMENU_TEXTDOMAIN) . ' ' . __('Item', WR_MEGAMENU_TEXTDOMAIN) . ' %s', 'index');
             }
         }
     }
     $content = !empty($el_title) ? $content . ': ' . "<span>{$el_title}</span>" : $content;
     // element name
     if ($type == 'element') {
         if (!$is_sub_element) {
             $name = ucfirst(str_replace('wr_', '', $shortcode));
         } else {
             $name = __(ucfirst($parent_shortcode), WR_MEGAMENU_TEXTDOMAIN) . ' ' . __('Item', WR_MEGAMENU_TEXTDOMAIN);
         }
     } else {
         $name = $content;
     }
     if (empty($shortcode_data)) {
         $shortcode_data = $this->config['shortcode_structure'];
     }
     // Process index for subitem element
     if (!empty($index)) {
         $shortcode_data = str_replace('_WR_INDEX_', $index, $shortcode_data);
     }
     $shortcode_data = stripslashes($shortcode_data);
     $element_wrapper = !empty($exception['item_wrapper']) ? $exception['item_wrapper'] : ($is_sub_element ? 'li' : 'div');
     $content_class = $is_sub_element ? 'jsn-item-content' : 'wr-mm-element';
     $modal_title = empty($modal_title) ? !empty($exception['data-modal-title']) ? "data-modal-title='{$exception['data-modal-title']}'" : '' : $modal_title;
     $element_type = "data-el-type='{$type}'";
     $data = array('element_wrapper' => $element_wrapper, 'modal_title' => $modal_title, 'element_type' => $element_type, 'name' => $name, 'shortcode' => $shortcode, 'shortcode_data' => $shortcode_data, 'content_class' => $content_class, 'content' => $content, 'action_btn' => empty($exception['action_btn']) ? '' : $exception['action_btn']);
     $extra = array();
     if (isset($this->config['exception']['disable_preview_container'])) {
         $extra = array('has_preview' => FALSE);
     }
     $data = array_merge($data, $extra);
     $html_preview = WR_Megamenu_Helpers_Functions::get_element_item_html($data);
     return array($html_preview);
 }