示例#1
0
 /**
  * load advanced ads settings
  */
 public function options()
 {
     // don’t initiate if main plugin not loaded
     if (!class_exists('Advanced_Ads')) {
         return array();
     }
     return Advanced_Ads::get_instance()->options();
 }
示例#2
0
 /**
  * Initialize the module
  *
  * @since   1.0.0
  */
 private function __construct()
 {
     $advads_options = Advanced_Ads::get_instance()->options();
     $options = $this->options();
     if (!empty($advads_options['use-adblocker']) && !empty($this->options['folder_name']) && !empty($this->options['active_plugins_hash']) && $this->get_upload_directory()) {
         add_action('plugins_loaded', array($this, 'wp_plugins_loaded'));
     }
 }
 /**
  * load ad groups
  */
 public function load_groups()
 {
     // load all groups
     $search = !empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : '';
     $args = array('taxonomy' => $this->taxonomy, 'search' => $search, 'hide_empty' => 0);
     // get wp term objects
     $terms = Advanced_Ads::get_ad_groups($args);
     // add meta data to groups
     $this->groups = $this->load_groups_objects_from_terms($terms);
 }
示例#4
0
 /**
  * Simple wp ajax interface for ad selection.
  *
  * Provides a single ad given ID and selection method.
  */
 public function advads_ajax_ad_select()
 {
     // set proper header
     header('Content-Type: application/json; charset: utf-8');
     // allow modules / add ons to test (this is rather late but should happen before anything important is called)
     do_action('advanced-ads-ajax-ad-select-init');
     // init handlers
     $selector = Advanced_Ads_Select::get_instance();
     $methods = $selector->get_methods();
     $method = isset($_REQUEST['ad_method']) ? (string) $_REQUEST['ad_method'] : null;
     $id = isset($_REQUEST['ad_id']) ? (string) $_REQUEST['ad_id'] : null;
     $arguments = isset($_REQUEST['ad_args']) ? $_REQUEST['ad_args'] : array();
     if (is_string($arguments)) {
         $arguments = stripslashes($arguments);
         $arguments = json_decode($arguments, true);
     }
     $adIds = isset($_REQUEST['ad_ids']) ? $_REQUEST['ad_ids'] : null;
     if (is_string($adIds)) {
         $adIds = json_decode($adIds, true);
     }
     $response = array();
     if (isset($methods[$method]) && isset($id)) {
         $advads = Advanced_Ads::get_instance();
         if (is_array($adIds)) {
             // ads loaded previously and passed by query
             $advads->current_ads += $adIds;
         }
         $l = count($advads->current_ads);
         // build content
         $content = $selector->get_ad_by_method($id, $method, $arguments);
         $adIds = array_slice($advads->current_ads, $l);
         // ads loaded by this request
         $response = array('status' => 'success', 'item' => $content, 'id' => $id, 'method' => $method, 'ads' => $adIds);
     } else {
         // report error
         $response = array('status' => 'error', 'message' => 'No valid ID or METHOD found.');
     }
     echo json_encode($response);
     die;
 }
    /**
     * load content of the ad parameter metabox
     *
     * @since 1.0.0
     */
    public function load_ad_parameters_metabox()
    {
        $types = Advanced_Ads::get_instance()->ad_types;
        $type = $_REQUEST['ad_type'];
        $ad_id = absint($_REQUEST['ad_id']);
        if (empty($ad_id)) {
            wp_die();
        }
        $ad = new Advanced_Ads_Ad($ad_id);
        if (!empty($types[$type]) && method_exists($types[$type], 'render_parameters')) {
            $types[$type]->render_parameters($ad);
            ?>
			<div id="advanced-ads-ad-parameters-size">
				<p><?php 
            _e('size:', 'advanced-ads');
            ?>
</p>
				<label><?php 
            _e('width', 'advanced-ads');
            ?>
<input type="number" size="4" maxlength="4" value="<?php 
            echo isset($ad->width) ? $ad->width : 0;
            ?>
" name="advanced_ad[width]">px</label>
				<label><?php 
            _e('height', 'advanced-ads');
            ?>
<input type="number" size="4" maxlength="4" value="<?php 
            echo isset($ad->height) ? $ad->height : 0;
            ?>
" name="advanced_ad[height]">px</label>
			</div>
			<?php 
        }
        wp_die();
    }
示例#6
0
 /**
  * return content of a placement
  *
  * @since 1.1.0
  * @param string $id   slug of the display
  * @param array  $args optional arguments (passed to child)
  */
 public static function output($id = '', $args = array())
 {
     // get placement data for the slug
     if ($id == '') {
         return;
     }
     $placements = Advanced_Ads::get_ad_placements_array();
     if (isset($placements[$id]['item']) && $placements[$id]['item'] !== '') {
         $_item = explode('_', $placements[$id]['item']);
         if (!isset($_item[1]) || empty($_item[1])) {
             return;
         }
         // inject options
         if (isset($placements[$id]['options']) && is_array($placements[$id]['options'])) {
             foreach ($placements[$id]['options'] as $_k => $_v) {
                 if (!isset($args[$_k])) {
                     $args[$_k] = $_v;
                 }
             }
         }
         // return either ad or group content
         switch ($_item[0]) {
             case 'ad':
             case Advanced_Ads_Select::AD:
                 // create class from placement id (not if header injection)
                 if (!isset($placements[$id]['type']) || $placements[$id]['type'] !== 'header') {
                     if (!isset($args['output'])) {
                         $args['output'] = array();
                     }
                     if (!isset($args['output']['class'])) {
                         $args['output']['class'] = array();
                     }
                     $class = 'advads-' . $id;
                     if (!in_array($class, $args['output']['class'])) {
                         $args['output']['class'][] = $class;
                     }
                 }
                 // fix method id
                 $_item[0] = Advanced_Ads_Select::AD;
                 break;
                 // avoid loops (programmatical error)
             // avoid loops (programmatical error)
             case Advanced_Ads_Select::PLACEMENT:
                 return;
             case Advanced_Ads_Select::GROUP:
             default:
         }
         // add the placement to the global output array
         $advads = Advanced_Ads::get_instance();
         $advads->current_ads[] = array('type' => 'placement', 'id' => $id, 'title' => $placements[$id]['name']);
         return Advanced_Ads_Select::get_instance()->get_ad_by_method((int) $_item[1], $_item[0], $args);
     }
 }
    /**
     * render next-steps
     */
    private static function render_next_steps($recent_ads = array())
    {
        $model = Advanced_Ads::get_instance()->get_model();
        $groups = $model->get_ad_groups();
        $placements = $model->get_ad_placements_array();
        $next_steps = array();
        if (count($recent_ads) == 0) {
            $next_steps[] = '<p><a class="button button-primary" href="' . admin_url('post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG) . '">' . __('Create your first ad', 'advanced-ads') . '</a></p>';
        }
        if (count($groups) == 0) {
            $next_steps[] = '<p class="description">' . __('Ad Groups contain ads and are currently used to rotate multiple ads on a single spot.', 'advanced-ads') . '</p>' . '<p><a class="button button-primary" href="' . admin_url('admin.php?action=edit&page=advanced-ads-groups') . '">' . __('Create your first group', 'advanced-ads') . '</a></p>';
        }
        if (count($placements) == 0) {
            $next_steps[] = '<p class="description">' . __('Ad Placements are the best way to manage where to display ads and groups.', 'advanced-ads') . '</p>' . '<p><a class="button button-primary" href="' . admin_url('admin.php?action=edit&page=advanced-ads-placements') . '">' . __('Create your first placement', 'advanced-ads') . '</a></p>';
        }
        // display all options
        if (count($next_steps) > 0) {
            ?>
<br/><h4><?php 
            _e('Next steps', 'advanced-ads');
            ?>
</h4><?php 
            foreach ($next_steps as $_step) {
                echo $_step;
            }
        }
    }
示例#8
0
 /**
  * render setting to enable/disable adblocker
  *
  */
 public function render_settings_use_adblocker()
 {
     $advads_options = Advanced_Ads::get_instance()->options();
     $checked = !empty($advads_options['use-adblocker']) ? 1 : 0;
     echo '<input id="advanced-ads-use-adblocker" type="checkbox" value="1" name="' . ADVADS_SLUG . '[use-adblocker]" ' . checked($checked, 1, false) . '>';
     echo '<p class="description">' . __('Prevents ad block software from breaking your website when blocking asset files (.js, .css).', 'advanced-ads') . '</p>';
 }
示例#9
0
 /**
  * get widget placements for select field
  * 
  * @since 1.6.11
  * @return arr $items for select field
  */
 public static function widget_placements_for_select()
 {
     $select = array();
     $placements = Advanced_Ads::get_ad_placements_array();
     foreach ($placements as $_placement_slug => $_placement) {
         if (isset($_placement['type']) && 'sidebar_widget' === $_placement['type']) {
             $select['placements']['placement_' . $_placement_slug] = $_placement['name'];
         }
     }
     return $select;
 }
 /**
  * Return an instance of this class.
  *
  * @since     1.0.0
  * @return    Advanced_Ads    A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#11
0
    return;
}
// load basic path to the plugin
define('ADVADS_BASE_PATH', plugin_dir_path(__FILE__));
define('ADVADS_BASE_URL', plugin_dir_url(__FILE__));
define('ADVADS_BASE_DIR', dirname(plugin_basename(__FILE__)));
// directory of the plugin without any paths
// general and global slug, e.g. to store options in WP, textdomain
define('ADVADS_SLUG', 'advanced-ads');
define('ADVADS_URL', 'https://wpadvancedads.com/');
define('ADVADS_VERSION', '1.6.2.1');
/*----------------------------------------------------------------------------*
 * Autoloading, modules and functions
 *----------------------------------------------------------------------------*/
// load public functions (might be used by modules, other plugins or theme)
require_once ADVADS_BASE_PATH . 'includes/functions.php';
require_once ADVADS_BASE_PATH . 'includes/load_modules.php';
Advanced_Ads_ModuleLoader::getLoader();
// enable autoloading
/*----------------------------------------------------------------------------*
 * Public-Facing and Core Functionality
 *----------------------------------------------------------------------------*/
Advanced_Ads::get_instance();
Advanced_Ads_ModuleLoader::loadModules(ADVADS_BASE_PATH . 'modules/');
// enable modules, requires base class
/*----------------------------------------------------------------------------*
 * Dashboard and Administrative Functionality
 *----------------------------------------------------------------------------*/
if (is_admin()) {
    Advanced_Ads_Admin::get_instance();
}
示例#12
0
 /**
  * control the output of the group by type and amount of ads
  *
  * @since 1.4.8
  * @return str $output output of ad(s) by ad
  */
 public function output()
 {
     if (!$this->id) {
         return;
     }
     // load ads
     $ads = $this->load_all_ads();
     if ($ads === array()) {
         return;
     }
     // get ad weights serving as an order here
     $weights = $this->get_ad_weights();
     asort($weights);
     // if ads and weights don’t have the same keys, update weights array
     if (count($weights) == 0 && count($ads) > 0 || count($weights) != count($ads) || array_diff_key($weights, $ads) != array() || array_diff_key($ads, $weights) != array()) {
         $this->update_ad_weights();
         $weights = $this->ad_weights;
     }
     // remove ads with 0 ad weight
     foreach ($weights as $_ad_id => $_ad_weight) {
         if ($_ad_weight === 0) {
             unset($weights[$_ad_id]);
         }
     }
     // order ads based on group type
     switch ($this->type) {
         case 'ordered':
             // order to highest weight first
             arsort($weights);
             $ordered_ad_ids = array_keys($weights);
             break;
         default:
             // default
             $ordered_ad_ids = $this->shuffle_ads($ads, $weights);
     }
     $ordered_ad_ids = apply_filters('advanced-ads-group-output-ad-ids', $ordered_ad_ids, $this->type, $ads, $weights);
     // load the ad output
     $output = array();
     $ads_displayed = 0;
     $ad_count = apply_filters('advanced-ads-group-ad-count', $this->ad_count, $this);
     $ad_select = Advanced_Ads_Select::get_instance();
     foreach ($ordered_ad_ids as $_ad_id) {
         // load the ad object
         $ad = $ad_select->get_ad_by_method($_ad_id, Advanced_Ads_Select::AD, $this->ad_args);
         if ($ad !== null) {
             $output[] = $ad;
             $ads_displayed++;
             // break the loop when maximum ads are reached
             if ($ads_displayed === $ad_count) {
                 break;
             }
         }
     }
     // add the group to the global output array
     $advads = Advanced_Ads::get_instance();
     $advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
     // filter grouped ads output
     $output_string = implode('', apply_filters('advanced-ads-group-output-array', $output, $this));
     // filter final group output
     return apply_filters('advanced-ads-group-output', $output_string, $this);
 }
    /**
     * display widget functions
     */
    public static function dashboard_widget_function($post, $callback_args)
    {
        // load ad optimization feed
        $feeds = array(array('link' => 'http://webgilde.com/en/ad-optimization/', 'url' => 'http://webgilde.com/en/ad-optimization/feed/', 'title' => __('From the ad optimization universe', ADVADS_SLUG), 'items' => 2, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0), array('link' => ADVADS_URL, 'url' => ADVADS_URL . 'feed/', 'title' => __('Advanced Ads Tutorials', ADVADS_SLUG), 'items' => 2, 'show_summary' => 0, 'show_author' => 0, 'show_date' => 0));
        // get number of ads
        $recent_ads = Advanced_Ads::get_instance()->get_model()->get_ads();
        echo '<p>';
        printf(__('%d ads – <a href="%s">manage</a> - <a href="%s">new</a>', ADVADS_SLUG), count($recent_ads), 'edit.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG, 'post-new.php?post_type=' . Advanced_Ads::POST_TYPE_SLUG);
        echo '</p>';
        // get and display plugin version
        $advads_plugin_data = get_plugin_data(ADVADS_BASE_PATH . 'advanced-ads.php');
        if (isset($advads_plugin_data['Version'])) {
            $version = $advads_plugin_data['Version'];
            echo '<p><a href="' . ADVADS_URL . '" target="_blank" title="' . __('plugin manual and homepage', ADVADS_SLUG) . '">Advanced Ads</a> ' . $version . '</p>';
        }
        $notice_options = Advanced_Ads_Admin_Notices::get_instance()->options();
        $_notice = 'nl_first_steps';
        if (!isset($notice_options['closed'][$_notice])) {
            ?>
<div class="advads-admin-notice">
				    <p><button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php 
            echo $_notice;
            ?>
"><?php 
            _e('Get the tutorial via email', ADVADS_SLUG);
            ?>
</button></p>
				</div><?php 
        }
        $_notice = 'nl_adsense';
        if (!isset($notice_options['closed'][$_notice])) {
            ?>
<div class="advads-admin-notice">
				    <p><button type="button" class="button-primary advads-notices-button-subscribe" data-notice="<?php 
            echo $_notice;
            ?>
"><?php 
            _e('Get AdSense tips via email', ADVADS_SLUG);
            ?>
</button></p>
				</div><?php 
        }
        // rss feed
        // $this->dashboard_widget_function_output('advads_dashboard_widget', $feed);
        self::dashboard_cached_rss_widget('advads_dashboard_widget', array('Advanced_Ads_Admin', 'dashboard_widget_function_output'), array('advads' => $feeds));
    }
示例#14
0
/**
 * return true if ads can be displayed
 *
 * @since 1.4.9
 * @return bool, true if ads can be displayed
 */
function advads_can_display_ads()
{
    return Advanced_Ads::get_instance()->can_display_ads();
}
        <li><?php 
_e('If you want to display the ad everywhere, don\'t do anything here. ', 'advanced-ads');
?>
</li>
        <li><?php 
_e('The fewer conditions you enter, the better the performance will be.', 'advanced-ads');
?>
</li>
        <li><?php 
printf(__('Learn more about display conditions from the <a href="%s" target="_blank">manual</a>.', 'advanced-ads'), ADVADS_URL . 'manual/display-conditions/#utm_source=advanced-ads&utm_medium=link&utm_campaign=edit-display');
?>
</li>
    </ul>
    <?php 
// -TODO use model
$advanced_ads_ad_conditions = Advanced_Ads::get_ad_conditions();
if (is_array($advanced_ads_ad_conditions)) {
    foreach ($advanced_ads_ad_conditions as $_key => $_condition) {
        if (!isset($_condition['callback'])) {
            continue;
        }
        ?>
<div class="advanced-ad-display-condition">
            <?php 
        if (is_array($_condition['callback']) && method_exists($_condition['callback'][0], $_condition['callback'][1])) {
            call_user_func(array($_condition['callback'][0], $_condition['callback'][1]), $ad);
            // works also in php below 5.3
            // $_condition['callback'][0]::$_condition['callback'][1]($ad); // works only in php 5.3 and above
        }
        ?>
</div><?php 
 /**
  * helper for check with strings
  *
  * @since 1.6.3
  * @param str $string string that is going to be checked
  * @return bool true if ad can be displayed
  */
 static function helper_check_string($string = '', $options = array())
 {
     if (!isset($options['operator']) || !isset($options['value']) || '' === $options['value']) {
         return true;
     }
     $operator = $options['operator'];
     $value = $options['value'];
     // check length of url
     if ($operator !== 'regex' && $operator !== 'regex_not') {
         if (strlen($value) > strlen($string)) {
             return false;
         }
     }
     // check the condition by mode and bool
     $condition = true;
     switch ($operator) {
         // referrer contains string on any position
         case 'contain':
             $condition = stripos($string, $value) !== false;
             break;
             // referrer does not contain string on any position
         // referrer does not contain string on any position
         case 'contain_not':
             $condition = stripos($string, $value) === false;
             break;
             // referrer starts with the string
         // referrer starts with the string
         case 'start':
             $condition = stripos($string, $value) === 0;
             break;
             // referrer does not start with the string
         // referrer does not start with the string
         case 'start_not':
             $condition = stripos($string, $value) !== 0;
             break;
             // referrer ends with the string
         // referrer ends with the string
         case 'end':
             // check if string is longer than referrer
             $strlen = strlen($string);
             $vallen = strlen($value);
             $condition = substr_compare($string, $value, $strlen - $vallen, $vallen, true) === 0;
             break;
             // referrer does not end with the string
         // referrer does not end with the string
         case 'end_not':
             // check if string is longer than referrer
             $strlen = strlen($string);
             $vallen = strlen($value);
             $condition = substr_compare($string, $value, $strlen - $vallen, $vallen, true) !== 0;
             break;
             // referrer is equal to the string
         // referrer is equal to the string
         case 'match':
             // strings do match, but should not or not match but should
             $condition = strcasecmp($value, $string) === 0;
             break;
             // referrer is not equal to the string
         // referrer is not equal to the string
         case 'match_not':
             // strings do match, but should not or not match but should
             $condition = strcasecmp($value, $string) !== 0;
             break;
             // string is a regular expression
         // string is a regular expression
         case 'regex':
             // check regular expression first
             if (@preg_match($value, null) === false) {
                 Advanced_Ads::log("Advanced Ads: regular expression '{$value}' in visitor condition is broken.");
             } else {
                 $condition = preg_match($value, $string);
             }
             break;
             // string is not a regular expression
         // string is not a regular expression
         case 'regex_not':
             if (@preg_match($value, null) === false) {
                 Advanced_Ads::log("Advanced Ads: regular expression '{$value}' in visitor condition is broken.");
             } else {
                 $condition = !preg_match($value, $string);
             }
             break;
     }
     return $condition;
 }
<?php

/**
 * conditions under which to (not) show an ad
 * I don’t like huge arrays like this to clutter my classes
 *  and anyway, this might be needed on multiple places
 *
 * at the bottom, you find a filter to be able to extend / remove your own elements
 *
 * elements
 * key - internal id of the condition; needs to be unique, obviously
 * label - title in the dashboard
 * description - (optional) description displayed in the dashboard
 * type - information / markup type
 *      idfield - input field for comma separated lists of ids
 *      radio - radio button
 *      others - added to not trigger internal sanitization
 *
 * note: ’idfield’ always has a {field}_not version that is created automatically and being its own condition
 *
 */
// avoid direct execution
if (!class_exists('Advanced_Ads', false)) {
    die;
}
$advanced_ads_slug = Advanced_Ads::get_instance()->get_plugin_slug();
$advanced_ads_ad_conditions = array('enabled' => array('type' => 'other'), 'posttypes' => array('label' => __('Post Types', $advanced_ads_slug), 'description' => __('Choose the public post types on which to display the ad.', $advanced_ads_slug), 'type' => 'textvalues', 'callback' => array('Advanced_Ads_Display_Condition_Callbacks', 'post_types')), 'categoryids' => array('label' => __('Categories, Tags and Taxonomies', $advanced_ads_slug), 'description' => __('Choose terms from public category, tag and other taxonomies a post must belong to in order to have ads.', $advanced_ads_slug), 'type' => 'idfield', 'callback' => array('Advanced_Ads_Display_Condition_Callbacks', 'terms')), 'categoryarchiveids' => array('label' => __('Category Archives', $advanced_ads_slug), 'description' => __('comma seperated IDs of category archives', $advanced_ads_slug), 'type' => 'idfield', 'callback' => array('Advanced_Ads_Display_Condition_Callbacks', 'category_archives')), 'postids' => array('label' => __('Individual Posts, Pages and Public Post Types', $advanced_ads_slug), 'description' => __('Choose on which individual posts, pages and public post type pages you want to display or hide ads.', $advanced_ads_slug), 'type' => 'other', 'callback' => array('Advanced_Ads_Display_Condition_Callbacks', 'single_posts')), 'is_front_page' => array('label' => __('Home Page', $advanced_ads_slug), 'description' => __('show on Home page', $advanced_ads_slug), 'type' => 'radio'), 'is_singular' => array('label' => __('Singular Pages', $advanced_ads_slug), 'description' => __('show on singular pages/posts', $advanced_ads_slug), 'type' => 'radio'), 'is_archive' => array('label' => __('Archive Pages', $advanced_ads_slug), 'description' => __('show on any type of archive page (category, tag, author and date)', $advanced_ads_slug), 'type' => 'radio'), 'is_search' => array('label' => __('Search Results', $advanced_ads_slug), 'description' => __('show on search result pages', $advanced_ads_slug), 'type' => 'radio'), 'is_404' => array('label' => __('404 Page', $advanced_ads_slug), 'description' => __('show on 404 error page', $advanced_ads_slug), 'type' => 'radio'), 'is_attachment' => array('label' => __('Attachment Pages', $advanced_ads_slug), 'description' => __('show on attachment pages', $advanced_ads_slug), 'type' => 'radio'), 'is_main_query' => array('label' => __('Secondary Queries', $advanced_ads_slug), 'description' => __('allow ads in secondary queries', $advanced_ads_slug), 'type' => 'radio'));
return apply_filters('advanced-ads-conditions', $advanced_ads_ad_conditions);
示例#18
0
 /**
  * flush rewrites on plugin activation so permalinks for them work from the beginning on
  *
  * @since 1.0.0
  * @link http://codex.wordpress.org/Function_Reference/register_post_type#Flushing_Rewrite_on_Activation
  */
 public function post_types_rewrite_flush()
 {
     // load custom post type
     Advanced_Ads::get_instance()->create_post_types();
     // flush rewrite rules
     flush_rewrite_rules();
 }
示例#19
0
if (Advanced_Ads_Checks::plugin_updates_available()) {
    $messages[] = __('There are <strong>plugin updates available</strong>. Please update.', 'advanced-ads');
}
if (Advanced_Ads_Checks::licenses_invalid()) {
    $messages[] = sprintf(__('One or more license keys for <strong>Advanced Ads add-ons are invalid or missing</strong>. Please add valid license keys <a href="%s">here</a>.', 'advanced-ads'), admin_url('admin.php?page=advanced-ads-settings#top#licenses'));
}
if (Advanced_Ads_Checks::licenses_expired()) {
    $messages[] = sprintf(__('<strong>Advanced Ads</strong> license(s) expired. Support and updates are disabled. Please visit <a href="%s"> the license page</a> for more information.', 'advanced-ads'), admin_url('admin.php?page=advanced-ads-settings#top#licenses'));
}
if (Advanced_Ads_Checks::active_autoptimize() && !defined('AAP_VERSION')) {
    $messages[] = sprintf(__('<strong>Autoptimize plugin detected</strong>. While this plugin is great for site performance, it is known to alter code, including scripts from ad networks. <a href="%s" target="_blank">Advanced Ads Pro</a> has a build-in support for Autoptimize.', 'advanced-ads'), ADVADS_URL . 'add-ons/advanced-ads-pro');
}
if (count(Advanced_Ads_Checks::conflicting_plugins())) {
    $messages[] = sprintf(__('Plugins that are known to cause (partial) problems: <strong>%1$s</strong>. <a href="%2$s" target="_blank">Learn more</a>.', 'advanced-ads'), implode(', ', Advanced_Ads_Checks::conflicting_plugins()), ADVADS_URL . 'manual/known-plugin-conflicts/');
}
$options = Advanced_Ads::get_instance()->options();
if (isset($options['disabled-ads'])) {
    $messages[] = sprintf(__('Ads are disabled for all or some pages. See "disabled ads" in <a href="%s">settings</a>.', 'advanced-ads'), admin_url('admin.php?page=advanced-ads-settings#top#general'));
}
Advanced_Ads_Checks::jquery_ui_conflict();
if (count($messages)) {
    foreach ($messages as $_message) {
        ?>
<div class="message error"><p><?php 
        echo $_message;
        ?>
</p></div><?php 
    }
}
?>
    <h2><?php 
示例#20
0
 /**
  * return ad content for frontend output
  *
  * @since 1.0.0
  * @return string $output ad output
  */
 public function output()
 {
     if (!$this->is_ad) {
         return '';
     }
     $output = $this->prepare_frontend_output();
     // add the ad to the global output array
     $advads = Advanced_Ads::get_instance();
     $advads->current_ads[] = array('type' => 'ad', 'id' => $this->id, 'title' => $this->title);
     // action when output is created
     do_action('advanced-ads-output', $this, $output);
     return $output;
 }
<?php

$types = Advanced_Ads::get_instance()->ad_types;
/**
 * when changing ad type ad parameter content is loaded via ajax
 * @filesource admin/assets/js/admin.js
 * @filesource includes/class-ajax-callbacks.php ::load_ad_parameters_metabox
 * @filesource classes/ad-type-content.php :: renter_parameters()
 */
do_action('advanced-ads-ad-params-before', $ad, $types);
?>
<div id="advanced-ads-ad-parameters">
    <?php 
$type = isset($types[$ad->type]) ? $types[$ad->type] : current($types);
$type->render_parameters($ad);
?>
    <div id="advanced-ads-ad-parameters-size">
        <p><?php 
_e('size:', ADVADS_SLUG);
?>
</p>
        <label><?php 
_e('width', ADVADS_SLUG);
?>
<input type="number" size="4" maxlength="4" value="<?php 
echo isset($ad->width) ? $ad->width : 0;
?>
" name="advanced_ad[width]">px</label>
        <label><?php 
_e('height', ADVADS_SLUG);
?>
 /**
  * get items for item select field
  *
  * @return arr $select items for select field
  */
 public static function items_for_select()
 {
     $select = array();
     $model = Advanced_Ads::get_instance()->get_model();
     // load all ads
     $ads = $model->get_ads(array('orderby' => 'name', 'order' => 'ASC'));
     foreach ($ads as $_ad) {
         $select['ads']['ad_' . $_ad->ID] = $_ad->post_title;
     }
     // load all ad groups
     $groups = $model->get_ad_groups();
     foreach ($groups as $_group) {
         $select['groups']['group_' . $_group->term_id] = $_group->name;
     }
     // load all placements
     $placements = $model->get_ad_placements_array();
     foreach ($placements as $key => $_placement) {
         $select['placements']['placement_' . $key] = $_placement['name'];
     }
     return $select;
 }
示例#23
0
 /**
  * control the output of the group by type and amount of ads
  *
  * @since 1.4.8
  * @param array/null ordered_ad_ids ordered ids of the ads that belong to the group
  * @return str $output output of ad(s) by ad
  */
 public function output($ordered_ad_ids = false)
 {
     // if $ordered_ad_ids was not passed to the function, load it
     $ordered_ad_ids = $ordered_ad_ids === false ? $this->get_ordered_ad_ids() : $ordered_ad_ids;
     if ($ordered_ad_ids === null) {
         return;
     }
     // load the ad output
     $output = array();
     $ads_displayed = 0;
     $ad_count = apply_filters('advanced-ads-group-ad-count', $this->ad_count, $this);
     $ad_select = Advanced_Ads_Select::get_instance();
     foreach ($ordered_ad_ids as $_ad_id) {
         // load the ad object
         $ad = $ad_select->get_ad_by_method($_ad_id, Advanced_Ads_Select::AD, $this->ad_args);
         if ($ad !== null) {
             $output[] = $ad;
             $ads_displayed++;
             // break the loop when maximum ads are reached
             if ($ads_displayed === $ad_count) {
                 break;
             }
         }
     }
     // add the group to the global output array
     $advads = Advanced_Ads::get_instance();
     $advads->current_ads[] = array('type' => 'group', 'id' => $this->id, 'title' => $this->name);
     // filter grouped ads output
     $output_string = implode('', apply_filters('advanced-ads-group-output-array', $output, $this));
     // filter final group output
     return apply_filters('advanced-ads-group-output', $output_string, $this);
 }