parent_base == 'edit' ) {
return;
}
adsensei_show_vi_api_error();
echo adsensei_show_vi_notices();
adsensei_show_ads_txt_notice();
if( adsensei_is_admin_page() ) {
echo '
' . sprintf( __( '
Please disable your browser AdBlocker to resolve problems with WP ADSENSEI ad setup
', 'adsenseib30' ), admin_url() . 'admin.php?page=adsensei-settings#adsensei_settingsgeneral_header' ) . '
';
}
if( isset( $_GET['adsensei-action'] ) && $_GET['adsensei-action'] === 'validate' && adsensei_is_admin_page() && adsensei_is_any_ad_activated() && adsensei_is_post_type_activated() && adsensei_get_active_ads() > 0 ) {
echo '' . sprintf( __( '
No errors detected in WP ADSENSEI settings. If ads are still not shown read the
troubleshooting guide' ), 'http://wpadsensei.com/docs/adsense-ads-are-not-showing/?utm_source=plugin&utm_campaign=wpadsensei-settings&utm_medium=website&utm_term=toplink' ) . '
';
}
adsensei_show_rate_div();
}
function adsensei_admin_messages_new(){
if( adsensei_is_admin_page() ) {
echo '' . sprintf( __( '
Please disable your browser AdBlocker to resolve problems with WP ADSENSEI ad setup
', 'adsenseib30' ), admin_url() . 'admin.php?page=adsensei-settings#adsensei_settingsgeneral_header' ) . '
';
}
}
function adsensei_show_rate_div(){
$install_date = get_option( 'adsensei_install_date' );
$display_date = date( 'Y-m-d h:i:s' );
$datetime1 = new DateTime( $install_date );
$datetime2 = new DateTime( $display_date );
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
$rate = get_option( 'adsensei_rating_div', false );
if( $diff_intrval >= 7 && ($rate === "no" || false === $rate || adsensei_rate_again() ) ) {
echo '
Awesome, you\'ve been using WP ADSENSEI for more than 1 week.
May i ask you to give it a 5-star rating on Wordpress?
This will help to spread its popularity and to make this plugin a better one.
Your help is much appreciated. Thank you very much
';
}
}
// add_action( 'admin_notices', 'adsensei_admin_messages' );
/* Hide the rating div
* @return json string
*/
function adsensei_hide_rating_div() {
update_option( 'adsensei_rating_div', 'yes' );
delete_option( 'adsensei_date_next_notice' );
echo json_encode( array("success") );
exit;
}
add_action( 'wp_ajax_adsensei_hide_rating', 'adsensei_hide_rating_div' );
/**
* Write the timestamp when rating notice will be opened again
*/
function adsensei_hide_rating_notice_week() {
$nextweek = time() + (7 * 24 * 60 * 60);
$human_date = date( 'Y-m-d h:i:s', $nextweek );
update_option( 'adsensei_date_next_notice', $human_date );
update_option( 'adsensei_rating_div', 'yes' );
echo json_encode( array("success") );
exit;
}
add_action( 'wp_ajax_adsensei_hide_rating_week', 'adsensei_hide_rating_notice_week' );
/**
* Check if admin notice will open again after one week of closing
* @return boolean
*/
function adsensei_rate_again() {
$rate_again_date = get_option( 'adsensei_date_next_notice' );
if( false === $rate_again_date ) {
return false;
}
$current_date = date( 'Y-m-d h:i:s' );
$datetime1 = new DateTime( $rate_again_date );
$datetime2 = new DateTime( $current_date );
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
if( $diff_intrval >= 0 ) {
return true;
}
}
/**
* Show a message when pro or free plugin gets disabled
*
* @return void
* @not used
*/
function adsensei_plugin_deactivated_notice() {
if( false !== ( $deactivated_notice_id = get_transient( 'adsensei_deactivated_notice_id' ) ) ) {
if( '1' === $deactivated_notice_id ) {
$message = __( "WP ADSENSEI and WP ADSENSEI Pro cannot be activated both. We've automatically deactivated WP ADSENSEI.", 'wpstg' );
} else {
$message = __( "WP ADSENSEI and WP ADSENSEI Pro cannot be activated both. We've automatically deactivated WP ADSENSEI Pro.", 'wpstg' );
}
?>
0 ) {
return true;
}
// check if any other ad is assigned and activated
if( isset( $adsensei_options['pos1']['BegnAds'] ) ||
isset( $adsensei_options['pos2']['MiddAds'] ) ||
isset( $adsensei_options['pos3']['EndiAds'] ) ||
isset( $adsensei_options['pos4']['MoreAds'] ) ||
isset( $adsensei_options['pos5']['LapaAds'] ) ||
isset( $adsensei_options['pos6']['Par1Ads'] ) ||
isset( $adsensei_options['pos7']['Par2Ads'] ) ||
isset( $adsensei_options['pos8']['Par3Ads'] ) ||
isset( $adsensei_options['pos9']['Img1Ads'] )
) {
return true;
}
// no ad is activated
return false;
}
/**
* Check if any post type is enabled
*
* @global array $adsensei_options
* @return boolean
*/
function adsensei_is_post_type_activated() {
global $adsensei_options;
if( empty( $adsensei_options['post_types'] ) ) {
return false;
}
return true;
}
/**
* Check if ad codes are populated
*
* @global array $adsensei_options
* @return booleantrue if ads are empty
*/
function adsensei_ads_empty() {
global $adsensei_options;
$check = array();
for ( $i = 1; $i <= 10; $i++ ) {
if( !empty( $adsensei_options['ads']['ad' . $i]['code'] ) ) {
$check[] = 'true';
}
}
if( count( $check ) === 0 ) {
return true;
}
return false;
}
/**
* Return VI admin notice
* @return string
*/
function adsensei_get_vi_notice() {
global $adsensei;
if( false !== get_option( 'adsensei_close_vi_welcome_notice' ) || !adsensei_is_admin_page() ) {
return false;
}
$mail = get_option( 'admin_email' );
$domain = $adsensei->vi->getDomain();
$white = '
' .
sprintf(
__( 'This update features vi stories from video intelligence. This video player will supply you with both video
content and video advertising.
To begin earning, visit the WP ADSENSEI plugin page, sign up to vi stories and place the ad live now! Read the FAQ.
By clicking sign up you agree to send your current domain, email and affiliate ID to video intelligence & WP ADSENSEI
', 'quick-adsense-reloaed' ), 'https://www.vi.ai/publisher-registration/?aid=WP_Adsensei&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20adsensei&utm_campaign=white', admin_url() . 'admin.php?page=adsensei-settings#adsensei_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Adsensei&utm_source=Wordpress&utm_medium=wp%20adsensei&utm_campaign=white'
)
. '
';
$black = '
' .
sprintf(
__( 'This update features vi stories from video intelligence. This video player will supply you with both video
content and video advertising.
To begin earning, visit the WP ADSENSEI plugin page, sign up to vi stories and place the ad live now! Read the FAQ.
By clicking sign up you agree to send your current domain, email and affiliate ID to video intelligence & WP ADSENSEI
', 'adsenseib30' ), 'https://www.vi.ai/publisher-registration/?aid=WP_Adsensei&domain=' . $domain . '&email=' . $mail . '&utm_source=Wordpress&utm_medium=wp%20adsensei&utm_campaign=black', admin_url() . 'admin.php?page=adsensei-settings#adsensei_settingsvi_header', 'https://www.vi.ai/publisherfaq/?aid=WP_Adsensei&utm_source=Wordpress&utm_medium=wp%20adsensei&utm_campaign=black'
)
. '
';
$variant = get_option( 'adsensei_vi_variant' );
switch ( $variant ) {
case 'a':
return $white;
break;
case 'b':
return $black;
break;
default:
return $white;
break;
}
}
/**
* Check if vi admin notice should be opened again again one week after closing
* @return boolean
*/
function adsensei_show_vi_notice_again() {
$show_again_date = get_option( 'adsensei_show_vi_notice_later' );
if( false === $show_again_date ) {
return false;
}
$current_date = date( 'Y-m-d h:i:s' );
$datetime1 = new DateTime( $show_again_date );
$datetime2 = new DateTime( $current_date );
$diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
if( $diff_intrval >= 0 ) {
return true;
}
}
/**
* Show all vi notices
*/
function adsensei_show_vi_notices() {
global $adsensei, $adsensei_options;
if( !adsensei_is_admin_page() ) {
return false;
}
// adsense ads.txt content
$adsense = new wpadsensei\adsense( $adsensei_options );
$adsensePublisherIds = $adsense->getPublisherIds();
$adsenseAdsTxtText = '';
if( !empty( $adsensePublisherIds ) ) {
foreach ( $adsensePublisherIds as $adsensePublisherId ) {
$adsenseAdsTxtText .= "google.com, " . str_replace( 'ca-', '', $adsensePublisherId ) . ", DIRECT, f08c47fec0942fa0\r\n";
}
}
// vi ads.txt content
$viAdsTxtText = '';
if( $adsensei->vi->getPublisherId() ) {
$viAdsTxtText = $adsensei->vi->getAdsTxtContent();
}
// Show ads.txt warning if logged into vi and ads.txt option is disabled
if( get_transient( 'adsensei_vi_ads_txt_disabled' ) && get_option( 'adsensei_vi_token' ) ) {
// ads.txt content
$notice['message'] = sprintf( 'ADS.TXT couldn\'t be updated automatically.
You need the ads.txt to display vi video ads.
If you want WP ADSENSEI to create an ads.txt automatically you can enable the ads.txt option at General & Position. Alternatively you can also enter the following line manually into ' . get_site_url() . '/ads.txt:'
. "
"
. "
" . $viAdsTxtText . "
"
. $adsenseAdsTxtText
. "
"
. 'If the file does not exist you need to create it first. Learn More'
, admin_url() . 'admin.php?page=adsensei-settings#adsensei_settingsgeneral_header'
, 'https://adsplugin.net/make-more-revenue-by-using-an-ads-txt-in-your-website-root-domain/'
);
$notice['type'] = 'update-nag';
$adsTxtDisabled = new wpadsensei\template( '/includes/vendor/vi/views/notices', $notice );
echo $adsTxtDisabled->render();
return false;
}
// show ad.txt update notice
if( get_transient( 'adsensei_vi_ads_txt_notice' ) ) {
$notice['message'] = 'ADS.TXT has been added
WP ADSENSEI has updated your ads.txt '
. 'file with lines that declare video inteligence as a legitmate seller of your inventory and enables you to make more money through video inteligence. FAQ';
$notice['type'] = 'update-nag';
$notice['transient'] = 'adsensei_vi_ads_txt_notice';
$adsUpdated = new wpadsensei\template( '/includes/vendor/vi/views/notices', $notice );
// echo $adsUpdated->render();
}
// show ad.txt update notice
if( get_transient( 'adsensei_vi_ads_txt_error' ) ) {
// ads.txt content
$notice['message'] = "ADS.TXT couldn't be added
Important note: WP ADSENSEI hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into
" . get_home_path() . "ads.txt:"
. "
"
. "
vi.ai " . $adsensei->vi->getPublisherId() . " DIRECT # 41b5eef6
"
. $adsenseAdsTxtText
. "
"
. "Only by doing so you are able to make more money through video inteligence.";
$notice['type'] = 'error';
// render blurb
$adsTxtError = new wpadsensei\template( '/includes/vendor/vi/views/notices', $notice );
echo $adsTxtError->render();
}
}
/**
* Show a ads.txt notices if WP ADSENSEI has permission to update or create an ads.txt
*/
function adsensei_show_ads_txt_notice() {
global $adsensei, $adsensei_options;
if( !adsensei_is_admin_page() )
return false;
// show ads.txt error notice
if( get_transient( 'close_ads_txt_error' ) && isset( $adsensei_options['adsTxtEnabled'] ) ) {
// Check if adsense is used and add the adsense publisherId to ads.txt blurb as well
$adsense = new wpadsensei\adsense( $adsensei_options );
$adsensePublisherIds = $adsense->getPublisherIds();
$adsenseAdsTxtText = '';
if( !empty( $adsensePublisherIds ) ) {
foreach ( $adsensePublisherIds as $adsensePublisherId ) {
$adsenseAdsTxtText .= "google.com, " . str_replace( 'ca-', '', $adsensePublisherId ) . ", DIRECT, f08c47fec0942fa0\n\r";
}
}
$viAdsTxtText = '';
if( $adsensei->vi->getPublisherId() ) {
$viAdsTxtText = $adsensei->vi->getAdsTxtContent();
}
// ads.txt content
$notice['message'] = "ADS.TXT couldn't be updated automatically
Important note: WP ADSENSEI hasn't been able to update your ads.txt file automatically. Please make sure to enter the following line manually into " . get_home_path() . "ads.txt:"
. "
"
. "
" . $viAdsTxtText . "
"
. $adsenseAdsTxtText
. "
"
. "Only by doing so AdSense ads are shown on your site.";
$notice['type'] = 'error';
$notice['action'] = 'adsensei_ads_txt_error';
// render blurb
$adsTxtError = new wpadsensei\template( '/includes/admin/views/notices', $notice );
echo $adsTxtError->render();
}
}
/**
* Show api errors
*/
function adsensei_show_vi_api_error() {
if( !adsensei_is_admin_page() ) {
return false;
}
if( false !== get_option( 'adsensei_vi_api_error' ) ) {
$notice['message'] = 'WP ADSENSEI - Can not retrive ad settings from vi API. Error: ' . get_option( 'adsensei_vi_api_error' );
$notice['type'] = 'error';
$notice['action'] = '';
// render blurb
$blurb = new wpadsensei\template( '/includes/admin/views/notices', $notice );
echo $blurb->render();
}
}
/**
* Store the transient for 30 days
*/
function adsensei_hide_license_expired_notice() {
set_transient( 'adsensei_notice_lic_expired', 'hide', 60 * 60 * 24 * 30 );
}
add_action( 'adsensei_hide_license_expired_notice', 'adsensei_hide_license_expired_notice' );
/**
* Return update notice for Google Auto Ads
* @since 3.5.3.0
*/
function adsensei_show_update_auto_ads() {
$message = sprintf( __( 'WP ADSENSEI & Google Auto Ads
'
. 'WP ADSENSEI Pro adds support for Google Auto Ads
Get the Pro plugin from wpadsensei.com'
, 'mashsb' ), admin_url() . 'admin.php?page=adsensei-settings'
);
if( get_option( 'adsensei_show_notice_auto_ads' ) === 'no' ) {
return false;
}
// admin notice after updating wp adsensei
echo '';
}
/**
* Hide GDPR notice
*
* @global array $mashsb_options
*/
function mashsb_hide_auto_ads_notice() {
global $adsensei_options;
// Get all settings
update_option( 'adsensei_show_notice_auto_ads', 'no' );
}
add_action( 'adsensei_hide_auto_ads_notice', 'mashsb_hide_auto_ads_notice' );