-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass-flm-base-controller.php
More file actions
38 lines (36 loc) · 1.1 KB
/
Copy pathclass-flm-base-controller.php
File metadata and controls
38 lines (36 loc) · 1.1 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
<?php
class flmBaseController
{
public static function update()
{
$data = file_get_contents("php://input");
die($data);
}
public static function toggleActivation()
{
echo "<script>console.log(" . get_option("flm_status") . ");</script>";
$status = (get_option("flm_status") == 1) ? 0 : 1;
update_option("flm_status", $status);
wp_redirect( $_SERVER['HTTP_REFERER'] );
exit();
}
public static function saveModalData()
{
check_admin_referer('flm-model-form');
$data = $_POST;
$data["links"] = array_filter($data["links"], function($idx) {
return !empty($idx["title"]) || !empty($idx["link"]);
});
unset($data["_wpnonce"]);
unset($data["_wp_http_referer"]);
unset($data["action"]);
$json = json_encode($data);
if (empty(get_option("flm_modal_data"))) {
add_option('flm_modal_data', $json);
} else {
update_option('flm_modal_data', $json);
}
wp_redirect($_POST["_wp_http_referer"]);
exit();
}
}