Monetize Me

აღწერა

Monetize Me is a modular, option-based advertising manager for Google AdSense and other trusted third-party monetization code. It does not register a custom post type or taxonomy.

The plugin provides four top-level settings tabs:

  • Ads
  • Ad Categories
  • Sponsors
  • Placements

A new installation includes these starter categories:

  • Header Ads (header-ads)
  • Footer Ads (footer-ads)
  • In-article Ads (in-article-ads)
  • Sidebar Ads (sidebar-ads)

It also includes the starter sponsor General (general). The records are editable and removable.

Main features:

  • Manage ad categories and sponsors independently.
  • Save trusted Google AdSense, script, iframe, HTML, or other monetization code.
  • Assign one category and one sponsor to each ad.
  • Enable or disable individual ads.
  • Keep saved ad cards collapsed initially and expand or collapse them from their headers for easier management of large ad libraries.
  • Randomly select one enabled ad when several ads match the requested filters.
  • Render ads through the [mmps] shortcode.
  • Render ads through the dynamic Advertisement Gutenberg block.
  • Map categories and sponsors to supported theme action hooks.
  • Insert ads between archive items using random intervals or exact positions.
  • Insert ads before content, after content, and between paragraphs.
  • Select which public post types receive automatic Post Content Ads.
  • Optionally enqueue the bundled frontend stylesheet.
  • Extend selection, placement, and rendering with public functions, actions, and filters.

Automatic archive and Post Content Ads are disabled initially. Enable them from Monetize Me > Placements after creating an enabled ad that matches the selected category and sponsor.

On a single-site installation, settings are stored in one regular option and managed from the top-level Monetize Me admin menu.

On WordPress Multisite, the plugin is network-managed. Settings are available only from the top-level Monetize Me page in Network Admin, and one network option controls all sites.

Shortcode

Basic random enabled ad:

[mmps]

Filter by category slug:

[mmps adcategory="in-article-ads"]

Filter by category and sponsor and add an outer CSS class:

[mmps adcategory="in-article-ads" adsponsor="general" classname="article-ad"]

Attributes:

  • adcategory – Saved category ID, name, or slug.
  • adsponsor – Saved sponsor ID, name, or slug.
  • classname – Space-separated CSS classes added to the outer .monetize-me container.

The shortcode always renders one randomly selected enabled ad from the matching records.

Gutenberg Block

Search the block inserter for Advertisement.

Block controls:

  • Ad Category
  • Ad Sponsor
  • Extra CSS Class

The dynamic block always renders one randomly selected matching ad. It always uses the standard frontend wrapper. The editor displays a safe configuration preview and does not execute saved ad scripts or iframes.

Theme Developer Integration

Monetize Me registers callbacks on the following theme action hooks. Add the relevant do_action() call at the intended location in a theme or child theme, then map a category and sponsor to that hook from Monetize Me > Placements. An optional space-separated CSS class string can be passed with each hook and is added to the outer .monetize-me container.

After the site header:

<?php do_action( 'monetize_me_after_header', 'site-header-ad' ); ?>

Immediately before the site footer:

<?php do_action( 'monetize_me_before_footer', 'site-footer-ad' ); ?>

Before an archive loop starts:

<?php do_action( 'monetize_me_before_archive_start', 'archive-start-ad' ); ?>

After an archive loop ends:

<?php do_action( 'monetize_me_after_archive_end', 'archive-end-ad' ); ?>

After each archive item:

<?php
global $wp_query;

$position = $wp_query->current_post + 1;

do_action(
    'monetize_me_between_archive_item',
    get_post(),
    $position,
    'archive-list-ad'
);
?>

$position must be a one-based archive item number. The optional third argument is a space-separated CSS class string. The between-item hook renders only when Archive Loop Ads are enabled and the current position matches the configured interval or exact-position rule.

Random interval example: a minimum of 3 and maximum of 4 displays the next ad after a randomly selected gap of three or four additional archive items.

