Example #1
0
 /**
  * Icons
  * @param type $element
  * @return string
  */
 static function render($element)
 {
     $element = parent::get_extra_info($element);
     $label = parent::get_label($element);
     $item_id = isset($element['item_id']) ? $element['item_id'] : '';
     $icon_id = $item_id != '' ? '-' . $item_id : '';
     $output = "<div id='icon_selector" . $icon_id . "' class='icon_selector' data-item_id='" . $item_id . "'>\n\t\t\t<input type='hidden' value='{$element['std']}' id='{$element['id']}' DATA_INFO />\n\t\t</div>";
     if (WR_Megamenu_Helpers_Functions::is_modal()) {
         add_filter('wr_mm_assets_enqueue_modal', array(__CLASS__, 'enqueue_assets_modal'));
     } else {
         WR_Megamenu_Init_Assets::load(array('wr-joomlashine-iconselector-js'));
     }
     return parent::final_element($element, $output, $label);
 }
Example #2
0
 /**
  * Color picker
  * @param type $element
  * @return string
  */
 static function render($element)
 {
     $element = parent::get_extra_info($element);
     $label = parent::get_label($element);
     $bg_color = $element['std'] ? $element['std'] : '#000';
     $wrap_color_class = isset($element['wrap_color_class']) ? $element['wrap_color_class'] : '';
     $_hidden = !isset($element['hide_value']) || isset($element['hide_value']) && $element['hide_value'] == false ? 'type="text"' : 'type="hidden"';
     $output = "<div class='color-selector input-group {$wrap_color_class}' id='color-picker-{$element['id']}'>\n\t\t\t\t\t\t<input {$_hidden} size='10' class='input-small {$element['class']}' id='{$element['id']}' name='{$element['id']}' value='{$element['std']}'  DATA_INFO />\n\t\t\t\t\t\t<span class='input-group-btn'>\n\t\t\t\t\t\t\t<a href='javascript:void(0);' class='btn btn-default btn-sm' title=''>...</a>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t</div>";
     if (!WR_Megamenu_Helpers_Functions::is_modal()) {
         WR_Megamenu_Init_Assets::load(array('wr-colpick-js', 'wr-colpick-css'));
     } else {
         add_filter('wr_mm_assets_enqueue_modal', array(__CLASS__, 'enqueue_assets_color'));
     }
     return parent::final_element($element, $output, $label);
 }
Example #3
0
 /**
  * HTML content for Shortcode editing Modal
  */
 public function content()
 {
     // Load required assets
     $assets = apply_filters('wr_mm_assets_enqueue_modal', array('wr-mm-handlesetting-js'));
     WR_Megamenu_Init_Assets::load($assets);
     include WR_MEGAMENU_TPL_PATH . '/modal.php';
 }
Example #4
0
 /**
  * Render form.
  *
  * @param   string   $alignment   Form alignment, either 'form-inline', 'form-horizontal' or leave empty for vertical alignment.
  * @param   array    $js_init     Print Javascript initialization for which: tabs, accordion, tips?
  * @param   string   $section_id  Which form section to render? Leave empty to render all sections by default.
  *
  * @return  void
  */
 public function render($alignment = null, $js_init = array('tips', 'accordions', 'tabs'), $section_id = '')
 {
     // Do 'wr_pre_render_form' action
     do_action('wr_pre_render_form', $this);
     // Render all form sections or a specified one?
     if (!empty($section_id) && array_key_exists($section_id, $this->fields)) {
         // Update Javascript initialization
         $js_init[] = 'ajax';
         // Backup current fields data
         $fields = $this->fields;
         // Remove data of unnecessary form section
         foreach (array_keys($this->fields) as $sid) {
             if ($section_id != $sid) {
                 unset($this->fields[$sid]['fields']);
                 unset($this->fields[$sid]['fieldsets']);
                 unset($this->fields[$sid]['accordion']);
                 unset($this->fields[$sid]['tabs']);
             }
         }
     }
     // Load assets
     WR_Megamenu_Init_Assets::load(array('wr-form-css', 'wr-form-js'));
     // Load form template
     if (!empty($alignment)) {
         $tpl = WR_Megamenu_Loader::get_path("form/tmpl/form-{$alignment}.php");
     }
     if (isset($tpl) && !empty($tpl)) {
         include $tpl;
     } else {
         include WR_Megamenu_Loader::get_path('form/tmpl/form.php');
     }
     // Render all form sections or a specified one?
     if (!empty($section_id) && array_key_exists($section_id, $this->fields)) {
         // Restore original fields data
         $this->fields = $fields;
     }
     // Do 'wr_post_render_form' action
     do_action('wr_post_render_form', $this);
 }
