Coder Social home page Coder Social logo

automattic / ad-code-manager Goto Github PK

View Code? Open in Web Editor NEW
118.0 128.0 56.0 2.45 MB

Easily manage the ad codes that need to appear in your templates

Home Page: https://wordpress.org/plugins/ad-code-manager/

License: GNU General Public License v2.0

PHP 82.36% CSS 2.22% JavaScript 10.19% Shell 5.23%
wordpress wordpress-plugin advertisement-management doubleclick-for-publishers google-adsense wpvip-plugin

ad-code-manager's Introduction

Ad Code Manager

Stable tag: 0.7.1
Requires at least: 5.7
Tested up to: 5.9
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Tags: advertising, ad codes, ads, adsense, dfp, doubleclick for publishers
Contributors: rinatkhaziev, jeremyfelt, danielbachhuber, carldanley, zztimur, automattic, doejo

Manage your ad codes through the WordPress admin safely and easily.

Description

Ad Code Manager gives non-developers an interface in the WordPress admin for configuring your complex set of ad codes.

Some code-level configuration may be necessary to set up Ad Code Manager. Ad tags must be added (via do_action()) to your theme's template files where you'd like ads to appear. Alternatively, you can incorporate ad tags into your website with our widget and shortcode. Check out the configuration guide below for the full details.

A common set of parameters must also be defined for your ad provider. This includes the tag IDs used by your template, the default URL for your ad provider, and the default HTML surrounding that URL. Ad Code Manager supports Google DoubleClick For Publishers (and Async), and Google AdSense. All the logic is abstracted, however, so configuring a different provider is relatively easy. Check providers/doubleclick-for-publishers.php for an idea of how to extend ACM to suit your needs.

Once this configuration is in place, the Ad Code Manager admin interface will allow you to add new ad codes, modify the parameters for your script URL, and define conditionals to determine when the ad code appears. Conditionals are core WordPress functions like is_page(), is_category(), or your own custom functions that evaluate certain expressions and then return true or false.

Fork the plugin on Github and follow our development blog.

Installation

The plugin requires PHP 7.4 or later. It is also tested WordPress 5.7 and later, though it may run on older versions.

Since the plugin is in its early stages, there are a couple additional configuration steps:

  1. Upload ad-code-manager to the /wp-content/plugins/ directory.
  2. Activate the plugin through the 'Plugins' menu in WordPress.
  3. Incorporate ad tags in your theme template with do_action( 'acm_tag', 'slot' );. Also, you can use [acm-tag id="slot"] shortcode or ACM Widget.
  4. Implement filters to make the plugin work with your provider.
  5. Configure your ad codes in the WordPress admin (Tools -> Ad Code Manager).

Screenshots

  1. Adding an ad code with a site name, zone, and multiple conditionals. Adding an ad code with a site name, zone, and multiple conditionals.

  2. Edit existing ad codes inline through the admin interface. Edit existing ad codes inline through the admin interface.

  3. Access the Help menu in the upper right for configuration assistance. Access the Help menu in the upper right for configuration assistance.

  4. Example of ad tag in use in a theme header template. Example of ad tag in use in a theme header template.

Configure Ad Code Manager to manage the advertisements on your site

Ad Code Manager is a VIP-sponsored plugin designed to make managing the ad codes used to display advertisements on your site easier. There's a little bit of work you'll need to do upfront to integrate Ad Code Manager with your theme.

The high-level idea behind Ad Code Manager is that it gives non-developers an admin interface to manage ad codes. It then permits users to (optionally) target specific ad codes using conditionals like is_home() and is_single(). Ad codes are associated with positions in the theme through the use of ad tags.

Currently, Ad Code Manager easily integrates with Google DoubleClick For Publishers Async and Google AdSense. Other ad providers are supported with additional configuration.

Google AdSense and DoubleClick For Publishers Async

Let's use AdSense as our first example. You'll want to incorporate some of the default ad tags into your theme by use of do_action(). Here's an example you might put in your header.php file:

do_action( 'acm_tag', '728x90_leaderboard' );

Once done, you can select the "Google AdSense" provider in the admin. Ad codes can be registered against ad tags (positions) by choosing the ad tag from the drop-down, entering the tag ID and publisher ID, and hitting "Add New Ad Code".

And like that, your 728x90 leaderboard will appear on your site.

The Google AdSense configuration comes with many of Google's suggested sizes. Additional ad tags can be registered by way of filtering:

add_filter( 'acm_ad_tag_ids', 'acmx_filter_ad_tag_ids' );
function acmx_filter_ad_tag_ids( $ids ) {
	$ids[] = array(
		'enable_ui_mapping' => true,
		'tag'               => '100x100_smallsquare',
		'url_vars'          => array(
			'tag'    => '100x100_smallsquare',
			'height' => '100',
			'width'  => '100',
		),
	);

	return $ids;
}

Keep in mind that you'll still need to incorporate a do_action( 'acm_tag', '100x100_smallsquare' ); in your theme to display the ad tag.

If you choose Google DFP Async as your provider, you'll likely need to register additional ad tags, as we only package two default ad tags.

Custom Ad Provider Implementations

As mentioned previously, other ad code providers are supported with additional configuration. Here's an example of the different filters you would use to configure the older version of Google DoubleClick For Publishers:

/**
 * Define the default URL to be used when rendering ad codes
 */
add_filter( 'acm_default_url', 'acmx_filter_default_url' ) ;
function acmx_filter_default_url( $url ) {
	if ( 0 === strlen( $url )  ) {
		return "http://ad.doubleclick.net/adj/%site_name%/%zone1%;s1=%zone1%;s2=;pid=%permalink%;fold=%fold%;kw=;test=%test%;ltv=ad;pos=%pos%;dcopt=%dcopt%;tile=%tile%;sz=%sz%;";
	}
}

/**
 * Whitelist the DFP URL to be used in ad tags. The whitelist
 * helps prevent execution of arbitrary scripts
 */
add_filter( 'acm_whitelisted_script_urls', 'acmx_filter_whitelisted_script_urls');
function acmx_filter_whitelisted_script_urls( $whitelisted_urls ) {
	$whitelisted_urls = array( 'ad.doubleclick.net' );
	return $whitelisted_urls;
}

/**
 * Define the different ad tags (locations) you'd like to use in your theme
 */
add_filter( 'acm_ad_tag_ids', 'acmx_ad_tags_ids' );
function acmx_ad_tags_ids( $ad_tag_ids ) {
	return array(
		array(
			'tag'      => '728x90-atf',
			'url_vars' => array(
				'sz'     => '728x90',
				'fold'   => 'atf',
				'width'  => '728',
				'height' => '90',
			),
		),
		array(
			'tag'      => '728x90-btf',
			'url_vars' => array(
				'sz'     => '728x90',
				'fold'   => 'btf',
				'width'  => '728',
				'height' => '90',
			),
		),
		array(
			'tag'      => '300x250-atf',
			'url_vars' => array(
				'sz'     => '300x250',
				'fold'   => 'atf',
				'width'  => '300',
				'height' => '250',
			),
		),
		array(
			'tag'      => '300x250-btf',
			'url_vars' => array(
				'sz'     => '300x250',
				'fold'   => 'btf',
				'width'  => '300',
				'height' => '250',
			),
		),
		array(
			'tag'      => '160x600-atf',
			'url_vars' => array(
				'sz'     => '160x600',
				'fold'   => 'atf',
				'width'  => '160',
				'height' => '600',
			),
		),
		array(
			'tag'      => '1x1',
			'url_vars' => array(
				'sz'   => '1x1',
				'fold' => 'int',
				'pos'  => 'top',
			),
		)
	);
}

add_filter( 'acm_output_html','acmx_filter_output_html', 5, 2 );
/**
 * Register the full script output to use with each ad tag.
 */
