/** * 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; } }
/** * 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)); }