-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpcivicrm-datatable.php
52 lines (44 loc) · 1.78 KB
/
wpcivicrm-datatable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
Plugin Name: Data source CiviCRM api for wpDataTable
Description: Provides a CiviCRM api data source for wpDataTable plugin.
Version: 1.0.2
Author: Jaap Jansma
License: AGPL3
License URI: https://www.gnu.org/licenses/agpl-3.0.html
Text Domain: wpcivicrm-datatable
*/
defined('ABSPATH') or die("Cannot access pages directly.");
define('WPCIVICRM_DATATABLES_ROOT_PATH', plugin_dir_path(__FILE__)); // full path to the wpDataTables root directory
function wpcivicrm_datatable_init() {
require_once WPCIVICRM_DATATABLES_ROOT_PATH . "classes/class.wdtcivicrm.datatable.inc.php";
require_once WPCIVICRM_DATATABLES_ROOT_PATH . "classes/class.civicrm_content_replacement.inc.php";
require_once WPCIVICRM_DATATABLES_ROOT_PATH . "classes/class.local.inc.php";
require_once WPCIVICRM_DATATABLES_ROOT_PATH . "classes/class.wpcmrf.inc.php";
WPCivicrm_Datatable::init();
WPCivicrm_Datatable_ContentReplacement::init();;
}
/**
* Returns a list of possible connection profiles.
* @return array
*/
function wpcivicrm_datatable_get_profiles() {
static $profiles = null;
if (is_array($profiles)) {
return $profiles;
}
$profiles = array();
$profiles = WPCivicrm_Datatable_Local::profiles($profiles);
$profiles = WPCivicrm_Datatable_Wpcmrf::profiles($profiles);
$profiles = apply_filters('wpcivicrm_datatable_get_profiles', $profiles);
return $profiles;
}
function wpcivicrm_datatable_api($entity, $action, $params, $options, $profile_id) {
$profiles = wpcivicrm_datatable_get_profiles();
if (!isset($profiles[$profile_id])) {
return ['error' => 'Invalid connection', 'is_error' => '1'];
}
$func = $profiles[$profile_id]['function'];
return call_user_func($func, $entity, $action, $params, $options, $profiles[$profile_id]['profile_id']);
}
wpcivicrm_datatable_init();