/** * @see Envato_Market_Items::themes() */ function test_themes() { $this->assertEmpty($this->items->themes('invalid')); // Replace private themes reference $ref = new ReflectionProperty('Envato_Market_Items', 'themes'); $ref->setAccessible(true); $themes = $ref->getValue(); $ref->setValue(null, array()); $this->assertEmpty($this->items->themes()); $ref = new ReflectionProperty('Envato_Market_Items', 'themes'); $ref->setAccessible(true); $ref->setValue(null, $themes); }
/** * Set the list of themes * * @since 1.0.0 * * @param bool $forced Forces an API request. Default is 'false'. * @param bool $use_cache Attempts to rebuild from the cache before making an API request. */ public function set_themes($forced = false, $use_cache = false) { self::$themes = get_site_transient(envato_market()->get_option_name() . '_themes'); if (false === self::$themes || true === $forced) { $themes = envato_market()->api()->themes(); foreach (envato_market()->get_option('items', array()) as $item) { if (empty($item)) { continue; } if ('theme' === $item['type']) { $request_args = array('headers' => array('Authorization' => 'Bearer ' . $item['token'])); $request = envato_market()->api()->item($item['id'], $request_args); if (false !== $request) { $themes[] = $request; } } } self::process_themes($themes); } elseif (true === $use_cache) { self::process_themes(self::$themes['purchased']); } }