/** * Filters 'get_the_post_format_url' to make for a more robust and back-compatible function. If WP did * not find a URL, check the post content for one. If nothing is found, return the post permalink. * * @since 1.6.0 * @access public * @param string $url * @param object $post * @note Setting defaults for the parameters so that this function can become a filter in future WP versions. * @return string */ function hybrid_get_the_post_format_url($url = '', $post = null) { if (empty($url)) { $post = is_null($post) ? get_post() : $post; $content_url = hybrid_get_content_url($post->post_content); $url = !empty($content_url) ? $content_url : get_permalink($post->ID); } return $url; }
/** * Filters 'get_the_post_format_url' to make for a more robust and back-compatible function. If WP did * not find a URL, check the post content for one. If nothing is found, return the post permalink. * * @since 1.6.0 * @access public * @param string $url * @param object $post * @return string */ function hybrid_get_the_post_format_url($url = '', $post = null) { if (!$url) { $post = is_null($post) ? get_post() : $post; $content_url = hybrid_get_content_url($post->post_content); $url = $content_url ? esc_url($content_url) : esc_url(get_permalink($post->ID)); } return $url; }