Esempio n. 1
0
 /**
  * component_actions function.
  * 
  * @access public
  * @since 1.0.0
  * @return void
  */
 public function component_actions()
 {
     $response = false;
     // Component activation.
     if ((isset($_GET['activate-component']) || isset($_POST['activate-component'])) && WooDojo_Utils::get_or_post('activate-component') != '') {
         $response = $this->activate_component(trim(esc_attr(WooDojo_Utils::get_or_post('activate-component'))), trim(esc_attr(WooDojo_Utils::get_or_post('component-type'))));
     }
     // Component deactivation.
     if ((isset($_GET['deactivate-component']) || isset($_POST['deactivate-component'])) && WooDojo_Utils::get_or_post('deactivate-component') != '') {
         $response = $this->deactivate_component(trim(esc_attr(WooDojo_Utils::get_or_post('deactivate-component'))), trim(esc_attr(WooDojo_Utils::get_or_post('component-type'))));
     }
     // Component download.
     if ((isset($_GET['download-component']) || isset($_POST['download-component'])) && WooDojo_Utils::get_or_post('download-component') != '') {
         $response = $this->download_component(trim(esc_attr(WooDojo_Utils::get_or_post('download-component'))), trim(esc_attr(WooDojo_Utils::get_or_post('component-type'))));
     }
     // Component upgrade.
     if ((isset($_GET['upgrade-component']) || isset($_POST['upgrade-component'])) && WooDojo_Utils::get_or_post('upgrade-component') != '') {
         $response = $this->upgrade_component(trim(esc_attr(WooDojo_Utils::get_or_post('upgrade-component'))), trim(esc_attr(WooDojo_Utils::get_or_post('component-type'))));
     }
     return $response;
 }
Esempio n. 2
0
 /**
  * upgrade_component function.
  * 
  * @access public
  * @since 1.0.0
  * @param string $component
  * @param string $type
  * @param boolean $redirect
  * @return void
  */
 public function upgrade_component($component, $type = 'downloadable', $redirect = true)
 {
     global $woodojo;
     $redirect_to = admin_url('admin.php?page=' . $this->config->token . '&component=' . $component . '&component-type=' . $type . '&process-action=' . 'upgrade' . '&upgrade-component=' . $component . '&activate=false');
     // Backup the current version.
     $dir = $this->config->downloads_path;
     if ($type == 'bundled') {
         $dir = $this->config->components_path;
     }
     $component_dir = $dir . dirname($this->components[$type][$component]->filepath);
     $files = WooDojo_Utils::glob_php('*', 0, $component_dir);
     if (count($files) > 0) {
         foreach ($files as $k => $v) {
             if ($v == $dir || is_dir($v)) {
                 unset($files[$k]);
             } else {
                 $files[$k] = str_replace($this->config->downloads_path, '', $v);
             }
         }
     }
     $has_zip = WooDojo_Utils::create_zip($files, $dir, $this->config->backups_path . sanitize_title_with_dashes($component) . '.zip', true);
     if ($has_zip == true) {
         // Download the latest version.
         $upgraded = $this->download_component($component, $type, false, false);
     }
     if ($upgraded == true) {
         wp_redirect(admin_url('admin.php?page=' . $this->config->token . '&upgraded-component=' . $component . '&type=' . $type));
         exit;
     } else {
         wp_redirect(admin_url('admin.php?page=' . $this->config->token . '&upgrade-error=' . $component . '&type=' . $type));
         exit;
     }
 }
Esempio n. 3
0
 /**
  * get_screenshots function.
  * 
  * @access public
  * @since 1.0.0
  * @uses WooDojo_Utils::glob_php()
  * @uses global $woodojo->settings->screenshot_url
  * @return array $screenshots
  */
 public function get_screenshots()
 {
     global $woodojo;
     $screenshots = array();
     if (isset($this->component->screenshot_url) && $this->component->screenshot_url != '') {
         $screenshots = explode(',', $this->component->screenshot_url);
     }
     if (is_array($screenshots) && count($screenshots) > 0) {
         foreach ($screenshots as $k => $v) {
             $screenshots[$k] = esc_url($woodojo->settings->screenshot_url . $v);
         }
     }
     $screenshots_path = trailingslashit($this->config->assets_path . 'screenshots/' . $this->component_token);
     $screenshots_url = trailingslashit($this->config->assets_url . 'screenshots/' . $this->component_token);
     if (count($screenshots) == 0 && is_dir($screenshots_path)) {
         $files = WooDojo_Utils::glob_php('*.jpg', GLOB_MARK, $screenshots_path);
         if (count($files) > 0) {
             foreach ($files as $k => $v) {
                 $screenshots[] = $screenshots_url . basename($v);
             }
         }
     }
     return $screenshots;
 }
Esempio n. 4
0
 /**
  * admin_scripts function.
  * 
  * @access public
  * @since 1.0.0
  * @return void
  */
 function admin_scripts()
 {
     wp_register_script($this->token . '-admin', $this->assets_url . 'js/admin.js', array('jquery'), '1.2.4', false);
     wp_enqueue_script($this->token . '-admin');
     $translation_strings = WooDojo_Utils::load_common_l10n();
     $ajax_vars = array($this->token . '_component_toggle_nonce' => wp_create_nonce($this->token . '_component_toggle_nonce'));
     $data = array_merge($translation_strings, $ajax_vars);
     /* Specify variables to be made available to the admin.js file. */
     wp_localize_script($this->token . '-admin', $this->token . '_localized_data', $data);
 }