Forum Replies Created

Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter cafoundationfund

    (@cafoundationfund)

    The following snippet is in the child time function.php.

    add_filter(‘tc_grid_display_figcaption_content’, ‘my_grid_content’);
    function my_grid_content(){

    $text = apply_filters( ‘the_content’, get_the_content() );
    $text = str_replace(‘]]>’, ‘]]>’, $text);

    return sprintf(‘<div class=”tc-g-cont”>%s</div>’,
    $text
    );
    }

    It does not work. Can you advise?

    Thread Starter cafoundationfund

    (@cafoundationfund)

    Hover over the images and you will see the iframe excerpt.

    cafoundationfund.org/projects

    I will try the snippet in the child theme function to see if it is removed.

    Best,
    Miguel

    Thread Starter cafoundationfund

    (@cafoundationfund)

    Got it to work. However I want the excerpt to work. The content is ugly. I will start a new string of posts. This was is confusing.

    Thread Starter cafoundationfund

    (@cafoundationfund)

    When I add this to the bottom:

    <?php
    add_filter(‘tc_grid_display_figcaption_content’, ‘my_grid_content’);
    function my_grid_content(){

    $text = apply_filters( ‘the_content’, get_the_content() );
    $text = str_replace(‘]]>’, ‘]]>’, $text);

    return sprintf(‘<div class=”tc-g-cont”>%s</div>’,
    $text
    );
    }

    I get this:

    Parse error: syntax error, unexpected ‘<‘ in /home/wp_phcans/cafoundationfund.org/wp-content/themes/customizr-child/functions.php on line 338

    Thread Starter cafoundationfund

    (@cafoundationfund)

    I am already running this on the functions.php

    <?php
    /**
    * This is where you can copy and paste your functions !
    */

    add_filter(‘tc_slide_background’ , ‘set_video_slider’, 10, 4);
    function set_video_slider($_original_bg , $link, $id, $s_name ) {
    //////////////// Parameters : ////////////////
    $my_slider_name = ‘video’;//set the name you have choosen when creating your slider
    $slide_position = 2; //<= this will replace the first slide
    $_video = ‘https://www.youtube.com/watch?v=T1qTKtsGpA4&#8217;;//<=the url of your vimeo or youtube video
    $_autoplay = true;//<= true = autoplay
    $_mute_volume = true;// true = volume set to 0
    $_unmute_on_hover = true;//true = the video will unmute on mouse hover
    $_pause_on_slide = true;//true = the video is paused on slide change
    $_related_videos = false;// true = display related videos . Works just with youtube videos, vimeo doesn’t allow this for non premium users.
    $_yt_loop = true;
    //////////////////////////////////////////////
    //uncomment this video array to run the random video
    //$_video = array( ‘https://www.youtube.com/watch?v=oUlLeDKPCYA&#8217; , ‘https://vimeo.com/108792063&#8217;, ‘https://vimeo.com/73373514&#8217;, ‘https://vimeo.com/39312923&#8217;, ‘https://vimeo.com/108104171&#8217;, ‘https://vimeo.com/106535324&#8217; , ‘https://vimeo.com/108138933&#8217;, ‘https://vimeo.com/107789364&#8217;, ‘https://vimeo.com/107580451&#8217; );

    $sliders = tc__f(‘__get_option’ , ‘tc_sliders’);

    //remove previous filter if set
    remove_filter(’embed_oembed_html’, ‘_add_an_id_for_youtube_player’ , 10, 4);
    remove_filter(‘oembed_result’ , ‘enable_youtube_jsapi’);
    remove_filter(‘oembed_result’ , ‘set_youtube_autoplay’);
    remove_filter(‘oembed_fetch_url’ , ‘set_vimeo_url_query_args’);

    if ( $my_slider_name != $s_name )
    return $_original_bg;

    $_slides = array();
    foreach ($sliders[$s_name] as $_sid) {
    $_slides[] = $_sid;
    }
    if ( $id != $_slides[$slide_position-1] )
    return $_original_bg;

    if ( ! is_array($_video) ) {
    $_return_video = $_video;
    } else {
    $rand_key = array_rand($_video, 1);
    $_return_video = $_video[$rand_key];
    }

    //youtube or vimeo?
    $_provider = ( false !== strpos($_return_video, ‘youtube’) ) ? ‘youtube’ : false;
    $_provider = ( false !== strpos($_return_video, ‘vimeo’) ) ? ‘vimeo’ : $_provider;

    if ( ! $_provider )
    return $_original_bg;

    if ( ‘youtube’ == $_provider ) {
    add_filter(’embed_oembed_html’, ‘_add_an_id_for_youtube_player’ , 10, 4);
    //Adding parameters to WordPress oEmbed https://foxland.fi/adding-parameters-to-wordpress-oembed/
    add_filter(‘oembed_result’ , ‘enable_youtube_jsapi’);
    if ( false !== $_autoplay )
    add_filter(‘oembed_result’ , ‘set_youtube_autoplay’);
    if ( false !== $_yt_loop )
    add_filter(‘oembed_result’ , ‘set_youtube_loop’);
    if ( false === $_related_videos )
    add_filter(‘oembed_result’ , ‘set_youtube_no_related_videos’);
    } elseif ( ‘vimeo’ == $_provider && false !== $_autoplay ) {
    add_filter(‘oembed_fetch_url’ , ‘set_vimeo_url_query_args’);
    }

    //write some javascript : dynamic centering on resizing, responsiveness, Vimeo and YouTube API controls
    _write_video_slide_script($id, $_mute_volume, $_unmute_on_hover, $_pause_on_slide, $_provider);
    $_return_video = add_query_arg( ‘cached’ , time(), $_return_video );

    //( false !== strpos($_return_video, ‘?’) ) ? ‘&cached=’ : ‘?cached=’;
    $_return_video = apply_filters(‘the_content’, $_return_video );

    /* For someone autombed is not hooked to the content */
    if ( false === strpos($_return_video, ‘<iframe’) ){
    global $wp_embed;
    $_return_video = $wp_embed -> autoembed( $_return_video );
    }

    return $_return_video;
    }

    function set_vimeo_url_query_args($provider) {
    $provider = add_query_arg( ‘autoplay’, 1 , $provider );
    $provider = add_query_arg( ‘loop’, 1 , $provider );
    return $provider;
    }
    function set_youtube_autoplay($html) {
    if ( strstr( $html,’youtube.com/embed/’ ) )
    return str_replace( ‘?feature=oembed’, ‘?feature=oembed&autoplay=1’, $html );
    return $html;
    }

    function set_youtube_loop($html) {
    if ( strstr( $html,’youtube.com/embed/’ ) )
    return preg_replace( ‘|(youtube.com/embed/)(.*?)(\?feature=oembed)|’, ‘$0&loop=1&playlist=$2’, $html );
    return $html;
    }

    function set_youtube_no_related_videos($html) {
    if ( strstr( $html,’youtube.com/embed/’ ) )
    return str_replace( ‘?feature=oembed’, ‘?feature=oembed&rel=0’, $html );
    return $html;
    }

    function _add_an_id_for_youtube_player($html, $url, $attr, $post_ID ) {
    //@to do make the id unique
    return str_replace(‘<iframe’, ‘<iframe id=”youtube-video”‘, $html);
    }

    function enable_youtube_jsapi($html) {
    if ( strstr( $html,’youtube.com/embed/’ ) )
    return str_replace( ‘?feature=oembed’, ‘?feature=oembed&enablejsapi=1’, $html );
    return $html;
    }

    function _write_video_slide_script($id, $_mute_volume, $_unmute_on_hover, $_pause_on_slide, $_provider) {
    ?>
    <script type=”text/javascript”>
    jQuery(function ($) {
    var $_slide_wrap = $(‘.slide-‘+<?php echo $id ?>),
    $vid_iframe = $(‘iframe’ , $_slide_wrap ),
    vid_height = $vid_iframe.attr(‘height’),
    vid_width = $vid_iframe.attr(‘width’),
    wind_width = $(window).width(),
    is_active = false,
    $slider_wrapper = $_slide_wrap.closest(‘div[id*=customizr-slider]’),
    $_pause_on_slide = <?php echo (true != $_pause_on_slide) ? ‘false’ : ‘true’; ?>,
    $_mute_volume = <?php echo (true != $_mute_volume) ? ‘false’ : ‘true’; ?>,
    $_unmute_on_hover = <?php echo (true != $_unmute_on_hover) ? ‘false’ : ‘true’; ?>,
    $_provider = ‘<?php echo $_provider; ?>’;

    //$(‘.carousel-caption’ , $_slide_wrap ).remove();
    $(‘.carousel-image’, $_slide_wrap ).css(‘text-align’ , ‘center’);

    //Beautify the video
    $(‘iframe’ , $_slide_wrap )
    .attr(‘width’ , ”).attr(‘height’ , ”)
    .css(‘width’, ‘100%’).css(‘max-width’, ‘100%’).css(‘position’,’relative’)
    _re_center();
    $(window).resize( function() {
    setTimeout(function() { _re_center();}, 200)
    });

    function _re_center() {
    var new_height = (wind_width * vid_width) / vid_height,
    _height = $slider_wrapper.height(),
    push_up = (new_height – _height )/2;
    $(‘iframe’ , $_slide_wrap ).css(‘height’ , new_height ).css(‘bottom’ , push_up );
    }

    //VIMEO PLAYER API
    //https://developer.vimeo.com/player/js-api
    // Listen for messages from the player
    if (window.addEventListener){
    window.addEventListener(‘message’, onMessageReceived, false);
    }
    else {
    window.attachEvent(‘onmessage’, onMessageReceived, false);
    }

    // Helper function for sending a message to the player
    function post(action, value, player) {
    if ( ! player || 0 == player.length )
    return;
    var data = {
    method: action
    };

    if (value)
    data.value = value;

    var message = JSON.stringify(data);
    url = player.attr(‘src’).split(‘?’),
    player[0].contentWindow.postMessage(message, url);
    }

    //Mute volume when player is ready
    function onMessageReceived(e) {
    var data = JSON.parse(e.data),
    $activeSlide = $slider_wrapper.find(‘.item.active’),
    $player = $(‘iframe[src*=vimeo]’, $activeSlide );
    switch (data.event) {
    case ‘ready’:
    ( true == $_mute_volume) && post(‘setVolume’, +0.00001 , $player );
    break;
    }
    }
    //EVENTS :
    //Unmute on hover
    $_mute_volume && $_unmute_on_hover && $slider_wrapper.hover( function() {
    post(‘setVolume’, +0.8 , $(‘iframe[src*=vimeo]’, $(this).find(‘.item.active’) ) );
    }, function() {
    post(‘setVolume’, +0.000001 , $(‘iframe[src*=vimeo]’, $(this).find(‘.item.active’) ) );
    });

    // Call the API on ‘slid’
    $slider_wrapper.on(‘slid’, function() {
    ( true == $_pause_on_slide) && _pause_inactive_slides();
    });

    function _pause_inactive_slides() {
    var $activeSlide = $slider_wrapper.find(‘.item.active’),
    $player = $(‘iframe[src*=vimeo]’, $activeSlide );

    //if current slide has no player. Pause all other players, else play this player
    if ( ! $player.length ) {
    $slider_wrapper.find(‘iframe[src*=vimeo]’).each( function() {
    post( ‘pause’, false , $(this) );
    });
    }
    post( ‘play’, null, $player );
    }

    //YOUTUBE PLAYER API
    //https://developers.google.com/youtube/iframe_api_reference
    //https://developers.google.com/youtube/player_parameters
    //https://stackoverflow.com/questions/8869372/how-do-i-automatically-play-a-youtube-video-iframe-api-muted
    //https://css-tricks.com/play-button-youtube-and-vimeo-api/

    if ( ‘youtube’ == $_provider ) {
    var player;
    //important : the function onYouTubeIframeAPIReady has to be added to the window object
    //when wrapped in another closure
    window.onYouTubeIframeAPIReady = function () {
    player = new YT.Player(‘youtube-video’, {
    events: {
    ‘onReady’: onPlayerReady
    //’onStateChange’: onPlayerStateChange
    }
    });
    }

    //Play and Mute volume when player is ready
    function onPlayerReady() {
    //player.playVideo();
    _bind_youtube_events();

    if ( true == $_mute_volume)
    player.mute();
    else
    player.unMute();
    }

    function _bind_youtube_events() {
    //Unmute on hover
    if ( $_mute_volume && $_unmute_on_hover ){
    $slider_wrapper.hover( function() {
    if ( 0 != $(‘iframe[src*=youtube]’, $(this).find(‘.item.active’) ).length )
    player.unMute();
    }, function() {
    if ( 0 != $(‘iframe[src*=youtube]’, $(this).find(‘.item.active’) ).length )
    player.mute();
    });
    }

    // Call the API on ‘slid’
    $slider_wrapper.on(‘slid’, function() {
    if ( true !== $_pause_on_slide)
    return;
    var $activeSlide = $slider_wrapper.find(‘.item.active’),
    $player = $(‘iframe[src*=youtube]’, $activeSlide );

    //if current slide has no player. Pause all other players, else play this player if it was in pause
    if ( ! $player.length ) {
    $slider_wrapper.find(‘iframe[src*=youtube]’).each( function() {
    player.pauseVideo();
    });
    } else if ( 2 == player.getPlayerState() ){
    player.playVideo();
    }

    });//end on slid
    };//end _bind_youtube_events

    //load the youtube API script asynchronously
    var tag = document.createElement(‘script’);
    tag.src = “https://www.youtube.com/player_api&#8221;;
    var firstScriptTag = document.getElementsByTagName(‘script’)[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    }

    });
    </script>
    <?php
    }

    add_action(‘wp_footer’, ‘fp_titles_linkizr’, 200);
    function fp_titles_linkizr(){
    // limitate the js to the home page
    if ( ! tc__f(‘__is_home’) )
    return;
    $widget_front = ( class_exists(‘TC_fpu’) || class_exists(‘TC_fpc’) ) ? “fpc-widget-front” : “widget-front”;
    ?>
    <script type=”text/javascript”>
    jQuery(document).ready(function () {
    !function ($){
    “use strict”;
    // grab all links
    var $a_hrefs = $(“.<?php echo $widget_front ?> a”),
    $links = ( $a_hrefs.filter(“round-div”).length > 0 ) ? $a_hrefs.filter(“round-div”) : $a_hrefs.filter(“.fp-button”);
    if ( $links.length == 0 )
    return;

    // grab all fp-titles
    var $titles = $(“.<?php echo $widget_front; ?> > :header”);

    $titles.each( function(i) {
    var $edit_span = $(this).find(‘span’);
    $edit_span.detach();
    var _target = $( $links[i] ).attr(‘target’) == ‘blank’ ? ‘_blank’ : $( $links[i]).attr(‘target’),
    target = _target ? ‘target=”‘+ _target + ‘”‘ : ”,
    // let’s wrap the title into the round-div link
    linkizd_title = ‘<a class=”fp-title-link” href=”‘ + $( $links[i] ).attr(‘href’) +'” ‘+ target +
    ‘ title=”‘ + $( $links[i] ).attr(‘title’) + ‘”>’ + $(this).text() + ”;
    $(this).html(linkizd_title);
    $(this).append($edit_span);
    });
    }(window.jQuery);
    });
    </script>
    <?php
    }

    add_filter(‘tc_credits_display’, ‘my_custom_credits’, 20);
    function my_custom_credits(){
    $credits = ”;
    $newline_credits = ”;
    return ‘
    <div class=”span4 credits”>
    <p> · © ‘.esc_attr( date( ‘Y’ ) ).’ ‘.esc_attr(get_bloginfo()).’ · ‘.($newline_credits ? ‘
    · ‘.$newline_credits.’ ·’ : ”).'</p> </div>’;
    }

    Thread Starter cafoundationfund

    (@cafoundationfund)

    Thanks for the example. Would you have the exact code for this the Customizr theme? Adding this code snippet to the functions.php as is will create an error.

    I have the same problem. https://www.cafoundationfund.org. upload function selects hard drive images. After selecting the jpg logo, nothing is uploaded.

Viewing 7 replies - 16 through 22 (of 22 total)