public static function getPluginsInFolder($path, $type) { require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'filesystem.php'; $folders = PIPES_Helper_FileSystem::dirs($path); $path_elements = explode(DIRECTORY_SEPARATOR, $path); $datas = array(); foreach ($folders as $folder) { $path_xml = $path . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . $folder . '.xml'; if (!is_file($path_xml)) { $data = null; } elseif (end($path_elements) == '' && !is_plugin_active($folder . '/' . $folder . '.php')) { $data = null; } else { $data = self::parseXMLInstallFile($path_xml); } if (isset($data['element']) && (isset($data['addon']) && $data['addon'] == $type)) { $datas[$data['element']] = $data; } } return $datas; }
public static function get_templates() { $upload_dir = wp_upload_dir(); $path = $upload_dir['basedir'] . DS . 'wppipes' . DS . 'templates'; $pipes = array(); if (!is_dir($path)) { return $pipes; } $files = PIPES_Helper_FileSystem::files($path); if (!is_array($files)) { return $pipes; } foreach ($files as $file) { $item = new stdClass(); $extension = ogbFile::getExten($file); if ($extension == 'pipe') { $content = file_get_contents($path . DS . $file); $item = json_decode($content); $item->filename = $file; $pipes[] = $item; } } return $pipes; }