created plugin custer, and removed shortcodes change_id and user_infos from cipf plugin
This commit is contained in:
42
plugins/custer/author_id.php
Normal file
42
plugins/custer/author_id.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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!');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* get the current author id
|
||||
* return 0 if not found
|
||||
* get id outside loop : https://wordpress.stackexchange.com/q/65548
|
||||
*
|
||||
*/
|
||||
function get_author_id() {
|
||||
if (is_author()) {
|
||||
$user_id = get_queried_object_id();
|
||||
}
|
||||
else if (in_the_loop()) {
|
||||
$user_id = get_the_author_meta('ID');
|
||||
}
|
||||
// else if (is_singular()) {
|
||||
// $user_id = get_queried_object()->post_author;
|
||||
// }
|
||||
else {
|
||||
$user_id = 0;
|
||||
}
|
||||
|
||||
return $user_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user