Advanced: Actions

We have built some custom actions into AdSanity to help developers like yourself extend the default behaviors. Below is a list of actions that we include in the plugin. Custom code can be placed in your theme’s functions.php file or in a custom plugin. If you need help understanding what actions are or how to use them, we recommend this resource on WordPress.org.

Custom Post Type Setup

# ads_init

This hook runs when the ads post type is being set up. This hook could be used to register additional taxonomies for example.

Ad Display

Each of the ad display hooks allows you to add HTML markup to the ad display in various positions around the ad unit.

The $post object is made available to each callback as the first argument.

# adsanity_before_ad_wrapper

This action allows you to insert content before any AdSanity markup has been written to the page.

# adsanity_before_ad

This action allows you to insert content inside of the wrapping and aligning markup. Regardless of the ad type, this action would display content just before the ad is rendered.

# adsanity_after_ad

This action allows you to insert content inside of the wrapping and aligning markup. Regardless of the ad type, this action would display content just after the ad is rendered.

# adsanity_after_ad_wrapper

This action allows you to insert content after all AdSanity markup has been written to the page.

Tracking

# adsanity_before_track_click

This action can be used to execute custom code before a click is tracked. This might be useful to track the click in an additional external application. No new content should be displayed though since the request that runs this action will also forward the visitor on to the destination URL.

The $post object is made available to the callback as the first argument.

# adsanity_before_redirect

This action can be used to execute custom code after a click is tracked but before the visitor is redirected to the destination URL. No new content should be displayed though since the request that runs this action will also forward the visitor on to the destination URL.

The $post object is made available to the callback as the first argument.

Settings

# adsanity_register_settings

This hook can be used to register additional settings to be displayed on the AdSanity Settings page.

Reporting

# adsanity_after_reports_page_heading

This action can be used to add content after the page heading and before the tab navigation on both the Reports Dashboard as well as the Custom Reports.

# adsanity_before_stats_dashboard

This action can be used to add content above the “All-Time Summary” block on the Reports dashboard.

# adsanity_after_stats_columns

This action can be used to add content after the “All-Time” stat blocks.

# adsanity_custom_stats_before_ad_selection

This action can be used to add content between the start/end dates and the Ad Selection above the Custom Reports charts.

# adsanity_custom_reports_table_heading

This action can be used to add additional columns to the Custom Reports detail table.

# adsanity_custom_reports_table_total

This action can be used to add additional column values to the Custom Reports detail table total row.

General Information

# adsanity_about_screen

This action allows you to add content to the bottom of the about screen.

# adsanity_changelog_screen

This action allows you to add content to the bottom of the changelog screen. This could be helpful to document any custom changes you’ve made via hooks and filters.

# adsanity_support_screen

This action allows you to add content to the bottom of the support screen. This could be useful to embed answers to commonly asked questions or frequently used resources.