Disciple_Tools_Posts

Class Disciple_Tools_Posts Functions for creating, finding, updating or deleting posts

package

Disciple_Tools\Posts

Methods

Disciple_Tools_Posts constructor.

__construct() 

add_connection_to_post

add_connection_to_post(\string $post_type, \int $post_id, \string $field_key, \int $value) 
static

Arguments

$post_type

\string

$post_id

\int

$field_key

\string

$value

\int

add_post_contact_method

add_post_contact_method(array $post_settings, \int $post_id, \string $key, \string $value, array $field) 
static

Arguments

$post_settings

array

$post_id

\int

$key

\string

$value

\string

$field

array

Used in in the method get_custom, this method mutates $fields to add data about a particular contact in the required format. You might want to use this instead of get_custom for performance reasons.

adjust_post_custom_fields(array $post_settings, integer $post_id, array &$fields, array $fields_to_return = array(), null $meta_fields = null, null $post_user_meta = null) : void
static

Arguments

$post_settings

array

This is what get_custom_fields_settings() returns

$post_id

integer

The ID number of the contact

$fields

array

This array will be mutated with the results

$fields_to_return

array

if not empty only add the fields that are specified (optional)

$meta_fields

null

a way to pass in the post's meta fields instead of getting in from the database (optional)

$post_user_meta

null

pass in the user post meta if already available (optional)

can_access

can_access(string $post_type) : boolean
static

Arguments

$post_type

string

Response

boolean

can_create

can_create(string $post_type) : boolean
static

Arguments

$post_type

string

Response

boolean

can_delete

can_delete(string $post_type) : boolean
static

Arguments

$post_type

string

Response

boolean

A user can update the record if they have the global permission or if the post if assigned or shared with them

can_update(string $post_type, integer $post_id) : boolean
static

Arguments

$post_type

string

$post_id

integer

Response

boolean

A user can view the record if they have the global permission or if the post if assigned or shared with them

can_view(string $post_type, integer $post_id) : boolean
static

Arguments

$post_type

string

$post_id

integer

Response

boolean

can_view_all

can_view_all(string $post_type) : boolean
static

Arguments

$post_type

string

Response

boolean

Make sure there are no extra or misspelled fields Make sure the field values are the correct format

check_for_invalid_post_fields(array $post_settings, array $fields, array $allowed_fields = array()) : array
static

Arguments

$post_settings

array

$fields

array

$allowed_fields

array

Response

array

Helper function to create a unique metakey for contact channels.

create_channel_metakey( $channel_key,  $field_type) : string
static

Arguments

$channel_key

$field_type

Response

string

delete_post

delete_post(\int $post_id, \string $post_type) 
static

Arguments

$post_id

\int

$post_type

\string

Reduced the number of fields on a post to what is useful in D.T

filter_wp_post_object_fields(object $post) : array
static

Arguments

$post

object

Response

array

format_activity_message

format_activity_message( $activity,  $post_type_settings) 
static

Arguments

$activity

$post_type_settings

format_connection_message

format_connection_message( $p2p_id,  $activity,  $action = 'connected to') 
static

Arguments

$p2p_id

$activity

$action

format_post_contact_details

format_post_contact_details( $post_settings,  $meta_fields,  $type,  $key,  $value) 
static

Arguments

$post_settings

$meta_fields

$type

$key

$value

get_label_for_post_type

get_label_for_post_type( $post_type,  $singular = false) 
static

Arguments

$post_type

$singular

Get most recent activity for the field

get_most_recent_activity_for_field( $post_id,  $field_key) : mixed
static

Arguments

$post_id

$field_key

Response

mixed

get_multi_select_options

get_multi_select_options( $post_type,  $field,  $search = "") 
static

Arguments

$post_type

$field

$search

Cached version of get_page_by_title so that we're not making unnecessary SQL all the time

get_post_by_title_cached(string $title, string $output = OBJECT, string|array $post_type = 'page',  $connection_type = 'none') : \WP_Post|null
static
link

Uncached Functions

Arguments

$title

string

Page title

$output

string

Optional. Output type; OBJECT*, ARRAY_N, or ARRAY_A.

$post_type

string|array

Optional. Post type; default is 'page'.

$connection_type

Response

\WP_Post|null

WP_Post on success or null on failure

get_posts_shared_with_user

get_posts_shared_with_user(string $post_type, integer $user_id,  $search_for_post_name = '') : array
static

Arguments

$post_type

string

$user_id

integer

$search_for_post_name

Response

array

get_subassigned_users

get_subassigned_users( $post_id) 
static

Arguments

$post_id

get_viewable

get_viewable(string $post_type, integer $most_recent) : array|\WP_Error|\WP_Query
static

Arguments

$post_type

string

$most_recent

integer

Response

array|\WP_Error|\WP_Query

is_post_key_contact_method_or_connection

is_post_key_contact_method_or_connection( $post_settings,  $key) 
static

Arguments

$post_settings

$key

remove_connection_from_post

remove_connection_from_post(\string $post_type, \int $post_id, \string $field_key, \int $value) 
static

Arguments

$post_type

\string

$post_id

\int

$field_key

\string

$value

\int

search_viewable_post

search_viewable_post(\string $post_type, array $query, \bool $check_permissions = true) 
static

Arguments

$post_type

\string

$query

array

$check_permissions

\bool

unique_hash

unique_hash() 
static

update_connections

update_connections(array $post_settings, \int $post_id, array $fields,  $existing_contact = null) 
static

Arguments

$post_settings

array

$post_id

\int

$fields

array

$existing_contact

update_location_grid_fields

update_location_grid_fields(array $field_settings, \int $post_id, array $fields,  $post_type, array $existing_post = null) 
static

Arguments

$field_settings

array

$post_id

\int

$fields

array

$post_type

$existing_post

array

update_multi_select_fields

update_multi_select_fields(array $field_settings, \int $post_id, array $fields, array $existing_contact = null) 
static

Arguments

$field_settings

array

$post_id

\int

$fields

array

$existing_contact

array

update_post_contact_method

update_post_contact_method(\int $post_id, \string $key, array $values) 
static

Arguments

$post_id

\int

$key

\string

$values

array

update_post_contact_methods

update_post_contact_methods(array $post_settings, \int $post_id, array $fields, array $existing_contact = null) 
static

Arguments

$post_settings

array

$post_id

\int

$fields

array

$existing_contact

array

update_post_user_meta_fields

update_post_user_meta_fields(array $field_settings, \int $post_id, array $fields, array $existing_record) 
static

Arguments

$field_settings

array

$post_id

\int

$fields

array

$existing_record

array