Tagged: x
-
AuthorPosts
-
April 17, 2016 at 1:59 am #886497
mathijs84ParticipantHi 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 WordPressand 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?
April 17, 2016 at 5:16 pm #887182
RadModeratorHi 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="eannativeembedtag" 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="eannativeembedtag" 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.
April 18, 2016 at 4:06 am #887830
mathijs84ParticipantRad,
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]
April 18, 2016 at 6:32 am #888055
Paul RModeratorHi,
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
April 21, 2016 at 4:27 am #893335
mathijs84ParticipantSo 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; }April 21, 2016 at 4:29 am #893338
mathijs84ParticipantThis reply has been marked as private.April 21, 2016 at 4:54 pm #894379
RadModeratorHi 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 74Since 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.
May 5, 2016 at 2:41 am #913915
mathijs84ParticipantHi 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?
May 5, 2016 at 10:05 am #914370
RadModeratorHi 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.
June 22, 2016 at 3:48 am #1053963
mathijs84ParticipantHi 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>June 22, 2016 at 3:12 pm #1055018
RadModeratorHi 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.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-856864 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
