PluginProbe
Additional Terms Lite for WooCommerce / 1.7.3
Additional Terms Lite for WooCommerce v1.7.3
1.7.3 1.7.2.1 trunk 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 All 35 releases
woo-additional-terms / src / Ajax / Ajax.php

Ajax.php in Additional Terms Lite for WooCommerce 1.7.3, at src/Ajax/Ajax.php

84 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Abstract AJAX class.
4 *
5 * @since 1.6.0
6 *
7 * @package woo-additional-terms
8 */
9
10 namespace Woo_Additional_Terms\Ajax;
11
12 /**
13 * AJAX class.
14 */
15 abstract class Ajax {
16
17 /**
18 * The action name.
19 *
20 * @since 1.6.0
21 *
22 * @var string
23 */
24 private $action;
25
26 /**
27 * The nonce name.
28 *
29 * @since 1.6.0
30 *
31 * @var string
32 */
33 private $nonce;
34
35 /**
36 * Constructor.
37 *
38 * @since 1.6.0
39 *
40 * @param string $action The action name.
41 * @param string $nonce The nonce name. Default is empty.
42 *
43 * @return void
44 */
45 public function __construct( $action, $nonce = '' ) {
46
47 $this->action = sanitize_key( $action );
48 $this->nonce = ! empty( $nonce ) ? sanitize_key( $nonce ) : $this->action;
49 }
50
51 /**
52 * Register the AJAX action for the admin area.
53 *
54 * @since 1.6.0
55 *
56 * @return void
57 */
58 public function register_admin() {
59
60 add_action( "wp_ajax_woo_additional_terms_{$this->action}", array( $this, 'ajax_callback' ) );
61 }
62
63 /**
64 * Verify the AJAX nonce.
65 *
66 * @since 1.6.0
67 *
68 * @return void
69 */
70 protected function verify_nonce() {
71
72 check_ajax_referer( $this->nonce );
73 }
74
75 /**
76 * AJAX callback.
77 *
78 * @since 1.6.0
79 *
80 * @return void
81 */
82 abstract public function ajax_callback();
83 }
84