/**
  *
  * @TODO document
  *
  */
 function load_plugins()
 {
     $plugins = $this->get_latest_cached('plugins');
     if (!is_object($plugins)) {
         return $plugins;
     }
     $output = '';
     $plugins = pagelines_store_object_sort($plugins);
     $plugins = json_decode(json_encode($plugins), true);
     // convert objects to arrays
     $plugins = self::external_plugins($plugins);
     foreach ($plugins as $key => $plugin) {
         $plugins[$key]['file'] = sprintf('/%1$s/%1$s.php', $key);
     }
     // get status of each plugin
     foreach ($plugins as $key => $ext) {
         $plugins[$key]['status'] = $this->plugin_check_status(WP_PLUGIN_DIR . $ext['file']);
         $plugins[$key]['name'] = $plugins[$key]['status']['data']['Name'] ? $plugins[$key]['status']['data']['Name'] : $plugins[$key]['name'];
     }
     // reset array keys ( sort functions reset keys to int )
     foreach ($plugins as $key => $ext) {
         unset($plugins[$key]);
         $key = str_replace('.php', '', basename($ext['file']));
         $plugins[$key] = $ext;
     }
     return $plugins;
 }
 /**
  * Section install tab.
  *
  */
 function extension_sections($tab = '', $mode = 'install')
 {
     if ($tab == 'child' && !is_child_theme()) {
         return $this->ui->extension_banner(__('A PageLines child theme is not currently activated', 'pagelines'));
     }
     if (!$this->has_extend_plugin()) {
         return $this->ui->get_extend_plugin($this->has_extend_plugin('status'), $tab);
     }
     $list = array();
     $type = 'section';
     if ('install' == $mode) {
         $sections = $this->get_latest_cached('sections');
         if (!is_object($sections)) {
             return $sections;
         }
         $sections = pagelines_store_object_sort($sections);
         $list = $this->get_master_list($sections, $type, $tab);
     }
     // end install mode
     if ('installed' == $mode) {
         global $load_sections;
         // Get sections
         $available = $load_sections->pagelines_register_sections(true, true);
         $disabled = get_option('pagelines_sections_disabled', array());
         $upgradable = $this->get_latest_cached('sections');
         foreach ($available as $key => $section) {
             $available[$key] = self::sort_status($section, $disabled, $available, $upgradable);
         }
         $sections = self::merge_sections($available);
         $this->updates_list(array('list' => $sections, 'type' => 'section'));
         $list = $this->get_master_list($sections, $type, $tab, 'installed');
     }
     // end installed mode
     return $this->ui->extension_list(array('list' => $list, 'tab' => $tab, 'type' => 'sections'));
 }
 /**
  *
  * @TODO document
  *
  */
 function extension_scan_themes($themes)
 {
     $default_headers = array('Demo' => 'Demo', 'External' => 'External', 'Long' => 'Long');
     $themes = pagelines_store_object_sort($themes);
     $themes = json_decode(json_encode($themes), true);
     $get_themes = apply_filters('store_get_themes', pl_get_themes());
     foreach ($get_themes as $theme => $theme_data) {
         $up = null;
         $purchased = null;
         // Now we add our data...
         $theme_file = $theme_data['Stylesheet Files'][0];
         $pl_theme_data = get_file_data($theme_file, $default_headers);
         if ($theme_data['Template'] != 'pagelines') {
             continue;
         }
         if ('pagelines' == $theme_data['Stylesheet']) {
             continue;
         }
         // check for an update...
         if (isset($themes[$theme_data['Stylesheet']]['version']) && $themes[$theme_data['Stylesheet']]['version'] > $theme_data['Version']) {
             $up = $themes[$theme_data['Stylesheet']]['version'];
         } else {
             $up = '';
         }
         $pid = isset($themes[$theme_data['Stylesheet']]['productid']) ? $themes[$theme_data['Stylesheet']]['productid'] : '';
         $subscribed = isset($themes[$theme_data['Stylesheet']]['subscribed']) ? $themes[$theme_data['Stylesheet']]['subscribed'] : null;
         if (in_array($theme, $themes)) {
             continue;
         }
         $purchased = isset($themes[$theme_data['Stylesheet']]['purchased']) ? $themes[$theme_data['Stylesheet']]['purchased'] : '';
         // If we got this far, theme is a pagelines child theme not handled by the API
         // So we need to inject it into our themes array.
         $plus = isset($themes[$theme_data['Stylesheet']]['plus_product']) ? $themes[$theme_data['Stylesheet']]['plus_product'] : false;
         $new_theme = array();
         $new_theme['name'] = $theme_data['Name'];
         $new_theme['author'] = $theme_data['Author Name'];
         $new_theme['author_url'] = $theme_data['Author URI'];
         $new_theme['apiversion'] = $up;
         $new_theme['version'] = $theme_data['Version'];
         $new_theme['text'] = $theme_data['Description'];
         $new_theme['long'] = $pl_theme_data['Long'];
         $new_theme['external'] = $pl_theme_data['External'];
         $new_theme['Demo'] = $pl_theme_data['Demo'];
         $new_theme['tags'] = $theme_data['Tags'];
         $new_theme['featured'] = isset($themes[$theme_data['Stylesheet']]['featured']) ? $themes[$theme_data['Stylesheet']]['featured'] : null;
         $new_theme['price'] = isset($themes[$theme_data['Stylesheet']]['price']) ? $themes[$theme_data['Stylesheet']]['price'] : null;
         $new_theme['pid'] = $pid;
         $new_theme['subscribed'] = $subscribed;
         $new_theme['count'] = null;
         $new_theme['slug'] = isset($themes[$theme_data['Stylesheet']]['slug']) ? $themes[$theme_data['Stylesheet']]['slug'] : null;
         if ($purchased) {
             $new_theme['purchased'] = $purchased;
         }
         $new_theme['plus_product'] = $plus;
         $themes[$theme_data['Stylesheet']] = $new_theme;
     }
     return $themes;
 }