When they search, make sure they find you!

Hooks & Data Storage

This page documents every WordPress hook the plugin uses, the database storage format, the AJAX save endpoint, and the JavaScript localized data object.

Data Storage

The plugin stores all configuration in a single option in the wp_options table:

  • Option name: idamc_menu_order
  • Format: Serialized associative array with three keys

Structure:

  • order — Array of menu slugs in custom display order.

    Example: ['index.php', 'edit.php', 'idamc-divider-1234', 'upload.php']
  • hidden — Array of menu slugs that are hidden from non-administrators.

    Example: ['tools.php', 'edit-comments.php']
  • dividers — Array of unique divider IDs inserted by the administrator.

    Example: ['idamc-divider-1644592800000-a7b3']

Reading the saved order in PHP:

$menu_data = get_option( 'idamc_menu_order', array(
    'order'    => array(),
    'hidden'   => array(),
    'dividers' => array(),
) );

WordPress Hooks Used

Hook Priority Purpose
admin_menu 999 Adds the “Edit Menu” toggle link to the admin sidebar.
admin_menu 9999 Applies the saved custom order to the global $menu array after all plugins have registered their items.
adminmenu default Prints an inline script that stamps each menu <li> element with a data-idamc-slug attribute for JavaScript identification.
admin_enqueue_scripts default Enqueues jQuery UI Sortable (bundled with WordPress), admin.js, and admin.css.
wp_ajax_idamc_save_menu_order default Handles the AJAX POST request to save the menu configuration.

AJAX Endpoint

  • Action: idamc_save_menu_order
  • Method: POST
  • Nonce: idamc_save_menu_order (verified via check_ajax_referer)
  • Required capability: manage_options

POST parameters:

  • order[] — Array of menu slugs in the desired order.
  • hidden[] — Array of menu slugs to hide from non-admins.
  • dividers[] — Array of divider IDs currently in the menu.

All input values are sanitized with sanitize_text_field before being saved to the database.

JavaScript Localized Data (idamcData)

The plugin passes a JavaScript object called idamcData to the front end via wp_localize_script. It contains:

  • ajaxurl — The WordPress AJAX endpoint URL.
  • nonce — The security nonce for AJAX requests.
  • currentOrder — The currently saved menu state (order, hidden, dividers).
  • i18n — An object of translatable UI strings:
    • save, editMenu, addDivider, removeDivider
    • showMenuItem, hideMenuItem, saveError

Custom Action

The plugin fires a custom action idamc_fs_loaded after the Freemius SDK has been initialized. You can hook into this action to run code that depends on the Freemius instance being available:

add_action( 'idamc_fs_loaded', function() {
    // Freemius SDK is now initialized.
    // Access the Freemius instance or run dependent code here.
} );