created plugin custer, and removed shortcodes change_id and user_infos from cipf plugin

This commit is contained in:
asus
2024-03-17 02:27:28 +01:00
parent 494943e4f7
commit 6ad1fb5137
13 changed files with 668 additions and 127 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace CUSTER;
/*
* it means someone outside wp is accessing the file, in this case kill it.
*/
if (!defined('ABSPATH')) {
die('You can not access this file!');
}
/*
* change the current user to the author id of the current object
* the only option is to force the author
* -> there is no sens in forcing the logged_in, because it's already the default
*
* [custer_change_id] -> default (author)
* [custer_change_id author] -> author
* [custer_change_id off] -> reset to logged_in
*
*/
function shortcode_change_id($options) {
/*
* set the default value for option
* currently it can only be author
*
*/
$option = 'author';
if (is_array($options)) {
$option = reset($options);
}
if (!is_string($option)) {
return;
}
if ($option === 'author') {
$id = get_author_id();
Custer::set_current_user_backup();
wp_set_current_user($id);
}
else if ($option === 'off') {
$id = Custer::reset_current_user_backup();
wp_set_current_user($id);
}
else
return;
}
add_shortcode('custer_change_id', __NAMESPACE__.'\shortcode_change_id');
?>