1: <?php
2: /**
3: * Front End Functions
4: *
5: * @package EPL
6: * @subpackage Functions/Front
7: * @copyright Copyright (c) 2019, Merv Barrett
8: * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9: * @since 1.0
10: */
11:
12: // Exit if accessed directly.
13: if ( ! defined( 'ABSPATH' ) ) {
14: exit;
15: }
16:
17: /**
18: * Modify the Read More Link of archive pages which can be styled with
19: * CSS using the epl-more-link selector
20: *
21: * @param string $more Existing read more, normally three dots.
22: *
23: * @return string
24: * @since 1.0
25: * @since 3.4.44 Fix: Notice when $post is null.
26: **/
27: function epl_property_new_excerpt_more( $more ) {
28: global $post;
29: if ( is_null( $post ) ) {
30: return $more;
31: }
32: return '...<a href="' . get_permalink( $post->ID ) . '" class="epl-more-link">' . __( 'Read More', 'easy-property-listings' ) . '&rarr;</a>';
33: }
34: add_filter( 'excerpt_more', 'epl_property_new_excerpt_more' );
35:
36: /**
37: * Youtube Video Link Filter so the YouTube short links will work
38: *
39: * @param string $text YouTube URL.
40: *
41: * @return string
42: * @since 1.0
43: * @since 3.4.4 Added support for youtube shorts videos.
44: */
45: function epl_get_youtube_id_from_url( $text ) {
46: $text = preg_replace( "/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user|shorts)\/))([^\?&\"'>]+)/", '$1', $text );
47: $text = explode( '?', $text );
48: return $text[0];
49: }
50: