elementor
3 years ago
admin-create-shortcode.php
7 years ago
admin-create-user.php
3 years ago
admin-custom-function.php
3 years ago
admin-rest-api.php
4 years ago
admin-settings.php
3 years ago
admin-social-button.php
3 years ago
admin-social-enque-script.php
5 years ago
counter-widget.php
3 years ago
counter.php
3 years ago
custom-function.php
4 years ago
login-widget.php
3 years ago
login.php
5 years ago
share-widget.php
3 years ago
share.php
3 years ago
admin-rest-api.php
117 lines
| 1 | <?php |
| 2 | |
| 3 | defined('ABSPATH') || exit; |
| 4 | |
| 5 | /** |
| 6 | * Function Name : xs_return_call_back_login_function(); |
| 7 | * Function Details : WP Rest API. |
| 8 | * |
| 9 | * @params : void |
| 10 | * |
| 11 | * @return : array() |
| 12 | * |
| 13 | * @since : 1.0 |
| 14 | */ |
| 15 | if(!function_exists('xs_return_call_back_login_function')) { |
| 16 | |
| 17 | function xs_return_call_back_login_function(WP_REST_Request $request) { |
| 18 | |
| 19 | $param = $request['data']; |
| 20 | $code = $request['code']; |
| 21 | if(is_null($param)) { |
| 22 | $typeSocial = ''; |
| 23 | } |
| 24 | |
| 25 | $typeSocial = $param; |
| 26 | $socialType = ''; |
| 27 | $callBackUrl = ''; |
| 28 | |
| 29 | require_once(WSLU_LOGIN_PLUGIN . '/inc/admin-create-user.php'); |
| 30 | die(); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * wp rest api add action |
| 36 | */ |
| 37 | add_action('rest_api_init', function() { |
| 38 | |
| 39 | //https://dev.finesttheme.com/social/wp-json/wslu-social-login/type/google |
| 40 | register_rest_route('wslu-social-login', '/type/(?P<data>\w+)/', |
| 41 | array( |
| 42 | 'methods' => 'GET', |
| 43 | 'callback' => 'xs_return_call_back_login_function', |
| 44 | 'permission_callback' => '__return_true', |
| 45 | ) |
| 46 | ); |
| 47 | |
| 48 | |
| 49 | register_rest_route('wslu/v1', '/check_cache/(?P<type>\w+)/', |
| 50 | array( |
| 51 | 'methods' => 'POST', |
| 52 | 'callback' => 'post_check_counter_cache', |
| 53 | 'permission_callback' => '__return_true', |
| 54 | ) |
| 55 | ); |
| 56 | |
| 57 | register_rest_route('wslu/v1', '/save_cache/(?P<type>\w+)/', |
| 58 | array( |
| 59 | 'methods' => 'POST', |
| 60 | 'callback' => 'post_save_instagram_counter_cache', |
| 61 | 'permission_callback' => '__return_true', |
| 62 | ) |
| 63 | ); |
| 64 | }); |
| 65 | |
| 66 | |
| 67 | function post_save_instagram_counter_cache(WP_REST_Request $request) { |
| 68 | |
| 69 | $data = $request->get_params(); |
| 70 | |
| 71 | $ins = new \WP_Social\Lib\Counter\Instagram_Counter(); |
| 72 | |
| 73 | $ins->cache_instagram_return($data['content']['count'], \WP_Social\App\Settings::get_counter_cache_time()); |
| 74 | |
| 75 | return array( |
| 76 | 'success' => true, |
| 77 | 'msg' => 'successfully fetched and cached', |
| 78 | //'result' => $data, |
| 79 | ); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | function post_check_counter_cache(WP_REST_Request $request) { |
| 84 | |
| 85 | $data = $request->get_params(); |
| 86 | |
| 87 | if($data['type'] == 'instagram') { |
| 88 | |
| 89 | $ins = new \WP_Social\Lib\Counter\Instagram_Counter(); |
| 90 | |
| 91 | $ins->load(); |
| 92 | |
| 93 | if($ins->cache_expired) { |
| 94 | |
| 95 | return array( |
| 96 | 'msg' => 'Successfull', |
| 97 | 'expired' => true, |
| 98 | 'unm' => $ins->user_id, |
| 99 | 'success' => true, |
| 100 | ); |
| 101 | } |
| 102 | |
| 103 | |
| 104 | return array( |
| 105 | 'msg' => 'Successfull', |
| 106 | 'expired' => false, |
| 107 | 'success' => true, |
| 108 | ); |
| 109 | } |
| 110 | |
| 111 | return array( |
| 112 | 'msg' => 'error', |
| 113 | 'success' => false, |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 |