Exact-position example: 3,7,10 displays ads after archive items 3, 7, and 10.

Post Content Ads

Post Content Ads use the the_content filter only on selected singular public post types in the main query and main loop. Password-protected content, feeds, admin requests, and JSON requests are excluded.

Available placements:

  • Before content
  • After content
  • Between paragraphs

The webmaster can select one or more public post types, including registered custom post types. The standard post type is selected by default.

Inline random interval example: a minimum of 3 and maximum of 4 places each next ad after a randomly selected gap of three or four additional paragraphs.

Inline exact-position example: 3,7,10 inserts ads after paragraphs 3, 7, and 10.

Frontend Markup and CSS

All shortcode, block, hook, archive, and Post Content Ad output uses this structure:

<div class="monetize-me category-slug">
    <div class="ad-wrapper">
        <!-- selected ad code -->
    </div>
</div>

The selected category slug is added to the outer container. Shortcode and block extra classes are also added to that outer container.

The bundled assets/css/frontend.css file is enabled by default. It adds vertical spacing, gives the ad wrapper a measurable full width for responsive networks such as Google AdSense, and centers fixed-size ad content. Disable it from Monetize Me > Placements > Frontend Styles only when the active theme provides equivalent width and alignment rules.

Public Functions

Category APIs:

  • monetize_me_get_categories()
  • monetize_me_get_category( $identifier )
  • monetize_me_get_category_options()

Sponsor APIs:

  • monetize_me_get_sponsors()
  • monetize_me_get_sponsor( $identifier )
  • monetize_me_get_sponsor_options()

Ad selection and rendering APIs:

  • monetize_me_get_ads( $enabled_only = false )
  • monetize_me_get_ad( $ad_id )
  • monetize_me_get_matching_ads( $category = '', $sponsor = '' )
  • monetize_me_select_ad( $category = '', $sponsor = '', $context = array() )
  • monetize_me_render_ad( $category = '', $sponsor = '', $classname = '', $context = array() )
  • monetize_me_render_ad_record( $ad, $classname = '', $context = array() )

Render one random matching ad from a theme template:

<?php
$ad_html = monetize_me_render_ad(
    'in-article-ads',
    'general',
    'custom-theme-ad',
    array(
        'source' => 'theme_template',
    )
);

echo $ad_html; // Intentionally contains trusted ad-network script or iframe markup.
?>

Placement and settings APIs:

  • monetize_me_get_theme_placements()
  • monetize_me_get_placement_settings()
  • monetize_me_get_theme_hook_settings( $hook_name )
  • monetize_me_get_archive_placement_settings()
  • monetize_me_get_content_placement_settings()
  • monetize_me_get_content_post_type_options()
  • monetize_me_should_display_archive_ad( $position )
  • monetize_me_get_placement_ad( $hook_name, $context = array(), $classname = '' )
  • monetize_me_render_placement( $hook_name, $context = array(), $classname = '' )
  • monetize_me_settings_page_url()

Frontend stylesheet APIs:

  • monetize_me_should_enqueue_frontend_css()
  • monetize_me_enqueue_frontend_css()

Important filters include:

  • monetize_me_get_categories
  • monetize_me_get_sponsors
  • monetize_me_get_ads
  • monetize_me_matching_ads
  • monetize_me_selected_ad
  • monetize_me_ad_code
  • monetize_me_rendered_ad
  • monetize_me_theme_placements
  • monetize_me_placement_settings
  • monetize_me_should_display_archive_ad
  • monetize_me_content_post_type_options
  • monetize_me_content_post_types
  • monetize_me_should_enqueue_frontend_css

Raw Ad Code and Security

Ad network code commonly requires <script>, <iframe>, and provider-specific HTML. Monetize Me therefore stores and renders the submitted ad code without KSES filtering, HTML escaping, wpautop(), nl2br(), or automatic <br> insertion.

Only users with the plugin management capability can access save handlers. Every settings form uses a dedicated WordPress nonce, and every write request verifies both the capability and nonce before updating data. On Multisite, management requires the network settings capability.

Because saved code executes on the frontend, paste code only from a trusted provider or advertiser. A compromised administrator account can use any raw-code feature maliciously; protect administrator accounts with strong passwords and multi-factor authentication.

ეკრანული სურათები

ბლოკები

ეს პლაგინი უზრუნველყოფს 1 ბლოკს.

  • Advertisement Display one randomly selected Monetize Me advertisement filtered by category and sponsor.

დაყენება

Single-site WordPress

  1. Upload the monetize-me directory to /wp-content/plugins/, or install the ZIP from Plugins > Add New > Upload Plugin.
  2. Activate Monetize Me from the Plugins screen.
  3. Open the top-level Monetize Me menu.
  4. Review the starter categories and the General sponsor.
  5. Open Ads, create an ad, select its category and sponsor, paste trusted monetization code, enable the ad, and save. Saved ad cards load collapsed; click a card header whenever you need to edit its details.
  6. Use the shortcode or Gutenberg block, or configure theme and automatic placements from Placements.

WordPress Multisite

  1. Install the plugin from Network Admin > Plugins > Add New, or upload the monetize-me directory to /wp-content/plugins/.
  2. Network activate Monetize Me.
  3. Open Network Admin > Monetize Me.
  4. Create and manage the shared categories, sponsors, ads, and placements there.
  5. Individual sites do not receive a separate Monetize Me settings page.

First ad checklist

  1. Confirm that the required category and sponsor exist.
  2. Create an ad and select both records.
  3. Paste code only from a trusted ad provider or advertiser.
  4. Enable the ad and save.
  5. Add [mmps adcategory="category-slug" adsponsor="sponsor-slug"] to content, insert the Advertisement block, or configure a placement.
  6. Clear page caches after changing ad code or placement settings.

ხდკ

Why are my saved ad fields hidden on the Ads page?

Saved ad cards are collapsed initially to prevent a large ad library from making the settings page unnecessarily tall. Click the ad card header to expand or collapse its fields. Clicking Remove deletes the card without toggling it. A newly added ad opens automatically for editing.

Why is no ad displayed?

Confirm that the ad is enabled and that its selected category and sponsor match the shortcode, block, hook, or automatic placement filters. Also clear page and CDN caches. For responsive Google AdSense units, keep the bundled frontend CSS enabled unless the theme gives .monetize-me and .ad-wrapper a non-zero measurable width. In browser developer tools, an AdSense error mentioning availableWidth=0 indicates a container-width problem.

Does Monetize Me add `
` tags to ad scripts?

No. The plugin does not run saved ad code through wpautop(), nl2br(), KSES, or HTML escaping during frontend rendering.

Why does the block editor not show the live advertisement?

The editor intentionally displays a safe configuration preview so third-party scripts and iframes do not execute inside the editor. The selected ad is rendered dynamically on the frontend.

Can I disable the plugin CSS?

Yes. Disable Load the Monetize Me frontend CSS file from Monetize Me > Placements > Frontend Styles.

Where are settings stored on Multisite?

One network option stores all categories, sponsors, ads, and placements. Individual sites do not have separate settings pages.

Are settings removed when the plugin is deactivated or deleted?

No. Monetize Me preserves its settings option on both deactivation and uninstall so the existing categories, sponsors, ads, and placements are available if the plugin is installed or activated again.

Can a theme add another placement hook?

Developers can filter monetize_me_theme_placements to register another action name, then call that action in the theme. The custom hook appears in the Placements mapping table.

მიმოხილვები

There are no reviews for this plugin.

მონაწილეები & დეველოპერები

“Monetize Me” ღია პროგრამული უზრუნველყოფაა. შემდეგმა ადამიანებმა წვილი შეიტანეს მის განვითარებაში.

მონაწილეები

გადათარგმნეთ Monetize Me თქვენს ენაზე.

დაინტერესებული ხართ დეველოპმენტით?

