Files
2024_WEBSITE_fipf/plugins/fbpatch/menu/menu_content.php

97 lines
1.6 KiB
PHP

<?php
namespace FBPATCH;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* the construction of the admin menu page
*
*/
function plugin_content() {
$patches = Fbpatch::get_patches();
$nonce = Fbpatch::NONCE;
$admin_post_patches = Fbpatch::ADMIN_POST_PATCH_CHOICE;
ob_start();
include(plugin_dir_path(__DIR__) . '/html/menu.html');
$html = ob_get_clean();
echo $html;
}
function patches_choice() {
$nonce = Fbpatch::NONCE;
if (!isset($_POST[$nonce['_name']])) {
\FBPATCH\redirect_menu_referer($_POST);
exit;
}
if (!wp_verify_nonce($_POST[$nonce['_name']], $nonce['_action'])) {
\FBPATCH\redirect_menu_referer($_POST);
exit;
}
/*
*
*
[24-Mar-2024 12:24:08 UTC] -> _POST {
"action":"add_patches",
"nonce_name":"7eeb560dc0",
"_wp_http_referer":"\/wp-admin\/admin.php?page=fbpatch-plugin",
"hide_show":"on"
}
*/
$pathes_on = array();
foreach($_POST as $key => $value) {
if ($value !== 'on') {
continue;
}
$pathes_on[] = $key;
}
Fbpatch::set_patches($pathes_on);
\FBPATCH\redirect_menu_referer($_POST);
}
add_action('admin_post_'.Fbpatch::ADMIN_POST_PATCH_CHOICE, __NAMESPACE__.'\patches_choice');
function redirect_menu_referer($post) {
if (!isset($post)) {
wp_redirect(admin_url(), 301);
exit;
}
if (is_null($post)) {
wp_redirect(admin_url(), 301);
exit;
}
if (empty($post)) {
wp_redirect(admin_url(), 301);
exit;
}
if (!isset($post['_wp_http_referer'])) {
wp_redirect(admin_url(), 301);
exit;
}
wp_redirect(home_url($post['_wp_http_referer']), 301);
exit;
}
?>