質問編集履歴
3
PHPコードとCSSを別々に記述
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,10 +1,74 @@
|
|
1
|
-
```
|
1
|
+
```CSS
|
2
|
+
|
3
|
+
//コメント欄に項目を追加
|
4
|
+
|
5
|
+
add_filter( 'comment_form_defaults','change_comment_form_flower');
|
6
|
+
|
7
|
+
function change_comment_form_flower($default) {
|
8
|
+
|
9
|
+
$commenter = wp_get_current_commenter();
|
10
|
+
|
11
|
+
/***メール入力欄の下に花選択を表示させる*************************/
|
12
|
+
|
13
|
+
/* $default['fields']['email'] .= '<p class="comment-form-author">' .*/
|
14
|
+
|
15
|
+
/* $default['fields']['jyuu'] .= '<p class="comment-form-jyuu">' . */
|
16
|
+
|
17
|
+
$default['fields']['email'] .= '<p class="comment-form-email">' .
|
18
|
+
|
19
|
+
'<label for="flower">'. __('お花を選んで下さい') .'</label>
|
20
|
+
|
21
|
+
<input type="radio" id="flower" class="flower" name="flower" value="hasu">
|
22
|
+
|
23
|
+
<label for="hasu">
|
24
|
+
|
25
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/hasu.png" alt="ハスの画像" width="100" height="100" border="0">
|
26
|
+
|
27
|
+
</label>
|
28
|
+
|
29
|
+
<input type="radio" id="flower" class="flower" name="flower" value="bara">
|
30
|
+
|
31
|
+
<label for="baraw">
|
32
|
+
|
33
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/baraw.png" alt="バラの画像" width="100" hight="100" border="0">
|
34
|
+
|
35
|
+
</label>
|
36
|
+
|
37
|
+
<input type="radio" id="flower" class="flower" name="flower" value="kiku">
|
38
|
+
|
39
|
+
<label for="kiku">
|
40
|
+
|
41
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/kiku.png" alt="キクの画像" width="100" height="100" border="0">
|
42
|
+
|
43
|
+
</label>
|
44
|
+
|
45
|
+
<input type="radio" id="flower" class="flower" name="flower" value="ran">
|
46
|
+
|
47
|
+
<label for="ran">
|
48
|
+
|
49
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/ran.png" alt="ランの画像" width="100" height="100" border="0">
|
50
|
+
|
51
|
+
</label>
|
52
|
+
|
53
|
+
<input type="radio" id="flower" class="flower" name="flower" value="tulips">
|
54
|
+
|
55
|
+
<label for="tulips">
|
56
|
+
|
57
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/tulips.png" alt="チューリップの画像" width="100" height="100" border="0">
|
58
|
+
|
59
|
+
</label>
|
60
|
+
|
61
|
+
</p>';
|
62
|
+
|
63
|
+
return $default;
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
```PHP
|
2
68
|
|
3
69
|
/* タイトルが「Mymessage」または「guestbook」の固定ページで行う処理を書く2021.04.21*/
|
4
70
|
|
5
|
-
|
71
|
+
<?php if ( is_page(array('Mymessage'),('guestbook')) ): ?>
|
6
|
-
|
7
|
-
if ( is_page(array('Mymessage'),('guestbook')) ){と書くべきなのか?**
|
8
72
|
|
9
73
|
/*アバター選択制2021.03.28*/
|
10
74
|
|
@@ -122,70 +186,6 @@
|
|
122
186
|
|
123
187
|
add_filter('get_avatar_data','new_get_avatar_data',10,2);
|
124
188
|
|
125
|
-
|
126
|
-
|
127
|
-
//コメント欄に項目を追加
|
128
|
-
|
129
|
-
add_filter( 'comment_form_defaults','change_comment_form_flower');
|
130
|
-
|
131
|
-
function change_comment_form_flower($default) {
|
132
|
-
|
133
|
-
$commenter = wp_get_current_commenter();
|
134
|
-
|
135
|
-
/***メール入力欄の下に花選択を表示させる*************************/
|
136
|
-
|
137
|
-
/* $default['fields']['email'] .= '<p class="comment-form-author">' .*/
|
138
|
-
|
139
|
-
/* $default['fields']['jyuu'] .= '<p class="comment-form-jyuu">' . */
|
140
|
-
|
141
|
-
$default['fields']['email'] .= '<p class="comment-form-email">' .
|
142
|
-
|
143
|
-
'<label for="flower">'. __('お花を選んで下さい') .'</label>
|
144
|
-
|
145
|
-
<input type="radio" id="flower" class="flower" name="flower" value="hasu">
|
146
|
-
|
147
|
-
<label for="hasu">
|
148
|
-
|
149
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/hasu.png" alt="ハスの画像" width="100" height="100" border="0">
|
150
|
-
|
151
|
-
</label>
|
152
|
-
|
153
|
-
<input type="radio" id="flower" class="flower" name="flower" value="bara">
|
154
|
-
|
155
|
-
<label for="baraw">
|
156
|
-
|
157
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/baraw.png" alt="バラの画像" width="100" hight="100" border="0">
|
158
|
-
|
159
|
-
</label>
|
160
|
-
|
161
|
-
<input type="radio" id="flower" class="flower" name="flower" value="kiku">
|
162
|
-
|
163
|
-
<label for="kiku">
|
164
|
-
|
165
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/kiku.png" alt="キクの画像" width="100" height="100" border="0">
|
166
|
-
|
167
|
-
</label>
|
168
|
-
|
169
|
-
<input type="radio" id="flower" class="flower" name="flower" value="ran">
|
170
|
-
|
171
|
-
<label for="ran">
|
172
|
-
|
173
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/ran.png" alt="ランの画像" width="100" height="100" border="0">
|
174
|
-
|
175
|
-
</label>
|
176
|
-
|
177
|
-
<input type="radio" id="flower" class="flower" name="flower" value="tulips">
|
178
|
-
|
179
|
-
<label for="tulips">
|
180
|
-
|
181
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/tulips.png" alt="チューリップの画像" width="100" height="100" border="0">
|
182
|
-
|
183
|
-
</label>
|
184
|
-
|
185
|
-
</p>';
|
186
|
-
|
187
|
-
return $default;
|
188
|
-
|
189
189
|
}
|
190
190
|
|
191
191
|
//ラジオボタンの情報をデータベースに追加する
|
@@ -202,7 +202,9 @@
|
|
202
202
|
|
203
203
|
}
|
204
204
|
|
205
|
-
|
205
|
+
}
|
206
|
+
|
207
|
+
|
206
208
|
|
207
209
|
**/* タイトルが「Mymemories」の個別ページで行う処理を書く2021.04.21アバターの選択なし*/の場合は
|
208
210
|
|
@@ -210,7 +212,7 @@
|
|
210
212
|
|
211
213
|
else if ( is_single('Mymemories') ) {}
|
212
214
|
|
213
|
-
;
|
215
|
+
<?php endif; ?>
|
214
216
|
|
215
217
|
```⑴ 各固定ページからボタンで飛んだ時、それぞれのコメント入力欄を表示させ登録したい
|
216
218
|
|
2
ソースをソースコード欄に移しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,218 @@
|
|
1
|
+
```PHP,CSS
|
2
|
+
|
3
|
+
/* タイトルが「Mymessage」または「guestbook」の固定ページで行う処理を書く2021.04.21*/
|
4
|
+
|
5
|
+
**<?php if ( is_page(array('Mymessage'),('guestbook')) ): ?>と書くのか?
|
6
|
+
|
7
|
+
if ( is_page(array('Mymessage'),('guestbook')) ){と書くべきなのか?**
|
8
|
+
|
9
|
+
/*アバター選択制2021.03.28*/
|
10
|
+
|
11
|
+
/*get_avatarの画像URLを書き換える*/
|
12
|
+
|
13
|
+
function new_get_avatar_data($args,$id_or_email){
|
14
|
+
|
15
|
+
$check_avatar =null;
|
16
|
+
|
17
|
+
$user = null;
|
18
|
+
|
19
|
+
$hash = null;
|
20
|
+
|
21
|
+
if($args['found_avatar'] == true){
|
22
|
+
|
23
|
+
if ( ! empty( $id_or_email->user_id )){
|
24
|
+
|
25
|
+
$user = get_user_by( 'id', (int) $id_or_email->user_id );
|
26
|
+
|
27
|
+
$email = $user->user_email;
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
|
34
|
+
|
35
|
+
$email = $id_or_email->comment_author_email;
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
if(! empty($email)){
|
42
|
+
|
43
|
+
$hash = md5( strtolower( trim( $email ) ) );
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
|
50
|
+
|
51
|
+
$headers = @get_headers($uri);
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
if (preg_match("|200|", $headers[0])) {
|
56
|
+
|
57
|
+
$check_avatar = TRUE;
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
if(!empty($id_or_email)){
|
68
|
+
|
69
|
+
$flower = get_comment_meta($id_or_email->comment_ID);}
|
70
|
+
|
71
|
+
if(is_object($id_or_email) && isset( $id_or_email->user_id ) && empty($check_avatar) && ! empty($flower)){
|
72
|
+
|
73
|
+
$flower = $flower['flower'][0];
|
74
|
+
|
75
|
+
if($flower == 'hasu'){
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/hasu.png';//ハスの画像
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
elseif($flower == 'bara'){
|
84
|
+
|
85
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/baraw.png';//バラの画像
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
elseif($flower == 'kiku'){
|
90
|
+
|
91
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/kiku.png';//キクの画像
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
elseif($flower == 'ran'){
|
96
|
+
|
97
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/ran.png';//スズランの画像
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
elseif($flower == 'tulips'){
|
102
|
+
|
103
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/tulips.png';//チューリップの画像
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
return $args;
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
else{
|
116
|
+
|
117
|
+
return $args;
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
add_filter('get_avatar_data','new_get_avatar_data',10,2);
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
//コメント欄に項目を追加
|
128
|
+
|
129
|
+
add_filter( 'comment_form_defaults','change_comment_form_flower');
|
130
|
+
|
131
|
+
function change_comment_form_flower($default) {
|
132
|
+
|
133
|
+
$commenter = wp_get_current_commenter();
|
134
|
+
|
135
|
+
/***メール入力欄の下に花選択を表示させる*************************/
|
136
|
+
|
137
|
+
/* $default['fields']['email'] .= '<p class="comment-form-author">' .*/
|
138
|
+
|
139
|
+
/* $default['fields']['jyuu'] .= '<p class="comment-form-jyuu">' . */
|
140
|
+
|
141
|
+
$default['fields']['email'] .= '<p class="comment-form-email">' .
|
142
|
+
|
143
|
+
'<label for="flower">'. __('お花を選んで下さい') .'</label>
|
144
|
+
|
145
|
+
<input type="radio" id="flower" class="flower" name="flower" value="hasu">
|
146
|
+
|
147
|
+
<label for="hasu">
|
148
|
+
|
149
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/hasu.png" alt="ハスの画像" width="100" height="100" border="0">
|
150
|
+
|
151
|
+
</label>
|
152
|
+
|
153
|
+
<input type="radio" id="flower" class="flower" name="flower" value="bara">
|
154
|
+
|
155
|
+
<label for="baraw">
|
156
|
+
|
157
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/baraw.png" alt="バラの画像" width="100" hight="100" border="0">
|
158
|
+
|
159
|
+
</label>
|
160
|
+
|
161
|
+
<input type="radio" id="flower" class="flower" name="flower" value="kiku">
|
162
|
+
|
163
|
+
<label for="kiku">
|
164
|
+
|
165
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/kiku.png" alt="キクの画像" width="100" height="100" border="0">
|
166
|
+
|
167
|
+
</label>
|
168
|
+
|
169
|
+
<input type="radio" id="flower" class="flower" name="flower" value="ran">
|
170
|
+
|
171
|
+
<label for="ran">
|
172
|
+
|
173
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/ran.png" alt="ランの画像" width="100" height="100" border="0">
|
174
|
+
|
175
|
+
</label>
|
176
|
+
|
177
|
+
<input type="radio" id="flower" class="flower" name="flower" value="tulips">
|
178
|
+
|
179
|
+
<label for="tulips">
|
180
|
+
|
181
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/tulips.png" alt="チューリップの画像" width="100" height="100" border="0">
|
182
|
+
|
183
|
+
</label>
|
184
|
+
|
185
|
+
</p>';
|
186
|
+
|
187
|
+
return $default;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
//ラジオボタンの情報をデータベースに追加する
|
192
|
+
|
193
|
+
add_action( 'comment_post', 'save_comment_meta_data_flower' );
|
194
|
+
|
195
|
+
function save_comment_meta_data_flower( $comment_id ) {
|
196
|
+
|
197
|
+
$flowers = explode(',', $_POST['flower']);
|
198
|
+
|
199
|
+
foreach ($flowers as $flower)
|
200
|
+
|
201
|
+
echo update_comment_meta( $comment_id, 'flower', $flower, true);
|
202
|
+
|
203
|
+
}
|
204
|
+
|
205
|
+
**} **
|
206
|
+
|
207
|
+
**/* タイトルが「Mymemories」の個別ページで行う処理を書く2021.04.21アバターの選択なし*/の場合は
|
208
|
+
|
209
|
+
処理をしない、画像は表示しない
|
210
|
+
|
211
|
+
else if ( is_single('Mymemories') ) {}
|
212
|
+
|
213
|
+
;**
|
214
|
+
|
1
|
-
⑴ 各固定ページからボタンで飛んだ時、それぞれのコメント入力欄を表示させ登録したい
|
215
|
+
```⑴ 各固定ページからボタンで飛んだ時、それぞれのコメント入力欄を表示させ登録したい
|
2
216
|
|
3
217
|
|
4
218
|
|
@@ -22,218 +236,4 @@
|
|
22
236
|
|
23
237
|
分かりません。
|
24
238
|
|
25
|
-
⑶ ソースコード(function.php)エラーは出ていないのですが。
|
239
|
+
⑶ ソースコード(function.php)エラーは出ていないのですが認識もされません。
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
/* タイトルが「Mymessage」または「guestbook」の固定ページで行う処理を書く2021.04.21*/
|
30
|
-
|
31
|
-
**<?php if ( is_page(array('Mymessage'),('guestbook')) ): ?>と書くのか?**
|
32
|
-
|
33
|
-
**if ( is_page(array('Mymessage'),('guestbook')) ){と書くべきなのか?**
|
34
|
-
|
35
|
-
/*アバター選択制2021.03.28*/
|
36
|
-
|
37
|
-
/*get_avatarの画像URLを書き換える*/
|
38
|
-
|
39
|
-
function new_get_avatar_data($args,$id_or_email){
|
40
|
-
|
41
|
-
$check_avatar =null;
|
42
|
-
|
43
|
-
$user = null;
|
44
|
-
|
45
|
-
$hash = null;
|
46
|
-
|
47
|
-
if($args['found_avatar'] == true){
|
48
|
-
|
49
|
-
if ( ! empty( $id_or_email->user_id )){
|
50
|
-
|
51
|
-
$user = get_user_by( 'id', (int) $id_or_email->user_id );
|
52
|
-
|
53
|
-
$email = $user->user_email;
|
54
|
-
|
55
|
-
}
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
|
60
|
-
|
61
|
-
$email = $id_or_email->comment_author_email;
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
if(! empty($email)){
|
68
|
-
|
69
|
-
$hash = md5( strtolower( trim( $email ) ) );
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
|
76
|
-
|
77
|
-
$headers = @get_headers($uri);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
if (preg_match("|200|", $headers[0])) {
|
82
|
-
|
83
|
-
$check_avatar = TRUE;
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
if(!empty($id_or_email)){
|
94
|
-
|
95
|
-
$flower = get_comment_meta($id_or_email->comment_ID);}
|
96
|
-
|
97
|
-
if(is_object($id_or_email) && isset( $id_or_email->user_id ) && empty($check_avatar) && ! empty($flower)){
|
98
|
-
|
99
|
-
$flower = $flower['flower'][0];
|
100
|
-
|
101
|
-
if($flower == 'hasu'){
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/hasu.png';//ハスの画像
|
106
|
-
|
107
|
-
}
|
108
|
-
|
109
|
-
elseif($flower == 'bara'){
|
110
|
-
|
111
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/baraw.png';//バラの画像
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
elseif($flower == 'kiku'){
|
116
|
-
|
117
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/kiku.png';//キクの画像
|
118
|
-
|
119
|
-
}
|
120
|
-
|
121
|
-
elseif($flower == 'ran'){
|
122
|
-
|
123
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/ran.png';//スズランの画像
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
elseif($flower == 'tulips'){
|
128
|
-
|
129
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/tulips.png';//チューリップの画像
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
return $args;
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
}
|
140
|
-
|
141
|
-
else{
|
142
|
-
|
143
|
-
return $args;
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
}
|
148
|
-
|
149
|
-
add_filter('get_avatar_data','new_get_avatar_data',10,2);
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
//コメント欄に項目を追加
|
154
|
-
|
155
|
-
add_filter( 'comment_form_defaults','change_comment_form_flower');
|
156
|
-
|
157
|
-
function change_comment_form_flower($default) {
|
158
|
-
|
159
|
-
$commenter = wp_get_current_commenter();
|
160
|
-
|
161
|
-
/*******メール入力欄の下に花選択を表示させる*****************************/
|
162
|
-
|
163
|
-
/* $default['fields']['email'] .= '<p class="comment-form-author">' .*/
|
164
|
-
|
165
|
-
/* $default['fields']['jyuu'] .= '<p class="comment-form-jyuu">' . */
|
166
|
-
|
167
|
-
$default['fields']['email'] .= '<p class="comment-form-email">' .
|
168
|
-
|
169
|
-
'<label for="flower">'. __('お花を選んで下さい') .'</label>
|
170
|
-
|
171
|
-
<input type="radio" id="flower" class="flower" name="flower" value="hasu">
|
172
|
-
|
173
|
-
<label for="hasu">
|
174
|
-
|
175
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/hasu.png" alt="ハスの画像" width="100" height="100" border="0">
|
176
|
-
|
177
|
-
</label>
|
178
|
-
|
179
|
-
<input type="radio" id="flower" class="flower" name="flower" value="bara">
|
180
|
-
|
181
|
-
<label for="baraw">
|
182
|
-
|
183
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/baraw.png" alt="バラの画像" width="100" hight="100" border="0">
|
184
|
-
|
185
|
-
</label>
|
186
|
-
|
187
|
-
<input type="radio" id="flower" class="flower" name="flower" value="kiku">
|
188
|
-
|
189
|
-
<label for="kiku">
|
190
|
-
|
191
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/kiku.png" alt="キクの画像" width="100" height="100" border="0">
|
192
|
-
|
193
|
-
</label>
|
194
|
-
|
195
|
-
<input type="radio" id="flower" class="flower" name="flower" value="ran">
|
196
|
-
|
197
|
-
<label for="ran">
|
198
|
-
|
199
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/ran.png" alt="ランの画像" width="100" height="100" border="0">
|
200
|
-
|
201
|
-
</label>
|
202
|
-
|
203
|
-
<input type="radio" id="flower" class="flower" name="flower" value="tulips">
|
204
|
-
|
205
|
-
<label for="tulips">
|
206
|
-
|
207
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/tulips.png" alt="チューリップの画像" width="100" height="100" border="0">
|
208
|
-
|
209
|
-
</label>
|
210
|
-
|
211
|
-
</p>';
|
212
|
-
|
213
|
-
return $default;
|
214
|
-
|
215
|
-
}
|
216
|
-
|
217
|
-
//ラジオボタンの情報をデータベースに追加する
|
218
|
-
|
219
|
-
add_action( 'comment_post', 'save_comment_meta_data_flower' );
|
220
|
-
|
221
|
-
function save_comment_meta_data_flower( $comment_id ) {
|
222
|
-
|
223
|
-
$flowers = explode(',', $_POST['flower']);
|
224
|
-
|
225
|
-
foreach ($flowers as $flower)
|
226
|
-
|
227
|
-
echo update_comment_meta( $comment_id, 'flower', $flower, true);
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
**}**
|
232
|
-
|
233
|
-
/* タイトルが「Mymemories」の個別ページで行う処理を書く2021.04.21アバターの選択なし*/**の場合は**
|
234
|
-
|
235
|
-
**処理をしない、画像は表示しない**
|
236
|
-
|
237
|
-
else if ( is_single('Mymemories') ) {}
|
238
|
-
|
239
|
-
;
|
1
分岐条件が原因のようなので、その部分の記述がどのように違うのかを教えて頂けると助かります。*<?php 条件: ?>なのか、ただ条件でいいのか?固定ページのタイトルだけを条件に出来るのか?
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Wordpress
|
1
|
+
Wordpressで固定ページから各コメントページへの条件分岐はページタイトルだけでできますか?
|
test
CHANGED
@@ -18,407 +18,221 @@
|
|
18
18
|
|
19
19
|
みたが、まったく画像が表示されなくなってしまった。
|
20
20
|
|
21
|
-
条件分岐前は画像選択できていた
|
21
|
+
条件分岐前は画像選択できていたので、条件の記述が間違っていると思うのですが何が違うのか
|
22
|
+
|
23
|
+
分かりません。
|
22
24
|
|
23
25
|
⑶ ソースコード(function.php)エラーは出ていないのですが。
|
24
26
|
|
25
27
|
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
f
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
29
|
+
/* タイトルが「Mymessage」または「guestbook」の固定ページで行う処理を書く2021.04.21*/
|
30
|
+
|
31
|
+
**<?php if ( is_page(array('Mymessage'),('guestbook')) ): ?>と書くのか?**
|
32
|
+
|
33
|
+
**if ( is_page(array('Mymessage'),('guestbook')) ){と書くべきなのか?**
|
34
|
+
|
35
|
+
/*アバター選択制2021.03.28*/
|
36
|
+
|
37
|
+
/*get_avatarの画像URLを書き換える*/
|
38
|
+
|
39
|
+
function new_get_avatar_data($args,$id_or_email){
|
40
|
+
|
41
|
+
$check_avatar =null;
|
42
|
+
|
43
|
+
$user = null;
|
44
|
+
|
45
|
+
$hash = null;
|
46
|
+
|
47
|
+
if($args['found_avatar'] == true){
|
48
|
+
|
49
|
+
if ( ! empty( $id_or_email->user_id )){
|
50
|
+
|
51
|
+
$user = get_user_by( 'id', (int) $id_or_email->user_id );
|
52
|
+
|
53
|
+
$email = $user->user_email;
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
|
60
|
+
|
61
|
+
$email = $id_or_email->comment_author_email;
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
if(! empty($email)){
|
68
|
+
|
69
|
+
$hash = md5( strtolower( trim( $email ) ) );
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
|
76
|
+
|
77
|
+
$headers = @get_headers($uri);
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
if (preg_match("|200|", $headers[0])) {
|
82
|
+
|
83
|
+
$check_avatar = TRUE;
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
if(!empty($id_or_email)){
|
94
|
+
|
95
|
+
$flower = get_comment_meta($id_or_email->comment_ID);}
|
96
|
+
|
97
|
+
if(is_object($id_or_email) && isset( $id_or_email->user_id ) && empty($check_avatar) && ! empty($flower)){
|
98
|
+
|
99
|
+
$flower = $flower['flower'][0];
|
100
|
+
|
101
|
+
if($flower == 'hasu'){
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/hasu.png';//ハスの画像
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
elseif($flower == 'bara'){
|
110
|
+
|
111
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/baraw.png';//バラの画像
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
elseif($flower == 'kiku'){
|
116
|
+
|
117
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/kiku.png';//キクの画像
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
elseif($flower == 'ran'){
|
122
|
+
|
123
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/ran.png';//スズランの画像
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
elseif($flower == 'tulips'){
|
128
|
+
|
129
|
+
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/tulips.png';//チューリップの画像
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
return $args;
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
else{
|
142
|
+
|
143
|
+
return $args;
|
144
|
+
|
145
|
+
}
|
106
146
|
|
107
147
|
}
|
108
148
|
|
109
|
-
ret
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
g
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
<span class="comment-edit"><?php edit_comment_link('編集',' ',''); //編集リンク ?></span>
|
176
|
-
|
177
|
-
</div>
|
178
|
-
|
179
|
-
<?php if ($comment->comment_approved == '0') : ?>
|
180
|
-
|
181
|
-
<em>あなたのコメントは現在承認待ちです。</em>
|
182
|
-
|
183
|
-
<?php endif; ?>
|
184
|
-
|
185
|
-
<div class="comment-text"></div>
|
186
|
-
|
187
|
-
<?php comment_text(); //コメント本文 ?>
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
<?php //返信機能は不要なので削除 ?>
|
192
|
-
|
193
|
-
</div>
|
194
|
-
|
195
|
-
</div>
|
196
|
-
|
197
|
-
<?php
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
/*お住まいの情報をデータベースに追加する*/
|
202
|
-
|
203
|
-
add_action( 'comment_post', 'save_comment_meta_data_jyuu' );
|
204
|
-
|
205
|
-
function save_comment_meta_data_jyuu( $comment_id ) {
|
206
|
-
|
207
|
-
$jyuu = explode(',', $_POST['jyuu']);
|
208
|
-
|
209
|
-
foreach ($jyuu as $jyuu)
|
210
|
-
|
211
|
-
echo update_comment_meta( $comment_id, 'jyuu', $jyuu, true);
|
212
|
-
|
213
|
-
}
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
/* タイトルが「Mymessage」または「Mymememorialguestbook」の固定ページで行う処理を書く2021.04.21*/
|
218
|
-
|
219
|
-
/*<?php if ( is_page(array(5,'about','このサイトについて')) ) : ?>*/
|
220
|
-
|
221
|
-
if ( is_page(array('Mymessage','guestbook')) ){
|
222
|
-
|
223
|
-
/*アバター選択制2021.03.28*/
|
224
|
-
|
225
|
-
/*get_avatarの画像URLを書き換える*/
|
226
|
-
|
227
|
-
function new_get_avatar_data($args,$id_or_email){
|
228
|
-
|
229
|
-
$check_avatar =null;
|
230
|
-
|
231
|
-
$user = null;
|
232
|
-
|
233
|
-
$hash = null;
|
234
|
-
|
235
|
-
if($args['found_avatar'] == true){
|
236
|
-
|
237
|
-
if ( ! empty( $id_or_email->user_id )){
|
238
|
-
|
239
|
-
$user = get_user_by( 'id', (int) $id_or_email->user_id );
|
240
|
-
|
241
|
-
$email = $user->user_email;
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
|
248
|
-
|
249
|
-
$email = $id_or_email->comment_author_email;
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
if(! empty($email)){
|
256
|
-
|
257
|
-
$hash = md5( strtolower( trim( $email ) ) );
|
258
|
-
|
259
|
-
}
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
|
264
|
-
|
265
|
-
$headers = @get_headers($uri);
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
if (preg_match("|200|", $headers[0])) {
|
270
|
-
|
271
|
-
$check_avatar = TRUE;
|
272
|
-
|
273
|
-
}
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
}
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
if(!empty($id_or_email)){
|
282
|
-
|
283
|
-
$flower = get_comment_meta($id_or_email->comment_ID);}
|
284
|
-
|
285
|
-
if(is_object($id_or_email) && isset( $id_or_email->user_id ) && empty($check_avatar) && ! empty($flower)){
|
286
|
-
|
287
|
-
$flower = $flower['flower'][0];
|
288
|
-
|
289
|
-
if($flower == 'hasu'){
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/hasu.png';//ハスの画像
|
294
|
-
|
295
|
-
}
|
296
|
-
|
297
|
-
elseif($flower == 'bara'){
|
298
|
-
|
299
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/baraw.png';//バラの画像
|
300
|
-
|
301
|
-
}
|
302
|
-
|
303
|
-
elseif($flower == 'kiku'){
|
304
|
-
|
305
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/kiku.png';//キクの画像
|
306
|
-
|
307
|
-
}
|
308
|
-
|
309
|
-
elseif($flower == 'ran'){
|
310
|
-
|
311
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/ran.png';//スズランの画像
|
312
|
-
|
313
|
-
}
|
314
|
-
|
315
|
-
elseif($flower == 'tulips'){
|
316
|
-
|
317
|
-
$args['url'] = 'https://cft-info.com/wp-content/uploads/2021/03/tulips.png';//チューリップの画像
|
318
|
-
|
319
|
-
}
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
return $args;
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
}
|
328
|
-
|
329
|
-
else{
|
330
|
-
|
331
|
-
return $args;
|
332
|
-
|
333
|
-
}
|
149
|
+
add_filter('get_avatar_data','new_get_avatar_data',10,2);
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
//コメント欄に項目を追加
|
154
|
+
|
155
|
+
add_filter( 'comment_form_defaults','change_comment_form_flower');
|
156
|
+
|
157
|
+
function change_comment_form_flower($default) {
|
158
|
+
|
159
|
+
$commenter = wp_get_current_commenter();
|
160
|
+
|
161
|
+
/*******メール入力欄の下に花選択を表示させる*****************************/
|
162
|
+
|
163
|
+
/* $default['fields']['email'] .= '<p class="comment-form-author">' .*/
|
164
|
+
|
165
|
+
/* $default['fields']['jyuu'] .= '<p class="comment-form-jyuu">' . */
|
166
|
+
|
167
|
+
$default['fields']['email'] .= '<p class="comment-form-email">' .
|
168
|
+
|
169
|
+
'<label for="flower">'. __('お花を選んで下さい') .'</label>
|
170
|
+
|
171
|
+
<input type="radio" id="flower" class="flower" name="flower" value="hasu">
|
172
|
+
|
173
|
+
<label for="hasu">
|
174
|
+
|
175
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/hasu.png" alt="ハスの画像" width="100" height="100" border="0">
|
176
|
+
|
177
|
+
</label>
|
178
|
+
|
179
|
+
<input type="radio" id="flower" class="flower" name="flower" value="bara">
|
180
|
+
|
181
|
+
<label for="baraw">
|
182
|
+
|
183
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/baraw.png" alt="バラの画像" width="100" hight="100" border="0">
|
184
|
+
|
185
|
+
</label>
|
186
|
+
|
187
|
+
<input type="radio" id="flower" class="flower" name="flower" value="kiku">
|
188
|
+
|
189
|
+
<label for="kiku">
|
190
|
+
|
191
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/kiku.png" alt="キクの画像" width="100" height="100" border="0">
|
192
|
+
|
193
|
+
</label>
|
194
|
+
|
195
|
+
<input type="radio" id="flower" class="flower" name="flower" value="ran">
|
196
|
+
|
197
|
+
<label for="ran">
|
198
|
+
|
199
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/ran.png" alt="ランの画像" width="100" height="100" border="0">
|
200
|
+
|
201
|
+
</label>
|
202
|
+
|
203
|
+
<input type="radio" id="flower" class="flower" name="flower" value="tulips">
|
204
|
+
|
205
|
+
<label for="tulips">
|
206
|
+
|
207
|
+
<img src="https://cft-info.com/wp-content/uploads/2021/03/tulips.png" alt="チューリップの画像" width="100" height="100" border="0">
|
208
|
+
|
209
|
+
</label>
|
210
|
+
|
211
|
+
</p>';
|
212
|
+
|
213
|
+
return $default;
|
334
214
|
|
335
215
|
}
|
336
216
|
|
337
|
-
add_filter('get_avatar_data','new_get_avatar_data',10,2);
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
//
|
217
|
+
//ラジオボタンの情報をデータベースに追加する
|
342
|
-
|
218
|
+
|
343
|
-
add_
|
219
|
+
add_action( 'comment_post', 'save_comment_meta_data_flower' );
|
344
|
-
|
220
|
+
|
345
|
-
function
|
221
|
+
function save_comment_meta_data_flower( $comment_id ) {
|
346
|
-
|
347
|
-
|
222
|
+
|
348
|
-
|
349
|
-
/*******メール入力欄の下に花選択を表示させる*****************************/
|
350
|
-
|
351
|
-
/* $default['fields']['email'] .= '<p class="comment-form-author">' .*/
|
352
|
-
|
353
|
-
/* $default['fields']['jyuu'] .= '<p class="comment-form-jyuu">' . */
|
354
|
-
|
355
|
-
$default['fields']['email'] .= '<p class="comment-form-email">' .
|
356
|
-
|
357
|
-
|
223
|
+
$flowers = explode(',', $_POST['flower']);
|
358
|
-
|
359
|
-
|
224
|
+
|
360
|
-
|
361
|
-
|
225
|
+
foreach ($flowers as $flower)
|
362
|
-
|
363
|
-
|
226
|
+
|
364
|
-
|
365
|
-
</label>
|
366
|
-
|
367
|
-
<input type="radio" id="flower" class="flower" name="flower" value="bara">
|
368
|
-
|
369
|
-
<label for="baraw">
|
370
|
-
|
371
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/baraw.png" alt="バラの画像" width="100" hight="100" border="0">
|
372
|
-
|
373
|
-
</label>
|
374
|
-
|
375
|
-
<input type="radio" id="flower" class="flower" name="flower" value="kiku">
|
376
|
-
|
377
|
-
<label for="kiku">
|
378
|
-
|
379
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/kiku.png" alt="キクの画像" width="100" height="100" border="0">
|
380
|
-
|
381
|
-
</label>
|
382
|
-
|
383
|
-
|
227
|
+
echo update_comment_meta( $comment_id, 'flower', $flower, true);
|
384
|
-
|
385
|
-
<label for="ran">
|
386
|
-
|
387
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/ran.png" alt="ランの画像" width="100" height="100" border="0">
|
388
|
-
|
389
|
-
</label>
|
390
|
-
|
391
|
-
<input type="radio" id="flower" class="flower" name="flower" value="tulips">
|
392
|
-
|
393
|
-
<label for="tulips">
|
394
|
-
|
395
|
-
<img src="https://cft-info.com/wp-content/uploads/2021/03/tulips.png" alt="チューリップの画像" width="100" height="100" border="0">
|
396
|
-
|
397
|
-
</label>
|
398
|
-
|
399
|
-
</p>';
|
400
|
-
|
401
|
-
return $default;
|
402
228
|
|
403
229
|
}
|
404
230
|
|
405
|
-
//ラジオボタンの情報をデータベースに追加する
|
406
|
-
|
407
|
-
add_action( 'comment_post', 'save_comment_meta_data_flower' );
|
408
|
-
|
409
|
-
function save_comment_meta_data_flower( $comment_id ) {
|
410
|
-
|
411
|
-
$flowers = explode(',', $_POST['flower']);
|
412
|
-
|
413
|
-
foreach ($flowers as $flower)
|
414
|
-
|
415
|
-
echo update_comment_meta( $comment_id, 'flower', $flower, true);
|
416
|
-
|
417
|
-
|
231
|
+
**}**
|
418
|
-
|
419
|
-
|
232
|
+
|
420
|
-
|
421
|
-
/* タイトルが「Mymemories」の個別ページで行う処理を書く2021.04.21アバターの選択なし*/
|
233
|
+
/* タイトルが「Mymemories」の個別ページで行う処理を書く2021.04.21アバターの選択なし*/**の場合は**
|
234
|
+
|
235
|
+
**処理をしない、画像は表示しない**
|
422
236
|
|
423
237
|
else if ( is_single('Mymemories') ) {}
|
424
238
|
|