Hooks and Filters

NotedWP fires its own custom action hooks and integrates with many standard WordPress hooks. This page documents both categories so you can extend the plugin’s behavior from your own theme or plugin code.


Custom Action Hooks

These hooks are fired by NotedWP at key moments. You can add your own callbacks to react to review activity.

noted_pin_created

Fired immediately after a new pin is created via the REST API.

Parameters

Parameter Type Description
$pin_id int The ID of the newly created pin.
$pin_data array Associative array of pin data including project_id, page_id, body, author_type, author_user_id, author_guest_id, page_path, and all positional fields.

Example: Send a Slack notification on new pin

add_action('noted_pin_created', function (int $pin_id, array $pin_data) {
    $page_url = home_url($pin_data['page_path'] ?? '/');
    $message  = sprintf(
        'New feedback pin #%d on %s: %s',
        $pin_data['pin_number'] ?? $pin_id,
        $page_url,
        wp_trim_words($pin_data['body'] ?? '', 20)
    );

    wp_remote_post('https://hooks.slack.com/services/YOUR/WEBHOOK/URL', [
        'headers' => ['Content-Type' => 'application/json'],
        'body'    => wp_json_encode(['text' => $message]),
    ]);
}, 10, 2);

Example: Log pins to a custom table

add_action('noted_pin_created', function (int $pin_id, array $pin_data) {
    global $wpdb;
    $wpdb->insert($wpdb->prefix . 'my_feedback_log', [
        'pin_id'     => $pin_id,
        'project_id' => $pin_data['project_id'],
        'page_path'  => $pin_data['page_path'] ?? '/',
        'created_at' => current_time('mysql'),
    ]);
}, 10, 2);

noted_comment_created

Fired immediately after a comment is added to a pin via the REST API.

Parameters

Parameter Type Description
$comment_id int The ID of the newly created comment.
$comment_data array Associative array including pin_id, parent_id, body, author_type, author_user_id, author_guest_id.

Example: Auto-reopen a pin when a new comment is posted

add_action('noted_comment_created', function (int $comment_id, array $comment_data) {
    global $wpdb;
    $pin_id = $comment_data['pin_id'];

    $current_status = $wpdb->get_var($wpdb->prepare(
        "SELECT status FROM {$wpdb->prefix}noted_pins WHERE id = %d",
        $pin_id
    ));

    if ($current_status === 'resolved') {
        $wpdb->update(
            $wpdb->prefix . 'noted_pins',
            ['status' => 'open', 'resolved_at' => null, 'resolved_by' => null],
            ['id' => $pin_id]
        );
    }
}, 10, 2);

noted_pin_resolved

Fired after a pin’s status is changed to resolved (either individually or via bulk resolve).

Parameters

Parameter Type Description
$pin_id int The ID of the resolved pin.
$pin_data array The full pin row as an associative array (cast from the database object).

Example: Post a summary to a project management tool

add_action('noted_pin_resolved', function (int $pin_id, array $pin_data) {
    $admin_url = admin_url("admin.php?page=noted-pins&action=view&pin={$pin_id}");

    wp_remote_post('https://api.yourpm.com/webhooks/resolved', [
        'headers' => ['Content-Type' => 'application/json'],
        'body'    => wp_json_encode([
            'pin_id'      => $pin_id,
            'project_id'  => $pin_data['project_id'],
            'resolved_by' => $pin_data['resolved_by'],
            'admin_url'   => $admin_url,
        ]),
    ]);
}, 10, 2);

WordPress Hooks NotedWP Uses

The following is a comprehensive list of WordPress hooks that NotedWP registers callbacks on. This is useful if you need to understand load order, debug conflicts, or know which hooks are “occupied” by the plugin.

Core Lifecycle Hooks

Hook Callback Purpose
register_activation_hook Noted_Activator::activate Creates database tables, sets custom capabilities, sets default options, flushes rewrite rules.
register_deactivation_hook Noted_Activator::deactivate Removes custom capabilities, clears scheduled cron jobs.
register_deactivation_hook Noted_License::on_plugin_deactivate Deactivates the license key with the remote server.
plugins_loaded Anonymous closure Initializes all plugin classes: Noted_Activator, Noted_Capabilities, Noted_Admin, Noted_REST_API, Noted_Script_Loader, Noted_Notifications, Noted_Cron, Noted_Export_Registry, Noted_M13_Client.
init Anonymous closure Initializes Noted_Updater for custom update checks.
rest_api_init Noted_REST_API::register Registers all REST API routes under the noted/v1 namespace.
wp_initialize_site Noted_Activator::on_new_site Creates NotedWP tables on a newly added multisite blog.

Admin Hooks

