Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.
Jared Cobb edited this page Feb 9, 2018 · 5 revisions

Overview

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!

Actions

ccb_core_before_insert_update_post

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.

ccb_core_after_insert_update_post

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.

Filters

ccb_core_settings_capability

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.

ccb_core_allow_custom_uploads_directory

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.

ccb_core_settings_post_definitions

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.

ccb_core_settings_definitions

Allows filtering of the entire settings array.

Parameter Type Description
$settings array The current array of settings definitions.

ccb_core_synchronizer_post_api_map

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.

ccb_core_synchronizer_taxonomy_api_map

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.

ccb_core_synchronizer_api_response

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.

ccb_core_synchronizer_delete_empty_terms

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.

ccb_core_synchronizer_entity_insert_allowed

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.

ccb_core_synchronizer_entity_update_allowed

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.

ccb_core_synchronizer_entity_delete_allowed

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.

ccb_core_synchronizer_get_entity_id

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.

ccb_core_synchronizer_insert_post_args

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.

ccb_core_synchronizer_delete_attachment

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.

ccb_core_ajax_results_message

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.