/
demo-plugin.php
63 lines (52 loc) · 2.24 KB
/
demo-plugin.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
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @link rasta.online
* @since 1.0.0
* @package WP Demo Plugin
*
* @wordpress-plugin
* Plugin Name: Wordpress Demo Plugin
* Plugin URI: https://github.com/RapidAgileSoftware/wp-demo-plugin
* Description: This demo plugin uses a jTable extension to retrieve external user data
* Version: 1.0.0
* Author: Jens Krause
* Author URI: rasta.online
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
// If this file is called directly, abort.
if (! defined('WPINC')) {
die;
}
// make sure we dont include outoload twice (wp-config)
require_once(__DIR__ . '/vendor/autoload.php');
define('__version__', '1.0.0');
// make the Pluging configurable via config.local.php
require_once('config.php');
/**
* Plugin Activator
* is responsible for getting the Plugin up and running
* or shutting it down in a clean way
**/
$PluginActivator = new Rasta\UserFetcher\Activator($config['Endpoint'], $config['Page Title']);
register_activation_hook(__FILE__, [$PluginActivator, 'activate']);
register_deactivation_hook(__FILE__, [$PluginActivator, 'deactivate']);
add_action('wp_enqueue_scripts', [$PluginActivator, 'loadScripts']);
/**
* Plugin Api
* manages the Plugins needs while active
* contains all fetch data requests
**/
$PluginApi = new Rasta\UserFetcher\Api($config['Caching Time'], $config['Fetch Url']);
//add_action('wp_ajax_nopriv_list-users', [$PluginApi, 'fetchUserRequest']);
add_action('wp_ajax_list-users', [$PluginApi, 'fetchUserRequest']);
add_action('wp_ajax_user-details', [$PluginApi, 'fetchUserDetails']);
add_action('wp_ajax_user-posts', [$PluginApi, 'fetchUserPosts']);
add_action('wp_ajax_user-todos', [$PluginApi, 'fetchUserTodos']);
add_action('wp_ajax_user-albums', [$PluginApi, 'fetchUserAlbums']);
// let's expose it to public users too
add_action('wp_ajax_nopriv_list-users', [$PluginApi, 'fetchUserRequest']);
add_action('wp_ajax_nopriv_user-details', [$PluginApi, 'fetchUserDetails']);
add_action('wp_ajax_nopriv_user-posts', [$PluginApi, 'fetchUserPosts']);
add_action('wp_ajax_nopriv_user-todos', [$PluginApi, 'fetchUserTodos']);
add_action('wp_ajax_nopriv_user-albums', [$PluginApi, 'fetchUserAlbums']);