Example #5
0
 public function enqueue_script_nav_menu()
 {
     if (isset($GLOBALS['hook_suffix']) && $GLOBALS['hook_suffix'] != 'nav-menus.php') {
         return;
     }
     WR_Megamenu_Init_Assets::load(array('wr-joomlashine-iconselector-js', 'wr-mm-icon-options-js'));
     WR_Megamenu_Init_Assets::localize('wr-mm-icon-options-js', 'Wr_Megamenu_Ajax', WR_Megamenu_Helpers_Functions::localize_js());
 }
Example #6
0
 /**
  * Enqueue assets for shortcodes
  *
  * @global type $Wr_Megamenu_By_Sc_Providers
  *
  * @param type  $this_	:   current shortcode object
  * @param type  $extra	:   frontend_assets/ admin_assets
  * @param type  $post_fix :   _frontend/ ''
  */
 public static function shortcode_enqueue_assets($this_, $extra, $post_fix = '')
 {
     $extra_js = isset($this_->config['exception']) && isset($this_->config['exception'][$extra]) && is_array($this_->config['exception'][$extra]);
     $assets = array_merge($extra_js ? $this_->config['exception'][$extra] : array(), array(str_replace('wr_', '', $this_->config['shortcode']) . $post_fix));
     foreach ($assets as $asset) {
         if (!preg_match('/\\.(css|js)$/', $asset)) {
             WR_Megamenu_Init_Assets::load($asset);
         } else {
             global $Wr_Megamenu_By_Sc_Providers;
             if (empty($Wr_Megamenu_By_Sc_Providers)) {
                 continue;
             }
             // load assets file in common assets directory of provider
             $default_assets = self::assets_default($this_, $asset);
             // if can't find the asset file, search in /assets folder of the shortcode
             if (!$default_assets) {
                 // Get path of directory contains all shortcodes of provider
                 $shortcode_dir = WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'shortcode_dir');
                 if ($shortcode_dir == WR_MEGAMENU_LAYOUT_PATH) {
                     // this is core PB
                     $sc_path = WR_MEGAMENU_ELEMENT_PATH;
                     $sc_uri = WR_MEGAMENU_ROOT_URL . basename($sc_path);
                 } else {
                     // Get directory of shortcodes of this provider
                     $plugin_path = WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'path');
                     $plugin_uri = WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'uri');
                     $shortcode_dir_arr = (array) WR_Megamenu_Helpers_Shortcode::get_provider_info($this_->config['shortcode'], 'shortcode_dir');
                     $shortcode_dir = reset($shortcode_dir_arr);
                     $sc_path = $plugin_path . basename($shortcode_dir);
                     if (is_dir($sc_path)) {
                         $sc_uri = $plugin_uri . basename($shortcode_dir);
                     } else {
                         $sc_path = $plugin_path;
                         $sc_uri = $plugin_uri;
                     }
                 }
                 $ext_regex = '/(_frontend)*\\.(js|css)$/';
                 if (preg_match($ext_regex, $asset)) {
                     // load assets in directory of shortcodes
                     $require_sc = preg_replace($ext_regex, '', $asset);
                     self::assets_specific_shortcode($require_sc, $asset, $sc_path, $sc_uri);
                 } else {
                     // load js/css file in directory of current shortcode
                     $exts = array('js', 'css');
                     foreach ($exts as $ext) {
                         $require_sc = $this_->config['shortcode'];
                         $file = $asset . ".{$ext}";
                         // if this asset is processed, leave it
                         self::assets_check($file);
                         // enqueue or add to cache file
                         self::assets_specific_shortcode($require_sc, $file, $sc_path, $sc_uri);
                         // store it as processed asset
                         self::assets_check($file, true);
                     }
                 }
             }
         }
     }
 }
Example #7
0
 /**
  * Render about-us screen.
  *
  * @return void
  */
 public static function about_us()
 {
     // Load assets
     WR_Megamenu_Init_Assets::load(array('wr-mm-bootstrap3-css', 'wr-bootstrap3-js'));
     // Load template
     include WR_MEGAMENU_TPL_PATH . '/about-us.php';
 }
Example #8
0
 /**
  * Method to load specified asset.
  *
  * @param   string  $handle  Asset handle.
  *
  * @return  void
  */
 protected function load_asset($handle)
 {
     if (is_array($handle)) {
         foreach ($handle as $h) {
             $this->load_asset($h);
         }
         return;
     }
     // Prepare asset handle
     if (preg_match('/\\.(css|js)$/', $handle)) {
         $handle = WR_Megamenu_Init_Assets::file_to_handle($handle);
     }
     // Load asset
     WR_Megamenu_Init_Assets::load($handle);
 }
