ADSENSEI_VERSION,
'allowed_click' => esc_attr($allowed_click),
'adsensei_click_limit' => esc_attr($click_limit),
'adsensei_ban_duration' => esc_attr($ban_duration),
) );
}
}
/**
* Determines whether the current admin page is an ADSENSEI admin page.
*
* Only works after the `wp_loaded` hook, & most effective
* starting on `admin_menu` hook.
*
* @since 1.9.6
* @return bool True if ADSENSEI admin page.
*/
if(!function_exists('adsensei_is_admin_page')){
function adsensei_is_admin_page() {
$currentpage = isset($_GET['page']) ? $_GET['page'] : '';
if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
return false;
}
if ( 'adsensei-settings' == $currentpage ) {
return true;
}
}
}
/**
* Create ad blocker admin script
*
* @return mixed boolean | string
*/
function adsensei_check_ad_blocker() {
if( !adsensei_is_admin_page() ) {
return false;
}
?>
base;
if($currentScreen == 'toplevel_page_adsensei-settings'){
remove_all_actions('admin_notices');
if($adsensei_mode == 'new'){
add_action( 'admin_notices', 'adsensei_show_rate_div' );
add_action( 'admin_notices', 'adsensei_admin_messages_new' );
}
wp_enqueue_media();
//To add page
if ( ! class_exists( '_WP_Editors', false ) ) {
require( ABSPATH . WPINC . '/class-wp-editor.php' );
}
}
}
if($adsensei_mode != 'new'){
add_action( 'admin_notices', 'adsensei_admin_messages' );
}
global $current_user,$wp_version, $adsensei;
$dismissed = explode (',', get_user_meta (wp_get_current_user ()->ID, 'dismissed_wp_pointers', true));
$do_tour = !in_array ('wpadsensei_subscribe_pointer', $dismissed);
if ($do_tour) {
wp_enqueue_style ('wp-pointer');
wp_enqueue_script ('wp-pointer');
$js_dir = ADSENSEI_PLUGIN_URL . 'assets/js/';
wp_register_script( 'adsensei-newsletter', $js_dir . 'adsensei-newsletter.js', array('jquery'), ADSENSEI_VERSION, false );
wp_localize_script( 'adsensei-newsletter', 'adsenseinewsletter', array(
'current_user_email' => $current_user->user_email,
'current_user_name' => $current_user->display_name,
'do_tour' => $do_tour,
'path' => get_site_url()
) );
wp_enqueue_script('adsensei-newsletter');
}
$js_dir = ADSENSEI_PLUGIN_URL . 'assets/js/';
$css_dir = ADSENSEI_PLUGIN_URL . 'assets/css/';
// Use minified libraries if SCRIPT_DEBUG is turned off
$suffix = ( adsenseiIsDebugMode() ) ? '' : '.min';
wp_enqueue_script( 'adsensei-admin-scripts', $js_dir . 'adsensei-admin' . $suffix . '.js', array('jquery'), ADSENSEI_VERSION, false );
$signupURL = $adsensei->vi->getSettings()->data->signupURL;
$adsensei_import_classic_ads_popup = false;
$classic_ads_status = get_option( 'adsensei_import_classic_ads_popup' );
if($classic_ads_status === false && $adsensei_mode === false){
update_option('adsensei_import_classic_ads_popup', 'yes');
$adsensei_import_classic_ads_popup = true;
}elseif($classic_ads_status == 'yes'){
$adsensei_import_classic_ads_popup = true;
}
wp_localize_script( 'adsensei-admin-scripts', 'adsensei', array(
'nonce' => wp_create_nonce( 'adsensei_ajax_nonce' ),
'error' => __( "error", 'adsenseib30' ),
'path' => get_option( 'siteurl' ),
'plugin_url' => ADSENSEI_PLUGIN_URL,
'vi_revenue' => !empty( $adsensei->vi->getRevenue()->mtdReport ) ? $adsensei->vi->getRevenue()->mtdReport : '',
'vi_login_url' => $adsensei->vi->getLoginURL(),
'vi_signup_url' => !empty( $signupURL ) ? $signupURL : '',
'domain' => $adsensei->vi->getDomain(),
'email' => get_option( 'admin_email' ),
'aid' => 'WP_Adsensei',
'adsensei_import_classic_ads_popup' => $adsensei_import_classic_ads_popup,
'adsensei_get_active_ads' => adsensei_get_active_ads_backup()
) );
if( !apply_filters( 'adsensei_load_admin_scripts', adsensei_is_admin_page(), $hook ) ) {
return;
}
// These have to be global
wp_enqueue_script( 'adsensei-admin-ads', $js_dir . 'ads.js', array('jquery'), ADSENSEI_VERSION, false );
wp_enqueue_script( 'adsensei-jscolor', $js_dir . 'jscolor' . $suffix . '.js', array(), ADSENSEI_VERSION, false );
wp_enqueue_script( 'jquery-chosen', $js_dir . 'chosen.jquery' . $suffix . '.js', array('jquery'), ADSENSEI_VERSION, false );
wp_enqueue_script( 'jquery-form' );
$vi_dir = ADSENSEI_PLUGIN_URL . 'includes/vendor/vi/public/js/';
wp_enqueue_script( 'adsensei-vi', $vi_dir . 'vi.js', array(), ADSENSEI_VERSION, false );
wp_enqueue_style( 'adsensei-admin', $css_dir . 'adsensei-admin' . $suffix . '.css',array(), ADSENSEI_VERSION );
wp_enqueue_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css',array(), ADSENSEI_VERSION );
}
/**
* Load Admin Scripts available on plugins page
*
* Enqueues the required admin scripts.
*
* @since 1.0
* @global $post
* @param string $hook Page hook
* @return void
*/
function adsensei_load_plugins_admin_scripts( $hook ) {
if( !apply_filters( 'adsensei_load_plugins_admin_scripts', adsensei_is_plugins_page(), $hook ) ) {
return;
}
$js_dir = ADSENSEI_PLUGIN_URL . 'assets/js/';
$css_dir = ADSENSEI_PLUGIN_URL . 'assets/css/';
// Use minified libraries if SCRIPT_DEBUG is turned off
$suffix = ( adsenseiIsDebugMode() ) ? '' : '.min';
wp_enqueue_script( 'adsensei-plugins-admin-scripts', $js_dir . 'adsensei-plugins-admin' . $suffix . '.js', array('jquery'), ADSENSEI_VERSION, false );
wp_enqueue_style( 'adsensei-plugins-admin', $css_dir . 'adsensei-plugins-admin' . $suffix . '.css', array(),ADSENSEI_VERSION );
}
/**
* Load Admin Scripts available on all admin pages
*
* Enqueues the required admin scripts.
*
* @since 1.6.1
* @global $post
* @param string $hook Page hook
* @return void
*/
function adsensei_load_all_admin_scripts( $hook ) {
$css_dir = ADSENSEI_PLUGIN_URL . 'assets/css/';
wp_enqueue_style( 'adsensei-admin-all', $css_dir . 'adsensei-admin-all.css',array(), ADSENSEI_VERSION );
}
function adsensei_load_admin_fonts( $hook ) {
$font_url = ADSENSEI_PLUGIN_URL.'admin/assets/js';
$font_styles= '';
if( isset($hook) && $hook == "admin.php" ) {
echo $font_styles ;
}
}
/**
* Register CSS Styles
*
* Checks the styles option and hooks the required filter.
*
* @since 1.0
* @global $mashsb_options
* @return void
*/
//function adsensei_register_styles( $hook ) {
// global $adsensei_options;
//
// // Register empty adsensei.css to be able to register adsensei_inline_styles()
// //$url = ADSENSEI_PLUGIN_URL . 'assets/css/adsensei.css';
//
// //wp_enqueue_style( 'adsensei-styles', $url, array(), ADSENSEI_VERSION );
// wp_enqueue_style( 'adsensei-styles', false );
//}
/**
* Add dynamic CSS to write media queries for removing unwanted ads without the need to use any cache busting method
* (Cache busting could affect performance and lead to lot of support tickets so lets follow the css approach)
*
* @since 1.0
* @global1 array options
* @global2 $adsensei_css dynamic build css
*
* @return string
*/
function adsensei_inline_styles() {
global $adsensei_options;
$css = '';
if( isset( $adsensei_options['ads'] ) ) {
foreach ( $adsensei_options['ads'] as $key => $value ) {
$css .= adsensei_render_media_query( $key, $value );
}
}
$css .="
.adsensei-location ins.adsbygoogle {
background: transparent !important;
}
.adsensei.adsensei_ad_container { display: grid; grid-template-columns: auto; grid-gap: 10px; padding: 10px; }
.grid_image{animation: fadeIn 0.5s;-webkit-animation: fadeIn 0.5s;-moz-animation: fadeIn 0.5s;
-o-animation: fadeIn 0.5s;-ms-animation: fadeIn 0.5s;}
.adsensei-ad-label { font-size: 12px; text-align: center; color: #333;}
.adsensei-text-around-ad-label-text_around_left {
width: 50%;
float: left;
}
.adsensei-text-around-ad-label-text_around_right {
width: 50%;
float: right;
}
.adsensei-popupad {
position: fixed;
top: 0px;
left:0px;
width: 100%;
height: 100em;
background-color: rgba(0,0,0,0.6);
z-index: 999;
max-width: 100em !important;
margin: 0 auto;
}
.adsensei.adsensei_ad_container_ {
position: fixed;
top: 40%;
left: 36%;
}
#btn_close{
background-color: #fff;
width: 25px;
height: 25px;
text-align: center;
line-height: 22px;
position: absolute;
right: -10px;
top: -10px;
cursor: pointer;
transition: all 0.5s ease;
border-radius: 50%;
}
#btn_close_video{
background-color: #fff;
width: 25px;
height: 25px;
text-align: center;
line-height: 22px;
position: absolute;
right: -10px;
top: -10px;
cursor: pointer;
transition: all 0.5s ease;
border-radius: 50%;
z-index:100;
}
@media screen and (max-width: 480px) {
.adsensei.adsensei_ad_container_ {
left: 10px;
}
}
.adsensei-video {
position: fixed;
bottom: 0px;
z-index: 9999999;
}
adsensei_ad_container_video{
max-width:220px;
}
.adsensei_click_impression { display: none;}
.adsensei-sticky {
width: 100% !important;
background-color: hsla(0,0%,100%,.7);
position: fixed;
max-width: 100%!important;
bottom:0;
margin:0;
text-align: center;
}.adsensei-sticky .adsensei-location {
text-align: center;
}.adsensei-sticky .wp_adsensei_dfp {
display: contents;
}
a.adsensei-sticky-ad-close {
background-color: #fff;
width: 25px;
height: 25px;
text-align: center;
line-height: 22px;
position: absolute;
right: 0px;
top: -15px;
cursor: pointer;
transition: all 0.5s ease;
border-radius: 50%;
}
";
// Register empty style so we do not need an external css file
wp_register_style( 'adsensei-styles', false );
// Enque empty style
wp_enqueue_style( 'adsensei-styles' );
// Add inline css to that style
wp_add_inline_style( 'adsensei-styles', $css );
}
function adsensei_inline_styles_amp() {
global $adsensei_options;
$css = '';
if( isset( $adsensei_options['ads'] ) ) {
foreach ( $adsensei_options['ads'] as $key => $value ) {
$css .= adsensei_render_media_query( $key, $value );
}
}
$css .=".adsensei-ad-label { font-size: 12px; text-align: center; color: #333;}";
if (adsensei_is_amp_endpoint()){
echo $css;
}
}
/**
* Render Media Queries
*
* @param string $key
* @param string $value
* @return string
*/
function adsensei_render_media_query( $key, $value ) {
$html = '';
if( isset( $value['desktop'] ) ) {
//$html .= '/* Hide on desktop */';
$html .= '@media only screen and (min-width:1140px){#adsensei-' . $key . ', .adsensei-' . $key . ' {display:none;}}' . "\n";
}
if( isset( $value['tablet_landscape'] ) ) {
//$html .= '/* Hide on tablet landscape */';
$html .= '@media only screen and (min-width:1024px) and (max-width:1140px) {#adsensei-' . $key . ', .adsensei-' . $key . ' {display:none;}}' . "\n";
}
if( isset( $value['tablet_portrait'] ) ) {
//$html .= '/* Hide on tablet portrait */';
$html .= '@media only screen and (min-width:768px) and (max-width:1023px){#adsensei-' . $key . ', .adsensei-' . $key . ' {display:none;}}' . "\n";
}
if( isset( $value['phone'] ) ) {
//$html .= '/* Hide on mobile device */';
$html .= '@media only screen and (max-width:767px){#adsensei-' . $key . ', .adsensei-' . $key . ' {display:none;}}' . "\n";
}
return $html;
}
/*
* Check if debug mode is enabled
*
* @since 0.9.0
* @return bool true if Mashshare debug mode is on
*/
function adsenseiIsDebugMode() {
global $adsensei_options;
$debug_mode = (isset( $adsensei_options['debug_mode'] ) && $adsensei_options['debug_mode'] ) ? true : false;
return $debug_mode;
}
/**
* Create ad buttons for editor
* @since 0.9.0
*/
$wpvcomp = ( bool ) (version_compare( get_bloginfo( 'version' ), '3.1', '>=' ));
function adsensei_ads_head_script() {
global $adsensei_options, $wpvcomp;
if( isset( $adsensei_options['quicktags']['QckTags'] ) ) {
?>