Fieldmanager_Datasource_Post
class Fieldmanager_Datasource_Post extends Fieldmanager_Datasource (View source)
Datasource to populate autocomplete and option fields with WordPress Posts.
Properties
array | $options | The datasource options. |
from Fieldmanager_Datasource |
string | $options_callback | Options callback. |
from Fieldmanager_Datasource |
bool | $use_ajax | Allow Ajax. If set to false, Autocomplete will pre-load get_items() with no fragment, so False could cause performance problems. |
|
bool | $allow_optgroups | Allow option groups. |
from Fieldmanager_Datasource |
string | $ajax_action | The Ajax action. |
from Fieldmanager_Datasource |
static int | $counter | Counter to create uniquely named Ajax actions. |
from Fieldmanager_Datasource |
bool | $grouped | If true, group elements. |
from Fieldmanager_Datasource |
null | $query_callback | Supply a function which returns a list of posts; takes one argument, a possible fragment. |
|
array | $query_args | Arguments to get_posts(), which uses WP's defaults, plus suppress_filters = False, which can be overridden by setting suppress_filters = True here. |
|
string | $reciprocal | If not empty, set this post's ID as a value on the linked post. This is used to establish two-way relationships. |
|
bool | $show_date | Display the post publish date in the typeahead menu. |
|
string | $date_format | If $show_date is true, the format to use for displaying the date. |
|
bool | $publish_with_parent | Publish the child post when/if the parent is published. |
|
bool | $save_to_post_parent | Save to post parent. |
|
bool | $only_save_to_post_parent | Only save to post parent. |
Methods
Construct the object.
Get a post title by post ID.
Get posts which match this datasource, optionally filtered by a fragment, e.g. for Autocomplete.
Get an action to register by hashing (non cryptographically for speed) the options that make this datasource unique.
Format items for use in Ajax.
For post relationships, delete reciprocal post metadata prior to saving (presave will re-add).
Preload alter values for post parent The post datasource can store data outside FM's array.
Handle reciprocal postmeta and post parents.
Get edit link for a post.
Get edit link for a post.
Perform a LIKE search on post_title, since 's' in WP_Query is too fuzzy when trying to autocomplete a title.
Handle any actions based on the parent's status transition.
Details
__construct(array $options = array())
Construct the object.
string
get_value(int $value)
Get a post title by post ID.
array
get_items(string $fragment = null)
Get posts which match this datasource, optionally filtered by a fragment, e.g. for Autocomplete.
string
get_ajax_action()
Get an action to register by hashing (non cryptographically for speed) the options that make this datasource unique.
get_items_for_ajax(string|null $fragment = null)
Format items for use in Ajax.
autocomplete_search()
Ajax callback to find posts.
string
presave_alter_values(Fieldmanager_Field $field, mixed $values, mixed $current_values)
For post relationships, delete reciprocal post metadata prior to saving (presave will re-add).
array
preload_alter_values(Fieldmanager_Field $field, mixed $values)
Preload alter values for post parent The post datasource can store data outside FM's array.
This is how we add it back into the array for editing.
string
presave(Fieldmanager_Field $field, mixed $value, mixed $current_value)
Handle reciprocal postmeta and post parents.
string
get_view_link(mixed $value)
Get edit link for a post.
string
get_edit_link(int|string $value)
Get edit link for a post.
title_like(string $where, WP_Query $wp_query)
Perform a LIKE search on post_title, since 's' in WP_Query is too fuzzy when trying to autocomplete a title.
presave_status_transition(Fieldmanager_Field $field, int $value)
Handle any actions based on the parent's status transition.