diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..100725f
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,63 @@
+sudo: false
+dist: trusty
+
+language: php
+
+notifications:
+ email:
+ on_success: never
+ on_failure: change
+
+branches:
+ only:
+ - master
+
+cache:
+ directories:
+ - vendor
+ - $HOME/.composer/cache
+
+matrix:
+ include:
+ - php: 7.1
+ env: WP_VERSION=latest
+ - php: 7.0
+ env: WP_VERSION=latest
+ - php: 5.6
+ env: WP_VERSION=4.6
+ - php: 5.6
+ env: WP_VERSION=latest
+ - php: 5.6
+ env: WP_VERSION=trunk
+ - php: 5.6
+ env: WP_TRAVISCI=phpcs
+
+before_script:
+ - export PATH="$HOME/.composer/vendor/bin:$PATH"
+ - |
+ if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
+ phpenv config-rm xdebug.ini
+ else
+ echo "xdebug.ini does not exist"
+ fi
+ - |
+ if [[ ! -z "$WP_VERSION" ]] ; then
+ bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
+ composer global require "phpunit/phpunit=4.8.*|5.7.*"
+ fi
+ - |
+ if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
+ composer global require wp-coding-standards/wpcs
+ phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
+ fi
+
+script:
+ - |
+ if [[ ! -z "$WP_VERSION" ]] ; then
+ phpunit
+ WP_MULTISITE=1 phpunit
+ fi
+ - |
+ if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
+ phpcs
+ fi
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f232ee1
--- /dev/null
+++ b/README.md
@@ -0,0 +1,40 @@
+# Church Community Builder Core API
+
+## A WordPress Plugin that syncs your church data
+
+CCB Core API is a WordPress plugin that has one simple job: It **synchronizes** your church data from [Church Community Builder](https://www.churchcommunitybuilder.com/) into your WordPress database as [Custom Post Types](https://codex.wordpress.org/Post_Types#Custom_Post_Types), [Custom Taxonomies](https://codex.wordpress.org/Taxonomies#Custom_Taxonomies), and [Post Meta](https://codex.wordpress.org/Custom_Fields).
+
+## Who should use this?
+
+This plugin is geared toward Developers, Designers, and Site Administrators who are familiar with customizing WordPress templates. While it does a great job of synchronizing the data, you'll still need to alter your theme in order to take *advantage* of the data.
+
+## What's included?
+
+Out of the box, there are two complete integrations:
+
+### Public Groups
+
+This integration will synchronize any groups that are both _publicly listed_ and _active_ from the Church Community Builder `group_profiles` service to a Custom Post Type named `ccb_core_groups`.
+
+### Public Calendar (Events)
+
+This integration will synchronize all events from the Church Community Builder `public_calendar_listing` service to a Custom Post Type named `ccb_core_calendar`.
+
+## Features
+
+* **Auto Synchronize** - Set it and forget it! The plugin works in the background, never interrupting you or your visitors.
+* **Secure** - Your credentials are encrypted, and so is the connection with the Church Community Builder API.
+* **WordPress Standards** - The plugin follows WordPress coding standards and best practices, so it's easy to extend and build upon.
+* **Free** - Free as in "speech" or free as in "beer"? Yes! It's [GPLv2 licensed](https://tldrlegal.com/license/gnu-general-public-license-v2). Don't you love open source?
+
+## Customizing & Extending
+
+* Setup additional integrations with other Church Community Builder API services.
+* Write your own plugin that builds upon this one.
+* Customize the existing integrations (Groups & Events).
+
+
**[The Wiki](https://github.com/jaredcobb/ccb-core/wiki) has more information and code samples.**
+
+## General Usage
+
+General usage information (setting up the plugin and customizing your theme) can be found in the [usage docs](https://www.wpccb.com/documentation/).
\ No newline at end of file
diff --git a/README.txt b/README.txt
index 5faf81f..7cf0637 100644
--- a/README.txt
+++ b/README.txt
@@ -1,9 +1,9 @@
=== Church Community Builder Core API ===
Contributors: jaredcobb
Tags: ccb, church, api, chms
-Requires at least: 3.0.1
-Tested up to: 4.3.1
-Stable tag: 0.9.6
+Requires at least: 4.6.0
+Tested up to: 4.9.1
+Stable tag: 1.0.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -12,15 +12,14 @@ Provides a core integration to the Church Community Builder API.
== Description ==
Church Community Builder Core API *synchronizes* your church data to WordPress [custom post types](https://codex.wordpress.org/Custom_Post_Types).
-This plugin is geared toward developers (or advanced WordPress users who aren't afraid to get into a little bit of code).
-Find out more at [http://www.wpccb.com/](http://www.wpccb.com).
+This plugin is geared toward Developers, Designers, and Site Administrators who aren't afraid to get into a little bit of code.
+
+Find out more at [https://www.wpccb.com](https://www.wpccb.com) and [https://github.com/jaredcobb/ccb-core](https://github.com/jaredcobb/ccb-core).
= Why Use This Plugin? =
-One of the biggest challenges with getting your Church Community Builder data onto your site is the actual API integration.
-This plugin does all of the heavy lifting for you. Once your church data is securely synchronized you can use it freely in
-your theme, widgets, or even your own plugins!
+One of the biggest challenges with getting your Church Community Builder data onto your site is the actual API integration. This plugin does all of the heavy lifting for you. Once your church data is securely synchronized you can use it freely in your theme, widgets, or even your own plugins!
= Features =
@@ -34,7 +33,7 @@ your theme, widgets, or even your own plugins!
= Documentation =
-The [http://www.wpccb.com/documentation/](official documentation) has more information, including code samples, hooks, filters, and links to tutorials.
+Extensive developer documentation is available on the [GitHub wiki](https://github.com/jaredcobb/ccb-core/wiki).
== Installation ==
@@ -49,15 +48,11 @@ The [http://www.wpccb.com/documentation/](official documentation) has more infor
= I installed this plugin and my site doesn't look any different =
-This plugin has a very specific task: It gets some of your Church Community Builder data and imports it into your
-WordPress database (as custom post types). A developer (or advanced WordPress administrator) will need to
-alter your theme to *take advantage* of this data.
+This plugin has a very specific task: It gets some of your Church Community Builder data and imports it into your WordPress database (as custom post types). A developer (or advanced WordPress administrator) will need to alter your theme to *take advantage* of this data.
= Some of my groups in Church Community Builder aren't being synchronized =
-You'll need to ensure your [group settings](https://support.churchcommunitybuilder.com/customer/portal/articles/361764-editing-groups)
-allow the group to be publicly listed. A great way to cross reference if your group is publicly visible is to visit
-*yoursubdomain*.ccbchurch.com/w_group_list.php and see if the missing group shows up there.
+You'll need to ensure your [group settings](https://churchcommunitybuilder.force.com/s/article/2102903) allow the group to be publicly listed. A great way to cross reference if your group is publicly visible is to visit *yoursubdomain*.ccbchurch.com/w_group_list.php and see if the missing group shows up there.
== Screenshots ==
@@ -66,6 +61,12 @@ allow the group to be publicly listed. A great way to cross reference if your gr
== Changelog ==
+= 1.0.0 =
+* Official stable release
+* *Breaking Changes* - Please note that post type and custom taxonomy names have changed (see [release notes](https://github.com/jaredcobb/ccb-core/wiki/1.0.0-Stable-Release) )
+* Fixed broken group images (CCB API query parameter `include_image_link=true`)
+* Refactored code to be faster, simpler, and easier to extend
+
= 0.9.6 =
* Added automatic flushing of rewrite rules when custom post type settings are changed
* Added link to official documentation in README and About page
@@ -89,7 +90,7 @@ allow the group to be publicly listed. A great way to cross reference if your gr
= 0.9.2 =
* Added tooltips to some settings to help explain the functionality
* Added better defaults for date ranges
-* Updated the plugin web site to http://www.wpccb.com
+* Updated the plugin web site to https://www.wpccb.com
= 0.9.1 =
* Fixed an issue where some web hosts were not saving encypted passwords
diff --git a/admin/class-ccb-core-admin.php b/admin/class-ccb-core-admin.php
deleted file mode 100644
index d264ec7..0000000
--- a/admin/class-ccb-core-admin.php
+++ /dev/null
@@ -1,329 +0,0 @@
-
- */
-class CCB_Core_Admin extends CCB_Core_Plugin {
-
- /**
- * Initialize the class and set its properties.
- *
- * @since 0.9.0
- */
- public function __construct() {
- parent::__construct();
- }
-
- /**
- * Initialize the Settings Menu and Page
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function initialize_settings_menu() {
-
- $settings = new CCB_Core_Settings();
- $settings_definitions = $settings->get_settings_definitions();
- $settings_page = new CCB_Core_Settings_Page( $this->plugin_settings_name );
-
- add_menu_page( $this->plugin_display_name, $this->plugin_short_display_name, 'manage_options', $this->plugin_settings_name, '__return_null', 'dashicons-update', '80.9' );
-
- if ( is_array( $settings_definitions ) && ! empty( $settings_definitions ) ) {
- foreach ( $settings_definitions as $page_id => $page ) {
- $settings_page = new CCB_Core_Settings_Page( $page_id, $page );
- add_submenu_page( $this->plugin_settings_name, $page['page_title'], $page['page_title'], 'manage_options', $page_id, array( $settings_page, 'render_page' ) );
- }
- }
- }
-
- /**
- * Initialize the Settings
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function initialize_settings() {
-
- $settings = new CCB_Core_Settings();
- $settings_definitions = $settings->get_settings_definitions();
-
- if ( is_array( $settings_definitions ) && ! empty( $settings_definitions ) ) {
- foreach ( $settings_definitions as $page_id => $page ) {
-
- register_setting( $page_id, $this->plugin_settings_name, array( $settings, 'validate_settings' ) );
-
- if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) {
- foreach ( $page['sections'] as $section_id => $section ) {
-
- $settings_section = new CCB_Core_Settings_Section( $section_id, $section );
- add_settings_section( $section_id, $section['section_title'], array( $settings_section, 'render_section' ), $page_id );
-
- if ( isset( $section['fields'] ) && ! empty( $section['fields'] ) ) {
- foreach ( $section['fields'] as $field_id => $field ) {
-
- $settings_field = new CCB_Core_Settings_Field( $field_id, $field );
- add_settings_field( $field_id, $field['field_title'], array( $settings_field, 'render_field' ), $page_id, $section_id );
-
- }
- }
-
- }
- }
-
- }
- }
-
- }
-
- /**
- * Just before the settings are saved, check for changes
- * that would require us to flush the rewrite rules
- *
- * @param array $new_settings
- * @param array $previous_settings
- * @access public
- * @since 0.9.6
- * @return array
- */
- public function update_settings_callback( $new_settings, $previous_settings ) {
-
- // create a collection of settings that, if they change, should
- // trigger a flush_rewrite_rules event
- $setting_array = array(
- 'groups-enabled',
- 'groups-slug',
- 'calendar-enabled',
- 'calendar-slug',
- );
-
- foreach ( $setting_array as $setting ) {
- if ( isset( $new_settings[ $setting ] ) ) {
- if ( ! isset( $previous_settings[ $setting ] ) || $new_settings[ $setting ] !== $previous_settings[ $setting ] ) {
- // schedule an event to flush the rewrite rules on the next page load because the settings aren't quite saved yet
- wp_schedule_single_event( time(), 'schedule_flush_rewrite_rules' );
- }
- }
- }
-
- return $new_settings;
- }
-
- /**
- * Simple callback function for flushing the rewrite rules
- *
- * @access public
- * @since 0.9.6
- * @return void
- */
- public function flush_rewrite_rules_event() {
-
- flush_rewrite_rules();
- }
-
- /**
- * Register the CCB custom post types if enabled
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function initialize_custom_post_types() {
- $cpts = new CCB_Core_CPTs();
- $cpts->initialize();
- }
-
- /**
- * Launches a synchronization from an ajax hook and will respond
- * with a non-blocking ajax response
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function ajax_sync() {
-
- $nonce = $_POST['nextNonce'];
-
- if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-nonce' ) ) {
- wp_send_json( array('success' => false) );
- }
-
- // tell the user to move along and go about their business...
- $this->send_non_blocking_json_response( array( 'success' => true ) );
-
- $sync = new CCB_Core_Sync();
- $sync->sync();
-
- }
-
- /**
- * Checks for an active synchronization from an ajax hook
- * and responds with the transient value
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function ajax_poll_sync() {
-
- $nonce = $_POST['nextNonce'];
- if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-nonce' ) ) {
- wp_send_json( array('success' => false) );
- }
-
- $sync_in_progress = get_transient( $this->plugin_name . '-sync-in-progress' );
- wp_send_json( array( 'syncInProgress' => $sync_in_progress ) );
-
- }
-
- /**
- * Gets the latest synchronization results from an ajax hook
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function ajax_get_latest_sync() {
-
- $nonce = $_POST['nextNonce'];
- if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-nonce' ) ) {
- wp_send_json( array('success' => false) );
- }
-
- $latest_sync = $this->get_latest_sync_results();
- wp_send_json( $latest_sync );
-
- }
-
- /**
- * Checks the credentials for a user from an ajax hook
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function ajax_test_credentials() {
-
- $nonce = $_POST['nextNonce'];
- if ( ! wp_verify_nonce( $nonce, $this->plugin_name . '-nonce' ) ) {
- wp_send_json( array('success' => false) );
- }
-
- $sync = new CCB_Core_Sync();
- $validation_results = $sync->test_api_credentials();
-
- wp_send_json( $validation_results );
-
- }
-
- /**
- * Create a helpful settings link on the plugin page
- *
- * @param array $links
- * @access public
- * @since 0.9.0
- * @return array
- */
- public function add_settings_link( $links ) {
- $links[] = 'Settings';
- return $links;
- }
-
- /**
- * Check if we should schedule a synchronization based on
- * the options set by the user
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function check_auto_refresh() {
-
- $settings = get_option( $this->plugin_settings_name );
-
- if ( isset( $settings['auto-sync'] ) && $settings['auto-sync'] == 1 ) {
- $latest_sync = get_option( $this->plugin_name . '-latest-sync' );
-
- if ( ! empty( $latest_sync ) ) {
- $auto_sync_timeout = $settings['auto-sync-timeout'];
- $now = time();
- $diff = $now - $latest_sync['timestamp'];
-
- if ( $diff > $auto_sync_timeout * 60 ) {
- wp_schedule_single_event( time(), 'schedule_auto_refresh' );
- }
-
- }
- else {
- wp_schedule_single_event( time(), 'schedule_auto_refresh' );
- }
- }
- }
-
- /**
- * Callback function to kick off a synchronization
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function auto_sync() {
- $sync = new CCB_Core_Sync();
- $sync->sync();
- }
-
- /**
- * Register the stylesheets for the dashboard.
- *
- * @since 0.9.0
- */
- public function enqueue_styles( $hook ) {
-
- if ( stristr( $hook, $this->plugin_settings_name ) !== false ) {
- wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/ccb-core-admin.css', array(), $this->version, 'all' );
- wp_enqueue_style( 'switchery', plugin_dir_url( __FILE__ ) . 'css/vendor/switchery.min.css', array(), $this->version, 'all' );
- wp_enqueue_style( 'powerange', plugin_dir_url( __FILE__ ) . 'css/vendor/powerange.min.css', array(), $this->version, 'all' );
- wp_enqueue_style( 'picker', plugin_dir_url( __FILE__ ) . 'css/vendor/default.css', array(), $this->version, 'all' );
- wp_enqueue_style( 'picker-date', plugin_dir_url( __FILE__ ) . 'css/vendor/default.date.css', array(), $this->version, 'all' );
- wp_enqueue_style( 'tipr', plugin_dir_url( __FILE__ ) . 'css/vendor/tipr.css', array(), $this->version, 'all' );
- }
-
- }
-
- /**
- * Register the scripts for the dashboard.
- *
- * @since 0.9.0
- */
- public function enqueue_scripts( $hook ) {
-
- if ( stristr( $hook, $this->plugin_settings_name ) !== false ) {
- wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/ccb-core-admin.js', array( 'jquery' ), $this->version, false );
- wp_enqueue_script( 'switchery', plugin_dir_url( __FILE__ ) . 'js/vendor/switchery.min.js', array( 'jquery' ), $this->version, false );
- wp_enqueue_script( 'powerange', plugin_dir_url( __FILE__ ) . 'js/vendor/powerange.min.js', array( 'jquery' ), $this->version, false );
- wp_enqueue_script( 'picker', plugin_dir_url( __FILE__ ) . 'js/vendor/picker.js', array( 'jquery' ), $this->version, false );
- wp_enqueue_script( 'picker-date', plugin_dir_url( __FILE__ ) . 'js/vendor/picker.date.js', array( 'picker' ), $this->version, false );
- wp_enqueue_script( 'tipr', plugin_dir_url( __FILE__ ) . 'js/vendor/tipr.min.js', array( 'jquery' ), $this->version, false );
- wp_localize_script( $this->plugin_name, strtoupper( $this->plugin_settings_name ), array(
- 'nextNonce' => wp_create_nonce( $this->plugin_name . '-nonce' ))
- );
- }
-
- }
-
-}
diff --git a/admin/class-ccb-core-cpts.php b/admin/class-ccb-core-cpts.php
deleted file mode 100644
index a7a0cab..0000000
--- a/admin/class-ccb-core-cpts.php
+++ /dev/null
@@ -1,400 +0,0 @@
-
- */
-class CCB_Core_CPTs extends CCB_Core_Plugin {
-
- /**
- * The options we should use to register the groups CPT
- *
- * @since 0.9.0
- * @access protected
- * @var array $groups_cpt_options
- */
- protected $groups_cpt_options = array();
-
- /**
- * The options we should use to register the calendar CPT
- *
- * @since 0.9.0
- * @access protected
- * @var array $calendar_cpt_options
- */
- protected $calendar_cpt_options = array();
-
- /**
- * Initialize the class and set its properties.
- *
- * @since 0.9.0
- */
- public function __construct() {
-
- parent::__construct();
-
- }
-
- /**
- * Determine which CCB custom post types should be registered
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function initialize() {
-
- $settings = get_option( $this->plugin_settings_name );
-
- if ( isset( $settings['groups-enabled'] ) && $settings['groups-enabled'] == 1 ) {
-
- $this->groups_cpt_options['name'] = ( empty( $settings['groups-name'] ) ? 'Groups' : $settings['groups-name'] );
- $this->groups_cpt_options['slug'] = ( empty( $settings['groups-slug'] ) ? 'groups' : $settings['groups-slug'] );
- $this->groups_cpt_options['singular_name'] = rtrim( $this->groups_cpt_options['name'], 's' ); // this is ghetto
- $this->groups_cpt_options['exclude_from_search'] = ( $settings['groups-exclude-from-search'] == 'yes' ? true : false );
- $this->groups_cpt_options['publicly_queryable'] = ( $settings['groups-publicly-queryable'] == 'yes' ? true : false );
- $this->groups_cpt_options['show_ui'] = ( $settings['groups-show-ui'] == 'yes' ? true : false );
- $this->groups_cpt_options['show_in_nav_menus'] = ( $settings['groups-show-in-nav-menus'] == 'yes' ? true : false );
-
- $this->register_groups();
-
- }
-
- if ( isset( $settings['calendar-enabled'] ) && $settings['calendar-enabled'] == 1 ) {
-
- $this->calendar_cpt_options['name'] = ( empty( $settings['calendar-name'] ) ? 'Events' : $settings['calendar-name'] );
- $this->calendar_cpt_options['slug'] = ( empty( $settings['calendar-slug'] ) ? 'events' : $settings['calendar-slug'] );
- $this->calendar_cpt_options['singular_name'] = rtrim( $this->calendar_cpt_options['name'], 's' ); // this is ghetto
- $this->calendar_cpt_options['exclude_from_search'] = ( $settings['calendar-exclude-from-search'] == 'yes' ? true : false );
- $this->calendar_cpt_options['publicly_queryable'] = ( $settings['calendar-publicly-queryable'] == 'yes' ? true : false );
- $this->calendar_cpt_options['show_ui'] = ( $settings['calendar-show-ui'] == 'yes' ? true : false );
- $this->calendar_cpt_options['show_in_nav_menus'] = ( $settings['calendar-show-in-nav-menus'] == 'yes' ? true : false );
-
- $this->register_calendar();
-
- }
- }
-
- /**
- * Setup the CCB Groups custom post type and its taxonomies
- *
- * @access protected
- * @since 0.9.0
- * @return void
- */
- protected function register_groups() {
-
- register_post_type( $this->plugin_name . '-groups',
- array( 'labels' =>
- array(
- 'name' => $this->groups_cpt_options['name'],
- 'singular_name' => $this->groups_cpt_options['singular_name'],
- 'all_items' => __( 'All ' . $this->groups_cpt_options['name'], $this->plugin_name ),
- 'add_new' => __( 'Add New', $this->plugin_name ),
- 'add_new_item' => __( 'Add New ' . $this->groups_cpt_options['singular_name'], $this->plugin_name ),
- 'edit' => __( 'Edit', $this->plugin_name ),
- 'edit_item' => __( 'Edit ' . $this->groups_cpt_options['name'], $this->plugin_name ),
- 'new_item' => __( 'New ' . $this->groups_cpt_options['singular_name'], $this->plugin_name ),
- 'view_item' => __( 'View ' . $this->groups_cpt_options['singular_name'], $this->plugin_name ),
- 'search_items' => __( 'Search ' . $this->groups_cpt_options['singular_name'], $this->plugin_name ),
- 'not_found' => __( 'Nothing found in the Database.', $this->plugin_name ),
- 'not_found_in_trash' => __( 'Nothing found in Trash', $this->plugin_name ),
- 'parent_item_colon' => ''
- ),
- 'description' => __( 'These are the groups that are synchronized with your Church Community Builder software.', $this->plugin_name ),
- 'public' => true,
- 'publicly_queryable' => $this->groups_cpt_options['publicly_queryable'],
- 'exclude_from_search' => $this->groups_cpt_options['exclude_from_search'],
- 'show_ui' => $this->groups_cpt_options['show_ui'],
- 'show_in_nav_menus' => $this->groups_cpt_options['show_in_nav_menus'],
- 'query_var' => true,
- 'menu_position' => 8,
- 'menu_icon' => 'dashicons-groups',
- 'rewrite' => array( 'slug' => $this->groups_cpt_options['slug'] ),
- 'has_archive' => $this->groups_cpt_options['slug'],
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'sticky' ),
- )
- );
-
- $groups_taxonomies = self::get_groups_taxonomy_map();
- foreach ( $groups_taxonomies as $taxonomy_name=>$taxonomy ) {
- $taxonomy_options = array(
- 'hierarchical' => $taxonomy['hierarchical'],
- 'labels' => array(
- 'name' => $taxonomy['name_plural'],
- 'singular_name' => $taxonomy['name'],
- 'search_items' => "Search {$taxonomy['name_plural']}",
- 'all_items' => "All {$taxonomy['name_plural']}",
- 'parent_item' => "Parent {$taxonomy['name']}",
- 'parent_item_colon' => "Parent {$taxonomy['name']}:",
- 'edit_item' => "Edit {$taxonomy['name']}",
- 'update_item' => "Update {$taxonomy['name']}",
- 'add_new_item' => "Add New {$taxonomy['name']}",
- 'new_item_name' => "New {$taxonomy['name']}"
- ),
- 'show_admin_column' => true,
- 'show_ui' => true,
- 'query_var' => true,
- );
-
- register_taxonomy( $taxonomy_name, "{$this->plugin_name}-groups", $taxonomy_options );
- }
-
- }
-
- /**
- * Setup the CCB Events custom post type and its taxonomies
- *
- * @access protected
- * @since 0.9.0
- * @return void
- */
- protected function register_calendar() {
-
- register_post_type( $this->plugin_name . '-calendar',
- array( 'labels' =>
- array(
- 'name' => $this->calendar_cpt_options['name'],
- 'singular_name' => $this->calendar_cpt_options['singular_name'],
- 'all_items' => __( 'All ' . $this->calendar_cpt_options['name'], $this->plugin_name ),
- 'add_new' => __( 'Add New', $this->plugin_name ),
- 'add_new_item' => __( 'Add New ' . $this->calendar_cpt_options['singular_name'], $this->plugin_name ),
- 'edit' => __( 'Edit', $this->plugin_name ),
- 'edit_item' => __( 'Edit ' . $this->calendar_cpt_options['name'], $this->plugin_name ),
- 'new_item' => __( 'New ' . $this->calendar_cpt_options['singular_name'], $this->plugin_name ),
- 'view_item' => __( 'View ' . $this->calendar_cpt_options['singular_name'], $this->plugin_name ),
- 'search_items' => __( 'Search ' . $this->calendar_cpt_options['singular_name'], $this->plugin_name ),
- 'not_found' => __( 'Nothing found in the Database.', $this->plugin_name ),
- 'not_found_in_trash' => __( 'Nothing found in Trash', $this->plugin_name ),
- 'parent_item_colon' => ''
- ),
- 'description' => __( 'These are the calendar that are synchronized with your Church Community Builder software.', $this->plugin_name ),
- 'public' => true,
- 'publicly_queryable' => $this->calendar_cpt_options['publicly_queryable'],
- 'exclude_from_search' => $this->calendar_cpt_options['exclude_from_search'],
- 'show_ui' => $this->calendar_cpt_options['show_ui'],
- 'show_in_nav_menus' => $this->calendar_cpt_options['show_in_nav_menus'],
- 'query_var' => true,
- 'menu_position' => 8,
- 'menu_icon' => 'dashicons-calendar',
- 'rewrite' => array( 'slug' => $this->calendar_cpt_options['slug'] ),
- 'has_archive' => $this->calendar_cpt_options['slug'],
- 'capability_type' => 'post',
- 'hierarchical' => false,
- 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'sticky' ),
- )
- );
-
- $calendar_taxonomies = self::get_calendar_taxonomy_map();
- foreach ( $calendar_taxonomies as $taxonomy_name=>$taxonomy ) {
- $taxonomy_options = array(
- 'hierarchical' => $taxonomy['hierarchical'],
- 'labels' => array(
- 'name' => $taxonomy['name_plural'],
- 'singular_name' => $taxonomy['name'],
- 'search_items' => "Search {$taxonomy['name_plural']}",
- 'all_items' => "All {$taxonomy['name_plural']}",
- 'parent_item' => "Parent {$taxonomy['name']}",
- 'parent_item_colon' => "Parent {$taxonomy['name']}:",
- 'edit_item' => "Edit {$taxonomy['name']}",
- 'update_item' => "Update {$taxonomy['name']}",
- 'add_new_item' => "Add New {$taxonomy['name']}",
- 'new_item_name' => "New {$taxonomy['name']}"
- ),
- 'show_admin_column' => true,
- 'show_ui' => true,
- 'query_var' => true,
- );
-
- register_taxonomy( $taxonomy_name, "{$this->plugin_name}-calendar", $taxonomy_options );
- }
-
- }
-
- /**
- * Helper method to hold a map of structure from the groups custom post
- * type custom fields to the API schema
- *
- * @static
- * @access public
- * @return array
- */
- public static function get_groups_custom_fields_map() {
- return array(
- 'group_main_leader' => array(
- 'api_mapping' => 'main_leader',
- 'data_type' => 'object',
- 'child_object' => array(
- 'leader_full_name' => array(
- 'api_mapping' => 'full_name',
- 'data_type' => 'string'
- ),
- 'leader_email' => array(
- 'api_mapping' => 'email',
- 'data_type' => 'string'
- )
- )
- ),
- 'group_calendar_feed' => array(
- 'api_mapping' => 'calendar_feed',
- 'data_type' => 'string',
- ),
- 'addresses' => array(
- 'api_mapping' => 'addresses',
- 'data_type' => 'object',
- 'child_object' => array(
- 'address' => array(
- 'api_mapping' => 'address',
- 'data_type' => 'object',
- 'child_object' => array(
- 'longitude' => array(
- 'api_mapping' => 'longitude',
- 'data_type' => 'string'
- ),
- 'latitude' => array(
- 'api_mapping' => 'latitude',
- 'data_type' => 'string'
- ),
- 'address_line_1' => array(
- 'api_mapping' => 'line_1',
- 'data_type' => 'string'
- ),
- 'address_line_2' => array(
- 'api_mapping' => 'line_2',
- 'data_type' => 'string'
- ),
- )
- ),
- ),
- ),
- );
- }
-
- /**
- * Helper method to hold a map of structure from the calendar custom post
- * type custom fields to the API schema
- *
- * @static
- * @access public
- * @return array
- */
- public static function get_calendar_custom_fields_map() {
- return array(
- 'calendar_date' => array(
- 'api_mapping' => 'date',
- 'data_type' => 'string',
- ),
- 'calendar_start_time' => array(
- 'api_mapping' => 'start_time',
- 'data_type' => 'string',
- ),
- 'calendar_end_time' => array(
- 'api_mapping' => 'end_time',
- 'data_type' => 'string',
- ),
- 'calendar_duration' => array(
- 'api_mapping' => 'event_duration',
- 'data_type' => 'int',
- ),
- );
- }
-
- /**
- * Helper method to hold a map of structure from the groups custom post
- * type taxonomies to the API schema
- *
- * @static
- * @access public
- * @return array
- */
- public static function get_groups_taxonomy_map() {
-
- return array(
- 'group_areas' => array(
- 'name' => 'Area',
- 'name_plural' => 'Areas',
- 'hierarchical' => true,
- 'api_mapping' => 'area'
- ),
- 'group_days' => array(
- 'name' => 'Day',
- 'name_plural' => 'Days',
- 'hierarchical' => true,
- 'api_mapping' => 'meeting_day'
- ),
- 'group_types' => array(
- 'name' => 'Type',
- 'name_plural' => 'Types',
- 'hierarchical' => true,
- 'api_mapping' => 'group_type'
- ),
- 'group_times' => array(
- 'name' => 'Time',
- 'name_plural' => 'Times',
- 'hierarchical' => true,
- 'api_mapping' => 'meeting_time'
- ),
- 'group_departments' => array(
- 'name' => 'Department',
- 'name_plural' => 'Departments',
- 'hierarchical' => true,
- 'api_mapping' => 'department'
- ),
- 'group_tags' => array(
- 'name' => 'Group Tag',
- 'name_plural' => 'Group Tags',
- 'hierarchical' => false,
- 'api_mapping' => array(
- 'childcare_provided' => 'Childcare Provided'
- )
- ),
- );
- }
-
- /**
- * Helper method to hold a map of structure from the events custom post
- * type taxonomies to the API schema
- *
- * @static
- * @access public
- * @return array
- */
- public static function get_calendar_taxonomy_map() {
-
- return array(
- 'calendar_event_type' => array(
- 'name' => 'Type',
- 'name_plural' => 'Types',
- 'hierarchical' => true,
- 'api_mapping' => 'event_type'
- ),
- 'calendar_group_name' => array(
- 'name' => 'Group Name',
- 'name_plural' => 'Group Names',
- 'hierarchical' => true,
- 'api_mapping' => 'group_name'
- ),
- 'calendar_grouping_name' => array(
- 'name' => 'Grouping Name',
- 'name_plural' => 'Grouping Names',
- 'hierarchical' => true,
- 'api_mapping' => 'grouping_name'
- ),
- );
- }
-
-}
diff --git a/admin/class-ccb-core-settings-field.php b/admin/class-ccb-core-settings-field.php
deleted file mode 100644
index 37b25fe..0000000
--- a/admin/class-ccb-core-settings-field.php
+++ /dev/null
@@ -1,283 +0,0 @@
-
- */
-class CCB_Core_Settings_Field extends CCB_Core_Plugin {
-
- /**
- * The key for the field in the settings array
- *
- * @since 0.9.0
- * @access protected
- * @var string $field_id
- */
- protected $field_id;
-
- /**
- * An array of field settings
- *
- * @since 0.9.0
- * @access protected
- * @var array $field
- */
- protected $field;
-
- /**
- * The existing settings currently stored
- *
- * @since 0.9.0
- * @access protected
- * @var array $existing_settings
- */
- protected $existing_settings;
-
- /**
- * Initialize the class and set its properties.
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function __construct( $field_id, $field ) {
-
- parent::__construct();
-
- $this->field_id = $field_id;
- $this->field = $field;
- $this->existing_settings = get_option( $this->plugin_settings_name );
-
- }
-
- /**
- * General method that calls correct field render method based on config
- *
- * @access public
- * @since 0.9.0
- * @return void
- */
- public function render_field() {
- if ( isset( $this->field['field_render_function'] ) && is_callable( array( $this, $this->field['field_render_function'] ) ) ) {
- call_user_func( array( $this, $this->field['field_render_function'] ) );
- if ( isset( $this->field['field_tooltip'] ) ) {
- echo '';
- }
- }
- }
-
- /**
- * Render a textfield
- *
- * @access protected
- * @since 0.9.0
- * @return void
- */
- protected function render_text() {
- $value = '';
- $attributes = $this->build_attributes_string();
-
- if ( isset( $this->existing_settings[ $this->field_id ] ) ) {
- $value = $this->existing_settings[ $this->field_id ];
- }
-
- echo "field['field_placeholder']}\" name=\"{$this->plugin_settings_name}[{$this->field_id}]\" value=\"{$value}\" {$attributes} />";
- }
-
- /**
- * Render a switch button (checkbox)
- *
- * @access protected
- * @since 0.9.0
- * @return void
- */
- protected function render_switch() {
- $value = '';
- $attributes = $this->build_attributes_string();
-
- if ( isset( $this->existing_settings[ $this->field_id ] ) ) {
- $value = $this->existing_settings[ $this->field_id ];
- }
-
- echo "plugin_settings_name}[{$this->field_id}]\" value=\"1\" " . checked( $value, '1', false ) . "{$attributes} />";
- }
-
- /**
- * Render a slider widget (textfield)
- *
- * @access protected
- * @since 0.9.0
- * @return void
- */
- protected function render_slider() {
- $value = $this->field['field_default'];
- $attributes = $this->build_attributes_string();
-
- if ( isset( $this->existing_settings[ $this->field_id ] ) ) {
- $value = $this->existing_settings[ $this->field_id ];
- }
-
- echo "