$post_id,
'post_status' => 'advert-archive',
);
wp_update_post( $update_advert );
}
/**
* Encrypt Link
*
* @since 1.0.0
*
*/
function encryptLink($link,$type='') {
global $advert_options;
//adds an extra "key" at the end if deleted or left blank - leaving the option empty is not recommended
$advert_encryption = '';
if( array_key_exists('advert_decode_key',$advert_options) ){
$advert_encryption = $advert_options['advert_decode_key'];
}
//add an extra encryption value incase the key is not set or removed
//the encryption key
$key = $advert_encryption.'238378';
//encryption
$link = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $link, MCRYPT_MODE_ECB);
$link = base64_encode($link);
$link = urlencode($link);
//end encryption
return $link;
}
/**
* Decrypt Link
*
* @since 1.0.0
*
*/
function decryptLink($link,$type=''){
global $advert_options;
$advert_encryption = '';
if( array_key_exists('advert_decode_key',$advert_options) ){
$advert_encryption = $advert_options['advert_decode_key'];
}
//encryption key
//add an extra encryption value incase the key is not set or removed
$key = $advert_encryption.'238378';
// decryption happen here
$link = urldecode($link);
$link = base64_decode($link);
$link = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $link, MCRYPT_MODE_ECB));
return $link;
}
function advert_insert_head() {
/** Include the Ajax library on the front end */
$html = '';
/** Include the AdVert blocking scripts on the front end */
$html .= '';
echo $html;
}
function advert_insert_bottom() {
global $advert_options;
$advert_display_notice = 0;
if( array_key_exists('advert_display_notice_blocked',$advert_options) ){
$advert_display_notice = intval($advert_options['advert_display_notice_blocked']);
}
$advert_display_notice_text = '';
if( array_key_exists('advert_display_notice_blocked_text',$advert_options) ){
$advert_display_notice_text = $advert_options['advert_display_notice_blocked_text'];
}
else{
$advert_display_notice_text = __( 'You have blocked our Ads, we understand...you should know that we use AdVert, a user friendly Ad System. AdVert provides you an option to control the type of Ads shown...you are now in control. If you see something too much, click that option, or if you see something you like you can give that feedback too.
About AdVert', 'ADVERT_TEXTDOMAIN' );
}
$avblocked_cookie = (isset($_COOKIE['avblocked']) ? stripslashes(sanitize_text_field($_COOKIE['avblocked'])) : 'No');
if( $advert_display_notice === 1 && $avblocked_cookie === 'No'){
echo '
';
echo '
';
echo '
';
echo '
';
echo '
X
';
echo '
'. $advert_display_notice_text . '
'. __( 'If this notice continues to show daily, your cookies are either disabled or this website has manually changed the code.', 'ADVERT_TEXTDOMAIN' ) .'
' . __( 'About AdVert', 'ADVERT_TEXTDOMAIN' ) .'
';
echo '
';
echo '
';
echo '
';
echo '
';
}
/** check if user string has similar bot names -- if it does advert will not count impressions or clicks */
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/bot|crawl|slurp|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
echo '';
}
/** Include the AdVert blocking scripts on the front end */
$html = '';
$html .= '';
$html .= '';
$html .= '';
echo $html;
}
function advert_place_content_ads( $content ) {
global $get_network_type;
global $main_site_id;
global $current_site_id;
if ( is_single() && is_main_query() && in_the_loop() ){
if( $get_network_type === true && $current_site_id != $main_site_id ){
switch_to_blog($main_site_id);
}
$standard_locations = get_option('advert_standard_locations');
if(is_array($standard_locations)){
if(array_key_exists('beforecontent', $standard_locations)){
if(get_post_status($standard_locations['beforecontent']) === 'publish'){
$scode = '[advert_location location_id="'.$standard_locations['beforecontent'].'"]';
$content = '
' . do_shortcode($scode) . '
' . $content;
}
}
if(array_key_exists('aftercontent', $standard_locations)){
if(get_post_status($standard_locations['aftercontent']) === 'publish'){
$scode = '[advert_location location_id="'.$standard_locations['aftercontent'].'"]';
$content = $content . '
' . do_shortcode($scode) . '
';
}
}
}
if( $get_network_type === true && $current_site_id != $main_site_id ){
restore_current_blog();
}
}
return $content;
}
function advert_is_utf8($str) {
return (bool) preg_match('//u', $str);
}
function advert_frontend_modify_toolbar( $wp_admin_bar ) {
if(is_admin())
return;
global $advert_options;
if ( current_user_can( 'edit_adverts' ) ){
if ( !current_user_can( 'publish_adverts' ) && current_user_can( 'edit_adverts' ) ){
//add a parent item
$args = array(
'id' => 'advert_dashboard_group',
'title' => 'a'. __( 'AdVert Dashboard', 'ADVERT_TEXTDOMAIN' ) .'',
'href' => esc_url(admin_url( 'admin.php?page=advert-user' )),
'meta' => array( 'class' => 'advert-toolbar-group' )
);
$wp_admin_bar->add_node( $args );
//add a child item to our parent item
$args = array(
'id' => 'advert_dashboard_toolbar',
'title' => __( 'Dashboard', 'ADVERT_TEXTDOMAIN' ),
'href' => esc_url(admin_url( 'admin.php?page=advert-user' )),
'parent' => 'advert_dashboard_group'
);
$wp_admin_bar->add_node( $args );
//check if user has rights to view analysis
$user_analysis = 0;
if(array_key_exists('advert_allow_analysis_users', $advert_options)){
$user_analysis = intval($advert_options['advert_allow_analysis_users']);
}
if($user_analysis === 1){
// add a child item to our parent item
$args = array(
'id' => 'advert_analysis_toolbar',
'title' => __( 'Analysis', 'ADVERT_TEXTDOMAIN' ),
'href' => esc_url(admin_url( 'admin.php?page=advert-analysis-overview' )),
'parent' => 'advert_dashboard_group'
);
$wp_admin_bar->add_node( $args );
}
}
if ( current_user_can( 'publish_adverts' ) ){
//add a parent item
$args = array(
'id' => 'advert_dashboard_group',
'title' => 'a'. __( 'AdVert Dashboard', 'ADVERT_TEXTDOMAIN' ) .'',
'href' => esc_url(admin_url( 'admin.php?page=advert' )),
'meta' => array( 'class' => 'advert-toolbar-group' )
);
$wp_admin_bar->add_node( $args );
//add a child item to our parent item
$args = array(
'id' => 'advert_dashboard_toolbar',
'title' => __( 'Dashboard', 'ADVERT_TEXTDOMAIN' ),
'href' => esc_url(admin_url( 'admin.php?page=advert' )),
'parent' => 'advert_dashboard_group'
);
$wp_admin_bar->add_node( $args );
//add a child item to our parent item
$args = array(
'id' => 'advert_analysis_toolbar',
'title' => __( 'Analysis', 'ADVERT_TEXTDOMAIN' ),
'href' => esc_url(admin_url( 'admin.php?page=advert-analysis-overview' )),
'parent' => 'advert_dashboard_group'
);
$wp_admin_bar->add_node( $args );
//add a child item to our parent item
$args = array(
'id' => 'advert_control_panel_toolbar',
'title' => __( 'Control Panel', 'ADVERT_TEXTDOMAIN' ),
'href' => esc_url(admin_url( 'admin.php?page=advert-cp-general' )),
'parent' => 'advert_dashboard_group'
);
$wp_admin_bar->add_node( $args );
}
}
}
/**
* Loads front end css, js and localizes AJAX for AD Logging
*
* @since 1.0.0
*/
function advert_frontend_scripts() {
$version = new AdVert_For_Wordpress();
$version = $version->get_advert_version();
wp_register_script( 'advert', ADVERT_PLUGIN_URL . 'js/advertfe.min.js' ,array('jquery'), $version, true);
$url = array( 'url' => esc_url(admin_url('admin-ajax.php')) );
wp_localize_script( 'advert', 'ajax', $url );
wp_enqueue_script( 'advert' );
wp_enqueue_style('advert-style', ADVERT_PLUGIN_URL . 'css/advertfe.min.css');
if ( wp_is_mobile() )
wp_enqueue_script( 'jquery-touch-punch' );
}