質問編集履歴
3
試したこと2の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
### 試したこと
|
19
|
+
### 試したこと1
|
20
20
|
|
21
21
|
|
22
22
|
|
@@ -67,3 +67,17 @@
|
|
67
67
|
</div>
|
68
68
|
|
69
69
|
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
### 試したこと2
|
74
|
+
|
75
|
+
次のように、元からあるリンクを当該箇所へ移動させればできますが、こうではなく、上のようにPHP側の出力の時点でリンク化させたいです。
|
76
|
+
|
77
|
+
```javascript
|
78
|
+
|
79
|
+
var infolink = $('#user-notifications').attr('href');
|
80
|
+
|
81
|
+
$('.info a').attr('href', infolink);
|
82
|
+
|
83
|
+
```
|
2
進展があったため内容を変更いたしました。
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
「BuddyPress」で通知数を
|
1
|
+
「BuddyPress」で通知数をリンク化する方法
|
test
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
WordPressプラグイン「BuddyPress」で通知数を
|
5
|
+
WordPressプラグイン「BuddyPress」で出力した通知数をリンク化したいです。
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
下記
|
9
|
+
下記を試しても通知数はリンク化されませんでした。
|
10
10
|
|
11
11
|
|
12
12
|
|
@@ -20,62 +20,50 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
23
|
+
出力箇所にこう書くと通知数は出力できたのですが、
|
24
24
|
|
25
25
|
```php
|
26
26
|
|
27
|
-
|
27
|
+
<div class="info">
|
28
28
|
|
29
|
-
<?php bp_notifications_get_unread_notification_count(bp_loggedin_user_id());
|
29
|
+
<?php $info = bp_notifications_get_unread_notification_count(bp_loggedin_user_id());
|
30
30
|
|
31
|
-
|
31
|
+
echo $info;
|
32
32
|
|
33
|
-
|
33
|
+
?>
|
34
34
|
|
35
|
-
```php
|
36
|
-
|
37
|
-
/
|
35
|
+
</div>
|
38
|
-
|
39
|
-
<?php bp_notifications_get_notifications_for_user(bp_loggedin_user_id()); ?>
|
40
|
-
|
41
|
-
```
|
42
|
-
|
43
|
-
【3】
|
44
|
-
|
45
|
-
```php
|
46
|
-
|
47
|
-
//functions.phpに下記
|
48
|
-
|
49
|
-
function cg_current_user_notification_count() {
|
50
|
-
|
51
|
-
$notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object');
|
52
|
-
|
53
|
-
$count = !empty($notifications) ? count($notifications) : 0;
|
54
|
-
|
55
|
-
echo $count;
|
56
|
-
|
57
|
-
}
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
//出力箇所に下記
|
62
|
-
|
63
|
-
<?php cg_current_user_notification_count(); ?>
|
64
36
|
|
65
37
|
```
|
66
38
|
|
67
39
|
|
68
40
|
|
69
|
-
### 補足
|
70
|
-
|
71
|
-
|
41
|
+
上では次のように通知数しか出力できず、
|
72
42
|
|
73
43
|
```html
|
74
44
|
|
45
|
+
<div class="info">
|
46
|
+
|
47
|
+
1
|
48
|
+
|
49
|
+
</div>
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
下記のようにリンク化して出力したいです。
|
56
|
+
|
57
|
+
```html
|
58
|
+
|
59
|
+
<div class="info">
|
60
|
+
|
75
61
|
<a id="user-notifications" href="http://example.com/member/watashi/notifications/">
|
76
62
|
|
77
|
-
<span class="count">1</span>
|
63
|
+
<span class="count">1</span>
|
78
64
|
|
79
65
|
</a>
|
80
66
|
|
67
|
+
</div>
|
68
|
+
|
81
69
|
```
|
1
補足致しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,8 +11,6 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
方法をご存知の方がいらしたら教えてください。
|
14
|
-
|
15
|
-
|
16
14
|
|
17
15
|
|
18
16
|
|
@@ -65,3 +63,19 @@
|
|
65
63
|
<?php cg_current_user_notification_count(); ?>
|
66
64
|
|
67
65
|
```
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
### 補足
|
70
|
+
|
71
|
+
通知数は次にようにリンク化されたものを出力したいです。
|
72
|
+
|
73
|
+
```html
|
74
|
+
|
75
|
+
<a id="user-notifications" href="http://example.com/member/watashi/notifications/">
|
76
|
+
|
77
|
+
<span class="count">1</span><!--この通知数を<a>タグで囲って出力したい-->
|
78
|
+
|
79
|
+
</a>
|
80
|
+
|
81
|
+
```
|