Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/functions/helper/ads.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");

/*
 * Desciption	: check post meta if ads disabled
 * Author 		: Mouad Achemli
 * Source		: http://www.mwordpress.net
 *
*/
function check_post_ads($type, $postid) {
	switch ($type) {
		case 'header':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_ads_header' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'newsbar':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_ads_newsbar' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'inside':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_post_ads' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'sidebar':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_ads_sidebar' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'footer':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_ads_footer' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'facebook':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_ads_facebook' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'related':
			$option = '1';
			$check_key = get_post_meta($postid, 'display_readalso' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
		case 'outside':
			$option = '1';
			$check_key = get_post_meta($postid, 'current_ads_outside' , true);
			if ($check_key == 'on') {
				$option = '1';
			} elseif ($check_key == 'off') {
				$option = '0';
			}
			return $option;
		break;
	}
}

/*
 * Adsense Responsive
 *
*/
function mwp_display_adsense_code($client, $slot, $class) {

	if(mwp_option('adsense-on-scroll') == 0) {
		echo '<ins class="adsbygoogle '.$class.'"
		 style="display:inline-block;"
		 data-ad-client="'.$client.'"
		 data-ad-slot="'.$slot.'"></ins>
		<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
		<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
	} else {
		echo '<ins class="adsbygoogle '.$class.'"
		 style="display:inline-block;"
		 data-ad-client="'.$ad_client.'"
		 data-ad-slot="'.$slot.'"></ins>
		<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
	}
}
/*
 * Adsense Fixed
 *
*/
function mwp_display_adsense_fixed($client, $slot, $width, $height) {

	if(mwp_option('adsense-on-scroll') == 0) {
		echo '<ins class="adsbygoogle"
		 style="display:inline-block;width:'.$width.'px;height:'.$height.'px;"
		 data-ad-client="'.$client.'"
		 data-ad-slot="'.$slot.'"></ins>
		<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
		<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
	} else {
		echo '<ins class="adsbygoogle"
		 style="display:inline-block;width:'.$width.';height:'.$height.';"
		 data-ad-client="'.$ad_client.'"
		 data-ad-slot="'.$slot.'"></ins>
		<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>';
	}
}
/*
 * Desciption	: Display Ads based on MWP Panel
 * Author 		: Mouad Achemli
 * Source		: http://www.mwordpress.net
 *
*/
function mwp_ads_unit($type, $prefix, $class, $width, $height) {
	
	$ads_show 	= mwp_option($prefix . '-advert-display');
	$ads_type 	= mwp_option($prefix . '-advert-type');
	$ads_open 	= mwp_option($prefix . '-advert-open');
	$ads_follow = mwp_option($prefix . '-advert-follow');
	$ads_link 	= mwp_option($prefix . '-advert-link');
	$ads_image 	= mwp_option($prefix . '-advert-image');
	$ads_text 	= mwp_option($prefix . '-advert-text');
	$ads_code 	= mwp_option($prefix . '-advert-code');
	
	if (!empty($ads_image) && !empty($ads_text) && !empty($ads_link)) {
		$output_ads_image 	= $ads_image;
		$output_ads_text 	= $ads_text;
		$output_ads_link 	= $ads_link;
	} else {
		$output_ads_text 	= 'Advert test';
		$output_ads_link 	= 'https://www.mwordpress.net/';
		
		switch ($prefix) {
			case 'mads1':
				$output_ads_image 	= get_template_directory_uri().'/images/ads/728x90.jpg';
			break;
			case 'mads2':
				$output_ads_image 	= get_template_directory_uri().'/images/ads/336x280.jpg';
			break;
			case 'mads3':
				$output_ads_image 	= get_template_directory_uri().'/images/ads/336x280.jpg';
			break;
			case 'mads9':
				$output_ads_image 	= get_template_directory_uri().'/images/ads/728x90.jpg';
			break;
			case 'minside':
				$output_ads_image 	= get_template_directory_uri().'/images/ads/336x280.jpg';
			break;
		}

	}
	switch ($type) {
		
		case 'auto' :
			
			// Code ADS
			if ($ads_code <> "") { 
				echo stripslashes(stripslashes($ads_code)); 
			}
			// Banner ADS
			else {
				if ($ads_open == '1') {
					$target = "target='_blank'";
				} else {
					$target = '';
				}
				if ($ads_follow == '1') {
					$nofollow = "rel='nofollow'";
				} else {
					$nofollow = '';
				}
				echo '<a href="' . $output_ads_link . '" '.$target.' '.$nofollow.'>
					<img src="'.$output_ads_image.'" alt="' . $output_ads_text . '" width="'.$width.'" height="'.$height.'" />
				</a>';	
			}
			
		break;
		
	}
}

/*
 * Post content - Top
 *
*/
function mwp_single_ads_top() {
	
	$ad_format = mwp_option('mads2-advert-rs-type');
	// Enable ADS
	if (mwp_option('mads2-advert-display') == 1) : 
		// Hide ADS in Specific Posts (Fom Metabox)
		// Hide ADS in Specific Categories (From Panel)
		$queried_object = get_queried_object();
		$screen 		= mwp_option('sab-advert-device');
		$exclude 		= mwp_option('sab-advert-exclude');
		if ( !empty($exclude) && is_category($exclude) && !is_home() or 
		!empty($exclude) && in_category($exclude) && !is_home() or 
		is_singular() && check_post_ads('inside', $queried_object->ID) == 0) {
			// No ADS
		} else {
			// Adsense Revenu Share
			if (is_singular() && mwp_option('mads2-advert-revenu-share') == 1) {
				?>
				<div class="sad skip_css <?php echo $screen; ?>">
					<?php echo mwp_ads_revenu_share(false , $ad_format); ?>
				</div>
				<?php
			} 
			// Normal ADS
			else {
				?>
				<div class="sad skip_css <?php echo $screen; ?>">
					<?php mwp_ads_unit('auto', 'mads2', '', 336, 280); ?>
				</div>
				<?php
			}
		}
	endif;
}
/*
 * Post content - Bottom
 *
*/
function mwp_single_ads_bottom() {
	$ad_format = mwp_option('mads3-advert-rs-type');
	// Enable ADS
	if (mwp_option('mads3-advert-display') == 1) :
		// Hide ADS in Specific Posts (Fom Metabox)
		// Hide ADS in Specific Categories (From Panel)
		$queried_object = get_queried_object();
		$screen 		= mwp_option('sab-advert-device-2');
		$exclude 		= mwp_option('sab-advert-exclude-2');
		if ( !empty($exclude) && is_category($exclude) && !is_home() or 
		!empty($exclude) && in_category($exclude) && !is_home() or 
		is_singular() && check_post_ads('inside', $queried_object->ID) == 0) {
			// No ADS
		} else {
			// Adsense Revenu Share
			if (is_singular() && mwp_option('mads3-advert-revenu-share') == 1) {
				?>
				<div class="sad skip_css <?php echo $screen; ?>">
					<?php echo mwp_ads_revenu_share(false , $ad_format); ?>
				</div>
				<?php
			} 
			// Normal ADS
			else {
				?>
				<div class="sad skip_css <?php echo $screen; ?>">
					<?php mwp_ads_unit('auto', 'mads3', '', 336, 280); ?>
				</div>
				<?php
			}
		}
	endif;
}
/*
 * Post content - Inside
 *
*/
function mwp_single_ads_inside() {
	$queried_object = get_queried_object();
	$ad_format 		= esc_attr(mwp_option('minside-advert-rs-type'));
	// Enable ADS
	if (mwp_option('minside-advert-display') == 1) {
		// Hide ADS in Specific Posts (Fom Metabox)
		// Hide ADS in Specific Categories (From Panel)
		$screen 		= esc_attr(mwp_option('minside-advert-device'));
		$exclude 		= esc_attr(mwp_option('minside-advert-exclude'));
		if ( !empty($exclude) && is_category($exclude) && !is_home() or 
		!empty($exclude) && in_category($exclude) && !is_home() or 
		is_singular() && check_post_ads('inside', $queried_object->ID) == 0) {
			// No ADS
		} else {
			// Adsense Revenu Share
			if (is_singular() && mwp_option('minside-advert-revenu-share') == 1) {
				?>
				<div class="sad skip_css <?php echo esc_attr($screen); ?>">
					<?php echo mwp_ads_revenu_share(false , $ad_format); ?>
				</div>
				<?php
			}
			// Normal ADS
			else {
				?>
				<div class="sad skip_css <?php echo esc_attr($screen); ?>">
					<?php mwp_ads_unit('auto', 'minside', '', 336, 280); ?>
				</div>
				<?php
			}
		}
	}
}
/*
 * Header Ads
 * 
*/
function mwp_header_ads() {
	$queried_object = get_queried_object();
	// Enable ADS
	if (mwp_option('mads1-advert-display') == 1) {
		// Hide ADS in Specific Posts (Fom Metabox)
		// Hide ADS in Specific Categories (From Panel)
		$screen 	= mwp_option('mads1-advert-device');
		$exclude 	= mwp_option('mads1-advert-exclude');
		if ( !empty($exclude) && is_category($exclude) && !is_home() or 
		!empty($exclude) && in_category($exclude) && !is_home() or 
		is_singular() && check_post_ads('footer', $queried_object->ID) == 0) {
			// No ADS
		} else {
			// Adsense Revenu Share
			if (is_singular() && mwp_option('mads1-advert-revenu-share') == 1) {
				?>
				<div class="sad sad-head <?php echo esc_attr($screen); ?>">
					<?php echo mwp_ads_revenu_share(); ?>
				</div>
				<?php
			} 
			// Normal ADS
			else {
				?>
				<div class="sad sad-head <?php echo esc_attr($screen); ?>">
					<?php mwp_ads_unit('auto', 'mads1', '', 728, 90); ?>
				</div>
				<?php
			}
		}
	}
}
/*
 * Footer Ads
 * 
*/
function mwp_footer_ads() {
	$queried_object = get_queried_object();
	// Enable ADS
	if (mwp_option('mads9-advert-display') == 1) {
		// Hide ADS in Specific Posts (Fom Metabox)
		// Hide ADS in Specific Categories (From Panel)
		$screen 	= mwp_option('mads9-advert-device');
		$exclude 	= mwp_option('mads9-advert-exclude');
		if ( !empty($exclude) && is_category($exclude) && !is_home() or 
		!empty($exclude) && in_category($exclude) && !is_home() or 
		is_singular() && check_post_ads('footer', $queried_object->ID) == 0) {
			// No ADS
		} else {
			// Adsense Revenu Share
			if (is_singular() && mwp_option('mads9-advert-revenu-share') == 1) {
				?>
				<div class="sad <?php echo esc_attr($screen); ?>">
					<?php echo mwp_ads_revenu_share(); ?>
				</div>
				<?php
			} 
			// Normal ADS
			else {
				?>
				<div class="sad <?php echo esc_attr($screen); ?>">
					<?php mwp_ads_unit('auto', 'mads9', '', 728, 90); ?>
				</div>
				<?php
			}
		}
	}
}
/*
 * Desciption	: New In-feed Ad (Adsense)
 *
*/
function mwp_home_infeed_ad($c, $post_style) {
	
	$ads_code_1 	= mwp_option('mobile-home-ads-infeed-1');
	$get_ads_post_1 = mwp_option('mobile-home-ads-infeed-1-post');
	$ads_code_2 	= mwp_option('mobile-home-ads-infeed-2');
	$get_ads_post_2 = mwp_option('mobile-home-ads-infeed-2-post');
	$get_ads_class 	= mwp_option('mobile-posts-style');
	
	if (!empty($get_ads_post_1)) {
		$ads_post_1 = $get_ads_post_1;
	} else {
		$ads_post_1 = 3;
	}
	
	if (!empty($get_ads_post_2)) {
		$ads_post_2 = $get_ads_post_2;
	} else {
		$ads_post_2 = 6;
	}
	
	if ($get_ads_class == 3) {
		$ad_class = 'home-ad-3';
	} else {
		$ad_class = 'home-ad';
	}
	
	if ($c == $ads_post_1 && $ads_code_1 <> "") {
		echo '<li class="'.$post_style.' post '.$ad_class.'">';
			echo stripslashes(stripslashes($ads_code_1));
		echo '</li>';
	}
		
	if ($c == $ads_post_2 && $ads_code_2 <> "") {
		echo '<li class="'.$post_style.' post '.$ad_class.'">';
			echo stripslashes(stripslashes($ads_code_2));
		echo '</li>';
	}
}
/*
 * POSTQUARE ads
 *
*/
function mwp_single_postquare() {
	if (is_singular() && mwp_option('postquare-revenu-share') == 1) {
		echo '<div class="postquare-css">';
			echo mwp_ads_rs_postquare();
		echo '</div><div class="clearfix"></div>';
	} else {
		if(mwp_option('postquare-load-onscroll') == 0 && mwp_option('postquare-code') <> "" ) {
			echo '<div class="postquare-css">';
				echo stripslashes(stripslashes(mwp_option('postquare-code')));
			echo '</div><div class="clearfix"></div>'; 
		} elseif (mwp_option('postquare-load-onscroll') == 1) {
			echo '';
			$postquare_wid 		= sanitize_text_field(mwp_option('postquare_wid'));
			$postquare_pubid 	= sanitize_text_field(mwp_option('postquare_pubid'));
			$postquare_webid 	= sanitize_text_field(mwp_option('postquare_webid'));
			if (!empty($postquare_wid) && !empty($postquare_pubid) && !empty($postquare_webid)) {
				echo '<div class="postquare-css">';
				echo '<div id="POSTQUARE_WIDGET_'.$postquare_wid.'"></div>';
				?>
				<script>
				var pfired = false;
				window.addEventListener("scroll", function(){
				if ((document.documentElement.scrollTop != 0 && pfired === false) || (document.body.scrollTop != 0 && pfired === false)) {
					(function(P,o,s,t,Q,r,e){P['PostquareObject']=Q;P[Q]=P[Q]||function(){ (P[Q].q=P[Q].q||[]).push(arguments)},P[Q].l=1*new Date();r=o.createElement(s), e=o.getElementsByTagName(s)[0];r.async=1;r.src=t;e.parentNode.insertBefore(r,e) })(window,document,'script','//widget.engageya.com/_pos_loader.js','__posWidget');
					__posWidget('createWidget',{wwei:'POSTQUARE_WIDGET_<?php echo $postquare_wid; ?>',pubid:<?php echo $postquare_pubid; ?>,webid:<?php echo $postquare_webid; ?>,wid:<?php echo $postquare_wid; ?>,on:'postquare'});
					pfired = true;
				  }
				}, true)
				</script>
				<?php
				echo '</div><div class="clearfix"></div>';
			}
		} 
	}
}
/*
 * Post content - Inside (Helper)
 *
*/
if (mwp_option('minside-advert-display') == 1) {
	add_filter( 'the_content', 'mwp_insert_post_ads', 10, 1  );
}
function mwp_insert_post_ads( $content ) {
    
	global $post;
	
	preg_match_all('<!-- /wp:(.*?) -->', $content, $blocks);
	
	$videos_ids 		= mwp_option('category-videos');
	$gallery_ids 		= mwp_option('category-gallery');
	$caricature_ids 	= mwp_option('category-caricature');
	$ebookmagazine_ids 	= mwp_option('category-ebookmagazine');
	$article_ids 		= mwp_option('category-article');
	$related_check 		= mwp_option('mobile_read_also');
	$ads_check  		= mwp_option('minside-advert-display');

	if (function_exists('is_product') && is_product()) return $content;
	if (function_exists('is_amp_endpoint') && is_amp_endpoint()) return $content;
	if (!empty($videos_ids) && in_category($videos_ids)) return $content;
	if (!empty($gallery_ids) && in_category($gallery_ids)) return $content;
	if (!empty($caricature_ids) && in_category($caricature_ids)) return $content;
	if (!empty($ebookmagazine_ids) && in_category($ebookmagazine_ids)) return $content;
	if (!empty($article_ids) && in_category($article_ids)) return $content;
	if (has_shortcode($content, 'error')) return $content;
	if (has_shortcode($content, 'notice')) return $content;
	if (has_shortcode($content, 'information')) return $content;
	if (has_shortcode($content, 'success')) return $content;
	if (has_shortcode($content, 'proscons')) return $content;
	if (in_array('alert-info', $blocks[1])) return $content;
	if (in_array('alert-success', $blocks[1])) return $content;
	if (in_array('alert-danger', $blocks[1])) return $content;
	if (in_array('alert-warning', $blocks[1])) return $content;
	if (in_array('pros-cons', $blocks[1])) return $content;
	
	if ( is_singular() && ! is_admin() && $ads_check == 1) {
		if (check_post_ads('inside', get_the_ID()) == 1) {
			ob_start();
			mwp_single_ads_inside();
			$html_ad_code = ob_get_contents();
			ob_end_clean();
			
			$ads_code 		= $html_ad_code;
			$ads_paragraph 	= get_post_meta($post->ID, 'paragraph_ads' , true);
			
			if (!empty($ads_paragraph)) {
				$default_ads_paragraph = $ads_paragraph;
			} elseif ($related_check ==  1) {
				$default_ads_paragraph = 4;
			} else {
				$default_ads_paragraph = 2;
			}
			return prefix_insert_after_paragraph( $ads_code, $default_ads_paragraph, $content );
		}
	}
    return $content;
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists