{"id":15040526,"url":"https://github.com/automattic/ad-code-manager","last_synced_at":"2025-04-04T09:07:21.858Z","repository":{"id":2077021,"uuid":"3016242","full_name":"Automattic/ad-code-manager","owner":"Automattic","description":"Easily manage the ad codes that need to appear in your templates","archived":false,"fork":false,"pushed_at":"2024-12-04T05:30:50.000Z","size":2523,"stargazers_count":118,"open_issues_count":16,"forks_count":52,"subscribers_count":125,"default_branch":"develop","last_synced_at":"2025-04-04T09:07:16.211Z","etag":null,"topics":["advertisement-management","doubleclick-for-publishers","google-adsense","wordpress","wordpress-plugin","wpvip-plugin"],"latest_commit_sha":null,"homepage":"https://wordpress.org/plugins/ad-code-manager/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Automattic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-12-20T00:41:50.000Z","updated_at":"2025-04-04T03:01:17.000Z","dependencies_parsed_at":"2025-02-08T03:10:39.119Z","dependency_job_id":null,"html_url":"https://github.com/Automattic/ad-code-manager","commit_stats":{"total_commits":378,"total_committers":33,"mean_commits":"11.454545454545455","dds":0.7037037037037037,"last_synced_commit":"322619de4bcc773fa4af772733306c794071acce"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fad-code-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fad-code-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fad-code-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Automattic%2Fad-code-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Automattic","download_url":"https://codeload.github.com/Automattic/ad-code-manager/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247149500,"owners_count":20891954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advertisement-management","doubleclick-for-publishers","google-adsense","wordpress","wordpress-plugin","wpvip-plugin"],"created_at":"2024-09-24T20:44:42.171Z","updated_at":"2025-04-04T09:07:21.843Z","avatar_url":"https://github.com/Automattic.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ad Code Manager\n\nStable tag: 0.7.1  \nRequires at least: 5.7  \nTested up to: 5.9  \nRequires PHP: 7.4  \nLicense: GPLv2 or later  \nLicense URI: https://www.gnu.org/licenses/gpl-2.0.html  \nTags: advertising, ad codes, ads, adsense, dfp, doubleclick for publishers  \nContributors: rinatkhaziev, jeremyfelt, danielbachhuber, carldanley, zztimur, automattic, doejo\n\nManage your ad codes through the WordPress admin safely and easily.\n\n## Description\n\nAd Code Manager gives non-developers an interface in the WordPress admin for configuring your complex set of ad codes.\n\nSome 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.\n\nA 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.\n\nOnce 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.\n\n[Fork the plugin on Github](https://github.com/Automattic/Ad-Code-Manager) and [follow our development blog](http://adcodemanager.wordpress.com/).\n\n## Installation\n\nThe plugin requires PHP 7.4 or later. It is also tested WordPress 5.7 and later, though it may run on older versions.\n\nSince the plugin is in its early stages, there are a couple additional configuration steps:\n\n1. Upload `ad-code-manager` to the `/wp-content/plugins/` directory.\n2. Activate the plugin through the 'Plugins' menu in WordPress.\n3. 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.\n4. Implement filters to make the plugin work with your provider.\n5. Configure your ad codes in the WordPress admin (Tools -\u003e Ad Code Manager).\n\n## Screenshots\n\n1. Adding an ad code with a site name, zone, and multiple conditionals.\n   ![Adding an ad code with a site name, zone, and multiple conditionals.](.wordpress-org/screenshot-1.png)\n\n2. Edit existing ad codes inline through the admin interface.\n   ![Edit existing ad codes inline through the admin interface.](.wordpress-org/screenshot-2.png)\n\n3. Access the Help menu in the upper right for configuration assistance.\n   ![Access the Help menu in the upper right for configuration assistance.](.wordpress-org/screenshot-3.png)\n\n4. Example of ad tag in use in a theme header template.\n   ![Example of ad tag in use in a theme header template.](.wordpress-org/screenshot-4.jpg)\n\n## Configure Ad Code Manager to manage the advertisements on your site\n\nAd 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.\n\nThe 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.\n\nCurrently, Ad Code Manager easily integrates with Google DoubleClick For Publishers Async and Google AdSense. Other ad providers are supported with additional configuration.\n\n### Google AdSense and DoubleClick For Publishers Async\n\nLet'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:\n\n~~~php\ndo_action( 'acm_tag', '728x90_leaderboard' );\n~~~\n\nOnce 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\".\n\nAnd like that, your 728x90 leaderboard will appear on your site.\n\nThe Google AdSense configuration comes with many of Google's suggested sizes. Additional ad tags can be registered by way of filtering:\n\n~~~php\nadd_filter( 'acm_ad_tag_ids', 'acmx_filter_ad_tag_ids' );\nfunction acmx_filter_ad_tag_ids( $ids ) {\n\t$ids[] = array(\n\t\t'enable_ui_mapping' =\u003e true,\n\t\t'tag'               =\u003e '100x100_smallsquare',\n\t\t'url_vars'          =\u003e array(\n\t\t\t'tag'    =\u003e '100x100_smallsquare',\n\t\t\t'height' =\u003e '100',\n\t\t\t'width'  =\u003e '100',\n\t\t),\n\t);\n\n\treturn $ids;\n}\n~~~\n\nKeep in mind that you'll still need to incorporate a `do_action( 'acm_tag', '100x100_smallsquare' );` in your theme to display the ad tag.\n\nIf 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.\n\n### Custom Ad Provider Implementations\n\nAs 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:\n\n~~~php\n/**\n * Define the default URL to be used when rendering ad codes\n */\nadd_filter( 'acm_default_url', 'acmx_filter_default_url' ) ;\nfunction acmx_filter_default_url( $url ) {\n\tif ( 0 === strlen( $url )  ) {\n\t\treturn \"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%;\";\n\t}\n}\n\n/**\n * Whitelist the DFP URL to be used in ad tags. The whitelist\n * helps prevent execution of arbitrary scripts\n */\nadd_filter( 'acm_whitelisted_script_urls', 'acmx_filter_whitelisted_script_urls');\nfunction acmx_filter_whitelisted_script_urls( $whitelisted_urls ) {\n\t$whitelisted_urls = array( 'ad.doubleclick.net' );\n\treturn $whitelisted_urls;\n}\n\n/**\n * Define the different ad tags (locations) you'd like to use in your theme\n */\nadd_filter( 'acm_ad_tag_ids', 'acmx_ad_tags_ids' );\nfunction acmx_ad_tags_ids( $ad_tag_ids ) {\n\treturn array(\n\t\tarray(\n\t\t\t'tag'      =\u003e '728x90-atf',\n\t\t\t'url_vars' =\u003e array(\n\t\t\t\t'sz'     =\u003e '728x90',\n\t\t\t\t'fold'   =\u003e 'atf',\n\t\t\t\t'width'  =\u003e '728',\n\t\t\t\t'height' =\u003e '90',\n\t\t\t),\n\t\t),\n\t\tarray(\n\t\t\t'tag'      =\u003e '728x90-btf',\n\t\t\t'url_vars' =\u003e array(\n\t\t\t\t'sz'     =\u003e '728x90',\n\t\t\t\t'fold'   =\u003e 'btf',\n\t\t\t\t'width'  =\u003e '728',\n\t\t\t\t'height' =\u003e '90',\n\t\t\t),\n\t\t),\n\t\tarray(\n\t\t\t'tag'      =\u003e '300x250-atf',\n\t\t\t'url_vars' =\u003e array(\n\t\t\t\t'sz'     =\u003e '300x250',\n\t\t\t\t'fold'   =\u003e 'atf',\n\t\t\t\t'width'  =\u003e '300',\n\t\t\t\t'height' =\u003e '250',\n\t\t\t),\n\t\t),\n\t\tarray(\n\t\t\t'tag'      =\u003e '300x250-btf',\n\t\t\t'url_vars' =\u003e array(\n\t\t\t\t'sz'     =\u003e '300x250',\n\t\t\t\t'fold'   =\u003e 'btf',\n\t\t\t\t'width'  =\u003e '300',\n\t\t\t\t'height' =\u003e '250',\n\t\t\t),\n\t\t),\n\t\tarray(\n\t\t\t'tag'      =\u003e '160x600-atf',\n\t\t\t'url_vars' =\u003e array(\n\t\t\t\t'sz'     =\u003e '160x600',\n\t\t\t\t'fold'   =\u003e 'atf',\n\t\t\t\t'width'  =\u003e '160',\n\t\t\t\t'height' =\u003e '600',\n\t\t\t),\n\t\t),\n\t\tarray(\n\t\t\t'tag'      =\u003e '1x1',\n\t\t\t'url_vars' =\u003e array(\n\t\t\t\t'sz'   =\u003e '1x1',\n\t\t\t\t'fold' =\u003e 'int',\n\t\t\t\t'pos'  =\u003e 'top',\n\t\t\t),\n\t\t)\n\t);\n}\n\nadd_filter( 'acm_output_html','acmx_filter_output_html', 5, 2 );\n/**\n * Register the full script output to use with each ad tag.\n */\nfunction acmx_filter_output_html( $output_html, $tag_id ) {\n\t$output_html = '\u003c!-- DFP %pos% %sz% ad tag --\u003e \n\t\u003cscript\u003e\nif ( typeof ord=='undefined' ) { ord=Math.random()*10000000000000000; }\nif ( typeof( dfp_tile ) == 'undefined' ) { dfp_tile=%tile% };\ndocument.write('\u003cscript src=\"%url%ord=' + ord + '?\"\u003e\u003c/script\u003e');\n\u003c/script\u003e\u003cnoscript\u003e\u003ca href=\"%url%ord=%random%?\" target=\"_blank\"\u003e\u003cimg src=\"%url%ord=%random%?\" width=\"%width%\" height=\"%height%\" border=\"0\" alt=\"\u003e\u003c/a\u003e\u003c/noscript\u003e\n\u003c!-- //DFP %pos% %sz% tag --\u003e';\n\treturn $output_html;\n}\n\nadd_filter('acm_output_tokens', 'acmx_filter_output_tokens', 5, 3 );\n/**\n * Fine tune our output tokens.\n *\n * This is the real example of how easily you can modify output\n * depending on your ad network specs.\n */\nfunction acmx_filter_output_tokens( $output_tokens, $tag_id, $code_to_display ) {\n\tglobal $dfp_tile;\n\tglobal $dfp_ord;\n\tglobal $dfp_pos;\n\tglobal $dfp_dcopt;\n\tglobal $wp_query;\n\t\n\t// We can't really rely on get_permalink() so use $_SERVER['REQUEST_URI] as bulletproof solution for generating unique pids\n\t$link = strlen( $_SERVER['REQUEST_URI'] ) \u003e 1 ? sanitize_key( $_SERVER['REQUEST_URI'] ) : home_url();\n\t$output_tokens['%permalink%'] = str_replace( array( '/',':', '.' ), '', $link ); \n\t$output_tokens['%random%']    = $dfp_ord;\n\t$output_tokens['%tile%']      = ++$dfp_tile;\n\tif (  false === $dfp_pos[ $code_to_display['url_vars']['sz'] ] ) {\n\t\t$output_tokens['%pos%']                        = 'top';\n\t\t$dfp_pos[ $code_to_display['url_vars']['sz'] ] = true;\n\t} else {\n\t\t$output_tokens['%pos%'] = 'bottom';\n\t}\n\tif ( ! $dfp_dcopt ) {\n\t\t$output_tokens['%dcopt%'] = 'ist';\n\t\t$dfp_dcopt                = true;\n\t} else {\n\t\t$output_tokens['%dcopt%'] = '';\n\t}\n\t\n\t$output_tokens['%test%'] = isset( $_GET['test'] ) \u0026\u0026 $_GET['test'] == 'on' ? 'on' : '';\n\t\n\treturn $output_tokens;\n}\n~~~\n\n## Configuration Filters\n\nThere 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.\n\n[Check out this gist](https://gist.github.com/1631131) to see all of the filters in action.\n\n### `acm_ad_tag_ids`\n\nAd 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.\n\nArguments:\n* array $tag_ids array of default tag IDs\n\nExample usage: Add a new ad tag called 'my_top_leaderboard'\n\n~~~php\nadd_filter( 'acm_ad_tag_ids', 'my_acm_ad_tag_ids' );\nfunction my_acm_ad_tag_ids( $tag_ids ) {\n\t$tag_ids[] = array(\n\t\t'tag'      =\u003e 'my_top_leaderboard', // tag_id\n\t\t'url_vars' =\u003e array(\n\t\t\t'sz'              =\u003e '728x90', // %sz% token\n\t\t\t'fold'            =\u003e 'atf', // %fold% token\n\t\t\t'my_custom_token' =\u003e 'something' // %my_custom_token% will be replaced with 'something'\n\t\t),\n\t);\n\treturn $tag_ids;\n}\n~~~\n\n### `acm_default_url`\n\nSet the default tokenized URL used when displaying your ad tags. This filter is required.\n\nArguments:\n* string $url The tokenized URL of Ad Code\n\nExample usage: Set your default ad code URL\n\n~~~php\nadd_filter( 'acm_default_url', 'my_acm_default_url' );\nfunction my_acm_default_url( $url ) {\n\tif ( 0 === strlen( $url ) ) {\n\t\treturn \"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%;\";\n\t}\n}\n~~~\n\n### `acm_output_html`\n\nThe 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.\n\nThe `%url%` token used in this HTML will be filled in with the URL defined with `acm_default_url`.\n\nArguments:\n* string $output_html The original output HTML\n* string $tag_id Ad tag currently being accessed\n\nExample usage:\n\n~~~php\nadd_filter( 'acm_output_html', 'my_acm_output_html', 10, 2 );\nfunction my_acm_output_html( $output_html, $tag_id ) {\n\tswitch ( $tag_id ) {\n\t\tcase 'my_leaderboard':\n\t\t\t$output_html = '\u003ca href=\"%url%\"\u003e\u003cimg src=\"%image_url%\" /\u003e\u003c/a\u003e';\n\t\t\tbreak;\n\t\tcase 'rich_media_leaderboard':\n\t\t\t$output_html = '\u003cscript\u003e // omitted \u003c/script\u003e';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\treturn $output_html;\n}\n~~~\n\n### `acm_register_provider_slug`\n\nAd 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.\n\nWhen 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.\n\nArguments:\n* object $providers An object containing the current registered providers.\n\nExample usage:\n\n~~~php\nadd_filter( 'acm_register_provider_slug', 'my_acm_register_provider_slug' );\nfunction my_acm_register_provider_slug( $providers ) {\n\t$providers-\u003enew_provider_slug = array(\n\t\t'provider' =\u003e 'My_New_Ad_Company_ACM_Provider',\n\t\t'table'    =\u003e 'My_New_Ad_Company_ACM_WP_List_Table'\n\t);\n\n\treturn $providers;\n}\n~~~\n\n### `acm_whitelisted_script_urls`\n\nA security filter to define a safelist for which ad code script URLs can be added in the admin.\n\nArguments:\n* array $whitelisted_urls Existing whitelisted ad code URLs\n\nExample usage: Allow DoubleClick for Publishers ad codes to be used\n\n~~~php\nadd_filter( 'acm_whitelisted_script_urls', 'my_acm_safelisted_script_urls' );\nfunction my_acm_safelisted_script_urls( $safelisted_urls ) {\n\t$safelisted_urls = array( 'ad.doubleclick.net' );\n\treturn $safelisted_urls;\n}\n~~~\n\n### `acm_output_tokens`\n\nOutput 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.\n\nArguments:\n* array $output_tokens Any existing output tokens\n* string $tag_id Unique tag ID\n* array $code_to_display Ad Code that matched conditionals\n\nExample usage: Test to determine whether you're in test or production by passing ?test=on query argument\n\n~~~php\nadd_filter( 'acm_output_tokens', 'my_acm_output_tokens', 10, 3 );\nfunction my_acm_output_tokens( $output_tokens, $tag_id, $code_to_display ) {\n\t$output_tokens['%test%'] = isset( $_GET['test'] ) \u0026\u0026 $_GET['test'] == 'on' ? 'on' : '';\n\treturn $output_tokens;\n}\n~~~\n\n### `acm_whitelisted_conditionals`\n\nExtend the list of usable conditional functions with your own awesome ones. We safelist these so users can't execute random PHP functions.\n\nArguments:\n* array $conditionals Default conditionals\n\nExample usage: Register a few custom conditional callbacks\n\n~~~php\nadd_filter( 'acm_whitelisted_conditionals', 'my_acm_safelisted_conditionals' );\nfunction my_acm_safelisted_conditionals( $conditionals ) {\n\t$conditionals[] = 'my_is_post_type';\n\t$conditionals[] = 'is_post_type_archive';\n\t$conditionals[] = 'my_page_is_child_of';\n\n\treturn $conditionals;\n}\n~~~\n\n### `acm_conditional_args`\n\nFor certain conditionals (`has_tag()`, `has_category()`), you might need to pass additional arguments.\n\nArguments:\n* array $cond_args Existing conditional arguments\n* string $cond_func Conditional function (`is_category()`, `is_page()`, etc.)\n\nExample usage: `has_category()` and `has_tag()` use `has_term()`, which requires the object ID to function properly.\n\n~~~php\nadd_filter( 'acm_conditional_args', 'my_acm_conditional_args', 10, 2 );\nfunction my_acm_conditional_args( $cond_args, $cond_func ) {\n\tglobal $wp_query;\n\n\t// The `has_category()` and `has_tag()` functions call the `has_term()` function.\n\t// We should pass queried object id for it to produce correct result.\n\tif ( in_array( $cond_func, array( 'has_category', 'has_tag' ) ) \u0026\u0026 $wp_query-\u003eis_single == true ) {\n\t\t$cond_args[] = $wp_query-\u003equeried_object-\u003eID;\n\t}\n\n\t// my_page_is_child_of is our custom WP conditional tag and we have to pass queried object ID to it.\n\tif ( in_array( $cond_func, array( 'my_page_is_child_of' ) ) \u0026\u0026 $wp_query-\u003eis_page ) {\n\t\t$cond_args[] = $cond_args[] = $wp_query-\u003equeried_object-\u003eID;\n\t}\n\n\treturn $cond_args;\n}\n~~~\n\n### `acm_display_ad_codes_without_conditionals`\n\nChange 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.\n\nArguments:\n* bool $behavior Whether or not to display the ad codes that don't have conditionals\n\nExample usage:\n\n~~~php\nadd_filter( 'acm_display_ad_codes_without_conditionals', '__return_true' );\n~~~\n\n### `acm_provider_slug`\n\nBy 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.\n\nExample usage:\n\n~~~php\nadd_filter(\n\t'acm_provider_slug',\n\tfunction() {\n\t\treturn 'my-ad-network-slug';\n\t}\n);\n~~~\n\n### `acm_logical_operator`\n\nBy default, the logical operator is set to \"OR\", that is, ad code will be displayed if at least one conditional returns true.\nYou can change it to \"AND\", so that the ad code will be displayed only if ALL the conditionals match.\n\nExample usage:\n\n~~~php\nadd_filter(\n\t'acm_logical_operator',\n\tfunction() {\n\t\treturn 'AND';\n\t}\n);\n~~~\n\n### `acm_manage_ads_cap`\n\nBy default, the user has to have `manage_options` cap. This filter comes in handy if you want to relax the requirements.\n\nExample usage:\n\n~~~php\nadd_filter(\n\t'acm_manage_ads_cap',\n\tfunction( $cap ) {\n\t\treturn 'edit_others_posts';\n\t}\n);\n~~~\n\n### `acm_allowed_get_posts_args`\n\nThis 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-\u003eget_ad_codes()` method.\n\nExample usage:\n\n~~~php\nadd_filter(\n\t'acm_allowed_get_posts_args',\n\tfunction( $args_array ) {\n\t\treturn array( 'offset', 'exclude' );\n\t}\n);\n~~~\n\n### `acm_ad_code_count`\n\nBy 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-\u003eget_ad_codes()` `numberposts` query argument.\n\nExample usage:\n\n~~~php\nadd_filter(\n\t'acm_ad_code_count',\n\tfunction( $total ) {\n\t\treturn 100;\n\t}\n);\n~~~\n\n### `acm_list_table_columns`\n\nThis filter can alter table columns that are displayed in ACM UI.\n\nExample usage:\n\n~~~php\nadd_filter( 'acm_list_table_columns', 'my_acm_list_table_columns' );\nfunction my_acm_list_table_columns( $columns ) {\n\t$columns = array(\n\t\t'id'           =\u003e __( 'ID', 'ad-code-manager' ),\n\t\t'name'         =\u003e __( 'Name', 'ad-code-manager' ),\n\t\t'priority'     =\u003e __( 'Priority', 'ad-code-manager' ),\n\t\t'conditionals' =\u003e __( 'Conditionals', 'ad-code-manager' ),\n\t);\n\n\treturn $columns;\n}\n~~~\n\n### `acm_ad_code_args`\n\nThis 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\".\n\n\"editable\" and \"required\" indicate whether this field should be editable and required.\n\nExample usage:\n\n~~~php\nadd_filter( 'acm_ad_code_args', 'my_acm_ad_code_args' );\nfunction my_acm_ad_code_args( $args ) {\n\t$args = array(\n\t\tarray(\n\t\t\t'key'      =\u003e 'name',\n\t\t\t'label'    =\u003e __( 'Name', 'ad-code-manager' ),\n\t\t\t'editable' =\u003e true,\n\t\t\t'required' =\u003e true,\n\t\t),\n\t);\n\n\treturn $args;\n}\n~~~\n\n### Change Log\n\n[View the change log](https://github.com/Automattic/ad-code-manager/blob/master/CHANGELOG.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomattic%2Fad-code-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautomattic%2Fad-code-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautomattic%2Fad-code-manager/lists"}