├── assets
├── css
│ └── acf
│ │ ├── acfe
│ │ └── pages
│ │ │ └── page-settings-acfe.css
│ │ └── pages
│ │ └── page-admin-acf-migrate.css
├── images
│ └── acf
│ │ └── manual-sync
│ │ ├── ui-icons_222222_256x240.png
│ │ ├── ui-icons_2e83ff_256x240.png
│ │ ├── ui-icons_454545_256x240.png
│ │ ├── ui-icons_888888_256x240.png
│ │ ├── ui-icons_cd0a0a_256x240.png
│ │ ├── ui-bg_glass_55_fbf9ee_1x400.png
│ │ ├── ui-bg_glass_65_ffffff_1x400.png
│ │ ├── ui-bg_glass_75_dadada_1x400.png
│ │ ├── ui-bg_glass_75_e6e6e6_1x400.png
│ │ ├── ui-bg_glass_95_fef1ec_1x400.png
│ │ └── ui-bg_highlight-soft_75_cccccc_1x100.png
├── civicrm
│ ├── custom_php
│ │ └── .editorconfig
│ └── custom_templates
│ │ ├── .editorconfig
│ │ └── CRM
│ │ └── Contact
│ │ └── Form
│ │ └── Task
│ │ └── CreateWordPressUsers.tpl
├── templates
│ ├── help
│ │ └── settings-help.php
│ ├── civicrm
│ │ ├── cwps-acf-activity-type-cpt.tpl
│ │ ├── cwps-acf-contact-type-cpt.tpl
│ │ ├── cwps-acf-participant-role-cpt.tpl
│ │ ├── cwps-acf-participant-cpt.tpl
│ │ └── cwps-acf-geo-mashup-compat.tpl
│ ├── wordpress
│ │ ├── taxonomies
│ │ │ ├── term-participant-role-add.php
│ │ │ ├── term-participant-role-edit.php
│ │ │ ├── term-add.php
│ │ │ └── term-edit.php
│ │ ├── metaboxes
│ │ │ ├── metabox-admin-settings-submit.php
│ │ │ ├── metabox-acf-migrate-submit.php
│ │ │ ├── metabox-admin-settings-acf.php
│ │ │ ├── metabox-admin-settings-acfe.php
│ │ │ ├── metabox-acf-groups-terms.php
│ │ │ ├── metabox-acf-contacts-posts.php
│ │ │ ├── metabox-acf-posts-contacts.php
│ │ │ ├── metabox-acf-activities-posts.php
│ │ │ ├── metabox-acf-posts-activities.php
│ │ │ ├── metabox-acf-participants-posts.php
│ │ │ ├── metabox-acf-posts-participants.php
│ │ │ ├── metabox-acf-migrate-info.php
│ │ │ └── metabox-admin-settings-profile.php
│ │ ├── shortcodes
│ │ │ └── shortcode-address.php
│ │ └── pages
│ │ │ ├── page-admin-acf-migrate.php
│ │ │ ├── page-admin-settings.php
│ │ │ └── page-admin-acf-sync.php
│ └── buddypress
│ │ └── metaboxes
│ │ └── metabox-bp-field-content.php
└── js
│ └── acf
│ ├── fields
│ ├── civicrm-attachment-field.js
│ ├── civicrm-activity-target-field.js
│ ├── civicrm-activity-creator-field.js
│ ├── civicrm-activity-assignee-field.js
│ ├── civicrm-event-field.js
│ ├── civicrm-contact-field.js
│ ├── civicrm-relationship-field.js
│ ├── civicrm-contact-ref-field.js
│ ├── civicrm-multiset-field.js
│ ├── civicrm-yes-no-field.js
│ ├── civicrm-phone-field.js
│ ├── civicrm-im-field.js
│ ├── civicrm-address-field.js
│ └── civicrm-event-group-field.js
│ └── acfe
│ ├── fields
│ ├── civicrm-address-country-field.js
│ ├── cwps-field-action-reference-case.js
│ ├── cwps-field-action-reference-participant.js
│ ├── cwps-field-action-reference-contact.js
│ ├── civicrm-address-state-field.js
│ └── civicrm-address-county-field.js
│ └── pages
│ └── page-settings-acfe.js
├── .editorconfig
├── phpcs.xml
├── includes
├── acf
│ ├── acfe
│ │ ├── locations
│ │ │ └── cwps-acf-acfe-location-bypass.php
│ │ ├── classes
│ │ │ └── cwps-acf-acfe.php
│ │ └── fields
│ │ │ ├── cwps-acf-acfe-field-action-reference-case.php
│ │ │ ├── cwps-acf-acfe-field-action-reference-contact.php
│ │ │ ├── cwps-acf-acfe-field-action-reference-participant.php
│ │ │ └── cwps-acf-acfe-field-address-country.php
│ ├── classes
│ │ ├── cwps-acf-civicrm-base.php
│ │ ├── cwps-acf-acf.php
│ │ ├── cwps-acf-acf-blocks.php
│ │ ├── cwps-acf-participant-cpt-term-html.php
│ │ └── cwps-acf-civicrm-campaign.php
│ └── fields
│ │ └── cwps-acf-field-civicrm-contact-id.php
├── buddypress
│ └── cwps-bp-buddyboss.php
├── mapper
│ ├── cwps-mapper.php
│ ├── cwps-mapper-hooks.php
│ └── cwps-mapper-hooks-acf.php
└── civicrm
│ ├── cwps-civicrm-contact-field.php
│ └── cwps-civicrm-bulk.php
├── deploy.sh
└── README.md
/assets/css/acf/acfe/pages/page-settings-acfe.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Styles for the ACFE meta box on the Settings Page.
3 | *
4 | * @package CiviCRM_WP_Profile_Sync
5 | */
6 |
7 |
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-icons_2e83ff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-icons_2e83ff_256x240.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-icons_454545_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-icons_454545_256x240.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-icons_888888_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-icons_888888_256x240.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-bg_glass_55_fbf9ee_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-bg_glass_55_fbf9ee_1x400.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-bg_glass_65_ffffff_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-bg_glass_65_ffffff_1x400.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-bg_glass_75_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-bg_glass_75_dadada_1x400.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-bg_glass_75_e6e6e6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-bg_glass_75_e6e6e6_1x400.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-bg_glass_95_fef1ec_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-bg_glass_95_fef1ec_1x400.png
--------------------------------------------------------------------------------
/assets/images/acf/manual-sync/ui-bg_highlight-soft_75_cccccc_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christianwach/civicrm-wp-profile-sync/HEAD/assets/images/acf/manual-sync/ui-bg_highlight-soft_75_cccccc_1x100.png
--------------------------------------------------------------------------------
/assets/civicrm/custom_php/.editorconfig:
--------------------------------------------------------------------------------
1 | # CiviCRM-style editor configuration normalization.
2 | # @see https://editorconfig.org/
3 |
4 | # This is the not top-most .editorconfig file; search in parent directories.
5 | root = false
6 |
7 | # Indentation.
8 | [*.{php,tpl}]
9 | indent_style = space
10 | indent_size = 2
11 |
--------------------------------------------------------------------------------
/assets/civicrm/custom_templates/.editorconfig:
--------------------------------------------------------------------------------
1 | # CiviCRM-style editor configuration normalization.
2 | # @see https://editorconfig.org/
3 |
4 | # This is the not top-most .editorconfig file; search in parent directories.
5 | root = false
6 |
7 | # Indentation.
8 | [*.{php,tpl}]
9 | indent_style = space
10 | indent_size = 2
11 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: https://editorconfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # Unix-style newlines with a newline ending every file
7 | [*]
8 | end_of_line = lf
9 | insert_final_newline = true
10 | trim_trailing_whitespace = true
11 |
12 | # Tab indentation
13 | [*.php]
14 | indent_style = tab
15 |
--------------------------------------------------------------------------------
/assets/templates/help/settings-help.php:
--------------------------------------------------------------------------------
1 |
12 |
31 |
32 |
33 |
34 |
35 |
36 |
46 |
47 |
48 |
49 |
50 |
60 |
61 |
62 |
63 |
64 |
74 |
75 |
76 |
77 |
78 |
88 |
89 |
90 |
91 |
92 |
102 |
103 |
104 |
105 |
106 |
120 |
121 |
122 |
123 |
124 |
138 |
139 |
140 |
145 |
146 |
147 |
--------------------------------------------------------------------------------
/includes/acf/acfe/fields/cwps-acf-acfe-field-address-country.php:
--------------------------------------------------------------------------------
1 | CIVICRM_WP_PROFILE_SYNC_VERSION,
128 | 'url' => CIVICRM_WP_PROFILE_SYNC_URL,
129 | 'path' => CIVICRM_WP_PROFILE_SYNC_PATH,
130 | ];
131 |
132 | /**
133 | * Field Type translations.
134 | *
135 | * This must be populated in the class constructor because it is translatable.
136 | *
137 | * Array of strings that are used in JavaScript. This allows JS strings
138 | * to be translated in PHP and loaded via:
139 | *
140 | * var message = acf._e( 'civicrm_contact', 'error' );
141 | *
142 | * @since 0.5
143 | * @access public
144 | * @var array
145 | */
146 | public $l10n = [];
147 |
148 | /**
149 | * Sets up the Field Type.
150 | *
151 | * @since 0.5
152 | *
153 | * @param object $parent The parent object reference.
154 | */
155 | public function __construct( $parent ) {
156 |
157 | // Store references to objects.
158 | $this->plugin = $parent->acf_loader->plugin;
159 | $this->acf_loader = $parent->acf_loader;
160 | $this->acf = $parent->acf_loader->acf;
161 | $this->acfe = $parent;
162 | $this->civicrm = $this->acf_loader->civicrm;
163 |
164 | // Define label.
165 | $this->label = __( 'CiviCRM Address: Country', 'civicrm-wp-profile-sync' );
166 |
167 | // Define category.
168 | $this->category = __( 'CiviCRM ACFE Forms only', 'civicrm-wp-profile-sync' );
169 |
170 | // Define translations.
171 | $this->l10n = [];
172 |
173 | // Call parent.
174 | parent::__construct();
175 |
176 | }
177 |
178 | /**
179 | * Create extra Settings for this Field Type.
180 | *
181 | * These extra Settings will be visible when editing a Field.
182 | *
183 | * @since 0.6.6
184 | *
185 | * @param array $field The Field being edited.
186 | */
187 | public function render_field_settings( $field ) {
188 |
189 | // Only render Placeholder Setting Field here in ACF prior to version 6.
190 | if ( version_compare( ACF_MAJOR_VERSION, '6', '>=' ) ) {
191 | return;
192 | }
193 |
194 | // Get Placeholder Setting Field.
195 | $placeholder = $this->acf->field->field_setting_placeholder_get();
196 |
197 | // Now add it.
198 | acf_render_field_setting( $field, $placeholder );
199 |
200 | }
201 |
202 | /**
203 | * Renders the Field settings used in the "Presentation" tab.
204 | *
205 | * @since 0.6.6
206 | *
207 | * @param array $field The field settings array.
208 | */
209 | public function render_field_presentation_settings( $field ) {
210 |
211 | // Get Placeholder Setting Field.
212 | $placeholder = $this->acf->field->field_setting_placeholder_get();
213 |
214 | // Now add it.
215 | acf_render_field_setting( $field, $placeholder );
216 |
217 | }
218 |
219 | /**
220 | * Creates the HTML interface for this Field Type.
221 | *
222 | * @since 0.5
223 | *
224 | * @param array $field The Field being rendered.
225 | */
226 | public function render_field( $field ) {
227 |
228 | // Change Field into a "select" Field.
229 | $field['type'] = 'select';
230 |
231 | // Render.
232 | acf_render_field( $field );
233 |
234 | }
235 |
236 | /**
237 | * This filter is applied to the Field after it is loaded from the database.
238 | *
239 | * @since 0.5
240 | *
241 | * @param array $field The Field array holding all the Field options.
242 | * @return array $field The modified Field data.
243 | */
244 | public function load_field( $field ) {
245 |
246 | // Try and init CiviCRM.
247 | if ( ! $this->civicrm->is_initialised() ) {
248 | return $field;
249 | }
250 |
251 | // Get CiviCRM config.
252 | $config = CRM_Core_Config::singleton();
253 |
254 | $field['allow_null'] = 1;
255 | $field['multiple'] = 0;
256 | $field['ui'] = 1;
257 | $field['ajax'] = 0;
258 | $field['return_format'] = 'value';
259 | $field['choices'] = CRM_Core_PseudoConstant::country();
260 | // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
261 | $field['default_value'] = $config->defaultContactCountry;
262 |
263 | // --<
264 | return $field;
265 |
266 | }
267 |
268 | /**
269 | * This method is called in the "admin_enqueue_scripts" action on the edit
270 | * screen where this Field is created.
271 | *
272 | * Use this action to add CSS and JavaScript to assist your render_field()
273 | * action.
274 | *
275 | * @since 0.5
276 | */
277 | public function input_admin_enqueue_scripts() {
278 |
279 | // Enqueue our JavaScript.
280 | wp_enqueue_script(
281 | 'acf-input-' . $this->name,
282 | plugins_url( 'assets/js/acf/acfe/fields/civicrm-address-country-field.js', CIVICRM_WP_PROFILE_SYNC_FILE ),
283 | [ 'acf-input' ],
284 | CIVICRM_WP_PROFILE_SYNC_VERSION, // Version.
285 | true
286 | );
287 |
288 | }
289 |
290 | }
291 |
--------------------------------------------------------------------------------
/includes/acf/classes/cwps-acf-civicrm-campaign.php:
--------------------------------------------------------------------------------
1 | plugin = $parent->acf_loader->plugin;
61 | $this->acf_loader = $parent->acf_loader;
62 | $this->civicrm = $parent;
63 |
64 | // Init when the ACF CiviCRM object is loaded.
65 | add_action( 'cwps/acf/civicrm/loaded', [ $this, 'register_hooks' ] );
66 |
67 | }
68 |
69 | /**
70 | * Register WordPress hooks.
71 | *
72 | * @since 0.5
73 | */
74 | public function register_hooks() {
75 |
76 | }
77 |
78 | // -----------------------------------------------------------------------------------
79 |
80 | /**
81 | * Create a CiviCRM Campaign.
82 | *
83 | * If you want to "create" a Campaign, do not pass $data['id'] in. The presence
84 | * of an ID will cause an update to that Campaign.
85 | *
86 | * @since 0.5
87 | *
88 | * @param string $data The Campaign data.
89 | * @return array|bool $campaign The array of Campaign data, or false on failure.
90 | */
91 | public function create( $data ) {
92 |
93 | // Init return.
94 | $campaign = false;
95 |
96 | // Try and init CiviCRM.
97 | if ( ! $this->civicrm->is_initialised() ) {
98 | return $campaign;
99 | }
100 |
101 | // Define params to create new Campaign.
102 | $params = [
103 | 'version' => 3,
104 | ] + $data;
105 |
106 | // Call the API.
107 | $result = civicrm_api( 'Campaign', 'create', $params );
108 |
109 | // Log and bail if there's an error.
110 | if ( ! empty( $result['is_error'] ) && 1 === (int) $result['is_error'] ) {
111 | $e = new Exception();
112 | $trace = $e->getTraceAsString();
113 | $log = [
114 | 'method' => __METHOD__,
115 | 'params' => $params,
116 | 'result' => $result,
117 | 'backtrace' => $trace,
118 | ];
119 | $this->plugin->log_error( $log );
120 | return $campaign;
121 | }
122 |
123 | // Bail if there are no results.
124 | if ( empty( $result['values'] ) ) {
125 | return $campaign;
126 | }
127 |
128 | // The result set should contain only one item.
129 | $campaign = array_pop( $result['values'] );
130 |
131 | // --<
132 | return $campaign;
133 |
134 | }
135 |
136 | /**
137 | * Update a CiviCRM Contact with a given set of data.
138 | *
139 | * This is an alias of `self::create()` except that we expect an ID to have
140 | * been set in the data.
141 | *
142 | * @since 0.5
143 | *
144 | * @param array $data The CiviCRM Campaign data.
145 | * @return array|bool The array of data from the CiviCRM API, or false on failure.
146 | */
147 | public function update( $data ) {
148 |
149 | // Log and bail if there's no Campaign ID.
150 | if ( empty( $data['id'] ) ) {
151 | $e = new \Exception();
152 | $trace = $e->getTraceAsString();
153 | $log = [
154 | 'method' => __METHOD__,
155 | 'message' => __( 'A numeric ID must be present to update a Campaign.', 'civicrm-wp-profile-sync' ),
156 | 'data' => $data,
157 | 'backtrace' => $trace,
158 | ];
159 | $this->plugin->log_error( $log );
160 | return false;
161 | }
162 |
163 | // Pass through.
164 | return $this->create( $data );
165 |
166 | }
167 |
168 | // -----------------------------------------------------------------------------------
169 |
170 | /**
171 | * Get the data for a Campaign.
172 | *
173 | * @since 0.5
174 | *
175 | * @param integer $campaign_id The numeric ID of the Campaign.
176 | * @return array $campaign The array of Campaign data, or empty if none.
177 | */
178 | public function get_by_id( $campaign_id ) {
179 |
180 | // Init return.
181 | $campaign = [];
182 |
183 | // Try and init CiviCRM.
184 | if ( ! $this->civicrm->is_initialised() ) {
185 | return $campaign;
186 | }
187 |
188 | // Construct API query.
189 | $params = [
190 | 'version' => 3,
191 | 'id' => $campaign_id,
192 | ];
193 |
194 | // Get Campaign details via API.
195 | $result = civicrm_api( 'Campaign', 'get', $params );
196 |
197 | // Bail if there's an error.
198 | if ( ! empty( $result['is_error'] ) && 1 === (int) $result['is_error'] ) {
199 | return $campaign;
200 | }
201 |
202 | // Bail if there are no results.
203 | if ( empty( $result['values'] ) ) {
204 | return $campaign;
205 | }
206 |
207 | // The result set should contain only one item.
208 | $campaign = (object) array_pop( $result['values'] );
209 |
210 | // --<
211 | return $campaign;
212 |
213 | }
214 |
215 | // -----------------------------------------------------------------------------------
216 |
217 | /**
218 | * Gets the currently-active CiviCRM Campaigns.
219 | *
220 | * @since 0.5
221 | *
222 | * @return array $campaigns The array of data for CiviCRM Campaigns.
223 | */
224 | public function get_current() {
225 |
226 | // Return early if already calculated.
227 | static $campaigns;
228 | if ( isset( $campaigns ) ) {
229 | return $campaigns;
230 | }
231 |
232 | // Try and init CiviCRM.
233 | if ( ! $this->civicrm->is_initialised() ) {
234 | return [];
235 | }
236 |
237 | // Build params.
238 | $params = [
239 | 'version' => 3,
240 | 'sequential' => 1,
241 | 'is_active' => 1,
242 | 'status_id' => [ 'NOT IN' => [ 'Completed', 'Cancelled' ] ],
243 | 'options' => [
244 | 'sort' => 'name',
245 | 'limit' => 0,
246 | ],
247 | ];
248 |
249 | // Call the CiviCRM API.
250 | $result = civicrm_api( 'Campaign', 'get', $params );
251 |
252 | // Return early if something went wrong.
253 | if ( ! empty( $result['is_error'] ) && 1 === (int) $result['is_error'] ) {
254 | $e = new \Exception();
255 | $trace = $e->getTraceAsString();
256 | $log = [
257 | 'method' => __METHOD__,
258 | 'params' => $params,
259 | 'result' => $result,
260 | 'backtrace' => $trace,
261 | ];
262 | $this->plugin->log_error( $log );
263 | return [];
264 | }
265 |
266 | // Bail if there are no results.
267 | if ( empty( $result['values'] ) ) {
268 | return [];
269 | }
270 |
271 | // Assign Campaign data.
272 | $campaigns = $result['values'];
273 |
274 | // --<
275 | return $campaigns;
276 |
277 | }
278 |
279 | /**
280 | * Gets the choices for the currently-active CiviCRM Campaigns.
281 | *
282 | * @since 0.5
283 | *
284 | * @return array $campaigns The array of choices for CiviCRM Campaigns.
285 | */
286 | public function choices_get() {
287 |
288 | // Return early if already calculated.
289 | static $campaigns;
290 | if ( isset( $campaigns ) ) {
291 | return $campaigns;
292 | }
293 |
294 | // Get the currently-active Campaigns.
295 | $current = $this->get_current();
296 |
297 | // Build return array.
298 | $campaigns = [];
299 | foreach ( $current as $key => $value ) {
300 | $campaigns[ $value['id'] ] = $value['title'];
301 | }
302 |
303 | // --<
304 | return $campaigns;
305 |
306 | }
307 |
308 | }
309 |
--------------------------------------------------------------------------------