function acmx_filter_output_html( $output_html, $tag_id ) {
	$output_html = '<!-- DFP %pos% %sz% ad tag --> 
	<script>
if ( typeof ord=='undefined' ) { ord=Math.random()*10000000000000000; }
if ( typeof( dfp_tile ) == 'undefined' ) { dfp_tile=%tile% };
document.write('<script src="%url%ord=' + ord + '?"></script>');
</script><noscript><a href="%url%ord=%random%?" target="_blank"><img src="%url%ord=%random%?" width="%width%" height="%height%" border="0" alt="></a></noscript>
<!-- //DFP %pos% %sz% tag -->';
	return $output_html;
}

add_filter('acm_output_tokens', 'acmx_filter_output_tokens', 5, 3 );
/**
 * Fine tune our output tokens.
 *
 * This is the real example of how easily you can modify output
 * depending on your ad network specs.
 */
function acmx_filter_output_tokens( $output_tokens, $tag_id, $code_to_display ) {
	global $dfp_tile;
	global $dfp_ord;
	global $dfp_pos;
	global $dfp_dcopt;
	global $wp_query;
	
	// We can't really rely on get_permalink() so use $_SERVER['REQUEST_URI] as bulletproof solution for generating unique pids
	$link = strlen( $_SERVER['REQUEST_URI'] ) > 1 ? sanitize_key( $_SERVER['REQUEST_URI'] ) : home_url();
	$output_tokens['%permalink%'] = str_replace( array( '/',':', '.' ), '', $link ); 
	$output_tokens['%random%']    = $dfp_ord;
	$output_tokens['%tile%']      = ++$dfp_tile;
	if (  false === $dfp_pos[ $code_to_display['url_vars']['sz'] ] ) {
		$output_tokens['%pos%']                        = 'top';
		$dfp_pos[ $code_to_display['url_vars']['sz'] ] = true;
	} else {
		$output_tokens['%pos%'] = 'bottom';
	}
	if ( ! $dfp_dcopt ) {
		$output_tokens['%dcopt%'] = 'ist';
		$dfp_dcopt                = true;
	} else {
		$output_tokens['%dcopt%'] = '';
	}
	
	$output_tokens['%test%'] = isset( $_GET['test'] ) && $_GET['test'] == 'on' ? 'on' : '';
	
	return $output_tokens;
}

Configuration Filters

There are some filters which allow you to easily customize the output of the plugin. You should place these filters in your theme's functions.php file or in another appropriate place.

Check out this gist to see all of the filters in action.

acm_ad_tag_ids

Ad tag IDs are used as a parameter when adding tags to your theme (e.g. do_action( 'acm_tag', 'my_top_leaderboard' )). The url_vars defined as part of each tag here will also be used to replace tokens in your default URL.

Arguments:

  • array $tag_ids array of default tag IDs

Example usage: Add a new ad tag called 'my_top_leaderboard'

add_filter( 'acm_ad_tag_ids', 'my_acm_ad_tag_ids' );
function my_acm_ad_tag_ids( $tag_ids ) {
	$tag_ids[] = array(
		'tag'      => 'my_top_leaderboard', // tag_id
		'url_vars' => array(
			'sz'              => '728x90', // %sz% token
			'fold'            => 'atf', // %fold% token
			'my_custom_token' => 'something' // %my_custom_token% will be replaced with 'something'
		),
	);
	return $tag_ids;
}

acm_default_url

Set the default tokenized URL used when displaying your ad tags. This filter is required.

Arguments:

  • string $url The tokenized URL of Ad Code

Example usage: Set your default ad code URL

add_filter( 'acm_default_url', 'my_acm_default_url' );
function my_acm_default_url( $url ) {
	if ( 0 === strlen( $url ) ) {
		return "http://ad.doubleclick.net/adj/%site_name%/%zone1%;s1=%zone1%;s2=;pid=%permalink%;fold=%fold%;kw=;test=%test%;ltv=ad;pos=%pos%;dcopt=%dcopt%;tile=%tile%;sz=%sz%;";
	}
}

acm_output_html

The HTML outputted by the do_action( 'acm_tag', 'ad_tag_id' ); call in your theme. Support multiple ad formats (e.g. JavaScript or simple HTML tags) by adjusting the HTML rendered for a given ad tag.

The %url% token used in this HTML will be filled in with the URL defined with acm_default_url.

Arguments:

  • string $output_html The original output HTML
  • string $tag_id Ad tag currently being accessed

Example usage:

add_filter( 'acm_output_html', 'my_acm_output_html', 10, 2 );
function my_acm_output_html( $output_html, $tag_id ) {
	switch ( $tag_id ) {
		case 'my_leaderboard':
			$output_html = '<a href="%url%"><img src="%image_url%" /></a>';
			break;
		case 'rich_media_leaderboard':
			$output_html = '<script> // omitted </script>';
			break;
		default:
			break;
	}
	return $output_html;
}

acm_register_provider_slug

Ad Code Manager has a built-in list of providers that it gathers by scanning the 'providers' directory used by the plugin. Additional providers can be added by placing the appropriate files in that directory or using the acm_register_provider_slug filter to register those that may be included as part of your theme or another plugin.

When using this plugin, you are defining the provider slug as part of the existing object as well as an array of classes associated with that provider slug.

Arguments:

  • object $providers An object containing the current registered providers.

Example usage:

add_filter( 'acm_register_provider_slug', 'my_acm_register_provider_slug' );
function my_acm_register_provider_slug( $providers ) {
	$providers->new_provider_slug = array(
		'provider' => 'My_New_Ad_Company_ACM_Provider',
		'table'    => 'My_New_Ad_Company_ACM_WP_List_Table'
	);

	return $providers;
}

acm_whitelisted_script_urls

A security filter to define a safelist for which ad code script URLs can be added in the admin.

Arguments:

  • array $whitelisted_urls Existing whitelisted ad code URLs

Example usage: Allow DoubleClick for Publishers ad codes to be used

add_filter( 'acm_whitelisted_script_urls', 'my_acm_safelisted_script_urls' );
function my_acm_safelisted_script_urls( $safelisted_urls ) {
	$safelisted_urls = array( 'ad.doubleclick.net' );
	return $safelisted_urls;
}

acm_output_tokens

Output tokens can be registered depending on the needs of your setup. Tokens defined here will be replaced in the ad tag's tokenized URL in addition to the tokens already registered with your tag ID.

Arguments:

  • array $output_tokens Any existing output tokens
  • string $tag_id Unique tag ID
  • array $code_to_display Ad Code that matched conditionals

Example usage: Test to determine whether you're in test or production by passing ?test=on query argument

add_filter( 'acm_output_tokens', 'my_acm_output_tokens', 10, 3 );
function my_acm_output_tokens( $output_tokens, $tag_id, $code_to_display ) {
	$output_tokens['%test%'] = isset( $_GET['test'] ) && $_GET['test'] == 'on' ? 'on' : '';
	return $output_tokens;
}

acm_whitelisted_conditionals

Extend the list of usable conditional functions with your own awesome ones. We safelist these so users can't execute random PHP functions.

Arguments:

  • array $conditionals Default conditionals

Example usage: Register a few custom conditional callbacks

add_filter( 'acm_whitelisted_conditionals', 'my_acm_safelisted_conditionals' );
function my_acm_safelisted_conditionals( $conditionals ) {
	$conditionals[] = 'my_is_post_type';
	$conditionals[] = 'is_post_type_archive';
	$conditionals[] = 'my_page_is_child_of';

	return $conditionals;
}

acm_conditional_args

For certain conditionals (has_tag(), has_category()), you might need to pass additional arguments.

Arguments:

  • array $cond_args Existing conditional arguments
  • string $cond_func Conditional function (is_category(), is_page(), etc.)

Example usage: has_category() and has_tag() use has_term(), which requires the object ID to function properly.

add_filter( 'acm_conditional_args', 'my_acm_conditional_args', 10, 2 );
function my_acm_conditional_args( $cond_args, $cond_func ) {
	global $wp_query;

	// The `has_category()` and `has_tag()` functions call the `has_term()` function.
	// We should pass queried object id for it to produce correct result.
	if ( in_array( $cond_func, array( 'has_category', 'has_tag' ) ) && $wp_query->is_single == true ) {
		$cond_args[] = $wp_query->queried_object->ID;
	}

	// my_page_is_child_of is our custom WP conditional tag and we have to pass queried object ID to it.
	if ( in_array( $cond_func, array( 'my_page_is_child_of' ) ) && $wp_query->is_page ) {
		$cond_args[] = $cond_args[] = $wp_query->queried_object->ID;
	}

	return $cond_args;
}

acm_display_ad_codes_without_conditionals

Change the behavior of Ad Code Manager so that ad codes without conditionals display on the front end. The default behavior is that each ad code requires a conditional to be included in the presentation logic.

Arguments:

  • bool $behavior Whether or not to display the ad codes that don't have conditionals

Example usage:

add_filter( 'acm_display_ad_codes_without_conditionals', '__return_true' );

acm_provider_slug

By default, we use our bundled doubleclick_for_publishers config (check it in /providers/doubleclick-for-publishers.php). If you want to add your own flavor of DFP or even implement configuration for another ad network, you'd have to apply a filter to correct the slug.

Example usage:

add_filter(
	'acm_provider_slug',
	function() {
		return 'my-ad-network-slug';
	}
);

acm_logical_operator

By default, the logical operator is set to "OR", that is, ad code will be displayed if at least one conditional returns true. You can change it to "AND", so that the ad code will be displayed only if ALL the conditionals match.

Example usage:

add_filter(
	'acm_logical_operator',
	function() {
		return 'AND';
	}
);

acm_manage_ads_cap

By default, the user has to have manage_options cap. This filter comes in handy if you want to relax the requirements.

Example usage:

add_filter(
	'acm_manage_ads_cap',
	function( $cap ) {
		return 'edit_others_posts';
	}
);

acm_allowed_get_posts_args

This filter is only for edge cases. Most likely, you won't have to touch it. Allows to include additional query args for Ad_Code_Manager->get_ad_codes() method.

Example usage:

add_filter(
	'acm_allowed_get_posts_args',
	function( $args_array ) {
		return array( 'offset', 'exclude' );
	}
);

acm_ad_code_count

By default, the total number of ad codes to get is 50, which is reasonable for any small to mid-sized site. However, in certain cases, you would want to increase the limit. This will affect Ad_Code_Manager->get_ad_codes() numberposts query argument.

Example usage:

add_filter(
	'acm_ad_code_count',
	function( $total ) {
		return 100;
	}
);

acm_list_table_columns

This filter can alter table columns that are displayed in ACM UI.

Example usage:

add_filter( 'acm_list_table_columns', 'my_acm_list_table_columns' );
function my_acm_list_table_columns( $columns ) {
	$columns = array(
		'id'           => __( 'ID', 'ad-code-manager' ),
		'name'         => __( 'Name', 'ad-code-manager' ),
		'priority'     => __( 'Priority', 'ad-code-manager' ),
		'conditionals' => __( 'Conditionals', 'ad-code-manager' ),
	);

	return $columns;
}

acm_ad_code_args

This filter comes in pair with the previous one. It should return an array of ad network-specific parameters. E.g. in acm_list_table_columns example, we have 'id', 'name', 'priority', and 'conditionals'. All of them except 'name' are generic for Ad Code Manager. Hence, acm_provider_columns should return only "name".

"editable" and "required" indicate whether this field should be editable and required.

Example usage:

add_filter( 'acm_ad_code_args', 'my_acm_ad_code_args' );
function my_acm_ad_code_args( $args ) {
	$args = array(
		array(
			'key'      => 'name',
			'label'    => __( 'Name', 'ad-code-manager' ),
			'editable' => true,
			'required' => true,
		),
	);

	return $args;
}

