/** * Check if URL is local * * @since 0.9 * @param string $url URL to test * @return bool True if URL is local */ function ctc_is_local_url($url) { $bool = false; if (ctc_is_url($url) && preg_match('/^' . preg_quote(home_url(), '/') . '/', $url)) { $bool = true; } return apply_filters('ctc_is_local_url', $bool, $url); }
/** * Embed code based on audio/video URL or provided embed code * * If content is URL, use oEmbed to get embed code. If content is not URL, assume it is * embed code and run do_shortcode() in case of [video], [audio] or [embed] * * @since 0.9 * @param string $content URL */ function ctc_embed_code($content) { global $wp_embed; // Convert URL into media shortcode like [audio] or [video] if (ctc_is_url($content)) { $embed_code = $wp_embed->shortcode(array(), $content); } else { $embed_code = $content; } // Run shortcode // [video], [audio] or [embed] converted from URL or already existing in $content $embed_code = do_shortcode($embed_code); // Return filtered return apply_filters('ctc_embed_code', $embed_code, $content); }