/** * */ protected function checkExtensionList() { $list = AAM_Core_API::getOption('aam-extension-repository', array()); $repo = AAM_Core_Repository::getInstance(); //WP Error Fix bug report $list = is_array($list) ? $list : array(); foreach ($list as $extension) { $status = $repo->extensionStatus($extension->title); if ($status == AAM_Core_Repository::STATUS_UPDATE) { AAM_Core_Console::add(sprintf(__('Extension %s has new update available for download.'), $extension->title)); } } //TODO - Remove in Feb 2016 $this->checkRedundantExtensions(); }
/** * * @param type $object * @param type $id * @return type */ public function readOption($object, $id = 0) { return AAM_Core_API::getOption($this->getOptionName($object, $id)); }
/** * * @param type $object * @param type $object_id * @param type $default * @return type */ public function readOption($object, $object_id = 0, $default = null) { return AAM_Core_API::getOption($this->getOptionName($object, $object_id), $default); }
/** * * @return type */ public function getMetaboxList() { $cache = AAM_Core_API::getOption('aam_metabox_cache', array()); $subject = AAM_Backend_View::getSubject(); //if visitor, return only frontend widgets if ($subject instanceof AAM_Core_Subject_Visitor) { if (!empty($cache['widgets'])) { $response = array('widgets' => $cache['widgets']); } else { $response = array(); } } else { $response = $cache; } return $response; }
/** * Store the license key * * This is important to have just for the update extension purposes * * @param string $title * @param string $license * * @return void * * @access protected */ protected function storeLicense($title, $license) { //retrieve the installed list of extensions $list = AAM_Core_API::getOption('aam-extension-license', array()); $list[$title] = $license; //update the extension list AAM_Core_API::updateOption('aam-extension-license', $list); }
/** * Print plugin localization * * @param string $localKey * * @return void * * @access protected */ protected function printLocalization($localKey) { $subject = $this->getCurrentSubject(); wp_localize_script($localKey, 'aamLocal', array('nonce' => wp_create_nonce('aam_ajax'), 'ajaxurl' => admin_url('admin-ajax.php'), 'url' => array('site' => admin_url('index.php'), 'jsbase' => AAM_MEDIA . '/js', 'editUser' => admin_url('user-edit.php'), 'addUser' => admin_url('user-new.php')), 'subject' => array('type' => $subject->type, 'id' => $subject->id, 'name' => $subject->name, 'blog' => get_current_blog_id()), 'welcome' => AAM_Core_API::getOption('aam-welcome', 1), 'translation' => require dirname(__FILE__) . '/Localization.php')); }
/** * * @return int */ protected static function getNotification() { $list = AAM_Core_API::getOption('aam-extension-repository', array()); $repo = AAM_Core_Repository::getInstance(); $count = 0; foreach ($list as $extension) { $status = $repo->extensionStatus($extension->title); if ($status == AAM_Core_Repository::STATUS_UPDATE) { $count++; } } return $count; }
/** * * @return type */ protected function prepareExtensionCache() { if (empty($this->cache)) { $list = AAM_Core_API::getOption('aam-extension-repository', array()); $licenses = AAM_Core_API::getOption('aam-extension-license', array()); $this->cache = array(); foreach ($list as $row) { $this->cache[$row->title] = $row; if (isset($licenses[$row->title])) { $this->cache[$row->title]->license = $licenses[$row->title]; } } } return $this->cache; }
/** * Check extension status * * The list of extensions is comming from the external server. This list is * updated daily by the registered cron-job. * Each extension is following by next naming convension and stardard - the * title of an extension contains only latin letters and spaces and name is * no longer than 50 characters. As a standard, each extension defines the * global contant that indicates an extension version. The name of the * contants derives from the extension title by transforming all letters to * upper case and replacing the white spaces with underscore "_" * (e.g AAM Plus Package defines the contant AAM_PLUS_PACKAGE). * * @param string $title * * @return string * * @access public */ public function extensionStatus($title) { static $cache = null; $status = self::STATUS_INSTALLED; $const = str_replace(' ', '_', strtoupper($title)); if (is_null($cache)) { $list = AAM_Core_API::getOption('aam-extension-list', array()); $cache = array(); foreach ($list as $row) { $cache[$row->title] = $row; } } if (!defined($const)) { //extension does not exist $status = self::STATUS_DOWNLOAD; } elseif (!empty($cache[$title])) { $version = constant($const); if ($version != $cache[$title]->version) { //version mismatch? $status = self::STATUS_UPDATE; } } return $status; }
/** * * @param type $name * @param type $default * @return type */ public function getProperty($name, $default = null) { static $properties = null; if (empty($properties)) { $properties = AAM_Core_API::getOption('aam-utilities', array()); } return isset($properties[$name]) ? $properties[$name] : $default; }
/** * Print plugin localization * * @param string $localKey * * @return void * * @access protected */ protected function printLocalization($localKey) { $user = AAM_Core_Request::get('user'); $roles = array_keys(get_editable_roles()); $role = array_shift($roles); wp_localize_script($localKey, 'aamLocal', array('nonce' => wp_create_nonce('aam_ajax'), 'ajaxurl' => admin_url('admin-ajax.php'), 'url' => array('site' => admin_url('index.php'), 'jsbase' => AAM_MEDIA . '/js/aam', 'editUser' => admin_url('user-edit.php'), 'addUser' => admin_url('user-new.php')), 'subject' => array('type' => $user ? 'user' : 'role', 'id' => $user ? $user : $role, 'blog' => get_current_blog_id()), 'welcome' => AAM_Core_API::getOption('aam-welcome', 1))); }