D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
sadaunjx
/
public_html
/
wp-content
/
themes
/
newsplus1
/
inc
/
Filename :
functions-integrations.php
back
Copy
<?php /* Copyrights (C) Arb4Host Network */ ?> <?php function is_amp() { if ( function_exists('is_amp_endpoint') && is_amp_endpoint() ) { return true; } else { return false; } } function a4h_amp_component_scripts($data) { $data['amp_component_scripts']['amp-ad'] = 'https://cdn.ampproject.org/v0/amp-ad-0.1.js'; if ( a4h_ads_adsense_is_auto_ads_active() ) { $data['amp_component_scripts']['amp-auto-ads'] = 'https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js'; } $data['amp_component_scripts']['amp-analytics'] = 'https://cdn.ampproject.org/v0/amp-analytics-0.1.js'; $data['amp_component_scripts']['amp-iframe'] = 'https://cdn.ampproject.org/v0/amp-iframe-0.1.js'; return $data; } add_filter('amp_post_template_data', 'a4h_amp_component_scripts'); function a4h_filter_ads_adsense_dyanmic_code($code, $size, $colors) { if ( is_amp() ) { $width = $size ? $size[0] : 'auto'; $height = $size ? $size[1] : 250; $code = '<amp-ad type="adsense" width="'.$width.'" height="'.$height.'" data-ad-client="%2$s" data-ad-channel="%3$s" data-ad-slot="%4$s" '.$colors.'></amp-ad>'; } return $code; } add_filter('a4h_filter_ads_adsense_dyanmic_code', 'a4h_filter_ads_adsense_dyanmic_code', 10, 3); function a4h_ads_adsense_auto_ads_amp() { if ( !a4h_ads_adsense_is_auto_ads_active() ) { return; } $code = '<amp-auto-ads type="adsense" data-ad-client="%1$s" data-ad-channel="%2$s" data-ad-slot="%3$s"></amp-auto-ads>'; $code = apply_filters('a4h_filter_ads_adsense_auto_ads_code_amp', $code); $adsense_vars = apply_filters('a4h_ads_options_adsense', a4h_ads('adsense')); if ( a4h_ads('rs_ads') ) { $adsense_vars = a4h_ads_rs_math(); } $code = sprintf($code, $adsense_vars['client'], $adsense_vars['channel'], $adsense_vars['slot']); echo $code."\n";; } add_action('a4h_hook_amp_body_start', 'a4h_ads_adsense_auto_ads_amp', 9000); function a4h_amp_analytics_tracking() { if ( !a4h_options('ganalytics') ) { return; } ?> <amp-analytics type="googleanalytics"> <script type="application/json"> { "vars": { "account": "<?php echo a4h_options('ganalytics'); ?>" }, <?php do_action('a4h_hook_amp_ganalytics_js_end'); ?> "triggers": { "trackPageview": { "on": "visible", "request": "pageview" } } } </script> </amp-analytics> <?php } add_action('amp_post_template_footer', 'a4h_amp_analytics_tracking'); function a4h_amp_analytics_tracking_for_author() { global $post; if ( !a4h_ads('author_ganalytics') ) { return; } if ( !is_singular() || !get_the_author_meta('ganalytics', $post->post_author) ) { return; } ?> <amp-analytics type="googleanalytics"> <script type="application/json"> { "vars": { "account": "<?php echo esc_attr(get_the_author_meta('ganalytics', $post->post_author)); ?>" }, "triggers": { "trackPageview": { "on": "visible", "request": "pageview" } } } </script> </amp-analytics> <?php } add_action('amp_post_template_footer', 'a4h_amp_analytics_tracking_for_author'); function a4h_amp_post_template_css() { ?> :root { --widget-padding: 20px; --widget-spacing: 6px; --posts-gap: 20px; --post-width: 225px; --sidebar-side-width: 300px; --mark-color: #FFF5DF; } statcounter { width: 1px; height: 1px; } .ad { margin: 20px 0px; text-align: center; } amp-iframe, amp-youtube, amp-instagram, amp-vine { background: #FFFFFF; } .amp-wp-header .amp-wp-site-icon { right: auto; left: 18px; } .amp-wp-article-header .amp-wp-meta:first-of-type { text-align: right; } .amp-wp-article-header .amp-wp-meta:last-of-type { text-align: left; } .amp-wp-article-content ul, .amp-wp-article-content ol { margin-left: 0px; margin-right: 15px; } .amp-wp-article table, .amp-wp-article th, .amp-wp-article td { border: 1px solid #EEEEEE; } .amp-wp-article table { border-collapse: collapse; width: 100%; max-width: 100%; margin-bottom: 1rem; } .amp-wp-article table th, .amp-wp-article table td { padding: 0.75rem; vertical-align: top; border-top: 1px solid #e9ecef; } .meta-item.meta-updated .post-date-published { display: none; } .meta-item.meta-published .post-date-updated { display: none; } .main-post-meta .meta-item { position: relative; display: inline-block; margin: 0px 2px; white-space: nowrap; } .main-post-meta .meta-item::after { content: "/"; margin-right: 5px; font-size: 0.7em; opacity: 0.5; } .main-post-meta .meta-item:last-child:after { display: none; } .main-post-meta .main-color-bg-link a { display: inline-block; padding: 4px 10px; color: #FFFFFF; color: #FFFFFF; } .main-post-meta .main-color-bg-link a:hover { background: #000000; } .main-post-meta .meta-item-prefix::after { content: ":"; } .main-post-meta .meta-item.meta-sticky .meta-item-prefix::after { content: ""; } .amp-wp-article-featured-image { margin-top: 1em; } .amp-wp-article-content table { text-align: initial; } .amp-wp-article-content h1, .amp-wp-article-content h2, .amp-wp-article-content h3, .amp-wp-article-content h4, .amp-wp-article-content h5, .amp-wp-article-content h6 { margin-top: 1em; margin-bottom: 1em; } .amp-wp-article-content h1:not(.plain), .amp-wp-article-content h2:not(.plain), .amp-wp-article-content h3:not(.plain), .amp-wp-article-content h4:not(.plain), .amp-wp-article-content h5:not(.plain), .amp-wp-article-content h6:not(.plain) { display: inline-block; padding: 5px 15px; background-color: var(--mark-color); border-top: 2px solid rgba(0,0,0,0.1); } .amp-wp-article-content blockquote { position: relative; padding: 10px 60px; background-color: var(--mark-color); border-right: 2px solid rgba(0,0,0,0.1); } .amp-wp-article-content blockquote p:last-of-type { margin-bottom: 0px; } <?php } add_action('amp_post_template_css', 'a4h_amp_post_template_css'); function a4h_amp_custom_templates($file, $type, $post) { if ( $type == 'single' ) { return get_theme_file_path('amp.php'); } return $file; } add_filter('amp_post_template_file', 'a4h_amp_custom_templates', 10, 3); function a4h_yoast_breadcrumb_insert() { if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<div class="'.apply_filters('a4h_filter_breadcrumbs_css_class', 'py-2 sm-font medium-color breadcrumbs').'">', '</div>'); } } add_action('a4h_hook_singular_title_before', 'a4h_yoast_breadcrumb_insert'); add_action('a4h_hook_archive_title_before', 'a4h_yoast_breadcrumb_insert'); function a4h_yoast_breadcrumb_last_item_remove($links) { if ( sizeof($links) > 1 ) { array_pop($links); } return $links; } add_filter('wpseo_breadcrumb_links', 'a4h_yoast_breadcrumb_last_item_remove'); function a4h_yoast_breadcrumb_last_item_link($output, $crumb) { $output = '<a property="v:title" rel="v:url" href="'.$crumb['url'].'">'; $output.= $crumb['text']; $output.= '</a>'; return $output; } add_filter('wpseo_breadcrumb_single_link', 'a4h_yoast_breadcrumb_last_item_link' , 10, 2);