Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from jaredcobb/1.0.4
Browse files Browse the repository at this point in the history
Adds the CCB event id to each instance of a recurring event
  • Loading branch information
jaredcobb committed Apr 2, 2018
2 parents 920ef6a + 42cdbe7 commit 6b86f65
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.txt
Expand Up @@ -3,7 +3,7 @@ Contributors: jaredcobb
Tags: ccb, church, api, chms
Requires at least: 4.6.0
Tested up to: 4.9.4
Stable tag: 1.0.3
Stable tag: 1.0.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -61,6 +61,9 @@ You'll need to ensure your [group settings](https://churchcommunitybuilder.force

== Changelog ==

= 1.0.4 =
* Adds the CCB event id (as post meta) to each instance of a recurring event. This allows individual instances of a recurring event to be associated with each other in WordPress.

= 1.0.3 =
* Featured images associated with synchronized posts now also get deleted when the post is deleted
* A new filter `ccb_core_synchronizer_delete_attachment` has been created to optionally overwrite the default behavior of deleting attachments when posts are deleted
Expand Down
4 changes: 2 additions & 2 deletions ccb-core.php
Expand Up @@ -10,7 +10,7 @@
* Plugin Name: Church Community Builder Core API
* Plugin URI: https://www.wpccb.com
* Description: A plugin to provide a core integration of the Church Community Builder API into WordPress custom post types
* Version: 1.0.3
* Version: 1.0.4
* Author: Jared Cobb
* Author URI: https://www.jaredcobb.com/
* License: GPL-2.0+
Expand All @@ -27,7 +27,7 @@
define( 'CCB_CORE_PATH', plugin_dir_path( __FILE__ ) );
define( 'CCB_CORE_URL', plugin_dir_url( __FILE__ ) );
define( 'CCB_CORE_BASENAME', plugin_basename( __FILE__ ) );
define( 'CCB_CORE_VERSION', '1.0.3' );
define( 'CCB_CORE_VERSION', '1.0.4' );

// Check minimum requirements before proceeding.
require_once CCB_CORE_PATH . 'includes/class-ccb-core-requirements.php';
Expand Down
30 changes: 30 additions & 0 deletions includes/post-types/class-ccb-core-calendar.php
Expand Up @@ -29,6 +29,9 @@ class CCB_Core_Calendar extends CCB_Core_CPT {
* Initialize the class
*/
public function __construct() {
// Add the CCB event id as post meta onto each instance of the event.
add_action( 'ccb_core_after_insert_update_post', [ $this, 'update_event_id' ], 10, 5 );

$options = CCB_Core_Helpers::instance()->get_options();
$this->enabled = ! empty( $options['calendar_enabled'] ) ? true : false;
parent::__construct();
Expand Down Expand Up @@ -297,6 +300,33 @@ public function get_post_api_map( $maps ) {
return $maps;
}

/**
* Parses the CCB event id from the `name` node and
* saves it as post meta.
*
* @since 1.0.4
*
* @param SimpleXML $entity The entity object.
* @param array $settings The settings array for the import.
* @param array $args The `wp_insert_post` args.
* @param string $post_type The current post type.
* @param int $post_id The WordPress post id of this post.
* @return bool
*/
public function update_event_id( $entity, $settings, $args, $post_type, $post_id ) {
if ( ! empty( $entity->event_name ) ) {
foreach ( $entity->event_name->attributes() as $key => $value ) {
if ( 'ccb_id' === $key ) {
$event_id = (int) $value;
if ( $event_id ) {
return update_post_meta( $post_id, 'event_id', $event_id );
}
}
}
}
return false;
}

/**
* Returns a standardized configuration array of
* start and end dates to be used by the API call.
Expand Down

0 comments on commit 6b86f65

Please sign in to comment.