Change Log

View the change log.

ad-code-manager's People

Contributors

alexiskulash avatar carldanley avatar christianc1 avatar danielbachhuber avatar dependabot[bot] avatar dlh01 avatar garyjones avatar harvitronix avatar jblz avatar jeffsebring avatar jeremyfelt avatar jonathanstegall avatar joshbetz avatar jtsternberg avatar maevelander avatar mjangda avatar nickdaugherty avatar nrg-r9t avatar paulgibbs avatar philipjohn avatar rbcorrales avatar rinatkhaziev avatar sboisvert avatar shantanu2704 avatar sniperwolf avatar spencermorin avatar swissspidy avatar trepmal avatar tylercherpak avatar wboyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ad-code-manager's Issues

Potential issue: we need to check that user accidentally does not remove cb and id columns as it breaks UI

basically, something like this:

add_filter( 'acm_list_table_columns', 'my_acm_list_table_columns' );
function my_acm_list_table_columns( $columns ) {
    $columns = array(
        'site_name'      => __( 'Site Name', 'ad-code-manager' ),
        'zone1'          => __( 'Zone1', 'ad-code-manager' ),
        'campaign'       => __( 'Campaign', 'ad-code-manager' ),
        'priority'       => __( 'Priority', 'ad-code-manager' ),
        'conditionals'   => __( 'Conditionals', 'ad-code-manager' ),
    );
    return $columns;
}

will break UI for good.

bug with acm_display_ad_codes_without_conditionals

Take a look at https://github.com/Automattic/Ad-Code-Manager/blob/develop/ad-code-manager.php#L970.
If we don't have any conditionals and acm_display_ad_codes_without_conditionals returns true we add ad code to display list and then continue. In reality ad code without conditionals still gets to display_list.

Workaround would be:

            if ( empty( $ad_code['conditionals'] ) && ! apply_filters( 'acm_display_ad_codes_without_conditionals', false ) ) {
                continue;
            }

It works fine, but looks bizarre. It's the only one blocker i encountered so far while testing v0.2-alpha against sandboxed copy of a real site.

Feature: ACM in Debug Bar

Would often be useful to have a debug bar extension for Ad Code Manager rather than needing to view the source of a page to confirm that ad tags are displaying right.

So, if this were to happen, what's the thought on where - separate plugin entirely or part of ACM by default?

My initial thought is to make a separate plugin entirely just to avoid extra code in the main ACM codebase.

Rework contextual help

I got an idea this morning. We all know that repetition is bad. So instead of writing a readme section and then duplicating it as a contextual help, we could parse Markdown from readme.

Write a readme

This plugin should have a readme describing how to set it up, etc.

Include screenshots in the documentation

To show potential users what the admin interface looks like and how you should use it, we should include screenshots.

We should probably clean up the admin interface a bit first though.

Ad codes without a priority end up defaulting to zero

This is related to the upgrade path from v0.1.3 to v0.2 and I unfortunately noticed it after I shipped v0.2. It shouldn't be too big of a problem because we have some redundant checks in place.

Basically, ad codes in v0.1.3 didn't have priorities set. In v0.2, our get_ad_codes() query doesn't account for this fact when it should. If the postmeta value returns empty, we should set the priority to 10.

Check if the tag is unique for DFP Async

There might be a case when there are two tags registered with the same dimensions and the same tag id ( which is just a div id ). This confuses DFP Async, so we need to make sure that tags are unique

Update readme with what's new in v0.2

Let's make sure the readme is all up to date with what's new and what we've changed. Going through our Github issues and the commit messages is a good way of tracking this down.

Pagination Idea

Per our first real world tester Steve Baron:

It would be nice to have kind of responsive approach and paginate records only if their total rendered height exceeds available viewport space.

Allow the logical operator to be set on a code by code basis

Say I want one ad code to be evaluated as:

has_tag apple AND
is_singular

and another to be evaluated as

is_category OR
is_tag OR
is_archive

This currently isn't possible. I think the best way to accomodate is by adding another interface element to the admin screen.

