/** * Autoload shortcodes & sub shortcodes * @param string $path */ public static function autoload_shortcodes($path) { $items = substr_count($path, '/item'); $postfix = str_repeat('Item_', $items); // autoload shortcodes WR_Megamenu_Loader::register($path, 'WR_' . $postfix); }
/** * Render addons installation and management screen. * * @param string $plugin_file Either absolute path to plugin main file or plugin's identified name defined in WooRockets server. * * @return void */ public static function init($plugin_file) { // Hook into WordPress self::hook(); // Get template path if ($tmpl = WR_Megamenu_Loader::get_path('product/tmpl/addons.php')) { // Get product information $plugin = self::get($plugin_file); if (!$plugin) { die(__('Cannot get addons information for current product.', WR_LIBRARY_TEXTDOMAIN)); } // Check if user has customer account saved $customer_account = get_option('wr_mm_customer_account', null); $has_customer_account = is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password']); // Load template include_once $tmpl; } }
/** * 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); }
} ?> " id="wr-form-section-<?php esc_attr_e($sid); ?> "<?php if (isset($section['attributes'])) { echo ' ' . implode(' ', $section['attributes']); } ?> > <?php } // Load section template if (!isset($_GET['ajax']) || !$_GET['ajax'] || empty($section_id) || $section_id == $sid) { include WR_Megamenu_Loader::get_path('form/tmpl/section.php'); } if ($numSection > 1 && empty($section_id) || !isset($_GET['ajax']) || !$_GET['ajax']) { ?> </div> <?php } $first = false; } // Check if this is an Ajax request for specific form section if (empty($section_id) || !isset($_GET['ajax']) || !$_GET['ajax']) { ?> </div> <?php if (!isset($this->action)) { ?>
/** * Render input field for user to interact with. * * @param string $tpl Render field using this template. * * @return string */ protected function input($tpl = null) { // Prepare field template if (empty($tpl)) { $tpl = $this->type; } // Preset HTML code $html = ''; // Backup current field attributes to allow recursive call $backup = $this->attributes; // Get path to template file $file = WR_Megamenu_Loader::get_path("form/field/tmpl/{$tpl}.php"); if (empty($file)) { $file = WR_Megamenu_Loader::get_path('form/field/tmpl/text.php'); } // Load field template ob_start(); include $file; $html = ob_get_clean(); // Restore field attributes $this->attributes = $backup; return $html; }
/** * Search a file in registered paths. * * @param string $file Relative file path to search for. * * @return string */ public static function get_path($file) { // Generate alternative file name $slave = str_replace('_', '-', $file); // Filter paths to search for file self::$paths = apply_filters('wr_mm_loader_get_path', self::$paths); foreach (array_reverse(self::$paths) as $base => $prefixes) { if (@is_file($base . '/' . $slave)) { return $base . '/' . $slave; } elseif (@is_file($base . '/' . $file)) { return $base . '/' . $file; } } return null; }
<div id="wr_<?php esc_attr_e($aid); ?> " class="panel-collapse collapse <?php if ($first) { echo 'in'; } ?> "> <div class="panel-body"> <?php if (isset($accordion['fields'])) { $this->current_fields = $accordion['fields']; // Load fields template include WR_Megamenu_Loader::get_path('form/tmpl/fields.php'); } if (isset($accordion['fieldsets'])) { $this->current_fieldsets = $accordion['fieldsets']; // Load fieldsets template include WR_Megamenu_Loader::get_path('form/tmpl/fieldsets.php'); } ?> </div> </div> </div> <?php $first = false; } ?> </div>
/** * @version $Id$ * @package WR_Library * @author WooRockets Team <*****@*****.**> * @copyright Copyright (C) 2014 WooRockets.com All Rights Reserved. * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html * * Websites: http://www.woorockets.com * Technical Support: Feedback - http://www.woorockets.com */ if (isset($section['fields'])) { $this->current_fields = $section['fields']; // Load fields template include WR_Megamenu_Loader::get_path('form/tmpl/fields-setting.php'); } if (isset($section['fieldsets'])) { $this->current_fieldsets = $section['fieldsets']; // Load fieldsets template include WR_Megamenu_Loader::get_path('form/tmpl/fieldsets.php'); } if (isset($section['accordion'])) { $this->current_accordion = $section['accordion']; // Load accordion template include WR_Megamenu_Loader::get_path('form/tmpl/accordion.php'); } if (isset($section['tabs'])) { $this->current_tabs = $section['tabs']; // Load tabs template include WR_Megamenu_Loader::get_path('form/tmpl/tabs.php'); }
/** * Register Path to extended Parameter type * * @param string $path */ public function register_extended_parameter_path($path) { WR_Megamenu_Loader::register($path, 'WR_Megamenu_Helpers_Html_'); }
} ?> " id="wr-form-tab-<?php esc_attr_e($tid); ?> "> <?php if (isset($tab['fields'])) { $this->current_fields = $tab['fields']; // Load fields template include WR_Megamenu_Loader::get_path('form/tmpl/fields.php'); } if (isset($tab['fieldsets'])) { $this->current_fieldsets = $tab['fieldsets']; // Load fieldsets template include WR_Megamenu_Loader::get_path('form/tmpl/fieldsets.php'); } if (isset($tab['accordion'])) { $this->current_accordion = $tab['accordion']; // Load accordion template include WR_Megamenu_Loader::get_path('form/tmpl/accordion.php'); } ?> </div> <?php $first = false; } ?> </div> </div>
* * Websites: http://www.woorockets.com * Technical Support: Feedback - http://www.woorockets.com */ define('WR_MEGAMENU_ROOT_PATH', plugin_dir_path(__FILE__)); define('WR_MEGAMENU_ROOT_URL', plugin_dir_url(__FILE__)); define('WR_MEGAMENU_MAIN_FILE', WR_MEGAMENU_ROOT_PATH . 'main.php'); define('WR_MEGAMENU_BUILDER_ENTRY_URL', admin_url('admin.php?page=wr-megamenu-builder')); define('WR_MEGAMENU_META_KEY', '_wr_megamenu_'); define('WR_MEGAMENU_OPTION_KEY', 'wr-megamenu-megaed-menus'); define('WR_MEGAMENU_TMP_WIDGET_OPTION', 'wr-megamenu-tmp-widget-settings'); // Text domain for WR MegaMenu plugin define('WR_MEGAMENU_TEXTDOMAIN', 'wr-megamenu'); // Define absolute path of shortcodes folder define('WR_MEGAMENU_LAYOUT_PATH', WR_MEGAMENU_ROOT_PATH . 'includes/shortcode/layout'); define('WR_MEGAMENU_ELEMENT_PATH', WR_MEGAMENU_ROOT_PATH . 'shortcodes'); define('WR_MEGAMENU_ELEMENT_URL', WR_MEGAMENU_ROOT_URL . 'shortcodes'); // Define nonce ID define('WR_MEGAMENU_NONCE', 'wr_nonce_check'); // Define product identified name define('WR_MEGAMENU_IDENTIFIED_NAME', 'wr_megamenu'); // Define URL to load element editor define('WR_MEGAMENU_URL', admin_url('admin.php?wr-mm-gadget=edit-element')); // Define Custom Post Type name define('WR_MEGAMENU_POST_TYPE_NAME', 'wr_megamenu_profile'); // Define absolute path of templates folder define('WR_MEGAMENU_TPL_PATH', WR_MEGAMENU_ROOT_PATH . 'templates'); //// Register extra path and class suffix with class auto-loader WR_Megamenu_Loader::register(WR_MEGAMENU_ROOT_PATH . 'includes', 'WR_Megamenu_'); WR_Megamenu_Loader::register(WR_MEGAMENU_ROOT_PATH . 'includes/plugin', 'WR_Megamenu_');
/** * Render the output. * * @param string $action Gadget action to execute. * * @return void */ protected function render($action = 'default') { // Clean all buffered output while (ob_get_level()) { ob_end_clean(); } // Get response $response = $this->get_response(); // Tell browser that JSON string is returned @header('Content-Type: application/json'); // Check if template file exists for requested gadget action $file = WR_Megamenu_Loader::get_path("gadget/tmpl/{$this->gadget}/{$action}.php"); if ('success' == $response['status'] && !empty($file)) { // Start output buffering ob_start(); // Extract response array to variables: $status and $data extract($response); // Load template file to render output include_once $file; // Get final response $response['data'] = ob_get_clean(); if (empty($response['data']) && $response != $this->get_response()) { $response = $this->get_response(); } } // Print the JSON encoded response then xxit immediately to prevent WordPress from processing further exit(json_encode($response)); }