PluginProbe ʕ •ᴥ•ʔ
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager / trunk
Folders – Unlimited Folders to Organize Media Library Folder, Pages, Posts, File Manager vtrunk
3.1.9 3.1.8 3.1.7 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 trunk 1.3.7 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9 2.9.1 2.9.2
folders / includes / notifications.class.php
folders / includes Last commit date
class-email-signup.php 1 year ago class-help.php 1 month ago class-polylang.php 7 months ago class-review-box.php 1 year ago class-upgrade-box.php 10 months ago class-wpml.php 7 months ago folders.class.php 1 month ago form.class.php 10 months ago form.fields.php 1 year ago import.export.class.php 8 months ago media.replace.php 7 months ago notifications.class.php 8 months ago plugins.class.php 8 months ago tree.class.php 8 months ago
notifications.class.php
197 lines
1 <?php
2 /**
3 * Class Folders Plugins import/export
4 *
5 * @author : Premio <contact@premio.io>
6 * @license : GPL2
7 * */
8
9 if (! defined('ABSPATH')) {
10 exit;
11 }
12
13 /**
14 * Class Folders_Notifications
15 *
16 * This class is responsible for managing notifications related to folders.
17 */
18 class Folders_Notifications_Free
19 {
20 /**
21 * Class constructor.
22 *
23 * This method is called when an instance of the class is created. It is used to initialize the object.
24 *
25 * @return void
26 */
27
28 public $default_settings = null;
29
30
31 public function __construct() {
32 add_filter("check_for_folders_notification_settings", [$this, "notification_setting"], 10, 1);
33
34 }
35
36 public function notification_setting($current_settings)
37 {
38 if(!is_null($this->default_settings)) {
39 return $this->default_settings;
40 }
41 $folders_settings = get_option("folders_settings");
42 $folders_settings = !is_array($folders_settings)?[]:$folders_settings;
43 $post_setting = apply_filters("check_for_folders_post_args", ["show_in_menu" => 1]);
44 $post_types = get_post_types( $post_setting, 'objects' );
45 $default_post_type = [];
46 if(!empty($post_types)) {
47 foreach($post_types as $post_type => $setting) {
48 if(in_array($post_type, $folders_settings)) {
49 $default_post_type[$post_type] = $setting->label;
50 }
51 }
52 }
53 if(in_array("folders4plugins",$folders_settings)) {
54 $default_post_type['plugin'] = "Plugins";
55 }
56 $default_settings = [
57 'allow_notification' => 'off',
58 'notification_email' => [""],
59 'mail_setting' => [
60 'on_item_insert' => [
61 'status' => 'off',
62 'default' => $default_post_type,
63 'post_type' => [],
64 'title' => esc_html__("Send Notifications when users add any of the following new items", "folders"),
65 'email' => [
66 'subject' => "New {post_type} added by {user_name}, {email} - Folders",
67 'content' => "Activity: {post_type} added\nWhere: {post_type}\nTitle: {post_title}\nPost Status: {post_status}"
68 ],
69 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nPost title: {post_title}\nPost Status: {post_status}"
70 ],
71 'on_item_edit' => [
72 'status' => 'off',
73 'post_type' => [],
74 'default' => $default_post_type,
75 'title' => esc_html__("Send Notifications when users making edits to any of the following items", "folders"),
76 'email' => [
77 'subject' => "{post_type} edited by {user_name}, {email} - Folders",
78 'content' => "Activity: {post_type} edited\nWhere: {post_type}\nTitle: {post_title}"
79 ],
80 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nPost title: {post_title}"
81 ],
82 'on_item_remove' => [
83 'status' => 'off',
84 'post_type' => [],
85 'default' => $default_post_type,
86 'title' => esc_html__("Send Notifications when users delete/deactivate any of the following items", "folders"),
87 'email' => [
88 'subject' => "{post_type} deleted by {user_name}, {email} - Folders",
89 'content' => "Activity: {post_type} deleted\nWhere: {post_type}\nTitle: {post_title}"
90 ],
91 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nPost title: {post_title}"
92 ],
93 'on_creating_folder' => [
94 'status' => 'off',
95 'post_type' => [],
96 'default' => $default_post_type,
97 'title' => esc_html__("Send Notifications when users add a new folder", "folders"),
98 'email' => [
99 'subject' => "New folder added by {user_name}, {email} in {post_type} - Folders",
100 'content' => "Activity: {post_type} folder added\nWhere: {post_type}\nFolder name: {folder_name}"
101 ],
102 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nFolder name: {folder_name}"
103 ],
104 'on_removing_folder' => [
105 'status' => 'off',
106 'post_type' => [],
107 'default' => $default_post_type,
108 'title' => esc_html__("Send Notifications when users delete folder", "folders"),
109 'email' => [
110 'subject' => "Folder deleted by {user_name}, {email} in {post_type} - Folders",
111 'content' => "Activity: {post_type} folder deleted\nWhere: {post_type}\nFolder name: {folder_name}"
112 ],
113 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nFolder name: {folder_name}"
114 ],
115 'on_moving_folder' => [
116 'status' => 'off',
117 'post_type' => [],
118 'default' => $default_post_type,
119 'title' => esc_html__("Send Notifications when users move folder", "folders"),
120 'email' => [
121 'subject' => "Folder moved by {user_name}, {email} in {post_type} - Folders",
122 'content' => "Activity: {post_type} folder moved\nWhere: {post_type}\nFolder name: {folder_name}"
123 ],
124 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nFolder name: {folder_name}"
125 ],
126 'on_item_move' => [
127 'status' => 'off',
128 'post_type' => [],
129 'default' => $default_post_type,
130 'title' => esc_html__("Send Notifications when users move any of the following items to folder", "folders"),
131 'email' => [
132 'subject' => "{post_type} moved by {user_name}, {email} - Folders",
133 'content' => "Activity: {post_type} moved\nWhere: {post_type}\nTitle: {post_title}"
134 ],
135 'help' => "Username: {user_name}\nEmail: {email}\nPost type: {post_type}\nPost title: {post_title}\nFolder name: {folder_name}"
136 ],
137 'remove_users' => [
138 'status' => 'off',
139 'users' => [],
140 'default' => [],
141 'title' => esc_html__("Don't Send Notifications when these users make changes", "folders")
142 ],
143 ]
144 ];
145 $current_settings = !is_array($current_settings)?[]:$current_settings;
146
147 $this->default_settings = $this->set_default_value($current_settings, $default_settings);
148 return $this->default_settings;
149 }
150
151 function set_default_value($current_settings, $default_settings) {
152 if(is_array($default_settings)) {
153 foreach ($default_settings as $key => $value) {
154 if(isset($current_settings[$key]) && is_array($current_settings[$key]) && $this->is_numeric_array($current_settings[$key])) {
155 $default_settings[$key] = $current_settings[$key];
156 } else {
157 if (!is_array($value)) {
158 if (isset($current_settings[$key])) {
159 $default_settings[$key] = $current_settings[$key];
160 }
161 } else {
162 if (!isset($current_settings[$key])) {
163 $default_settings[$key] = $value;
164 } else if (!isset($default_settings[$key])) {
165 $default_settings[$key] = $current_settings[$key];
166 } else {
167 $default_settings[$key] = $this->set_default_value($current_settings[$key], $default_settings[$key]);
168 }
169 }
170 }
171 }
172 } else {
173 return $current_settings;
174 }
175 return $default_settings;
176 }
177
178 /**
179 * Checks if an array is numeric.
180 *
181 * @param array $arr The array to be checked.
182 *
183 * @return bool Returns true if the array is numeric, false otherwise.
184 */
185 function is_numeric_array(array $arr)
186 {
187 if ($arr === []) {
188 return true;
189 }
190 return array_keys($arr) === range(0, count($arr) - 1);
191 }
192
193 }
194 if(class_exists("Folders_Notifications_Free")) {
195 $Folders_Notifications = new Folders_Notifications_Free();
196 }
197