Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #886497
    mathijs84
    Participant

    Hi Rad,

    Thanks for that. The htacces file now looks like this, is this correct??

    <FilesMatch "\.(ttf|otf|eot|woff)$">
        <IfModule mod_headers.c>
            SetEnvIf Origin "http(s)?://(www\.)?(public.slidesharecdn.com|slideshare.net|cdn.teads.tv)$" AccessControlAllowOrigin=$0
            Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
        </IfModule>
    </FilesMatch>
    
    Header add Access-Control-Allow-Origin "*"
    Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
    Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress 

    and about Your suggestion

    How about just turn the code into shortcodes, then manually place the shortcode to the content like you wish to achieve?

    How do i do this please?

    #887182
    Rad
    Moderator

    Hi there,

    Yes, but please remove this

    Header add Access-Control-Allow-Origin "*"
    Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
    Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

    We only need to allow access from domains that your embed is accesing.

    As for the shortcode, instead of adding a code like this

    function my_custom_head_output() { 
    if(is_page(72) || is_page(76)): 
    ?>
    
    <script type="text/javascript" id="ean­native­embed­tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script>  
    
    <?php 
    endif;
    
    } 
    
    add_action( 'x_after_site_begin', 'my_custom_head_output');

    You can add it like this,

    function my_embed_shortcode_1( $atts, $content ) { 
    ?>
    <script type="text/javascript" id="ean­native­embed­tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script>  
    <?php 
    } 
    
    add_shortcode( 'my_embed_shortcode_1', 'my_embed_shortcode_1');

    Then you can add shortcode to any part of your text content like this, [my_embed_shortcode_1][/my_embed_shortcode_1]

    Hope this helps.

    #887830
    mathijs84
    Participant

    Rad,

    Thanks i changed the HTAcces. Is that ok like this?

    Further more:

    About the Functions.php. I have 3 codes inserted. Not sure how to change them all.

    I did the first one, is that correct? And what should the whole functions.php look like??

    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    // Additional Functions
    // =============================================================================
    
    function my_embed_shortcode_1( $atts, $content ) { 
    if(is_page(76)): 
    ?>
    
    <script type="text/javascript" id="ean_native_embed_tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script>  
    
    <?php 
    endif;
    
    } 
    
    add_shortcode( 'my_embed_shortcode_1', 'my_embed_shortcode_1');
    
    add_action( 'wp_footer', 'footer_embed_code', 999 );
    
    function footer_embed_code () { if(is_page(72)): ?>
    
    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 49968
           ,lang        : "en"
           ,slot        : '.x-container .x-column .x-img'
           ,format      : "inread"
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,css         : "margin: 0px 0px 19.695px;"
           ,BTF         : false
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
    <?php elseif(is_page(74)) : ?>
    
    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 50069
           ,lang        : "en"
           ,slot        : '#top .masthead .x-breadcrumb-wrap'
           ,format      : "inboard"
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,css         : "padding: 10.5px 0px;"
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
    <?php endif; }

    And last question, do i need to add something between the shortcode?? [my_embed_shortcode_1][/my_embed_shortcode_1]

    #888055
    Paul R
    Moderator

    Hi,

    Yes, you did the first one correctly.

    With regards to your shortcode, no need to add something in between.

    You only need to add this in your page

    
    [my_embed_shortcode_1]
    

    Hope that helps

    #893335
    mathijs84
    Participant

    So not sure what these next two need to be. Can you guys give me the code please

    I already added the shortcodes, so please check if it works

    1:

    add_action( 'wp_footer', 'footer_embed_code', 999 );
    
    function footer_embed_code () { if(is_page(72)): ?>
    
    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 49968
           ,lang        : "en"
           ,slot        : '.x-container .x-column .x-img'
           ,format      : "inread"
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,css         : "margin: 0px 0px 19.695px;"
           ,BTF         : false
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    

    2:

    
    <?php elseif(is_page(74)) : ?>
    
    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 50069
           ,lang        : "en"
           ,slot        : '#top .masthead .x-breadcrumb-wrap'
           ,format      : "inboard"
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,css         : "padding: 10.5px 0px;"
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
    <?php endif; }
    #893338
    mathijs84
    Participant
    This reply has been marked as private.
    #894379
    Rad
    Moderator

    Hi there,

    First, backup your current functions.php

    then replace its content with this,

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    // Additional Functions
    // =============================================================================
    
    class Ads_Embed {
    
      public function __construct () {
    
        add_shortcode( 'ads_embed_1', array( $this, 'ads_1') );
        add_shortcode( 'ads_embed_2', array( $this, 'ads_2') );
        add_shortcode( 'ads_embed_3', array( $this, 'ads_3') );
    
      }
    
      public function ads_1 ( $atts, $content ) { 
        
        ?><script type="text/javascript" id="ean_native_embed_tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script><?php
    
      }
    
      public function ads_2 ( $atts, $content ) { 
        ?>
                <script type="text/javascript">
            window._ttf = window._ttf || [];
            _ttf.push({
                   pid          : 49968
                   ,lang        : "en"
                   ,slot        : '.x-container .x-column .x-img'
                   ,format      : "inread"
                   ,minSlot     : 1
                   ,components  : { skip: {delay : 0}}
                   ,mutable     : true
                   ,css         : "margin: 0px 0px 19.695px;"
                   ,BTF         : false
            });
    
            (function (d) {
                    var js, s = d.getElementsByTagName('script')[0];
                    js = d.createElement('script');
                    js.async = true;
                    js.src = '//cdn.teads.tv/media/format.js';
                    s.parentNode.insertBefore(js, s);
            })(window.document);
            </script>
    
        <?php
      }
    
      public function ads_3 ( $atts, $content ) { 
        ?>
                  <script type="text/javascript">
              window._ttf = window._ttf || [];
              _ttf.push({
                     pid          : 50069
                     ,lang        : "en"
                     ,slot        : '#top .masthead .x-breadcrumb-wrap'
                     ,format      : "inboard"
                     ,components  : { skip: {delay : 0}}
                     ,mutable     : true
                     ,css         : "padding: 10.5px 0px;"
              });
    
              (function (d) {
                      var js, s = d.getElementsByTagName('script')[0];
                      js = d.createElement('script');
                      js.async = true;
                      js.src = '//cdn.teads.tv/media/format.js';
                      s.parentNode.insertBefore(js, s);
              })(window.document);
              </script>
              
        <?php
      }
    
    }
    
    new Ads_Embed();

    I cleaned it up a little using class. Now, you can simply add your ads shortcode to any of the content. For example,

    1. add [ads_embed_1] to page content that has page ID of 76
    2. add [ads_embed_2] to page content that has page ID of 72
    3. add [ads_embed_3] to page content that has page ID of 74

    Since you can manually add these shortcodes to any page, then you don’t need to check the page ID. Just place it directly to specific page’s content.

    Thanks.

    #913915
    mathijs84
    Participant

    Hi Rad,

    Thank a lot already. We are almost there but it seems we don;t have complete control over the position this way. It was suggested that we put the code inside a div to have more control.

    Is this possible?

    #914370
    Rad
    Moderator

    Hi there,

    It’s part of the recommendation I gave as above 🙂

    For example, let’s say you implemented the code above. Hence, [ads_embed_1] is a valid shortcode that you can add to any part of your content.

    This is a content, or another content.
    
    [ads_embed_1]
    
    This is a content, or another content.

    It will then become like this when rendered,

    This is a content, or another content.
    
    <script type="text/javascript" id="ean_native_embed_tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script>
    
    This is a content, or another content.

    With that, you can simply decide to where you wish to add [ads_embed_1]. Shortcode represent a content, and this time, it represent each of your embed code.

    Hope this helps.

    #1053963
    mathijs84
    Participant

    Hi there,

    Rad helped me great with implementing these codes and we have the scripts running on the site (streamads.work-planning.com)

    They now want to add two more scripts, for mobile. The regular ones don’t work on mobile.

    I tried to add the scripts by adding add [ads_embed_4] and add [ads_embed_5] but it broke the site

    Here is the original functions.php with the two scripts. COPuld you guys please let me know how to adjust please.

    Functions PHP

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    // Rewrite wp-include to other domain
    // =============================================================================
    
    /**
     * Rewrite the URL. WP uses the site_url() for content in /wp-includes/. This
     * function will rewrite all scripts which use the site_url() instead of the
     * domain of content_url().
     *
     * @author Michel Dekker <[email protected]>
     * @since 2016-06-01
     */
    function wp20160601_rewrite_include_url ($script, $handle = '') {
        $url = parse_url($script);
    
        if ($url['scheme'] . '://' . $url['host'] == site_url()) {
            $contentUrl = parse_url(content_url());
            
            return $contentUrl['scheme'] . '://' . $contentUrl['host'] . $url['path'] . ($url['query'] !== null ? '?' . $url['query'] : '') . ($url['fragment'] !== null ? '#' . $url['fragment'] : '');
        }
    
        return $script;
    }
    
    add_filter( 'script_loader_src', 'wp20160601_rewrite_include_url');
    add_filter( 'style_loader_src', 'wp20160601_rewrite_include_url');
    
    // Additional Functions
    // =============================================================================
    
    class Ads_Embed {
    
      public function __construct () {
    
        add_shortcode( 'ads_embed_1', array( $this, 'ads_1') );
        add_shortcode( 'ads_embed_2', array( $this, 'ads_2') );
        add_shortcode( 'ads_embed_3', array( $this, 'ads_3') );
       
    
      }
    
      public function ads_1 ( $atts, $content ) { 
        
        ?><script type="text/javascript" id="ean_native_embed_tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script><?php
    
      }
    
      public function ads_2 ( $atts, $content ) { 
        ?>
                <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 50069
           ,lang        : "en"
           ,slot        : '#x-section-2 .x-container .x-column'
           ,format      : "inread"
           ,mobile      : false
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
        <?php
      }
    
      public function ads_3 ( $atts, $content ) { 
        ?>
                  <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 49968
           ,lang        : "nl"
           ,slot        : '.x-column .x-text > p'
           ,format      : "inread"
           ,mobile      : false
           ,minSlot     : 1
           ,mutable     : true
           ,css         : "margin: 0px 0px 19.695px;"
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>          
        <?php
      }
    
    }
    
    new Ads_Embed();

    Script mobile Inboard

    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 52582
           ,lang        : "nl"
           ,slot        : '.x-column .x-text > p'
           ,format      : "inread"
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,BTF         : false
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>


    Script mobile Inread

    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 52581
           ,lang        : "nl"
           ,slot        : '.x-column .x-text > p'
           ,format      : "inread"
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,css         : "margin: 0px 0px 19.695px;"
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
    #1055018
    Rad
    Moderator

    Hi there,

    There are no ads_embed_4 and ads_embed_5, hence you can’t add [ads_embed_4] and [ads_embed_5].

    Or perhaps, you’re adding the new set of ads to existing code? If yes, then should be similar to this,

    <?php
    
    // =============================================================================
    // FUNCTIONS.PHP
    // -----------------------------------------------------------------------------
    // Overwrite or add your own custom functions to X in this file.
    // =============================================================================
    
    // =============================================================================
    // TABLE OF CONTENTS
    // -----------------------------------------------------------------------------
    //   01. Enqueue Parent Stylesheet
    //   02. Additional Functions
    // =============================================================================
    
    // Enqueue Parent Stylesheet
    // =============================================================================
    
    add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );
    
    // Rewrite wp-include to other domain
    // =============================================================================
    
    /**
     * Rewrite the URL. WP uses the site_url() for content in /wp-includes/. This
     * function will rewrite all scripts which use the site_url() instead of the
     * domain of content_url().
     *
     * @author Michel Dekker <[email protected]>
     * @since 2016-06-01
     */
    function wp20160601_rewrite_include_url ($script, $handle = '') {
        $url = parse_url($script);
    
        if ($url['scheme'] . '://' . $url['host'] == site_url()) {
            $contentUrl = parse_url(content_url());
            
            return $contentUrl['scheme'] . '://' . $contentUrl['host'] . $url['path'] . ($url['query'] !== null ? '?' . $url['query'] : '') . ($url['fragment'] !== null ? '#' . $url['fragment'] : '');
        }
    
        return $script;
    }
    
    add_filter( 'script_loader_src', 'wp20160601_rewrite_include_url');
    add_filter( 'style_loader_src', 'wp20160601_rewrite_include_url');
    
    // Additional Functions
    // =============================================================================
    
    class Ads_Embed {
    
      public function __construct () {
    
        add_shortcode( 'ads_embed_1', array( $this, 'ads_1') );
        add_shortcode( 'ads_embed_2', array( $this, 'ads_2') );
        add_shortcode( 'ads_embed_3', array( $this, 'ads_3') );
        add_shortcode( 'ads_embed_4', array( $this, 'ads_4') );
        add_shortcode( 'ads_embed_5', array( $this, 'ads_5') );
       
    
      }
    
      public function ads_1 ( $atts, $content ) { 
        
        ob_start();
        
        ?><script type="text/javascript" id="ean_native_embed_tag" src="http://cdn.elasticad.net/native/serve/js/nativeEmbed.gz.js"></script><?php
        
        return ob_get_clean();
    
      }
    
      public function ads_2 ( $atts, $content ) { 
        
        ob_start();
    
        ?>
                <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 50069
           ,lang        : "en"
           ,slot        : '#x-section-2 .x-container .x-column'
           ,format      : "inread"
           ,mobile      : false
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
        <?php
    
        return ob_get_clean();
    
      }
    
      public function ads_3 ( $atts, $content ) { 
        
         ob_start();
    
        ?>
                  <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 49968
           ,lang        : "nl"
           ,slot        : '.x-column .x-text > p'
           ,format      : "inread"
           ,mobile      : false
           ,minSlot     : 1
           ,mutable     : true
           ,css         : "margin: 0px 0px 19.695px;"
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>          
        <?php
    
        return ob_get_clean();
    
      }
    
        public function ads_4 ( $atts, $content ) { 
        
         ob_start();
    
        ?>
    
        <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 52582
           ,lang        : "nl"
           ,slot        : '.x-column .x-text > p'
           ,format      : "inread"
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,BTF         : false
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
    
        <?php
    
        return ob_get_clean();
        
      }
    
        public function ads_5 ( $atts, $content ) { 
        
         ob_start();
    
        ?>
                  
    <script type="text/javascript">
    window._ttf = window._ttf || [];
    _ttf.push({
           pid          : 52581
           ,lang        : "nl"
           ,slot        : '.x-column .x-text > p'
           ,format      : "inread"
           ,minSlot     : 1
           ,components  : { skip: {delay : 0}}
           ,mutable     : true
           ,css         : "margin: 0px 0px 19.695px;"
    });
    
    (function (d) {
            var js, s = d.getElementsByTagName('script')[0];
            js = d.createElement('script');
            js.async = true;
            js.src = '//cdn.teads.tv/media/format.js';
            s.parentNode.insertBefore(js, s);
    })(window.document);
    </script>
                  
        <?php
    
        return ob_get_clean();
        
      }
    
    }
    
    new Ads_Embed();

    Hope this helps.

  • <script> jQuery(function($){ $("#no-reply-856864 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>