/*
 Theme Name:   Bricks Child Theme
 Theme URI:    https://bricksbuilder.io/
 Description:  Use this child theme to extend Bricks.
 Author:       Bricks
 Author URI:   https://bricksbuilder.io/
 Template:     bricks
 Version:      1.1
 Text Domain:  bricks
*/

/* Visible play affordance for Bricks' keyboard-accessible video preview. */
#brxe-vwmui8 .bricks-video-preview-image::after {
  content: "▶";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #111b;
  color: #fff;
  font: 28px/1 Arial, sans-serif;
  pointer-events: none;
}
#brxe-vwmui8 .bricks-video-preview-image:focus-visible {
  outline: 3px solid var(--secad-color-brand);
  outline-offset: 3px;
}

function secad_sender_email( $original_email_address ) {
    	return 'info@secad.ie';
	}
 
// Function to change sender name
function secad_sender_name( $original_email_from ) {
    	return 'SECAD Training';
	}
 
// Hooking up our functions to WordPress filters 
	add_filter( 'wp_mail_from', 'secad_sender_email' );
	add_filter( 'wp_mail_from_name', 'secad_sender_name' );


function disable_rest_endpoints ( $endpoints ) {
    if ( isset( $endpoints['/wp/v2/users'] ) ) {
        unset( $endpoints['/wp/v2/users'] );
    }
    if ( isset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] ) ) {
        unset( $endpoints['/wp/v2/users/(?P<id>[\d]+)'] );
    }
    return $endpoints;
}
add_filter( 'rest_endpoints', 'disable_rest_endpoints');

// translating shortcodes
define( 'FILTERPRIORITY', 10 );
add_filter( 'the_content', 'do_shortcode', FILTERPRIORITY );
add_filter( 'widget_text', 'do_shortcode', FILTERPRIORITY );

//Stop Related YouTube videos I guess.. 
function stop_youtube_unrelated_videos($data, $url, $args = array()) {
    if (strpos($data, "feature=oembed") !== false) {
        $data = str_replace('feature=oembed', 'rel=0&amp;feature=oembed', $data);
  }
    return $data;
}
add_filter('oembed_result', 'stop_youtube_unrelated_videos', 10, 3);


add_shortcode('gtranslate_irish_english', function () {
    ob_start();
    ?>
    
    <div class="gtranslate-irish-english">
        <?php echo do_shortcode('[gtranslate]'); ?>
    </div>

    <style>
        .gtranslate-irish-english img[src*="/flags/svg/en.svg"],
        .gtranslate-irish-english img[src*="/flags/svg/gb.svg"],
        .gtranslate-irish-english img[src*="/flags/24/en.png"],
        .gtranslate-irish-english img[src*="/flags/32/en.png"] {
            content: url("https://cdn.gtranslate.net/flags/svg/ga.svg") !important;
        }
    </style>

    <?php
    return ob_get_clean();
});