Example #9
0
 function load_base_assets()
 {
     WR_Megamenu_Init_Assets::load(array('wr-bootstrap3-frontend-js', 'wr-mm-bootstrap3-icomoon-css', 'wr-font-awesome-css', 'wr-megamenu-site-css', 'wr-megamenu-site-js'));
 }
Example #10
0
 public static function load_assets()
 {
     global $pagenow, $post_type;
     // Load common assets
     if (is_admin()) {
         $page_setting = isset($_GET['page']) ? $_GET['page'] : '';
         if ($pagenow == 'nav-menus.php' || $post_type == 'wr_megamenu_profile' || $page_setting == 'wr-megamenu-settings' || $page_setting == 'wr-menu-addons') {
             WR_Megamenu_Init_Assets::load(array('wr-mm-bootstrap3-css', 'wr-bootstrap3-js', 'wr-joomlashine-css', 'wr-mm-css'));
             WR_Megamenu_Init_Assets::load(array('wr-font-icomoon-css', 'wr-font-awesome-css'));
             WR_Megamenu_Init_Assets::load(array('wr-jquery-ui-css', 'wr-jquery-select2-css', 'wr-jquery-select2-bootstrap3-css', 'wr-mm-admin-css'));
         }
         if ('admin.php' == $pagenow && isset($_GET['page']) && in_array($_GET['page'], WR_Megamenu_Admin_Menu::$pages)) {
             // Add filter to register assets to be loaded
             switch ($_GET['page']) {
                 case 'wr-megamenu-settings':
                     // Load required assets
                     WR_Megamenu_Init_Assets::load(array('wr-form-css', 'wr-form-js'));
                     break;
                 case 'wr-menu-addons':
                     // Load required assets
                     WR_Megamenu_Init_Assets::load(array('wr-addons-css', 'wr-addons-js'));
                     break;
             }
         } else {
             if (('post.php' == $pagenow || 'post-new.php' == $pagenow || 'widgets.php' == $pagenow) && $post_type == 'wr_megamenu_profile') {
                 if (class_exists('WR_Pb_Init')) {
                     global $Wr_Pb_Widgets;
                     $Wr_Pb_Widgets = array();
                 }
                 // Load css
                 WR_Megamenu_Init_Assets::load(array('wr-mm-element-font-css', 'wr-mm-layout-font-css'));
                 // Load js
                 if (function_exists('wp_enqueue_media')) {
                     wp_enqueue_media();
                 } else {
                     wp_enqueue_style('thickbox');
                     wp_enqueue_script('media-upload');
                     wp_enqueue_script('thickbox');
                 }
                 $scripts = array('jquery', 'jquery-ui', 'jquery-ui-resizable', 'jquery-ui-sortable', 'jquery-ui-tabs', 'jquery-ui-dialog', 'jquery-ui-button', 'jquery-ui-slider', 'wr-jquery-livequery-js', 'jquery-resize-js', 'wr-joomlashine-modalresize-js', 'wr-jquery-select2-js');
                 WR_Megamenu_Init_Assets::load($scripts);
                 WR_Megamenu_Init_Assets::load(array('wr-mm-js'));
                 $scripts = array('wr-mm-layout-js', 'wr-mm-placeholder');
                 WR_Megamenu_Init_Assets::load(apply_filters('wr_mm_assets_enqueue_admin', $scripts));
                 WR_Megamenu_Init_Assets::load('wr-mm-modal-js');
                 WR_Megamenu_Init_Assets::load(array('wr-colorpicker-js', 'wr-colorpicker-css'));
                 // Load element editor script
                 WR_Megamenu_Init_Assets::load('wr-mm-handleelement-js');
                 // Load element settings script
                 WR_Megamenu_Init_Assets::load('wr-mm-handlesetting-js');
                 // Load ZeroClipboard JavaScript library for Shortcode Content tab
                 WR_Megamenu_Init_Assets::load('wr-zeroclipboard-js');
                 WR_Megamenu_Init_Assets::load('wr-mm-widget-js');
                 WR_Megamenu_Helpers_Functions::wr_localize();
             }
         }
     } else {
         WR_Megamenu_Init_Assets::load(array('wr-mm-bootstrap3-css', 'wr-bootstrap3-js', 'wr-joomlashine-css', 'wr-mm-css'));
         WR_Megamenu_Init_Assets::load(array('wr-font-icomoon-css', 'wr-font-awesome-css'));
     }
 }