Skip to content

Commit

Permalink
get_sns_default_follow_userの返り値が不正の場合の対応
Browse files Browse the repository at this point in the history
  • Loading branch information
yhira committed Mar 22, 2024
1 parent 4131ed2 commit 24c4793
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/page-settings/sns-follow-funcs.php
Expand Up @@ -102,13 +102,13 @@ function get_sns_follow_button_color(){
define('OP_SNS_DEFAULT_FOLLOW_USER', 'sns_default_follow_user');
if ( !function_exists( 'get_sns_default_follow_user' ) ):
function get_sns_default_follow_user(){
$user_id = wp_get_current_user()->ID;//ユーザーを取得できない時は0になる
if ($user_id === 0) {
if (get_user_by('ID', 1)) {
$user_id = 1; //WordPressインストール初期時の管理者ユーザーのID
}
$user_id = get_theme_option(OP_SNS_DEFAULT_FOLLOW_USER);
// デフォルトユーザー保存なし?
if (!$user_id) {
// 管理ユーザーを取得
$user_id = get_users('role=administrator')[0]->ID;
}
return get_theme_option(OP_SNS_DEFAULT_FOLLOW_USER, $user_id);
return $user_id;
}
endif;

Expand Down

0 comments on commit 24c4793

Please sign in to comment.