დაათვალიერეთ კოდი, შეამოწმეთ SVN რეპო, ან გამოიწერეთ შექმნის ჟურნალი : RSS.

ცვლილებები

3.0.3

  • Collapsed saved ad cards initially on the Ads page to keep large ad libraries compact and easier to scan.
  • Added accessible header-based expand/collapse controls, an animated state indicator, and independent Remove behavior.
  • Opened newly added ad cards automatically so their fields are immediately available for editing.
  • Fixed responsive Google AdSense units failing to render when the flex-based wrapper collapsed the initially empty adsbygoogle element to zero width.
  • Replaced the frontend flex wrapper with a full-width block layout that remains compatible with responsive AdSense and fixed-size third-party ads.
  • Added explicit width, max-width, min-width, box-sizing, and responsive .adsbygoogle safeguards.
  • Expanded frontend CSS and troubleshooting documentation for AdSense availableWidth=0 errors.

3.0.0

  • Added optional CSS classes to theme action hooks and placement rendering APIs.
  • Upgraded the plugin release version to 3.0.0.
  • Resolved Plugin Check findings for direct nonce verification, one-time request unslashing, prefixed template variables, block API version 3, translator comments, and WordPress.org translation loading.
  • Completed a repository-readiness review of capabilities, nonces, sanitization, escaping, asset loading, dynamic block registration, and uninstall behavior.
  • Preserved all plugin settings during deactivation and uninstall for future reactivation or reinstallation.
  • Preserved submitted monetization code without adding <br> tags or applying automatic paragraph formatting.
  • Corrected unauthorized-request handling to return an HTTP 403 response.
  • Improved block editor data loading with JSON-encoded inline script data.
  • Made filtered custom theme placement hooks safe when no built-in default mapping exists.
  • Added comprehensive installation, activation, shortcode, block, theme-hook, public API, raw-code, Multisite, and troubleshooting documentation.
  • Added a GPLv2 license file.

2.0.2

  • NEW: Added Network Admin tool to copy all ad CPT posts from one site to one or more selected destination subsites.
  • NEW: Ad copy operation skips destination posts when the same ad slug already exists.
  • NEW: Copied Ad posts preserve content, excerpt, status, menu order, custom fields, and assigned Monetize Me taxonomy terms.
  • NEW: Missing destination adcategory and adsponsor terms are created automatically while copying Ads.
  • SECURITY: Restricted Ad copy workflow to Network Administrators using nonce verification and manage_network_options checks.

2.0.1

  • NEW: Network Admin settings page for Multisite environments.
  • NEW: Copy taxonomy terms (adcategory, adsponsor) from a source site to selected subsites.
  • NEW: Bulk subsite selection for term synchronization.
  • IMPROVED: Duplicate detection using term slug (skip existing terms).
  • IMPROVED: Operation summary showing copied, skipped, and failed counts.
  • SECURITY: Restrict term synchronization tools to Network Admin only.

2.0.0

  • Added a centralized Ad_Service class used by shortcode, widget, block, and renderer layers
  • Added cache-aware ad queries with automatic cache purging on ad save, delete, and taxonomy changes
  • Added public helper API functions: monetize_me_get_ad(), monetize_me_get_random_ads(), monetize_me_render_ad(), mm_get_ad(), mm_get_random_ad(), and mm_render_ad()
  • Added internal filters and actions for query arguments and rendered output
  • Preserved backward compatibility for existing shortcode, widget, block, and Renderer::render() usage

1.9.0

  • Major internal refactor for maintainability
  • Added modern plugin bootstrap structure
  • Removed runtime rewrite flushing
  • Improved shortcode normalization and rendering
  • Fixed widget slug handling bug
  • Modernized block registration structure
  • Added safer uninstall behavior
  • Updated readme and repository packaging

1.0.1

  • Revert back the ad sponsor taxonomy

1.0.0

  • Recreated the plugin by removing legacy width and height taxonomies
  • Added Ad Category taxonomy
  • Added Gutenberg block support