-
Notifications
You must be signed in to change notification settings - Fork 5
Hooks
There are several hooks that will allow you to customize the synchronization process. Need a hook? Create an issue and let's discuss the best implementation!
This action runs just before a post is inserted or updated during the synchronization process.
Parameter | Type | Description |
---|---|---|
$entity |
SimpleXML |
The entity object to be inserted / updated. |
$settings |
array | The settings for the import as defined in the Custom Post Type Class. |
$args |
array | The args that will be used for wp_insert_post. |
$post_type |
string | The current post type that will be inserted. |
This action runs just after a post is inserted or updated during the synchronization process.
Parameter | Type | Description |
---|---|---|
$entity |
SimpleXML |
The entity object to be inserted / updated. |
$settings |
array | The settings for the import as defined in the Custom Post Type Class. |
$args |
array | The args that will be used for wp_insert_post. |
$post_type |
string | The current post type that will be inserted. |
$post_id |
int | The post id of the post that was just inserted or updated. |
Defines the capability that is required for the user to access the settings page.
Parameter | Type | Description |
---|---|---|
$capability |
string |
The capability needed to access the settings pages. Default: manage_options . |
Allow for the ability to enable / disable custom upload path. Useful for preventing CCB images from being mixed with other images in your uploads folder.
Parameter | Type | Description |
---|---|---|
$allowed |
bool |
Whether the plugin should upload images into a custom subfolder in /uploads/ccb/ . Default: true . |
Allows custom post types to have their own settings pages. If you implement a custom post type and do not want to expose a settings page, simply return $settings
from within your implementation of get_post_settings_definitions()
.
Parameter | Type | Description |
---|---|---|
$settings |
array |
The current array of settings definitions. |
Allows filtering of the entire settings array.
Parameter | Type | Description |
---|---|---|
$settings |
array |
The current array of settings definitions. |
Returns a collection of all post type / API mappings. This is the main configuration for how the CCB API maps to a custom post type.
// A single map that defines the relationship between the CCB API entity node and the custom post type.
$map[ {post_type} ] = [
'service' => {ccb_service_name},
'data' => [ {ccb_query_string_parameters} ],
'nodes' => [ {node list that maps to a single entity} ],
'fields' => [
{entity_name_node} => 'post_title',
{entity_description_node} => 'post_content',
{any_other_node} => 'post_meta',
{any_other_node} => 'post_meta',
{any_other_node} => 'post_meta',
],
];
Parameter | Type | Description |
---|---|---|
$maps |
array |
A collection of all post type / API mappings. |
Returns a collection of all taxonomy / API mappings. This is the main configuration for how the CCB API maps some of the nodes on an entity to custom taxonomies.
// A single map that defines the relationship between some of the nodes on a CCB entity to custom taxonomies.
$map[ {post_type} ]['taxonomies']['hierarchical'][ {taxonomy} ] = [
'api_mapping' => {node},
];
$map[ {post_type} ]['taxonomies']['nonhierarchical'][ {taxonomy} ] = [
'api_mapping' => [ {node} => {tag_name} ],
];
Parameter | Type | Description |
---|---|---|
$maps |
array |
A collection of all taxonomy / API mappings. |
Filters the API response for each service during the synchronization process.
Parameter | Type | Description |
---|---|---|
$response |
array |
The API response for a specific service call. |
$settings |
array |
The settings used for the API call as defined by the Custom Post Type class. |
$post_type |
string |
The current post type being synchronized. |
Whether or not we should clean up (delete) empty terms after a synchronization. Recommended to be true.
Parameter | Type | Description |
---|---|---|
$delete_terms |
bool |
Whether or not to delete empty terms. |
$settings |
array |
The settings used for the API call as defined by the Custom Post Type class. |
$post_type |
string |
The current post type being synchronized. |
Whether or not this specific entity is allowed to insert. Helpful if you need to inspect an entity for custom business rules before allowing an insert to happen. For example, group_profiles
will send us inactive groups. We do not want to insert inactive groups.
Parameter | Type | Description |
---|---|---|
$allowed |
bool |
Whether or not the entity is allowed. |
$entity |
SimpleXML |
The entity to insert. |
$entity_id |
mixed |
The unique identifier from CCB. |
$post_type |
string |
The current post type being synchronized. |
Whether or not this specific entity is allowed to update. Helpful if you need to inspect an entity for custom business rules before allowing an update to happen.
Parameter | Type | Description |
---|---|---|
$allowed |
bool |
Whether or not the entity is allowed. |
$entity |
SimpleXML |
The entity to insert. |
$entity_id |
mixed |
The unique identifier from CCB. |
$post_type |
string |
The current post type being synchronized. |
Whether or not this specific entity is allowed to be deleted. Helpful if you need to inspect an entity for custom business rules before allowing a delete to happen.
Parameter | Type | Description |
---|---|---|
$allowed |
bool |
Whether or not the entity is allowed. |
$data |
array |
The WordPress post data. |
$entity_id |
mixed |
The unique identifier from CCB. |
$post_type |
string |
The current post type being synchronized. |
Filter the unique entity_id that we attempt to auto detect from the entity object. Typically a CCB ID or else we create our own.
Parameter | Type | Description |
---|---|---|
$entity_id |
mixed |
Either an integer id or hash. |
$entity |
SimpleXML |
The current entity object. |
Filters the wp_insert_post
$args
for each entity (fires on both inserts and updates).
Parameter | Type | Description |
---|---|---|
$args |
array |
The wp_insert_post args. |
$entity |
SimpleXML |
The current entity object. |
$settings |
array |
The settings used for the API call as defined by the Custom Post Type class. |
$post_type |
string |
The current post type being synchronized. |
Filters whether or not the attachment for this post should also be deleted.
Parameter | Type | Description |
---|---|---|
$delete |
bool |
Whether or not the attachment should be deleted. |
$post_id |
int |
The post id. |
Filters the message that gets output to the user after a synchronization is finished.
Parameter | Type | Description |
---|---|---|
$message |
string |
The message with the results. |
$latest_sync |
array |
The latest synchronization results. |