fixed pbm find author id ouside loop
This commit is contained in:
@@ -4,7 +4,7 @@ Plugin Name: custer_plugin
|
|||||||
Plugin URI:
|
Plugin URI:
|
||||||
Description: customize user : output infos on page, on email, and change current user id momentarly
|
Description: customize user : output infos on page, on email, and change current user id momentarly
|
||||||
Author: hugogogo
|
Author: hugogogo
|
||||||
Version: 0.1.4.1
|
Version: 0.1.5
|
||||||
Author URI:
|
Author URI:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -22,14 +22,8 @@ function get_author_id() {
|
|||||||
if (is_author()) {
|
if (is_author()) {
|
||||||
$user_id = get_queried_object_id();
|
$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 {
|
else {
|
||||||
$user_id = 0;
|
$user_id = get_the_author_meta('ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $user_id;
|
return $user_id;
|
||||||
@@ -44,29 +38,29 @@ function get_author_id() {
|
|||||||
* return 0 if not found
|
* return 0 if not found
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function get_anchor_id($anchor_name) {
|
//function get_anchor_id($anchor_name) {
|
||||||
$option_anchor = Custer::OPTION_ANCHOR;
|
// $option_anchor = Custer::OPTION_ANCHOR;
|
||||||
error_log("anchor_name:");
|
//error_log("anchor_name:");
|
||||||
error_log($anchor_name);
|
//error_log($anchor_name);
|
||||||
|
//
|
||||||
$anchors = get_option($option_anchor);
|
// $anchors = get_option($option_anchor);
|
||||||
error_log("anchors:");
|
//error_log("anchors:");
|
||||||
error_log(json_encode($anchors));
|
//error_log(json_encode($anchors));
|
||||||
if ($anchors === false) {
|
// if ($anchors === false) {
|
||||||
error_log("anchors === false");
|
//error_log("anchors === false");
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (isset($anchors[$anchor_name])) {
|
// if (isset($anchors[$anchor_name])) {
|
||||||
$user_id = $anchors[$anchor_name];
|
// $user_id = $anchors[$anchor_name];
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (empty($user_id)) {
|
// if (empty($user_id)) {
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return $user_id;
|
// return $user_id;
|
||||||
}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ function current_user_infos($atts) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ($id_is === 'author') {
|
else if ($id_is === 'author') {
|
||||||
$user_id = get_author_id();
|
$user_id = \CUSTER\get_author_id();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
Reference in New Issue
Block a user