-
Notifications
You must be signed in to change notification settings - Fork 19
/
options-ajax.php
40 lines (26 loc) · 963 Bytes
/
options-ajax.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
<?php
/*
Docs To WP Options Ajax Class
*/
class Docs_To_WP_Options_Ajax {
public function __construct() {
add_action( 'wp_ajax_docs_to_wp_save_options', array( $this, 'saveSettings' ) );
}
public function saveSettings() {
$client_id = $_POST['d2w_cid'];
$client_secret = $_POST['d2w_secret'];
$origin_folder = defined('DOCSTOWP_ORIGIN') ? DOCSTOWP_ORIGIN : $_POST['d2w_origin'];
$target_folder = defined('DOCSTOWP_DESTINATION') ? DOCSTOWP_DESTINATION : $_POST['d2w_dest'];
update_option( 'docs_to_wp_client_id', $client_id );
update_option( 'docs_to_wp_client_secret', $client_secret );
update_option( 'docs_to_wp_origin', $origin_folder );
update_option( 'docs_to_wp_target', $target_folder );
wp_send_json( array('success' => true ) );
}
}
function docs_to_wp_init_ajax() {
if( !defined( 'DOING_AJAX' ) || !DOING_AJAX )
return;
$ajax = new Docs_To_WP_Options_Ajax();
}
add_action('admin_init', 'docs_to_wp_init_ajax');