function postman_google_api_php_client_autoload($className) { $logger = new PostmanLogger('postman_google_api_php_client_autoload'); $logger->trace('Autoloading ' . $className); $classPath = explode('_', $className); // @jason: make sure the first segment of the classname is 'Postman' if (empty($classPath[0]) || empty($classPath[1])) { return; } if ($classPath[0] != 'Postman' && $classPath[1] != 'Google') { return; } else { // @jason: get rid of the first segment of the classname $classPath = array_slice($classPath, 1); } if (count($classPath) > 3) { // Maximum class file path depth in this project is 3. $classPath = array_slice($classPath, 1, 4); } $filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php'; if (file_exists($filePath)) { require_once $filePath; } }
/** * Create a custom post type * Callback function - must be public scope * * register_post_type should only be invoked through the 'init' action. * It will not work if called before 'init', and aspects of the newly * created or modified post type will work incorrectly if called later. * * https://codex.wordpress.org/Function_Reference/register_post_type */ public static function create_post_type() { register_post_type(self::POSTMAN_CUSTOM_POST_TYPE_SLUG, array('labels' => array('name' => _x('Sent Emails', 'The group of Emails that have been delivered', Postman::TEXT_DOMAIN), 'singular_name' => _x('Sent Email', 'An Email that has been delivered', Postman::TEXT_DOMAIN)), 'capability_type' => '', 'capabilities' => array())); $logger = new PostmanLogger('PostmanEmailLogPostType'); $logger->trace('Created post type: ' . self::POSTMAN_CUSTOM_POST_TYPE_SLUG); }
/** * * @param unknown $data */ public function import($data) { if (PostmanPreRequisitesCheck::checkZlibEncode()) { $logger = new PostmanLogger(get_class($this)); $logger->debug('Importing Settings'); $base64 = $data; $logger->trace($base64); $gz = base64_decode($base64); $logger->trace($gz); $json = @gzuncompress($gz); $logger->trace($json); if (!empty($json)) { $data = json_decode($json, true); $logger->trace($data); // overwrite the current version with the version from the imported options // this way database upgrading can occur $postmanState = get_option('postman_state'); $postmanState['version'] = $data['version']; $logger->trace(sprintf('Setting Postman version to %s', $postmanState['version'])); assert($postmanState['version'] == $data['version']); update_option('postman_state', $postmanState); $this->options = $data; $logger->info('Imported data'); $this->save(); return true; } else { $logger->error('Could not import data - data error'); return false; } } }