Files
2024_WEBSITE_fipf/plugins/fbpatch/menu/menu_content.php
2024-03-24 11:12:11 +01:00

77 lines
1.2 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() {
// Fbpatch::get_patchs();
$nonce = Fbpatch::NONCE;
ob_start();
include(plugin_dir_path(__DIR__) . '/html/menu.html');
$html = ob_get_clean();
echo $html;
}
function choose_patches() {
$nonce = Fbpatch::NONCE;
if (!isset($_POST[$nonce['_name']])) {
\FBPATCH\redirect_menu($_POST);
return;
}
if (!wp_verify_nonce($_POST[$nonce['_name']], $nonce['_action'])) {
\FBPATCH\redirect_menu($_POST);
return;
}
error_log("is logged in: " . json_encode(is_user_logged_in()));
\FBPATCH\redirect_menu($_POST);
}
add_action('admin_post_add_patches', __NAMESPACE__.'\choose_patches');
function redirect_menu($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;
}
?>