Exemple #1
0
 /**
  * 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_Pb_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_customer_account', null);
         $has_customer_account = is_array($customer_account) && !@empty($customer_account['username']) && !@empty($customer_account['password']);
         // Load template
         include_once $tmpl;
     }
 }
Exemple #2
0
 /**
  * Render the output.
  *
  * @param   string  $action  Gadget action to execute.
  *
  * @return  void
  */
 public 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_Pb_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));
 }
Exemple #3
0
 /**
  * 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_pb_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;
 }
 /**
  * Register autoloader.
  *
  * @return  void
  */
 function autoload()
 {
     WR_Pb_Loader::register(WR_PB_PATH . 'core', 'WR_Pb_');
     WR_Pb_Loader::register(WR_PB_PATH . 'core/gadget', 'WR_Gadget_');
     // Allow autoload registration from outside
     do_action('wr_pb_autoload');
 }
 /**
  * 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_Pb_Loader::register($path, 'WR_' . $postfix);
 }
Exemple #6
0
 /**
  * Register Path to extended Parameter type
  *
  * @param string $path
  */
 public function register_extended_parameter_path($path)
 {
     WR_Pb_Loader::register($path, 'WR_Pb_Helper_Html_');
 }