Create new priority declaration argument for ad codes

Hey,

has_category produces incorrect results. For example, if we are on home page, and there's a loop with posts where has_category( 'news', $post_id ) equals true, the news ad code will be added to $display_codes

We don't have any control over which code to display:

$code_to_display = $display_codes[0];

If has_category conditional was evaluated before is_home conditional, wrong ad code will be rendered.

I've made a workaround for this issue: https://gist.github.com/56f5825bd42200b7b36d

I'm not sure of proper way to fix it, but we might want to implement priority.

<?php
$display_codes = array( '0' => array ( array( /* homepage ad code */ ) ),
                       '10' => array ( array( /* news ad code */ ) ),
                       );
// and then we just
$priority = min( array_keys( $display_codes ) ); // or max
$code_to_display = $display_codes[$priority][0]

Two similar filters // may be needs refactoring

So we have acm_list_table_columns and acm_provider_columns. All the difference between them is that acm_list_table_columns return all table columns (e.g. id, name, priority, conditionals) and acm_provider_columns returns only ad network specific ones. May be we could use one filter and just skip service columns.

Use OR not AND by default

Conditionals should be evaluated with OR logic, otherwise the plugin won't render codes properly.

Example:


will never produce correct ad code, because one of them never equals true

Easy Google AdSense integration

Similar to what we've done with Google DFP Async, it would be great if our Google AdSense provider file offered much simpler integration.

AND conditional

Setting the logical operator from OR to AND does not seem to result in the expected behaviour for displaying ads.

For example:
Adding the conditional 'has_category' with value 'category 1' results in the ads only being displayed on category 1 pages.
Adding the conditional 'is_archive' with value '1' results in the ads only being displayed on archive pages.
However, including both conditionals shows the ads on all archive pages (if has_category is followed by is_archive) or all category 1 pages (if is_archive is followed by has_category).
The expected behaviour would be to only show ads on category 1 archive pages.

Add "delete" icon and action for inline editing conditionals

When you're editing an ad code with the inline edit functionality, you should be able to delete an existing conditional.

All that's needed for this implementation is a bit of JS that removes the input element from the DOM. When the user submits the form, the data will no longer exist and the conditional will be removed from the ad code

Provide inline help regarding conditionals

The whole conditionals thing might be confusing for end users. We should provide inline help, so that whenever users selects a conditional we display a short description on how to use this conditional, what arguments it might take, etc. See #46 for discussion

Abstract provider-specific code and data to a /providers/ folder

I thought of this as a way to abstract out the DFP-related code and also support other ad networks.

Basically, we'd have a file in a /providers/ directory for each ad network. This file would include all of the necessary defaults, configuration, whitelisted domains, etc. for that ad network. It would interact with the plugin by manipulating the filters we have set up. We'd make choosing your provider a code-level option or, if there were more than one, have a dropdown selector in the admin interface.

Allow columns to be optional when creating and editing ad codes

In both edit_ad_code() and create_ad_code(), the process is aborted if we run into a column that has been registered for the provider, but not available as part of the ad code data.

Depending on the view, it is possible that not all ad codes will make use of every column. Ideally, we'd have a way for provider authors to specify which columns are required or optional.

Broken link in VIP Lobby

The link pointing to Github in the VIP lobby still points to the old Github URL. This might not be the best place to point it out, but it felt awkward firing off an e-mail to support@ just for that. :)

Feature: Configuration scanner

It would be nice to have config scanner to check if the plugin is configured properly:

  • provider file is present,
  • ACM_WP_List_Table columns are properly defined,
  • ad code args are set correctly, there’s at least one tag id,
  • etc, you name it

Feature: Ad Code Preview

This should be probably a row action which either pops an overlay with previews or displays them inline

Iframe ads for double click

Hi,
When we looked at the code the specially for double click, we did not find any way to render iframe ads. Looks like right not it just supports javascript as. Is there a plan to incorporate iframe ads too?

Regards
Amit Sannad

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.