diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..74fb9e0 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +end_of_line = lf diff --git a/assets/icons/famfamfam/cross.png b/assets/icons/famfamfam/cross.png new file mode 100644 index 0000000..1514d51 Binary files /dev/null and b/assets/icons/famfamfam/cross.png differ diff --git a/assets/icons/famfamfam/readme.txt b/assets/icons/famfamfam/readme.txt new file mode 100644 index 0000000..2cf67dc --- /dev/null +++ b/assets/icons/famfamfam/readme.txt @@ -0,0 +1,22 @@ +Silk icon set 1.3 + +_________________________________________ +Mark James +http://www.famfamfam.com/lab/icons/silk/ +_________________________________________ + +This work is licensed under a +Creative Commons Attribution 2.5 License. +[ http://creativecommons.org/licenses/by/2.5/ ] + +This means you may use it for any purpose, +and make any changes you like. +All I ask is that you include a link back +to this page in your credits. + +Are you using this icon set? Send me an email +(including a link or picture if available) to +mjames@gmail.com + +Any other questions about this icon set please +contact mjames@gmail.com \ No newline at end of file diff --git a/assets/icons/famfamfam/tick.png b/assets/icons/famfamfam/tick.png new file mode 100644 index 0000000..a9925a0 Binary files /dev/null and b/assets/icons/famfamfam/tick.png differ diff --git a/assets/icons/loading.gif b/assets/icons/loading.gif new file mode 100644 index 0000000..e846e1d Binary files /dev/null and b/assets/icons/loading.gif differ diff --git a/lib/WP_Communibase_SettingsPage.php b/lib/WP_Communibase_SettingsPage.php index 5ae360d..754087a 100644 --- a/lib/WP_Communibase_SettingsPage.php +++ b/lib/WP_Communibase_SettingsPage.php @@ -48,18 +48,74 @@ public function create_admin_page() ?>
- +
+
+ Communibase is a paid service for community/association/club/society membership administration. + +
+ +
+ +
', + '' . + '
', isset($this->options['api_key']) ? esc_attr($this->options['api_key']) : '' ); } + const API_PRODUCTION = 'https://api.communibase.nl/0.1/'; + + /** + * + */ + public function renderFieldUseProdApi() + { + $isProductionApi = empty($this->options['api_url']) || $this->options['api_url'] === self::API_PRODUCTION; + echo ''; + } + /** * Get the settings option array and print one of its values */ public function renderFieldApiUrl() + { + // + printf( + '', + isset($this->options['api_url']) ? esc_attr($this->options['api_url']) : '' + ); + } + + public function renderFieldCustomApiUrl() { printf( - '', + '', isset($this->options['api_url']) ? esc_attr($this->options['api_url']) : '' ); } @@ -163,10 +277,10 @@ public function renderFieldApiUrl() /** * Get the settings option array and print one of its values */ - public function renderFieldApiHost() + public function renderFieldCustomApiHost() { printf( - '', + '', isset($this->options['api_host']) ? esc_attr($this->options['api_host']) : '' ); } diff --git a/lib/api/WP_Communibase_API.php b/lib/api/WP_Communibase_API.php new file mode 100644 index 0000000..7482869 --- /dev/null +++ b/lib/api/WP_Communibase_API.php @@ -0,0 +1,23 @@ +register_routes(); + }); + } +} \ No newline at end of file diff --git a/lib/api/WP_Communibase_API_ValidateKey.php b/lib/api/WP_Communibase_API_ValidateKey.php new file mode 100644 index 0000000..b76531b --- /dev/null +++ b/lib/api/WP_Communibase_API_ValidateKey.php @@ -0,0 +1,52 @@ + 'POST', + 'callback' => array( $this, 'post' ), + 'args' => array( + 'key' => array( + 'type' => 'string', + 'required' => true, + 'sanitize_callback' => 'sanitize_text_field' + ) + ), + 'permissions_callback' => array( $this, 'permissions' ), + )); + } + + /** + * Check request permissions + * + * @return bool + */ + public function permissions() + { + return current_user_can( 'manage_options' ); + } + + /** + * @param WP_REST_Request $req + * + * @return WP_Error|WP_REST_Response + */ + public function post(\WP_REST_Request $req) + { + try { + WP_Communibase_Connector::getInstance()->search('Person2', [], ['limit' => 1]); + return new \WP_REST_Response(true, 200); + } catch (\Exception $ex) { + return new \WP_Error('error', $ex->getMessage(), array('status' => 500)); + } + } +} diff --git a/plugin.php b/plugin.php index a9c088c..490112f 100644 --- a/plugin.php +++ b/plugin.php @@ -21,8 +21,14 @@ // Add Admin Settings page if (is_admin()) { + + // Init Settings Page require_once __DIR__ . '/lib/WP_Communibase_SettingsPage.php'; new WP_Communibase_SettingsPage(); } +// Init API endpoints +require_once __DIR__ . '/lib/api/WP_Communibase_API.php'; +WP_Communibase_API::init(); + // non-admin enqueues, actions, and filters