Пример #1
0
 /**
  * Obtains an array of available Importers
  *
  * @return array Array containing a list of importers, indexed by classname, containing a display name, description and namespace+class.
  */
 public function getImporters()
 {
     if (isset($this->np_cache['importers'])) {
         return $this->np_cache['importers'];
     }
     $base_namespace = '\\Myatu\\WordPress\\BackgroundManager\\Importers';
     $importers = apply_filters(Main::BASE_PUB_PREFIX . 'importers', \Pf4wp\Dynamic\Loader::get($base_namespace, $this->owner->getPluginDir() . Main::DIR_IMPORTERS));
     // Classes must be a subclass of Importers\Importer (checked, as we apply a filter)
     foreach ($importers as $importer_key => $importer) {
         if (!is_subclass_of($importer['class'], $base_namespace . '\\Importer')) {
             unset($importers[$importer_key]);
         }
     }
     // Sort importers by name
     uasort($importers, function ($a, $b) {
         return strcasecmp($a['name'], $b['name']);
     });
     // Store in non-persistent cache
     $this->np_cache['importers'] = $importers;
     return $importers;
 }
Пример #2
0
 /**
  * Obtains an array of available Meta boxes
  *
  * @return array Array containing a list of meta boxes
  */
 protected function getMetaBoxes()
 {
     if (!isset($this->np_cache['meta_boxes'])) {
         $this->np_cache['meta_boxes'] = \Pf4wp\Dynamic\Loader::get(__NAMESPACE__ . '\\Meta', $this->getPluginDir() . static::DIR_META, true);
     }
     return $this->np_cache['meta_boxes'];
 }