84 lines
1.3 KiB
PHP
84 lines
1.3 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_patchs();
|
|
$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;
|
|
}
|
|
|
|
/*
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
\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;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|