Hook Callback Purpose
admin_menu Noted_Admin::register_menu Registers the NotedWP admin menu pages (Dashboard, Feedback, Pages, Integrations, Export, Settings).
admin_enqueue_scripts Noted_Admin::enqueue_admin_assets Loads CSS and JS for the NotedWP admin screens.
admin_notices Noted_Admin::maybe_show_welcome Shows a welcome notice after first activation.
admin_notices Noted_Admin::maybe_show_license_notice Shows a notice if no license is active.
admin_notices Noted_M13_Client::maybe_show_revocation_notice Shows a notice if the M13 client token has been revoked.
admin_init Noted_M13_Client::maybe_auto_configure_export Auto-configures the M13 Dashboard export integration when in M13 client mode.

AJAX Hooks

Hook Callback Purpose
wp_ajax_noted_dismiss_license_notice Noted_Admin::dismiss_license_notice Handles dismissal of the license activation notice.
wp_ajax_noted_dismiss_m13_notice Noted_M13_Client::dismiss_notice Handles dismissal of the M13 revocation notice.

Frontend Hooks

Hook Callback Purpose
wp_enqueue_scripts Noted_Script_Loader::maybe_inject Conditionally loads the review overlay JavaScript and CSS on the frontend. Runs at priority 999 to load after theme scripts.
admin_bar_menu Noted_Script_Loader::add_admin_bar_link Adds a “NotedWP” link to the WordPress admin bar for quick access to the review overlay.

Post List Table Hooks

NotedWP hooks into the WordPress post and page list tables to show feedback counts inline.

Hook Callback Purpose
manage_page_posts_columns Noted_Admin::add_feedback_column Adds a “Feedback” column to the Pages list.
manage_post_posts_columns Noted_Admin::add_feedback_column Adds a “Feedback” column to the Posts list.
manage_page_posts_custom_column Noted_Admin::render_feedback_column Renders open/resolved pin counts in the Feedback column (Pages).
manage_post_posts_custom_column Noted_Admin::render_feedback_column Renders open/resolved pin counts in the Feedback column (Posts).
page_row_actions Noted_Admin::add_row_action Adds an “Open NotedWP” link to page row actions.
post_row_actions Noted_Admin::add_row_action Adds an “Open NotedWP” link to post row actions.

Update System Hooks

Hook Callback Purpose
pre_set_site_transient_update_plugins Noted_Updater::check_for_update Checks the NotedWP update server for new versions.
plugins_api Noted_Updater::plugin_information Supplies plugin information for the “View details” modal in the plugins list.
upgrader_process_complete Noted_Updater::after_update Runs post-update cleanup (cache clearing, DB migrations).
plugin_action_links_{basename} Noted_Updater::action_links Adds a “License” settings link to the plugin row on the Plugins page.

How to Hook In

From a Theme

Add your callbacks in your theme’s functions.php file. Wrap them in a check to avoid errors if NotedWP is deactivated:

// functions.php
add_action('plugins_loaded', function () {
    if (!class_exists('Noted_REST_API')) {
        return;
    }

    add_action('noted_pin_created', 'my_theme_on_pin_created', 10, 2);
});

function my_theme_on_pin_created(int $pin_id, array $pin_data) {
    // Your custom logic here.
    error_log("NotedWP pin #{$pin_id} created on page: " . ($pin_data['page_path'] ?? '/'));
}

From a Plugin

If you are writing a standalone plugin that extends NotedWP, use the same plugins_loaded guard:

<?php
/**
 * Plugin Name: My NotedWP Extension
 */

add_action('plugins_loaded', function () {
    if (!class_exists('Noted_REST_API')) {
        return;
    }

    // Safe to hook into NotedWP actions here.
    add_action('noted_pin_created', 'my_extension_handle_pin', 10, 2);
    add_action('noted_comment_created', 'my_extension_handle_comment', 10, 2);
    add_action('noted_pin_resolved', 'my_extension_handle_resolved', 10, 2);
}, 20); // Priority 20 ensures NotedWP has loaded first.

Removing a NotedWP Hook

You can remove any of NotedWP’s built-in hooks using remove_action() or remove_filter(). For static class methods, pass the class and method as an array:

// Remove the admin bar link.
add_action('plugins_loaded', function () {
    remove_action('admin_bar_menu', ['Noted_Script_Loader', 'add_admin_bar_link'], 999);
});

// Remove the Feedback column from the Pages list.
add_action('plugins_loaded', function () {
    remove_filter('manage_page_posts_columns', ['Noted_Admin', 'add_feedback_column']);
    remove_action('manage_page_posts_custom_column', ['Noted_Admin', 'render_feedback_column']);
});

Important. When removing hooks, the priority must match the priority used when the hook was added. Most NotedWP hooks use the default priority (10), except wp_enqueue_scripts and admin_bar_menu which use priority 999.