PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.25
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.25
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / includes / class-ajax.php

class-ajax.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.25, at includes/class-ajax.php

96 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Ajax related functions
4 *
5 * This class defines all code necessary to handle UsersWP ajax requests.
6 *
7 * @since 1.0.0
8 * @author GeoDirectory Team <info@wpgeodirectory.com>
9 */
10 class UsersWP_Ajax {
11
12 public function __construct() {
13 add_action( 'init', array( $this, 'add_ajax_events' ), 0 );
14 }
15
16 /**
17 * Handles the create custom field and sort custom field ajax requests.
18 *
19 * @since 1.0.0
20 * @package userswp
21 * @return void
22 */
23 public function add_ajax_events()
24 {
25
26 $ajax_events = $this->get_ajax_events();
27
28 foreach ( $ajax_events as $ajax_event => $nopriv ) {
29 add_action( 'wp_ajax_uwp_' . $ajax_event, array( $this, $ajax_event ) );
30
31 if ( $nopriv ) {
32 add_action( 'wp_ajax_nopriv_uwp_' . $ajax_event, array( $this, $ajax_event ) );
33 }
34 }
35 }
36
37 public function get_ajax_events(){
38 // uwp_event_name => nopriv
39 return array(
40 'notice_clear_try_bootstrap' => false,
41 'wizard_setup_menu' => false,
42 );
43 }
44
45 /**
46 * A quick delete of the try bootstrap notice option.
47 */
48 public function notice_clear_try_bootstrap(){
49 if (current_user_can('manage_options')) {
50 delete_option("uwp_notice_try_bootstrap");
51 }
52 }
53
54 /**
55 * Kill WordPress execution and display HTML message with error message.
56 *
57 * @since 1.0.0
58 * @package userswp
59 * @param string $message Optional. Error message.
60 * @param string $title Optional. Error title.
61 * @param int $status The HTTP response code. Default 200 for Ajax requests, 500 otherwise.
62 * @return void
63 */
64 public function uwp_die( $message = '', $title = '', $status = 400 ) {
65 add_filter( 'wp_die_ajax_handler', '_uwp_die_handler', 10, 3 );
66 add_filter( 'wp_die_handler', '_uwp_die_handler', 10, 3 );
67 wp_die( $message, $title, array( 'response' => $status )); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
68 }
69
70 /**
71 * Function to setup menu in the setup wizard.
72 *
73 * @return void
74 */
75 public function wizard_setup_menu() {
76
77 check_ajax_referer( 'uwp-wizard-setup-menu', 'security' );
78
79 if ( ! current_user_can( 'manage_options' ) ) {
80 wp_die( -1 );
81 }
82
83 $menu_id = isset($_REQUEST['menu_id']) ? sanitize_title_with_dashes($_REQUEST['menu_id']) : '';
84 $menu_location = isset($_REQUEST['menu_location']) ? sanitize_title_with_dashes($_REQUEST['menu_location']) : '';
85 $result = UsersWP_Tools::setup_menu( $menu_id, $menu_location);
86
87 if(is_wp_error( $result ) ){
88 wp_send_json_error( $result->get_error_message() );
89 }else{
90 wp_send_json_success($result);
91 }
92
93 wp_die();
94
95 }
96 }