RegisterPublicEvents.php
2.08 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace Favorites\Events;
use Favorites\Listeners\FavoriteButton;
use Favorites\Listeners\FavoritesArray;
use Favorites\Listeners\ClearFavorites;
use Favorites\Listeners\FavoriteCount;
use Favorites\Listeners\FavoriteList;
use Favorites\Listeners\CookieConsent;
class RegisterPublicEvents
{
public function __construct()
{
// Front End Favorite Button
add_action( 'wp_ajax_nopriv_favorites_favorite', [$this, 'favoriteButton']);
add_action( 'wp_ajax_favorites_favorite', [$this, 'favoriteButton']);
// User's Favorited Posts (array of IDs)
add_action( 'wp_ajax_nopriv_favorites_array', [$this, 'favoritesArray']);
add_action( 'wp_ajax_favorites_array', [$this, 'favoritesArray']);
// Clear Favorites
add_action( 'wp_ajax_nopriv_favorites_clear', [$this, 'clearFavorites']);
add_action( 'wp_ajax_favorites_clear', [$this, 'clearFavorites']);
// Total Favorite Count
add_action( 'wp_ajax_nopriv_favorites_totalcount', [$this, 'favoriteCount']);
add_action( 'wp_ajax_favorites_totalcount', [$this, 'favoriteCount']);
// Single Favorite List
add_action( 'wp_ajax_nopriv_favorites_list', [$this, 'favoriteList']);
add_action( 'wp_ajax_favorites_list', [$this, 'favoriteList']);
// Accept/Deny Cookies
add_action( 'wp_ajax_nopriv_favorites_cookie_consent', [$this, 'cookiesConsented']);
add_action( 'wp_ajax_favorites_cookie_consent', [$this, 'cookiesConsented']);
}
/**
* Favorite Button
*/
public function favoriteButton()
{
new FavoriteButton;
}
/**
* Generate a Nonce
*/
public function nonce()
{
new NonceHandler;
}
/**
* Get an array of current user's favorites
*/
public function favoritesArray()
{
new FavoritesArray;
}
/**
* Clear all Favorites
*/
public function clearFavorites()
{
new ClearFavorites;
}
/**
* Favorite Count for a single post
*/
public function favoriteCount()
{
new FavoriteCount;
}
/**
* Single Favorite List for a Specific User
*/
public function favoriteList()
{
new FavoriteList;
}
/**
* Cookies were either accepted or denied
*/
public function cookiesConsented()
{
new CookieConsent;
}
}