Content class: Favorites

Primary responsibility

Renders the user’s saved-items list. The actual favorites data comes from sibling plugins (mam-geodirectory contributes GD listings, mam-special-offers contributes promotions, etc.). The content class itself is a thin shell — get_content_type_form() returns “No settings required” and get_data_for_app() passes the category through unchanged; the favorites list and its flags are assembled by the phone-data pipeline (the user’s saved ids live in the favorites usermeta key).


Settings

The Favorites content class declares no per-button settings of its own — the button’s edit form literally returns “No settings required.” The one related setting is a global app setting owned by the app-settings registry, not by this class:

Setting Type Environment Purpose
hide_remove_all_favorites yes-no global Hides the “remove all” UI link

The hide_remove_all_favorites flag is surfaced to the app through the global settings section of the phone-data JSON.


Hooks

Name Type Role
mam_manage_favorites AJAX subaction The app posts subaction=mam_manage_favorites to the mam_main_ajax dispatcher when the user toggles a favorite. mam-main’s handle_favorites() (includes/helper-classes/post-comments.php) persists the change to the favorites usermeta key. It is a subaction of the dispatcher’s switch, not a do_action hook. mam-geodirectory owns the matching app-endpoint registration.

JSON shape

The favorites response section looks like:

{
  "favorites": ["123", "456", "789"],
  "hide_remove_all_favorites": "yes"
}

favorites is read from the favorites usermeta key and is an array of post-id strings (typed as strings — many mobile clients expect strings, not integers).


Gotchas

  • Favorites are stored in the favorites usermeta key. mam-main’s handle_favorites() persists the toggle there and the phone-data pipeline reads it back. Sibling plugins (mam-geodirectory, mam-special-offers) contribute the source records that populate the list.
  • favorites is a strings-array, not ints. Don’t return integer ids from your sibling plugin’s contribution.

  • Content classes overview
  • Hook: mam_manage_favorites
  • Mobile JSON shape

Metadata

Field Value
Article type Screen Reference
Plugin slug mam-main
Applies to plugin version 2.1.11+
Category App Settings Reference
Audience WordPress admin / PHP developer
Class name local_app_favorites (frozen)
Source file includes/content-classes/local-app-favorites-class.php
Last verified 2026-05-02
Was this article helpful?
Contents

    Need Support?

    Can't find the answer you're looking for? Don't worry we're here to help!