public function test_wp_filter_pre_oembed_result_non_existent_post() { $post_id = self::factory()->post->create(); $permalink = get_permalink($post_id); $this->go_to($permalink); $this->assertQueryTrue('is_single', 'is_singular'); add_filter('pre_oembed_result', array($this, '_filter_pre_oembed_result')); $actual = $this->oembed->get_html('https://example.com/'); remove_filter('pre_oembed_result', array($this, '_filter_pre_oembed_result')); $this->assertTrue(false !== $this->pre_oembed_result_filtered); $this->assertFalse($actual); }
/** * The do-it-all function that takes a URL and attempts to return the HTML. * * @see WP_oEmbed::discover() * @see WP_oEmbed::fetch() * @see WP_oEmbed::data2html() * * @param string $url The URL to the content that should be attempted to be embedded. * @param array $args Optional arguments. Usually passed from a shortcode. * @return bool|string False on failure, otherwise the UNSANITIZED (and potentially unsafe) HTML that should be used to embed. */ public function get_html($strURL, $arrArgs = array()) { if (isset($GLOBALS['arrFetchTweets_oEmbed'][$strURL])) { return $GLOBALS['arrFetchTweets_oEmbed'][$strURL]; } $strHTML = parent::get_html($strURL, $arrArgs); // Store the result in the global array. $GLOBALS['arrFetchTweets_oEmbed'][$strURL] = $strHTML; return $strHTML; }