Skip to content

Instantly share code, notes, and snippets.

@betweenbrain
Created February 11, 2019 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betweenbrain/48f580830b5cd600cdae68d1e1f601d8 to your computer and use it in GitHub Desktop.
Save betweenbrain/48f580830b5cd600cdae68d1e1f601d8 to your computer and use it in GitHub Desktop.
WordPress Fieldmanager Hooks

A non-authoritative, possibly incomplete list of hooks registered by Fieldmanager for WordPress v1.0.0.

  • fieldmanager_draggablepost_li_content
  • fm_element_markup_start: After starting the field, apply a filter to allow other plugins to append functionality.
  • fm_element_markup_end: Before closing the field, apply a filter to allow other plugins to append functionality.
  • fm_element_classes
  • fm_preload_alter_values: Alter values before rendering.
  • fm_process_index_value: Alter handling of an individual index value, which may make sense to change per field type.
  • fm_presave_alter_values: Alter or respond to all the values of a particular element.
  • fieldmanager_media_preview
  • fm_presave_data
  • fm_submenu_presave_data
  • fm_user_presave_data( $data ): Maintain legacy support for custom filter. $data Data being saved.
  • fm_user_context_get_data( $user_id, $meta_key, $single ) Allow control over retrieving from the user data storage.
    • $user_id User ID.
    • $meta_key Meta key to retrieve.
    • $single Get single value (true) or array of values (false, default).
  • fm_user_context_add_data( $user_id, $meta_key, $meta_value, $unique ): Allow control over adding to the user data storage.
    • $user_id User ID.
      • $meta_key Meta key to add.
      • $meta_value The meta value to store.
      • $unique If true, only add if key is unique. Default is false.
  • fm_user_context_update_data( $user_id, $meta_key, $meta_value, $data_prev_value ) :Allow control over updating the user data storage.
    • $user_id User ID.
      • $meta_key Meta key to add.
      • $meta_value The meta value to store.
    • $data_prev_value Only update if the previous value matches $data_prev_value.
  • fm_user_context_delete_data( $user_id, $meta_key, $meta_value): Allow control over deleting from the user data storage.
    • $user_id User ID.
      • $meta_key Meta key to add.
      • $meta_value Only delete if the current value matches.
  • fm_context_before_presave_data( $new_value, $old_value, $fm ): Prepare the data for saving, returns the filtered and sanitized value, safe to save.
    • $new_value Optional. The new value for the field.
    • $old_value Optional. The previous value.
      • $fm Optional. The Fieldmanager_Field to prepare.
  • fm_context_after_presave_data
  • url_to_postid( $url ): Post URLs to IDs function, supports custom post types. Returns post ID on success, false on failure.
  • fm_datasource_term_get_items($stack, $terms): Get taxonomy data.
  • fm_datasource_term_get_value( $value, $term ): Translate term id to title, e.g. for autocomplete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment