LearnPress – Course Wishlist - Version 4.0.2

Version Description

~ Added: API wishlist.

Download this release

Release Info

Developer ThimPress
Plugin Icon 128x128 LearnPress – Course Wishlist
Version 4.0.2
Comparing to
See all releases

Code changes from version 3.0.2 to 4.0.2

assets/css/wishlist.css CHANGED
@@ -1,42 +1,88 @@
1
- #learn-press-profile-tab-course-wishlist.has-courses .learn-press-message {
2
- display: none;
3
- }
4
-
5
- .course-wishlist.heartbeat {
6
- animation-name: course-wishlist-heartbeat;
7
- animation-duration: 1s;
8
- animation-timing-function: ease-out;
9
- animation-delay: 3s;
10
- animation-direction: alternate;
11
- animation-iteration-count: infinite;
12
- animation-fill-mode: none;
13
- animation-play-state: running;
14
- }
15
-
16
- .course-wishlist.heartbeat.ajaxload {
17
- animation-duration: 0.3s;
18
- animation-name: course-wishlist-heartbeat-ajaxload;
19
- animation-delay: 0s;
20
- }
21
-
22
- @keyframes course-wishlist-heartbeat {
23
- 0% {
24
- transform: scale(1);
25
- }
26
- 100% {
27
- transform: scale(1.2);
28
- }
29
- }
30
-
31
- @keyframes course-wishlist-heartbeat-ajaxload {
32
- 0% {
33
- transform: scale(1);
34
- }
35
- 100% {
36
- transform: scale(1.5);
37
- }
38
- }
39
-
40
- .learn-press-courses .learn-press-course-wishlist.wishlist-button {
41
- width: 100%;
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #learn-press-profile-tab-course-wishlist.has-courses .learn-press-message {
2
+ display: none;
3
+ }
4
+
5
+ .course-wishlist.heartbeat {
6
+ animation-name: course-wishlist-heartbeat;
7
+ animation-duration: 1s;
8
+ animation-timing-function: ease-out;
9
+ animation-delay: 3s;
10
+ animation-direction: alternate;
11
+ animation-iteration-count: infinite;
12
+ animation-fill-mode: none;
13
+ animation-play-state: running;
14
+ }
15
+
16
+ .course-wishlist.heartbeat.ajaxload {
17
+ animation-duration: 0.3s;
18
+ animation-name: course-wishlist-heartbeat-ajaxload;
19
+ animation-delay: 0s;
20
+ }
21
+
22
+ .lp4.course-wishlist:before {
23
+ content: "\f004";
24
+ margin-right: 5px;
25
+ font-family: "Font Awesome 5 Free";
26
+ font-size: 26px;
27
+ font-weight: 900;
28
+ }
29
+
30
+ .lp4.course-wishlist.filled:before {
31
+ font-family: "Font Awesome 5 Free";
32
+ font-size: 26px;
33
+ font-weight: 900;
34
+ content: "\f004";
35
+ margin-right: 5px;
36
+ }
37
+
38
+ .lp3.course-wishlist:before {
39
+ content: "\f08a";
40
+ margin-right: 5px;
41
+ font-family: fontawesome;
42
+ }
43
+
44
+ .lp3.course-wishlist.filled:before {
45
+ content: "\f004";
46
+ }
47
+
48
+ .learn-press-courses .course-wishlist{
49
+ float: right;
50
+ }
51
+ @keyframes course-wishlist-heartbeat {
52
+ 0% {
53
+ transform: scale(1);
54
+ }
55
+ 100% {
56
+ transform: scale(1.2);
57
+ }
58
+ }
59
+
60
+ @keyframes course-wishlist-heartbeat-ajaxload {
61
+ 0% {
62
+ transform: scale(1);
63
+ }
64
+ 100% {
65
+ transform: scale(1.5);
66
+ }
67
+ }
68
+
69
+ .learn-press-courses .learn-press-course-wishlist.wishlist-button {
70
+ width: 100%;
71
+ }
72
+
73
+ #learn-press-course .learn-press-course-wishlist,
74
+ #learn-press-profile .learn-press-course-wishlist
75
+ {
76
+ display: block;
77
+ position: relative !important;
78
+ background: #fff;
79
+ border: 1px solid #000;
80
+ font-size: 14px;
81
+ color: #000;
82
+ padding: 5px;
83
+ }
84
+
85
+ /**************** Page Profile ****************/
86
+ #learn-press-profile #profile-nav .lp-profile-nav-tabs > li.wishlist.active > a::before {
87
+ color: white;
88
+ }
assets/js/wishlist.js CHANGED
@@ -1,53 +1,53 @@
1
- ;(function ($) {
2
- "use strict";
3
- var timer = null,
4
- submit = function () {
5
- var $button = $(this),
6
- course_id = $button.attr('data-id'),
7
- nonce = $button.attr('data-nonce'),
8
- text = $button.data('text');
9
- if ($button.hasClass('ajaxload_wishlist')) {
10
- return;
11
- }
12
- $button.addClass('ajaxload_wishlist').prop('disabled', true);
13
- if (text) {
14
- $button.html(text);
15
- }
16
- $.ajax({
17
- url : window.location.href,
18
- type : 'post',
19
- dataType: 'html',
20
- data : {
21
- //action : 'learn_press_toggle_course_wishlist',
22
- 'lp-ajax': 'toggle_course_wishlist',
23
- course_id: course_id,
24
- nonce : nonce
25
- },
26
- success : function (response) {
27
- response = LP.parseJSON(response);
28
- var $b = $('.learn-press-course-wishlist-button-' + response.course_id),
29
- $p = $b.closest('[data-context="tab-wishlist"]');
30
- if ($p.length) {
31
- $p.fadeOut(function () {
32
- var $siblings = $p.siblings(),
33
- $parent = $p.closest('#learn-press-profile-tab-course-wishlist');
34
- $p.remove();
35
- if ($siblings.length == 0) {
36
- $parent.removeClass('has-courses');
37
- }
38
- });
39
- } else {
40
- $b.removeClass('ajaxload_wishlist')
41
- .toggleClass('on', response.state == 'on')
42
- .prop('title', response.title)
43
- .html(response.button_text);
44
- }
45
- $b.prop('disabled', false)
46
- }
47
- });
48
- };
49
- $(document).on('click', '.course-wishlist', function () {
50
- timer && clearTimeout(timer);
51
- timer = setTimeout($.proxy(submit, this), 50);
52
- });
53
- })(jQuery);
1
+ ;(function ($) {
2
+ "use strict";
3
+ var timer = null,
4
+ submit = function () {
5
+ var $button = $(this),
6
+ course_id = $button.attr('data-id'),
7
+ nonce = $button.attr('data-nonce'),
8
+ text = $button.data('text');
9
+ if ($button.hasClass('ajaxload_wishlist')) {
10
+ return;
11
+ }
12
+ $button.addClass('ajaxload_wishlist').prop('disabled', true);
13
+ if (text) {
14
+ $button.html(text);
15
+ }
16
+ $.ajax({
17
+ url : window.location.href,
18
+ type : 'post',
19
+ dataType: 'html',
20
+ data : {
21
+ //action : 'learn_press_toggle_course_wishlist',
22
+ 'lp-ajax': 'toggle_course_wishlist',
23
+ course_id: course_id,
24
+ nonce : nonce
25
+ },
26
+ success : function (response) {
27
+ response = LP.parseJSON(response);
28
+ var $b = $('.learn-press-course-wishlist-button-' + response.course_id),
29
+ $p = $b.closest('[data-context="tab-wishlist"]');
30
+ if ($p.length) {
31
+ $p.fadeOut(function () {
32
+ var $siblings = $p.siblings(),
33
+ $parent = $p.closest('#learn-press-profile-tab-course-wishlist');
34
+ $p.remove();
35
+ if ($siblings.length == 0) {
36
+ $parent.removeClass('has-courses');
37
+ }
38
+ });
39
+ } else {
40
+ $b.removeClass('ajaxload_wishlist')
41
+ .toggleClass('on', response.state == 'on')
42
+ .prop('title', response.title)
43
+ .html(response.button_text);
44
+ }
45
+ $b.prop('disabled', false)
46
+ }
47
+ });
48
+ };
49
+ $(document).on('click', '.course-wishlist', function () {
50
+ timer && clearTimeout(timer);
51
+ timer = setTimeout($.proxy(submit, this), 50);
52
+ });
53
+ })(jQuery);
inc/functions.php CHANGED
@@ -1,226 +1,246 @@
1
- <?php
2
- /**
3
- * LearnPress Wishlist Functions
4
- *
5
- * Define common functions for both front-end and back-end
6
- *
7
- * @author ThimPress
8
- * @package LearnPress/Wishlist/Functions
9
- * @version 3.0.0
10
- */
11
-
12
- // Prevent loading this file directly
13
- defined( 'ABSPATH' ) || exit;
14
-
15
- if ( ! function_exists( 'learn_press_course_wishlist_template' ) ) {
16
- /**
17
- * Get wishlist template.
18
- *
19
- * @param $name
20
- * @param null $args
21
- */
22
- function learn_press_course_wishlist_template( $name, $args = null ) {
23
- LP_Addon_Wishlist::instance()->get_template($name, $args);
24
- //learn_press_get_template( $name, $args, learn_press_template_path() . '/addons/wishlist/', LP_ADDON_WISHLIST_TEMPLATE );
25
- }
26
- }
27
-
28
- if ( ! function_exists( 'learn_press_wishlist_get_template' ) ) {
29
- /**
30
- * Get template.
31
- *
32
- * @param $name
33
- * @param null $args
34
- */
35
- function learn_press_wishlist_get_template( $name, $args = null ) {
36
- learn_press_get_template( $name, $args, learn_press_template_path() . '/addons/wishlist/', LP_ADDON_WISHLIST_PATH . '/templates/' );
37
- }
38
- }
39
-
40
- add_action( 'learn_press_wishlist_loop_item_title', 'learn_press_wishlist_loop_item_title', 5 );
41
-
42
- if ( ! function_exists( 'learn_press_wishlist_loop_item_title' ) ) {
43
- /**
44
- * Loop item title.
45
- */
46
- function learn_press_wishlist_loop_item_title() {
47
- learn_press_wishlist_get_template( 'loop/title.php' );
48
- }
49
- }
50
-
51
- if ( ! function_exists( 'learn_press_user_wishlist_has_course' ) ) {
52
- /**
53
- * Check user has course in wishlist.
54
- *
55
- * @param null $course_id
56
- * @param null $user_id
57
- *
58
- * @return bool
59
- */
60
- function learn_press_user_wishlist_has_course( $course_id = null, $user_id = null ) {
61
- if ( ! $course_id ) {
62
- $course_id = get_the_ID();
63
- }
64
-
65
- if ( ! $user_id ) {
66
- $user_id = get_current_user_id();
67
- }
68
-
69
- $wish_list = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
70
-
71
- return in_array( $course_id, $wish_list );
72
- }
73
- }
74
-
75
- add_action( 'learn_press_after_take_course', 'learn_press_update_wish_list', 10, 2 );
76
- if ( ! function_exists( 'learn_press_update_wish_list' ) ) {
77
- /**
78
- * Update user's wishlist.
79
- *
80
- * @param $user_id
81
- * @param $course_id
82
- */
83
- function learn_press_update_wish_list( $user_id, $course_id ) {
84
- if ( ! $user_id || ! $course_id ) {
85
- return;
86
- }
87
- $wish_list = get_user_meta( $user_id, '_lpr_wish_list', true );
88
- if ( ! $wish_list ) {
89
- $wish_list = array();
90
- }
91
- $key = array_search( $course_id, $wish_list );
92
- if ( $key !== false ) {
93
- unset( $wish_list[ $key ] );
94
- }
95
- update_user_meta( $user_id, '_lpr_wish_list', $wish_list );
96
- }
97
- }
98
-
99
- add_filter( 'learn_press_profile_tabs', 'learn_press_wishlist_tab', 10, 2 );
100
- if ( ! function_exists( 'learn_press_wishlist_tab' ) ) {
101
- /**
102
- * Add wishlist tab into profile page.
103
- *
104
- * @param $tabs
105
- * @param $user
106
- *
107
- * @return mixed
108
- */
109
- function learn_press_wishlist_tab( $tabs, $user ) {
110
- $content = '';
111
-
112
- $tabs[35] = array(
113
- 'tab_id' => 'user_wishlist',
114
- 'tab_name' => __( 'Wishlist', 'learnpress_wishlist' ),
115
- 'tab_content' => apply_filters( 'learn_press_user_wishlist_tab_content', $content, $user )
116
- );
117
- // Private customize
118
- if ( $user->ID != get_current_user_id() ) {
119
- unset ( $tabs[35] );
120
- }
121
-
122
- return $tabs;
123
- }
124
- }
125
-
126
- add_filter( 'learn_press_user_wishlist_tab_content', 'learn_press_user_wishlist_tab_content', 10, 2 );
127
- if ( ! function_exists( 'learn_press_user_wishlist_tab_content' ) ) {
128
- /**
129
- * Setup wishlist tab content.
130
- *
131
- * @param $content
132
- * @param $user
133
- *
134
- * @return string
135
- */
136
- function learn_press_user_wishlist_tab_content( $content, $user ) {
137
- ob_start();
138
- learn_press_course_wishlist_template( 'user-wishlist.php', array( 'user' => $user ) );
139
- $content .= ob_get_clean();
140
-
141
- return $content;
142
- }
143
- }
144
-
145
- if ( ! function_exists( 'learn_press_buddypress_is_active' ) ) {
146
- /**
147
- * Check BuddyPress active.
148
- *
149
- * @return bool
150
- */
151
- function learn_press_buddypress_is_active() {
152
- if ( ! function_exists( 'is_plugin_active' ) ) {
153
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
154
- }
155
-
156
- return class_exists( 'BuddyPress' ) && is_plugin_active( 'buddypress/bp-loader.php' );
157
- }
158
- }
159
-
160
- if ( learn_press_buddypress_is_active() ) {
161
-
162
- /*
163
- * Set up sub admin bar wishlist.
164
- */
165
- add_filter( 'learn_press_bp_courses_bar', 'learn_press_bp_courses_bar_wishlist', 20 );
166
- function learn_press_bp_courses_bar_wishlist( $wp_admin_nav ) {
167
-
168
- $courses_slug = apply_filters( 'learn_press_bp_courses_slug', '' );
169
- $courses_link = learn_press_get_current_bp_link();
170
-
171
- $wp_admin_nav[] = array(
172
- 'parent' => 'my-account-' . $courses_slug,
173
- 'id' => 'my-account-' . $courses_slug . '-wishlist',
174
- 'title' => __( 'Wishlist', 'learnpress_wishlist' ),
175
- 'href' => trailingslashit( $courses_link . 'wishlist' )
176
- );
177
-
178
- return $wp_admin_nav;
179
- }
180
-
181
- /*
182
- * Setup sub navigation wishlist.
183
- */
184
- if ( bp_is_my_profile() || current_user_can( 'manage_options' ) ) {
185
- add_filter( 'learn_press_bp_courses_sub_navs', 'learn_press_bp_courses_nav_wishlist' );
186
-
187
- function learn_press_bp_courses_nav_wishlist( $sub_navs ) {
188
- $nav_wishlist = array(
189
- 'name' => __( 'Wishlist', 'learnpress_wishlist' ),
190
- 'slug' => 'wishlist',
191
- 'show_for_displayed_user' => false,
192
- 'position' => 10,
193
- 'screen_function' => 'learn_press_bp_courses_wishlist',
194
- 'parent_url' => learn_press_get_current_bp_link(),
195
- 'parent_slug' => apply_filters( 'learn_press_bp_courses_slug', '' ),
196
- );
197
- array_push( $sub_navs, $nav_wishlist );
198
-
199
- return $sub_navs;
200
- }
201
-
202
- function learn_press_bp_courses_wishlist() {
203
- add_action( 'bp_template_title', 'learn_press_bp_courses_wishlist_title' );
204
- add_action( 'bp_template_content', 'learn_press_bp_courses_wishlist_content' );
205
- bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
206
- }
207
-
208
- /*
209
- * Setup title of navigation all.
210
- */
211
- function learn_press_bp_courses_wishlist_title() {
212
- echo __( 'Your wishlist', 'learnpress_wishlist' );
213
- }
214
-
215
- /*
216
- * Setup content of navigation all.
217
- */
218
- function learn_press_bp_courses_wishlist_content() {
219
- global $bp;
220
- echo apply_filters( 'learn_press_user_wishlist_tab_content', '', get_user_by( 'id', $bp->displayed_user->id ) );
221
- }
222
- }
223
- }
224
-
225
-
226
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * LearnPress Wishlist Functions
4
+ *
5
+ * Define common functions for both front-end and back-end
6
+ *
7
+ * @author ThimPress
8
+ * @package LearnPress/Wishlist/Functions
9
+ * @version 3.0.0
10
+ */
11
+
12
+ // Prevent loading this file directly
13
+ defined( 'ABSPATH' ) || exit;
14
+
15
+ if ( ! function_exists( 'learn_press_course_wishlist_template' ) ) {
16
+ /**
17
+ * Get wishlist template.
18
+ *
19
+ * @param $name
20
+ * @param null $args
21
+ */
22
+ function learn_press_course_wishlist_template( $name, $args = null ) {
23
+ LP_Addon_Wishlist::instance()->get_template( $name, $args );
24
+ //learn_press_get_template( $name, $args, learn_press_template_path() . '/addons/wishlist/', LP_ADDON_WISHLIST_TEMPLATE );
25
+ }
26
+ }
27
+
28
+ if ( ! function_exists( 'learn_press_wishlist_get_template' ) ) {
29
+ /**
30
+ * Get template.
31
+ *
32
+ * @param $name
33
+ * @param null $args
34
+ */
35
+ function learn_press_wishlist_get_template( $name, $args = null ) {
36
+
37
+ learn_press_get_template( $name, $args, learn_press_template_path() . '/addons/wishlist/', LP_ADDON_WISHLIST_PATH . '/templates/' );
38
+
39
+ }
40
+ }
41
+
42
+ add_action( 'learn_press_wishlist_loop_item_title', 'learn_press_wishlist_loop_item_title', 5 );
43
+
44
+ if ( ! function_exists( 'learn_press_wishlist_loop_item_title' ) ) {
45
+ /**
46
+ * Loop item title.
47
+ */
48
+ function learn_press_wishlist_loop_item_title() {
49
+ learn_press_wishlist_get_template( 'loop/title.php' );
50
+ }
51
+ }
52
+
53
+ if ( ! function_exists( 'learn_press_user_wishlist_has_course' ) ) {
54
+ /**
55
+ * Check user has course in wishlist.
56
+ *
57
+ * @param null $course_id
58
+ * @param null $user_id
59
+ *
60
+ * @return bool
61
+ */
62
+ function learn_press_user_wishlist_has_course( $course_id = null, $user_id = null ) {
63
+ if ( ! $course_id ) {
64
+ $course_id = get_the_ID();
65
+ }
66
+
67
+ if ( ! $user_id ) {
68
+ $user_id = get_current_user_id();
69
+ }
70
+
71
+ $wish_list = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
72
+
73
+ return in_array( $course_id, $wish_list );
74
+ }
75
+ }
76
+
77
+ add_action( 'learn_press_after_take_course', 'learn_press_update_wish_list', 10, 2 );
78
+ if ( ! function_exists( 'learn_press_update_wish_list' ) ) {
79
+ /**
80
+ * Update user's wishlist.
81
+ *
82
+ * @param $user_id
83
+ * @param $course_id
84
+ */
85
+ function learn_press_update_wish_list( $user_id, $course_id ) {
86
+ if ( ! $user_id || ! $course_id ) {
87
+ return;
88
+ }
89
+ $wish_list = get_user_meta( $user_id, '_lpr_wish_list', true );
90
+ if ( ! $wish_list ) {
91
+ $wish_list = array();
92
+ }
93
+ $key = array_search( $course_id, $wish_list );
94
+ if ( $key !== false ) {
95
+ unset( $wish_list[ $key ] );
96
+ }
97
+ update_user_meta( $user_id, '_lpr_wish_list', $wish_list );
98
+ }
99
+ }
100
+
101
+ add_filter( 'learn_press_profile_tabs', 'learn_press_wishlist_tab', 10, 2 );
102
+ if ( ! function_exists( 'learn_press_wishlist_tab' ) ) {
103
+ /**
104
+ * Add wishlist tab into profile page.
105
+ *
106
+ * @param $tabs
107
+ * @param $user
108
+ *
109
+ * @return mixed
110
+ */
111
+ function learn_press_wishlist_tab( $tabs, $user ) {
112
+ $content = '';
113
+
114
+ $tabs[35] = array(
115
+ 'tab_id' => 'user_wishlist',
116
+ 'tab_name' => __( 'Wishlist', 'learnpress_wishlist' ),
117
+ 'tab_content' => apply_filters( 'learn_press_user_wishlist_tab_content', $content, $user )
118
+ );
119
+ // Private customize
120
+ if ( $user->ID != get_current_user_id() ) {
121
+ unset ( $tabs[35] );
122
+ }
123
+
124
+ return $tabs;
125
+ }
126
+ }
127
+
128
+ add_filter( 'learn_press_user_wishlist_tab_content', 'learn_press_user_wishlist_tab_content', 10, 2 );
129
+ if ( ! function_exists( 'learn_press_user_wishlist_tab_content' ) ) {
130
+ /**
131
+ * Setup wishlist tab content.
132
+ *
133
+ * @param $content
134
+ * @param $user
135
+ *
136
+ * @return string
137
+ */
138
+ function learn_press_user_wishlist_tab_content( $content, $user ) {
139
+ ob_start();
140
+ learn_press_course_wishlist_template( 'user-wishlist.php', array( 'user' => $user ) );
141
+ $content .= ob_get_clean();
142
+
143
+ return $content;
144
+ }
145
+ }
146
+
147
+ if ( ! function_exists( 'learn_press_buddypress_is_active' ) ) {
148
+ /**
149
+ * Check BuddyPress active.
150
+ *
151
+ * @return bool
152
+ */
153
+ function learn_press_buddypress_is_active() {
154
+ if ( ! function_exists( 'is_plugin_active' ) ) {
155
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
156
+ }
157
+
158
+ return class_exists( 'BuddyPress' ) && is_plugin_active( 'buddypress/bp-loader.php' );
159
+ }
160
+ }
161
+
162
+ if ( learn_press_buddypress_is_active() ) {
163
+
164
+ /*
165
+ * Set up sub admin bar wishlist.
166
+ */
167
+ add_filter( 'learn_press_bp_courses_bar', 'learn_press_bp_courses_bar_wishlist', 20 );
168
+ function learn_press_bp_courses_bar_wishlist( $wp_admin_nav ) {
169
+
170
+ $courses_slug = apply_filters( 'learn_press_bp_courses_slug', '' );
171
+ $courses_link = learn_press_get_current_bp_link();
172
+
173
+ $wp_admin_nav[] = array(
174
+ 'parent' => 'my-account-' . $courses_slug,
175
+ 'id' => 'my-account-' . $courses_slug . '-wishlist',
176
+ 'title' => __( 'Wishlist', 'learnpress_wishlist' ),
177
+ 'href' => trailingslashit( $courses_link . 'wishlist' )
178
+ );
179
+
180
+ return $wp_admin_nav;
181
+ }
182
+
183
+ /*
184
+ * Setup sub navigation wishlist.
185
+ */
186
+ if ( bp_is_my_profile() || current_user_can( 'manage_options' ) ) {
187
+ add_filter( 'learn_press_bp_courses_sub_navs', 'learn_press_bp_courses_nav_wishlist' );
188
+
189
+ function learn_press_bp_courses_nav_wishlist( $sub_navs ) {
190
+ $nav_wishlist = array(
191
+ 'name' => __( 'Wishlist', 'learnpress_wishlist' ),
192
+ 'slug' => 'wishlist',
193
+ 'show_for_displayed_user' => false,
194
+ 'position' => 10,
195
+ 'screen_function' => 'learn_press_bp_courses_wishlist',
196
+ 'parent_url' => learn_press_get_current_bp_link(),
197
+ 'parent_slug' => apply_filters( 'learn_press_bp_courses_slug', '' ),
198
+ );
199
+ array_push( $sub_navs, $nav_wishlist );
200
+
201
+ return $sub_navs;
202
+ }
203
+
204
+ function learn_press_bp_courses_wishlist() {
205
+ add_action( 'bp_template_title', 'learn_press_bp_courses_wishlist_title' );
206
+ add_action( 'bp_template_content', 'learn_press_bp_courses_wishlist_content' );
207
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
208
+ }
209
+
210
+ /*
211
+ * Setup title of navigation all.
212
+ */
213
+ function learn_press_bp_courses_wishlist_title() {
214
+ echo __( 'Your wishlist', 'learnpress_wishlist' );
215
+ }
216
+
217
+ /*
218
+ * Setup content of navigation all.
219
+ */
220
+ function learn_press_bp_courses_wishlist_content() {
221
+ global $bp;
222
+ echo apply_filters( 'learn_press_user_wishlist_tab_content', '', get_user_by( 'id', $bp->displayed_user->id ) );
223
+ }
224
+ }
225
+ }
226
+
227
+ function learn_press_course_wishlist_loop_stars() {
228
+ if ( LP_COURSE_CPT !== get_post_type() ) {
229
+ return;
230
+ }
231
+
232
+ $filled = learn_press_user_wishlist_has_course();
233
+ ?>
234
+ <div class="course-wishlist">
235
+ <span class="course-wishlist__star<?php echo $filled ? ' filled' : ''; ?>"></span>
236
+ <a class="course-wishlist__btn"><?php esc_html_e( 'Add to Wishlist', 'learnpress-wishlist' ); ?></a>
237
+ </div>
238
+ <?php
239
+ }
240
+
241
+ //add_action( 'learn-press/before-courses-loop-item', 'learn_press_course_wishlist_loop_stars', 51 );
242
+ //
243
+ //
244
+ //add_action( 'learn-press/before-course-summary-sidebar', function () {
245
+ // LP_Addon_Wishlist::instance()->wishlist_button();
246
+ //}, 50 );
inc/load.php CHANGED
@@ -1,248 +1,272 @@
1
- <?php
2
- /**
3
- * Plugin load class.
4
- *
5
- * @author ThimPress
6
- * @package LearnPress/Wishlist/Classes
7
- * @version 3.0.0
8
- */
9
-
10
- // Prevent loading this file directly
11
- defined( 'ABSPATH' ) || exit;
12
-
13
- if ( ! class_exists( 'LP_Addon_Wishlist' ) ) {
14
- /**
15
- * Class LP_Addon_Wishlist.
16
- */
17
- class LP_Addon_Wishlist extends LP_Addon {
18
-
19
- /**
20
- * @var string
21
- */
22
- protected $_tab_slug = '';
23
-
24
- /**
25
- * @var string
26
- */
27
- public $version = LP_ADDON_WISHLIST_VER;
28
-
29
- /**
30
- * @var string
31
- */
32
- public $require_version = LP_ADDON_WISHLIST_REQUIRE_VER;
33
-
34
- /**
35
- * LP_Addon_Wishlist constructor.
36
- */
37
- public function __construct() {
38
- parent::__construct();
39
- add_filter( 'learn-press/profile-tabs', array( $this, 'wishlist_tab' ), 100, 1 );
40
- $this->_tab_slug = sanitize_title( __( 'wishlist', 'learnpress-wishlist' ) );
41
- }
42
-
43
- /**
44
- * Defined constants.
45
- */
46
- protected function _define_constants() {
47
- define( 'LP_ADDON_WISHLIST_PATH', dirname( LP_ADDON_WISHLIST_FILE ) );
48
- define( 'LP_ADDON_WISHLIST_INC', LP_ADDON_WISHLIST_PATH . '/inc/' );
49
- define( 'LP_ADDON_WISHLIST_TEMPLATE', LP_ADDON_WISHLIST_PATH . '/templates/' );
50
- }
51
-
52
- /**
53
- * Includes files.
54
- */
55
- protected function _includes() {
56
- include_once LP_ADDON_WISHLIST_INC . 'functions.php';
57
- }
58
-
59
- /**
60
- * Init hooks.
61
- */
62
- protected function _init_hooks() {
63
- add_action( 'learn-press/after-course-buttons', array( $this, 'wishlist_button' ), 100 );
64
- add_filter( 'learn_press_profile_tab_endpoints', array( $this, 'profile_tab_endpoints' ) );
65
- LP_Request_Handler::register_ajax( 'toggle_course_wishlist', array( $this, 'toggle_course_wishlist' ) );
66
-
67
- $this->rewrite_endpoint();
68
- }
69
-
70
-
71
- /**
72
- * Wishlist scripts.
73
- */
74
- protected function _enqueue_assets() {
75
- wp_enqueue_style( 'lp-course-wishlist-style', untrailingslashit( plugins_url( '/', LP_ADDON_WISHLIST_FILE ) ) . '/assets/css/wishlist.css' );
76
- wp_enqueue_script( 'lp-course-wishlist-script', untrailingslashit( plugins_url( '/', LP_ADDON_WISHLIST_FILE ) ) . '/assets/js/wishlist.js', array( 'jquery' ) );
77
- }
78
-
79
- /**
80
- * Rewrite endpoint.
81
- */
82
- public function rewrite_endpoint() {
83
- $endpoint = preg_replace( '!_!', '-', $this->get_tab_slug() );
84
- LP()->query_vars[ $endpoint ] = $endpoint;
85
- add_rewrite_endpoint( $endpoint, EP_ROOT | EP_PAGES );
86
- }
87
-
88
- public function profile_tab_endpoints( $endpoints ) {
89
- $endpoints[] = $this->get_tab_slug();
90
-
91
- return $endpoints;
92
- }
93
-
94
- public function toggle_course_wishlist() {
95
- sleep( 1 );
96
- $nonce = ! empty( $_POST['nonce'] ) ? $_POST['nonce'] : null;
97
- if ( ! wp_verify_nonce( $nonce, 'course-toggle-wishlist' ) ) {
98
- die ( __( 'You have not permission to do this action', 'learnpress-wishlist' ) );
99
- }
100
-
101
- $course_id = ! empty( $_POST['course_id'] ) ? absint( $_POST['course_id'] ) : 0;
102
- $user_id = get_current_user_id();
103
-
104
- if ( ( get_post_type( $course_id ) != 'lp_course' ) || ! $user_id ) {
105
- return;
106
- }
107
- $state = ! empty( $_POST['state'] ) ? $_POST['state'] : false;
108
- $wishlist = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
109
- if ( $state === false ) {
110
- $state = in_array( $course_id, $wishlist ) ? 'off' : 'on';
111
- }
112
- $pos = array_search( $course_id, $wishlist );
113
- if ( $state == 'on' ) {
114
- if ( $pos === false ) {
115
- $wishlist[] = $course_id;
116
- }
117
- } else {
118
- if ( $pos !== false ) {
119
- unset( $wishlist[ $pos ] );
120
- }
121
- }
122
- if ( sizeof( $wishlist ) ) {
123
- update_user_meta( $user_id, '_lpr_wish_list', $wishlist );
124
- } else {
125
- delete_user_meta( $user_id, '_lpr_wish_list' );
126
- }
127
- learn_press_send_json(
128
- array(
129
- 'state' => $state,
130
- 'course_id' => $course_id,
131
- 'user_id' => $user_id,
132
- 'title' => $this->_get_state_title( $state ),
133
- 'message' => '',
134
- 'button_text' => $state != 'on' ? __( 'Add to Wishlist', 'learnpress-wishlist' ) : __( 'Remove from Wishlist', 'learnpress-wishlist' )
135
- )
136
- );
137
- }
138
-
139
- /**
140
- * @param string $state
141
- *
142
- * @return mixed
143
- */
144
- private function _get_state_title( $state = 'on' ) {
145
- return $state == 'on' ? __( 'Remove this course from your wishlist', 'learnpress-wishlist' ) : __( 'Add this course to your wishlist', 'learnpress-wishlist' );
146
- }
147
-
148
- /**
149
- * @param string $state
150
- *
151
- * @return mixed
152
- */
153
- private function _get_state_message( $state = 'on' ) {
154
- return $state == 'on' ? __( 'This course added to your wishlist', 'learnpress-wishlist' ) : __( 'This course removed from your wishlist', 'learnpress-wishlist' );
155
- }
156
-
157
- /*
158
- * Show wishlist button
159
- */
160
- public function wishlist_button( $course_id = null ) {
161
- $user_id = get_current_user_id();
162
- if ( ! $course_id ) {
163
- $course_id = get_the_ID();
164
- }
165
-
166
- // If user or course are invalid then return.
167
- if ( ! $user_id || ! $course_id ) {
168
- return;
169
- }
170
-
171
- $classes = array( 'course-wishlist' /* dashicons dashicons-heart heartbeat'*/ );
172
- $state = learn_press_user_wishlist_has_course( $course_id, $user_id ) ? 'on' : 'off';
173
-
174
- if ( $state == 'on' ) {
175
- $classes[] = 'on';
176
- }
177
- $classes = apply_filters( 'learn_press_course_wishlist_button_classes', $classes, $course_id );
178
- $title = $this->_get_state_title( $state );
179
-
180
- // fetch template
181
- learn_press_course_wishlist_template( 'button.php', compact( 'user_id', 'course_id', 'classes', 'title', 'state' ) );
182
- }
183
-
184
- public function get_tab_slug() {
185
- return apply_filters( 'learn_press_course_wishlist_tab_slug', $this->_tab_slug, $this );
186
- }
187
-
188
- /**
189
- * Add Wishlist tab to user profile.
190
- *
191
- * @param $tabs
192
- *
193
- * @return mixed
194
- */
195
- public function wishlist_tab( $tabs ) {
196
- $tabs[ $this->get_tab_slug() ] = array(
197
- 'title' => __( 'Wishlist', 'learnpress-wishlist' ),
198
- 'slug' => $this->get_tab_slug(),
199
- 'callback' => array( $this, 'wishlist_tab_content' ),
200
- 'priority' => 20
201
- );
202
-
203
- return $tabs;
204
- }
205
-
206
- /**
207
- * Display content of tab Wishlist.
208
- *
209
- * @param $tab
210
- * @param $tabs
211
- * @param $profile
212
- */
213
- public function wishlist_tab_content( $tab, $tabs, $profile ) {
214
- $viewing_user = $profile->get_user();
215
- learn_press_course_wishlist_template(
216
- 'user-wishlist.php',
217
- array(
218
- 'wishlist' => $this->get_wishlist_courses( $viewing_user->get_id() )
219
- )
220
- );
221
- }
222
-
223
- public function get_wishlist_courses( $user_id ) {
224
- $pid = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
225
-
226
- $args = array(
227
- 'post_type' => 'lp_course',
228
- 'post__in' => $pid,
229
- 'post_status' => 'publish',
230
- 'ignore_sticky_posts' => true,
231
- 'posts_per_page' => - 1
232
- );
233
- $query = new WP_Query( $args );
234
- $wishlist = array();
235
- global $post;
236
- if ( $query->have_posts() ) :
237
- while ( $query->have_posts() ) : $query->the_post();
238
- $wishlist[ $post->ID ] = $post;
239
- endwhile;
240
- endif;
241
- wp_reset_postdata();
242
-
243
- return $wishlist;
244
- }
245
- }
246
- }
247
-
248
- add_action( 'plugins_loaded', array( 'LP_Addon_Wishlist', 'instance' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin load class.
4
+ *
5
+ * @author ThimPress
6
+ * @package LearnPress/Wishlist/Classes
7
+ * @version 4.0.0
8
+ */
9
+
10
+ // Prevent loading this file directly
11
+ defined( 'ABSPATH' ) || exit;
12
+ if ( ! class_exists( 'LP_Addon_Wishlist' ) ) {
13
+ /**
14
+ * Class LP_Addon_Wishlist.
15
+ */
16
+ class LP_Addon_Wishlist extends LP_Addon {
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_tab_slug = '';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ public $version = LP_ADDON_WISHLIST_VER;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ public $require_version = LP_ADDON_WISHLIST_REQUIRE_VER;
32
+
33
+ /**
34
+ * Path file addon
35
+ *
36
+ * @var string
37
+ */
38
+ public $plugin_file = LP_ADDON_WISHLIST_FILE;
39
+
40
+ /**
41
+ * LP_Addon_Wishlist constructor.
42
+ */
43
+ public function __construct() {
44
+ parent::__construct();
45
+ add_filter( 'learn-press/profile-tabs', array( $this, 'wishlist_tab' ), 100, 1 );
46
+ $this->_tab_slug = sanitize_title( __( 'wishlist', 'learnpress-wishlist' ) );
47
+ }
48
+
49
+ /**
50
+ * Defined constants.
51
+ */
52
+ protected function _define_constants() {
53
+ define( 'LP_ADDON_WISHLIST_PATH', dirname( LP_ADDON_WISHLIST_FILE ) );
54
+ define( 'LP_ADDON_WISHLIST_INC', LP_ADDON_WISHLIST_PATH . '/inc/' );
55
+ define( 'LP_ADDON_WISHLIST_TEMPLATE', LP_ADDON_WISHLIST_PATH . '/templates/' );
56
+ }
57
+
58
+ /**
59
+ * Includes files.
60
+ */
61
+ protected function _includes() {
62
+ include_once LP_ADDON_WISHLIST_INC . 'functions.php';
63
+
64
+ // Rest API
65
+ include_once LP_ADDON_WISHLIST_INC . 'rest-api/class-lp-rest-wishlist-v1-controller.php';
66
+ include_once LP_ADDON_WISHLIST_INC . 'rest-api/class-rest-api.php';
67
+ }
68
+
69
+ /**
70
+ * Init hooks.
71
+ */
72
+ protected function _init_hooks() {
73
+ add_action( 'learn-press/after-course-buttons', array( $this, 'wishlist_button' ), 100 );
74
+ add_filter( 'learn_press_profile_tab_endpoints', array( $this, 'profile_tab_endpoints' ) );
75
+ LP_Request_Handler::register_ajax( 'toggle_course_wishlist', array( $this, 'toggle_course_wishlist' ) );
76
+
77
+ $this->rewrite_endpoint();
78
+ }
79
+
80
+
81
+ /**
82
+ * Wishlist scripts.
83
+ */
84
+ protected function _enqueue_assets() {
85
+ wp_enqueue_style( 'lp-course-wishlist-style', untrailingslashit( plugins_url( '/', LP_ADDON_WISHLIST_FILE ) ) . '/assets/css/wishlist.css' );
86
+ wp_enqueue_script( 'lp-course-wishlist-script', untrailingslashit( plugins_url( '/', LP_ADDON_WISHLIST_FILE ) ) . '/assets/js/wishlist.js', array( 'jquery', 'lp-utils' ) );
87
+ }
88
+
89
+ /**
90
+ * Rewrite endpoint.
91
+ */
92
+ public function rewrite_endpoint() {
93
+ $endpoint = preg_replace( '!_!', '-', $this->get_tab_slug() );
94
+ LP()->query_vars[ $endpoint ] = $endpoint;
95
+ add_rewrite_endpoint( $endpoint, EP_ROOT | EP_PAGES );
96
+ }
97
+
98
+ public function profile_tab_endpoints( $endpoints ) {
99
+ $endpoints[] = $this->get_tab_slug();
100
+
101
+ return $endpoints;
102
+ }
103
+
104
+ public function toggle_course_wishlist() {
105
+ sleep( 1 );
106
+ $nonce = ! empty( $_POST['nonce'] ) ? $_POST['nonce'] : null;
107
+ if ( ! wp_verify_nonce( $nonce, 'course-toggle-wishlist' ) ) {
108
+ die( __( 'You have not permission to do this action', 'learnpress-wishlist' ) );
109
+ }
110
+
111
+ $course_id = ! empty( $_POST['course_id'] ) ? absint( $_POST['course_id'] ) : 0;
112
+ $user_id = get_current_user_id();
113
+
114
+ if ( ( get_post_type( $course_id ) != 'lp_course' ) || ! $user_id ) {
115
+ return;
116
+ }
117
+ $state = ! empty( $_POST['state'] ) ? $_POST['state'] : false;
118
+ $wishlist = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
119
+ if ( $state === false ) {
120
+ $state = in_array( $course_id, $wishlist ) ? 'off' : 'on';
121
+ }
122
+ $pos = array_search( $course_id, $wishlist );
123
+ if ( $state == 'on' ) {
124
+ if ( $pos === false ) {
125
+ $wishlist[] = $course_id;
126
+ }
127
+ } else {
128
+ if ( $pos !== false ) {
129
+ unset( $wishlist[ $pos ] );
130
+ }
131
+ }
132
+ if ( sizeof( $wishlist ) ) {
133
+ update_user_meta( $user_id, '_lpr_wish_list', $wishlist );
134
+ } else {
135
+ delete_user_meta( $user_id, '_lpr_wish_list' );
136
+ }
137
+ learn_press_send_json(
138
+ array(
139
+ 'state' => $state,
140
+ 'course_id' => $course_id,
141
+ 'user_id' => $user_id,
142
+ 'title' => $this->_get_state_title( $state ),
143
+ 'message' => '',
144
+ 'button_text' => $state != 'on' ? __(
145
+ 'Add to Wishlist',
146
+ 'learnpress-wishlist'
147
+ ) : __( 'Remove from Wishlist', 'learnpress-wishlist' ),
148
+ )
149
+ );
150
+ }
151
+
152
+ /**
153
+ * @param string $state
154
+ *
155
+ * @return mixed
156
+ */
157
+ private function _get_state_title( $state = 'on' ) {
158
+ return $state == 'on' ? __(
159
+ 'Remove this course from your wishlist',
160
+ 'learnpress-wishlist'
161
+ ) : __( 'Add this course to your wishlist', 'learnpress-wishlist' );
162
+ }
163
+
164
+ /**
165
+ * @param string $state
166
+ *
167
+ * @return mixed
168
+ */
169
+ private function _get_state_message( $state = 'on' ) {
170
+ return $state == 'on' ? __(
171
+ 'This course added to your wishlist',
172
+ 'learnpress-wishlist'
173
+ ) : __( 'This course removed from your wishlist', 'learnpress-wishlist' );
174
+ }
175
+
176
+ /*
177
+ * Show wishlist button
178
+ */
179
+ public function wishlist_button( $course_id = null ) {
180
+
181
+ $user_id = get_current_user_id();
182
+ if ( ! $course_id ) {
183
+ $course_id = get_the_ID();
184
+ }
185
+
186
+ // If user or course are invalid then return.
187
+ if ( ! $user_id || ! $course_id ) {
188
+ return;
189
+ }
190
+
191
+ $classes = array( 'course-wishlist' /* dashicons dashicons-heart heartbeat'*/ );
192
+ $state = learn_press_user_wishlist_has_course( $course_id, $user_id ) ? 'on' : 'off';
193
+
194
+ if ( $state == 'on' ) {
195
+ $classes[] = 'on';
196
+ }
197
+ $classes = apply_filters( 'learn_press_course_wishlist_button_classes', $classes, $course_id );
198
+ $title = $this->_get_state_title( $state );
199
+
200
+ // fetch template
201
+ learn_press_course_wishlist_template(
202
+ 'button.php',
203
+ compact( 'user_id', 'course_id', 'classes', 'title', 'state' )
204
+ );
205
+ }
206
+
207
+ public function get_tab_slug() {
208
+ return apply_filters( 'learn_press_course_wishlist_tab_slug', $this->_tab_slug, $this );
209
+ }
210
+
211
+ /**
212
+ * Add Wishlist tab to user profile.
213
+ *
214
+ * @param $tabs
215
+ *
216
+ * @return mixed
217
+ */
218
+ public function wishlist_tab( $tabs ) {
219
+ $tabs[ $this->get_tab_slug() ] = array(
220
+ 'title' => __( 'Wishlist', 'learnpress-wishlist' ),
221
+ 'slug' => $this->get_tab_slug(),
222
+ 'callback' => array( $this, 'wishlist_tab_content' ),
223
+ 'priority' => 20,
224
+ );
225
+
226
+ return $tabs;
227
+ }
228
+
229
+ /**
230
+ * Display content of tab Wishlist.
231
+ *
232
+ * @param $tab
233
+ * @param $tabs
234
+ * @param $profile
235
+ */
236
+ public function wishlist_tab_content( $tab, $tabs, $profile ) {
237
+ $viewing_user = $profile->get_user();
238
+ learn_press_course_wishlist_template(
239
+ 'user-wishlist.php',
240
+ array(
241
+ 'wishlist' => $this->get_wishlist_courses( $viewing_user->get_id() ),
242
+ )
243
+ );
244
+ }
245
+
246
+ public function get_wishlist_courses( $user_id ) {
247
+ $pid = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
248
+
249
+ $args = array(
250
+ 'post_type' => 'lp_course',
251
+ 'post__in' => $pid,
252
+ 'post_status' => 'publish',
253
+ 'ignore_sticky_posts' => true,
254
+ 'posts_per_page' => - 1,
255
+ );
256
+ $query = new WP_Query( $args );
257
+ $wishlist = array();
258
+ global $post;
259
+ if ( $query->have_posts() ) :
260
+ while ( $query->have_posts() ) :
261
+ $query->the_post();
262
+ $wishlist[ $post->ID ] = $post;
263
+ endwhile;
264
+ endif;
265
+ wp_reset_postdata();
266
+
267
+ return $wishlist;
268
+ }
269
+ }
270
+ }
271
+
272
+ add_action( 'plugins_loaded', array( 'LP_Addon_Wishlist', 'instance' ) );
inc/rest-api/class-lp-rest-wishlist-v1-controller.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * REST API for the Wishlist Add-on.
4
+ *
5
+ * @package LearnPress/JWT/RESTAPI
6
+ * @author Nhamdv <daonham95@gmail.com>
7
+ */
8
+ if ( class_exists( 'LP_REST_Jwt_Posts_Controller' ) ) {
9
+ class LP_Jwt_Wishlist_V1_Controller extends LP_REST_Jwt_Controller {
10
+ protected $namespace = 'learnpress/v1';
11
+
12
+ protected $rest_base = 'wishlist';
13
+
14
+ public function register_routes() {
15
+ register_rest_route(
16
+ $this->namespace,
17
+ '/' . $this->rest_base,
18
+ array(
19
+ array(
20
+ 'methods' => WP_REST_Server::READABLE,
21
+ 'callback' => array( $this, 'get_wishlists' ),
22
+ 'permission_callback' => '__return_true',
23
+ ),
24
+ )
25
+ );
26
+
27
+ register_rest_route(
28
+ $this->namespace,
29
+ '/' . $this->rest_base . '/course/(?P<id>[\d]+)',
30
+ array(
31
+ array(
32
+ 'methods' => WP_REST_Server::READABLE,
33
+ 'callback' => array( $this, 'get_course_wishlist' ),
34
+ 'permission_callback' => '__return_true',
35
+ ),
36
+ )
37
+ );
38
+
39
+ register_rest_route(
40
+ $this->namespace,
41
+ '/' . $this->rest_base . '/toggle',
42
+ array(
43
+ array(
44
+ 'methods' => WP_REST_Server::CREATABLE,
45
+ 'callback' => array( $this, 'add_remove_to_wishlist' ),
46
+ 'permission_callback' => '__return_true',
47
+ 'args' => array(
48
+ 'id' => array(
49
+ 'description' => esc_html__( 'Course ID', 'learnpress' ),
50
+ 'type' => 'integer',
51
+ 'sanitize_callback' => 'absint',
52
+ ),
53
+ ),
54
+ ),
55
+ )
56
+ );
57
+ }
58
+
59
+ public function get_wishlists( $request ) {
60
+ $user_id = get_current_user_id();
61
+
62
+ $response = new LP_REST_Response();
63
+ $response->data = new stdClass();
64
+
65
+ try {
66
+ if ( empty( $user_id ) ) {
67
+ throw new Exception( esc_html__( 'Login to continue', 'learnpress' ) );
68
+ }
69
+
70
+ $user_wishlist = get_user_meta( $user_id, '_lpr_wish_list', true );
71
+
72
+ if ( ! empty( $user_wishlist ) ) {
73
+ $response->data->items = $this->rest_do_course_request( $user_wishlist );
74
+ } else {
75
+ $response->data->items = array();
76
+ }
77
+
78
+ $response->status = 'success';
79
+ } catch ( \Throwable $th ) {
80
+ $response->message = $th->getMessage();
81
+ }
82
+
83
+ return rest_ensure_response( $response );
84
+ }
85
+
86
+ public function get_course_wishlist( $request ) {
87
+ $course_id = $request->get_param( 'id' );
88
+ $user_id = get_current_user_id();
89
+
90
+ $response = new LP_REST_Response();
91
+ $response->data = new stdClass();
92
+ $response->data->text = array(
93
+ 'add' => esc_html__( 'Add to wishlist', 'learnpress-wishlist' ),
94
+ 'remove' => esc_html__( 'Remove from wishlist', 'learnpress-wishlist' ),
95
+ );
96
+
97
+ try {
98
+ if ( empty( $course_id ) ) {
99
+ throw new Exception( esc_html__( 'No Course ID param.', 'learnpress' ) );
100
+ }
101
+
102
+ $user_wishlist = get_user_meta( $user_id, '_lpr_wish_list', true );
103
+
104
+ if ( ! empty( $user_wishlist ) && in_array( absint( $course_id ), $user_wishlist ) ) {
105
+ $response->message = esc_html__( 'This course available in your wishlist', 'learnpress-wishlist' );
106
+ $response->data->in_wishlist = 'yes';
107
+ } else {
108
+ $response->message = esc_html__( 'This course not in your wishlist', 'learnpress-wishlist' );
109
+ $response->data->in_wishlist = 'no';
110
+ }
111
+
112
+ if ( $user_wishlist ) {
113
+ $response->data->items = $this->rest_do_course_request( $user_wishlist );
114
+ }
115
+
116
+ $response->status = 'success';
117
+ } catch ( \Throwable $th ) {
118
+ $response->message = $th->getMessage();
119
+ }
120
+
121
+ return rest_ensure_response( $response );
122
+ }
123
+
124
+ public function add_remove_to_wishlist( $request ) {
125
+ $course_id = $request->get_param( 'id' );
126
+ $user_id = get_current_user_id();
127
+
128
+ $response = new LP_REST_Response();
129
+ $response->data = new stdClass();
130
+ $response->data->text = array(
131
+ 'add' => esc_html__( 'Add to wishlist', 'learnpress-wishlist' ),
132
+ 'remove' => esc_html__( 'Remove from wishlist', 'learnpress-wishlist' ),
133
+ );
134
+
135
+ try {
136
+ if ( empty( $course_id ) || get_post_type( $course_id ) !== LP_COURSE_CPT ) {
137
+ throw new Exception( esc_html__( 'No Course ID param.', 'learnpress' ) );
138
+ }
139
+
140
+ if ( empty( $user_id ) ) {
141
+ throw new Exception( esc_html__( 'No User.', 'learnpress' ) );
142
+ }
143
+
144
+ $user_wishlist = get_user_meta( $user_id, '_lpr_wish_list', true );
145
+ $wishlists = $user_wishlist ? $user_wishlist : array();
146
+
147
+ if ( ! empty( $wishlists ) && in_array( $course_id, $wishlists ) ) {
148
+ $pos = array_search( $course_id, $wishlists );
149
+
150
+ unset( $wishlists[ $pos ] );
151
+
152
+ $response->data->type = 'remove';
153
+ $response->message = esc_html__( 'This course has been removed from your wishlists', 'learnpress-wishlist' );
154
+ } else {
155
+ $wishlists[] = $course_id;
156
+
157
+ $response->data->type = 'add';
158
+ $response->message = esc_html__( 'This course has been added to your wishlists', 'learnpress-wishlist' );
159
+ }
160
+
161
+ if ( ! empty( $wishlists ) && count( $wishlists ) > 0 ) {
162
+ update_user_meta( $user_id, '_lpr_wish_list', $wishlists );
163
+
164
+ $response->data->items = $this->rest_do_course_request( $wishlists );
165
+ } else {
166
+ delete_user_meta( $user_id, '_lpr_wish_list' );
167
+ }
168
+
169
+ $response->status = 'success';
170
+ } catch ( \Throwable $th ) {
171
+ $response->message = $th->getMessage();
172
+ }
173
+
174
+ return rest_ensure_response( $response );
175
+ }
176
+
177
+ public function rest_do_course_request( $course_ids ) {
178
+ if ( empty( $course_ids ) ) {
179
+ return array();
180
+ }
181
+
182
+ $requests = new WP_REST_Request( 'GET', '/learnpress/v1/courses' );
183
+
184
+ $requests->set_query_params( array( 'include' => $course_ids ) );
185
+ $responses = rest_do_request( $requests );
186
+ $server = rest_get_server();
187
+ $data = $server->response_to_data( $responses, false );
188
+
189
+ return ! empty( $data ) ? $data : array();
190
+ }
191
+ }
192
+ }
inc/rest-api/class-rest-api.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Register Rest API
4
+ *
5
+ * @author Nhamdv <daonham95@gmail.com>
6
+ *
7
+ */
8
+ class LP_Wishlist_Rest_API {
9
+ protected static $instance = null;
10
+
11
+ public function __construct() {
12
+ add_filter( 'lp_rest_api_get_rest_namespaces', array( $this, 'rest_api_init' ) );
13
+ }
14
+
15
+ public function rest_api_init( $data ) {
16
+ $data['learnpress/v1']['wishlist'] = 'LP_Jwt_Wishlist_V1_Controller';
17
+
18
+ return $data;
19
+ }
20
+
21
+ public static function instance() {
22
+ if ( null === static::$instance ) {
23
+ static::$instance = new static();
24
+ }
25
+ return static::$instance;
26
+ }
27
+ }
28
+
29
+ LP_Wishlist_Rest_API::instance();
languages/learnpress-wishlist-ru_RU.po CHANGED
@@ -1,52 +1,52 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: LearnPress Courses Wishlist\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2016-09-07 05:43+0000\n"
6
- "PO-Revision-Date: 2016-09-07 05:47+0000\n"
7
- "Last-Translator: tvardovsky <tvardovsky@me.com>\n"
8
- "Language-Team: Russian\n"
9
- "Language: ru-RU\n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 && "
14
- "n%10<=4 &&(n%100<10||n%100 >= 20)? 1 : 2)\n"
15
- "X-Generator: Loco - https://localise.biz/"
16
-
17
- #: incs/class-lp-addon-wishlist.php:25
18
- msgid "wishlist"
19
- msgstr "Избранные"
20
-
21
- #: incs/class-lp-addon-wishlist.php:69
22
- msgid "You have not permission to do this action"
23
- msgstr "У вас нет прав на это действие"
24
-
25
- #: incs/class-lp-addon-wishlist.php:115
26
- msgid "Remove this course from your wishlist"
27
- msgstr "Удалить этот курс из Избранных"
28
-
29
- #: incs/class-lp-addon-wishlist.php:115
30
- msgid "Add this course to your wishlist"
31
- msgstr "Добавить этот курс в Избранные"
32
-
33
- #: incs/class-lp-addon-wishlist.php:124
34
- msgid "This course added to your wishlist"
35
- msgstr "Этот курс добавлен в Избранные"
36
-
37
- #: incs/class-lp-addon-wishlist.php:124
38
- msgid "This course removed from your wishlist"
39
- msgstr "Этот курс удален из Избранных"
40
-
41
- #: incs/class-lp-addon-wishlist.php:176 incs/lp-wishlist-functions.php:47
42
- #: incs/lp-wishlist-functions.php:93 incs/lp-wishlist-functions.php:107
43
- msgid "Wishlist"
44
- msgstr "Избранные"
45
-
46
- #: incs/lp-wishlist-functions.php:129
47
- msgid "Your wishlist"
48
- msgstr "Ваши Избранные"
49
-
50
- #: template/user-wishlist.php:22
51
- msgid "No courses in your wishlist!"
52
- msgstr "Ваш список Избранных пуст"
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: LearnPress Courses Wishlist\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2016-09-07 05:43+0000\n"
6
+ "PO-Revision-Date: 2016-09-07 05:47+0000\n"
7
+ "Last-Translator: tvardovsky <tvardovsky@me.com>\n"
8
+ "Language-Team: Russian\n"
9
+ "Language: ru-RU\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 && "
14
+ "n%10<=4 &&(n%100<10||n%100 >= 20)? 1 : 2)\n"
15
+ "X-Generator: Loco - https://localise.biz/"
16
+
17
+ #: incs/class-lp-addon-wishlist.php:25
18
+ msgid "wishlist"
19
+ msgstr "Избранные"
20
+
21
+ #: incs/class-lp-addon-wishlist.php:69
22
+ msgid "You have not permission to do this action"
23
+ msgstr "У вас нет прав на это действие"
24
+
25
+ #: incs/class-lp-addon-wishlist.php:115
26
+ msgid "Remove this course from your wishlist"
27
+ msgstr "Удалить этот курс из Избранных"
28
+
29
+ #: incs/class-lp-addon-wishlist.php:115
30
+ msgid "Add this course to your wishlist"
31
+ msgstr "Добавить этот курс в Избранные"
32
+
33
+ #: incs/class-lp-addon-wishlist.php:124
34
+ msgid "This course added to your wishlist"
35
+ msgstr "Этот курс добавлен в Избранные"
36
+
37
+ #: incs/class-lp-addon-wishlist.php:124
38
+ msgid "This course removed from your wishlist"
39
+ msgstr "Этот курс удален из Избранных"
40
+
41
+ #: incs/class-lp-addon-wishlist.php:176 incs/lp-wishlist-functions.php:47
42
+ #: incs/lp-wishlist-functions.php:93 incs/lp-wishlist-functions.php:107
43
+ msgid "Wishlist"
44
+ msgstr "Избранные"
45
+
46
+ #: incs/lp-wishlist-functions.php:129
47
+ msgid "Your wishlist"
48
+ msgstr "Ваши Избранные"
49
+
50
+ #: template/user-wishlist.php:22
51
+ msgid "No courses in your wishlist!"
52
+ msgstr "Ваш список Избранных пуст"
languages/learnpress-wishlist-vi.po CHANGED
@@ -1,76 +1,76 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: LearnPress Courses Wishlist\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: Wed Jan 27 2016 17:21:50 GMT+0700 (SE Asia Standard Time)\n"
6
- "PO-Revision-Date: Wed Jan 27 2016 17:22:32 GMT+0700 (SE Asia Standard Time)\n"
7
- "Last-Translator: admin <tunnhn@gmail.com>\n"
8
- "Language-Team: \n"
9
- "Language: Vietnamese\n"
10
- "Plural-Forms: nplurals=1; plural=0\n"
11
- "MIME-Version: 1.0\n"
12
- "Content-Type: text/plain; charset=UTF-8\n"
13
- "Content-Transfer-Encoding: 8bit\n"
14
- "X-Poedit-SourceCharset: UTF-8\n"
15
- "X-Poedit-Basepath: .\n"
16
- "X-Poedit-SearchPath-0: ..\n"
17
- "X-Poedit-KeywordsList: _:1;gettext:1;dgettext:2;ngettext:1,2;dngettext:2,3;"
18
- "__:1;_e:1;_c:1;_n:1,2;_n_noop:1,2;_nc:1,2;__ngettext:1,2;__ngettext_noop:1,2;"
19
- "_x:1,2c;_ex:1,2c;_nx:1,2,4c;_nx_noop:1,2,3c;_n_js:1,2;_nx_js:1,2,3c;"
20
- "esc_attr__:1;esc_html__:1;esc_attr_e:1;esc_html_e:1;esc_attr_x:1,2c;"
21
- "esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
22
- "X-Loco-Target-Locale: vi_VN\n"
23
- "X-Generator: Loco - https://localise.biz/"
24
-
25
- #. Name of the plugin
26
- msgid "LearnPress Courses Wishlist"
27
- msgstr ""
28
-
29
- #. URI of the plugin
30
- msgid "http://thimpress.com/learnpress"
31
- msgstr ""
32
-
33
- #. Description of the plugin
34
- msgid "Wishlist feature"
35
- msgstr ""
36
-
37
- #. Author of the plugin
38
- msgid "thimpress"
39
- msgstr ""
40
-
41
- #. Author URI of the plugin
42
- msgid "http://thimpress.com"
43
- msgstr ""
44
-
45
- #: ../incs/class-lp-addon-wishlist.php:61
46
- msgid "You have not permission to do this action"
47
- msgstr ""
48
-
49
- #: ../incs/class-lp-addon-wishlist.php:107
50
- msgid "Remove this course from your wishlist"
51
- msgstr "Xóa khóa học này khỏi danh sách yêu thích của bạn"
52
-
53
- #: ../incs/class-lp-addon-wishlist.php:107
54
- msgid "Add this course to your wishlist"
55
- msgstr ""
56
-
57
- #: ../incs/class-lp-addon-wishlist.php:116
58
- msgid "This course added to your wishlist"
59
- msgstr ""
60
-
61
- #: ../incs/class-lp-addon-wishlist.php:116
62
- msgid "This course removed from your wishlist"
63
- msgstr ""
64
-
65
- #: ../incs/class-lp-addon-wishlist.php:169 ../incs/lp-wishlist-functions.php:48 ..
66
- #: /incs/lp-wishlist-functions.php:94 ../incs/lp-wishlist-functions.php:108
67
- msgid "Wishlist"
68
- msgstr ""
69
-
70
- #: ../incs/lp-wishlist-functions.php:130
71
- msgid "Your wishlist"
72
- msgstr ""
73
-
74
- #: ../template/user-wishlist.php:22
75
- msgid "No courses in your wishlist!"
76
- msgstr ""
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: LearnPress Courses Wishlist\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: Wed Jan 27 2016 17:21:50 GMT+0700 (SE Asia Standard Time)\n"
6
+ "PO-Revision-Date: Wed Jan 27 2016 17:22:32 GMT+0700 (SE Asia Standard Time)\n"
7
+ "Last-Translator: admin <tunnhn@gmail.com>\n"
8
+ "Language-Team: \n"
9
+ "Language: Vietnamese\n"
10
+ "Plural-Forms: nplurals=1; plural=0\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-Basepath: .\n"
16
+ "X-Poedit-SearchPath-0: ..\n"
17
+ "X-Poedit-KeywordsList: _:1;gettext:1;dgettext:2;ngettext:1,2;dngettext:2,3;"
18
+ "__:1;_e:1;_c:1;_n:1,2;_n_noop:1,2;_nc:1,2;__ngettext:1,2;__ngettext_noop:1,2;"
19
+ "_x:1,2c;_ex:1,2c;_nx:1,2,4c;_nx_noop:1,2,3c;_n_js:1,2;_nx_js:1,2,3c;"
20
+ "esc_attr__:1;esc_html__:1;esc_attr_e:1;esc_html_e:1;esc_attr_x:1,2c;"
21
+ "esc_html_x:1,2c;comments_number_link:2,3;t:1;st:1;trans:1;transChoice:1,2\n"
22
+ "X-Loco-Target-Locale: vi_VN\n"
23
+ "X-Generator: Loco - https://localise.biz/"
24
+
25
+ #. Name of the plugin
26
+ msgid "LearnPress Courses Wishlist"
27
+ msgstr ""
28
+
29
+ #. URI of the plugin
30
+ msgid "http://thimpress.com/learnpress"
31
+ msgstr ""
32
+
33
+ #. Description of the plugin
34
+ msgid "Wishlist feature"
35
+ msgstr ""
36
+
37
+ #. Author of the plugin
38
+ msgid "thimpress"
39
+ msgstr ""
40
+
41
+ #. Author URI of the plugin
42
+ msgid "http://thimpress.com"
43
+ msgstr ""
44
+
45
+ #: ../incs/class-lp-addon-wishlist.php:61
46
+ msgid "You have not permission to do this action"
47
+ msgstr ""
48
+
49
+ #: ../incs/class-lp-addon-wishlist.php:107
50
+ msgid "Remove this course from your wishlist"
51
+ msgstr "Xóa khóa học này khỏi danh sách yêu thích của bạn"
52
+
53
+ #: ../incs/class-lp-addon-wishlist.php:107
54
+ msgid "Add this course to your wishlist"
55
+ msgstr ""
56
+
57
+ #: ../incs/class-lp-addon-wishlist.php:116
58
+ msgid "This course added to your wishlist"
59
+ msgstr ""
60
+
61
+ #: ../incs/class-lp-addon-wishlist.php:116
62
+ msgid "This course removed from your wishlist"
63
+ msgstr ""
64
+
65
+ #: ../incs/class-lp-addon-wishlist.php:169 ../incs/lp-wishlist-functions.php:48 ..
66
+ #: /incs/lp-wishlist-functions.php:94 ../incs/lp-wishlist-functions.php:108
67
+ msgid "Wishlist"
68
+ msgstr ""
69
+
70
+ #: ../incs/lp-wishlist-functions.php:130
71
+ msgid "Your wishlist"
72
+ msgstr ""
73
+
74
+ #: ../template/user-wishlist.php:22
75
+ msgid "No courses in your wishlist!"
76
+ msgstr ""
languages/learnpress-wishlist.pot CHANGED
@@ -1,82 +1,82 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2018-03-26 09:43+0700\n"
12
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "Language: \n"
16
- "MIME-Version: 1.0\n"
17
- "Content-Type: text/plain; charset=CHARSET\n"
18
- "Content-Transfer-Encoding: 8bit\n"
19
-
20
- #: learnpress-wishlist.php:52
21
- #, php-format
22
- msgid ""
23
- "<strong>%s</strong> addon version %s requires %s version %s or higher is "
24
- "<strong>installed</strong> and <strong>activated</strong>."
25
- msgstr ""
26
-
27
- #: learnpress-wishlist.php:53
28
- msgid "LearnPress Wishlist"
29
- msgstr ""
30
-
31
- #: learnpress-wishlist.php:55
32
- msgid "LearnPress"
33
- msgstr ""
34
-
35
- #: inc/functions.php:114 inc/functions.php:174 inc/functions.php:189
36
- #: inc/load.php:197
37
- msgid "Wishlist"
38
- msgstr ""
39
-
40
- #: inc/functions.php:212
41
- msgid "Your wishlist"
42
- msgstr ""
43
-
44
- #: inc/load.php:40
45
- msgid "wishlist"
46
- msgstr ""
47
-
48
- #: inc/load.php:98
49
- msgid "You have not permission to do this action"
50
- msgstr ""
51
-
52
- #: inc/load.php:134 templates/button.php:22
53
- msgid "Add to Wishlist"
54
- msgstr ""
55
-
56
- #: inc/load.php:134 templates/button.php:22
57
- msgid "Remove from Wishlist"
58
- msgstr ""
59
-
60
- #: inc/load.php:145
61
- msgid "Remove this course from your wishlist"
62
- msgstr ""
63
-
64
- #: inc/load.php:145
65
- msgid "Add this course to your wishlist"
66
- msgstr ""
67
-
68
- #: inc/load.php:154
69
- msgid "This course added to your wishlist"
70
- msgstr ""
71
-
72
- #: inc/load.php:154
73
- msgid "This course removed from your wishlist"
74
- msgstr ""
75
-
76
- #: templates/button.php:21
77
- msgid "Processing..."
78
- msgstr ""
79
-
80
- #: templates/user-wishlist.php:27
81
- msgid "No courses in your wishlist!"
82
- msgstr ""
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2018-03-26 09:43+0700\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+
20
+ #: learnpress-wishlist.php:52
21
+ #, php-format
22
+ msgid ""
23
+ "<strong>%s</strong> addon version %s requires %s version %s or higher is "
24
+ "<strong>installed</strong> and <strong>activated</strong>."
25
+ msgstr ""
26
+
27
+ #: learnpress-wishlist.php:53
28
+ msgid "LearnPress Wishlist"
29
+ msgstr ""
30
+
31
+ #: learnpress-wishlist.php:55
32
+ msgid "LearnPress"
33
+ msgstr ""
34
+
35
+ #: inc/functions.php:114 inc/functions.php:174 inc/functions.php:189
36
+ #: inc/load.php:197
37
+ msgid "Wishlist"
38
+ msgstr ""
39
+
40
+ #: inc/functions.php:212
41
+ msgid "Your wishlist"
42
+ msgstr ""
43
+
44
+ #: inc/load.php:40
45
+ msgid "wishlist"
46
+ msgstr ""
47
+
48
+ #: inc/load.php:98
49
+ msgid "You have not permission to do this action"
50
+ msgstr ""
51
+
52
+ #: inc/load.php:134 templates/button.php:22
53
+ msgid "Add to Wishlist"
54
+ msgstr ""
55
+
56
+ #: inc/load.php:134 templates/button.php:22
57
+ msgid "Remove from Wishlist"
58
+ msgstr ""
59
+
60
+ #: inc/load.php:145
61
+ msgid "Remove this course from your wishlist"
62
+ msgstr ""
63
+
64
+ #: inc/load.php:145
65
+ msgid "Add this course to your wishlist"
66
+ msgstr ""
67
+
68
+ #: inc/load.php:154
69
+ msgid "This course added to your wishlist"
70
+ msgstr ""
71
+
72
+ #: inc/load.php:154
73
+ msgid "This course removed from your wishlist"
74
+ msgstr ""
75
+
76
+ #: templates/button.php:21
77
+ msgid "Processing..."
78
+ msgstr ""
79
+
80
+ #: templates/user-wishlist.php:27
81
+ msgid "No courses in your wishlist!"
82
+ msgstr ""
learnpress-wishlist.php CHANGED
@@ -1,72 +1,87 @@
1
- <?php
2
- /*
3
- Plugin Name: LearnPress - Course Wishlist
4
- Plugin URI: http://thimpress.com/learnpress
5
- Description: Wishlist feature.
6
- Author: ThimPress
7
- Version: 3.0.2
8
- Author URI: http://thimpress.com
9
- Tags: learnpress
10
- Text Domain: learnpress-wishlist
11
- Domain Path: /languages/
12
- */
13
-
14
- /**
15
- * Prevent loading this file directly
16
- */
17
- defined( 'ABSPATH' ) || exit();
18
-
19
- define( 'LP_ADDON_WISHLIST_FILE', __FILE__ );
20
- define( 'LP_ADDON_WISHLIST_VER', '3.0.2' );
21
- define( 'LP_ADDON_WISHLIST_REQUIRE_VER', '3.0.0' );
22
-
23
- /**
24
- * Class LP_Addon_Wishlist_Preload
25
- */
26
- class LP_Addon_Wishlist_Preload {
27
-
28
- /**
29
- * LP_Addon_Wishlist_Preload constructor.
30
- */
31
- public function __construct() {
32
- add_action( 'learn-press/ready', array( $this, 'load' ) );
33
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
34
- }
35
-
36
- /**
37
- * Load addon
38
- */
39
- public function load() {
40
- LP_Addon::load( 'LP_Addon_Wishlist', 'inc/load.php', __FILE__ );
41
- remove_action( 'admin_notices', array( $this, 'admin_notices' ) );
42
- }
43
-
44
- /**
45
- * Admin notice
46
- */
47
- public function admin_notices() {
48
- ?>
49
- <div class="error">
50
- <p><?php echo wp_kses(
51
- sprintf(
52
- __( '<strong>%s</strong> addon version %s requires %s version %s or higher is <strong>installed</strong> and <strong>activated</strong>.', 'learnpress-wishlist' ),
53
- __( 'LearnPress Wishlist', 'learnpress-wishlist' ),
54
- LP_ADDON_WISHLIST_VER,
55
- sprintf( '<a href="%s" target="_blank"><strong>%s</strong></a>', admin_url( 'plugin-install.php?tab=search&type=term&s=learnpress' ), __( 'LearnPress', 'learnpress-wishlist' ) ),
56
- LP_ADDON_WISHLIST_REQUIRE_VER
57
- ),
58
- array(
59
- 'a' => array(
60
- 'href' => array(),
61
- 'blank' => array()
62
- ),
63
- 'strong' => array()
64
- )
65
- ); ?>
66
- </p>
67
- </div>
68
- <?php
69
- }
70
- }
71
-
72
- new LP_Addon_Wishlist_Preload();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: LearnPress - Course Wishlist
4
+ * Plugin URI: http://thimpress.com/learnpress
5
+ * Description: Wishlist feature.
6
+ * Author: ThimPress
7
+ * Version: 4.0.2
8
+ * Author URI: http://thimpress.com
9
+ * Tags: learnpress
10
+ * Text Domain: learnpress-wishlist
11
+ * Domain Path: /languages/
12
+ * Require_LP_Version: 4.1.6.4
13
+ *
14
+ * @package LearnPress-Course-Wishlist
15
+ */
16
+
17
+ /**
18
+ * Prevent loading this file directly
19
+ */
20
+ defined( 'ABSPATH' ) || exit();
21
+
22
+ const LP_ADDON_WISHLIST_FILE = __FILE__;
23
+
24
+ /**
25
+ * Class LP_Addon_Wishlist_Preload
26
+ */
27
+ class LP_Addon_Wishlist_Preload {
28
+ /**
29
+ * @var array|string[]
30
+ */
31
+ public static $addon_info = array();
32
+
33
+ /**
34
+ * LP_Addon_Wishlist_Preload constructor.
35
+ */
36
+ public function __construct() {
37
+ // Set Base name plugin.
38
+ define( 'LP_ADDON_WISHLIST_BASENAME', plugin_basename( LP_ADDON_WISHLIST_FILE ) );
39
+
40
+ // Set version addon for LP check .
41
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
42
+ self::$addon_info = get_file_data(
43
+ LP_ADDON_WISHLIST_FILE,
44
+ array(
45
+ 'Name' => 'Plugin Name',
46
+ 'Require_LP_Version' => 'Require_LP_Version',
47
+ 'Version' => 'Version',
48
+ )
49
+ );
50
+
51
+ define( 'LP_ADDON_WISHLIST_VER', self::$addon_info['Version'] );
52
+ define( 'LP_ADDON_WISHLIST_REQUIRE_VER', self::$addon_info['Require_LP_Version'] );
53
+
54
+ // Check LP activated .
55
+ if ( ! is_plugin_active( 'learnpress/learnpress.php' ) ) {
56
+ add_action( 'admin_notices', array( $this, 'show_note_errors_require_lp' ) );
57
+
58
+ deactivate_plugins( LP_ADDON_WISHLIST_BASENAME );
59
+
60
+ if ( isset( $_GET['activate'] ) ) {
61
+ unset( $_GET['activate'] );
62
+ }
63
+
64
+ return;
65
+ }
66
+
67
+ // Sure LP loaded.
68
+ add_action( 'learn-press/ready', array( $this, 'load' ) );
69
+ }
70
+
71
+ /**
72
+ * Load addon
73
+ */
74
+ public function load() {
75
+ LP_Addon::load( 'LP_Addon_Wishlist', 'inc/load.php', __FILE__ );
76
+ }
77
+
78
+ public function show_note_errors_require_lp() {
79
+ ?>
80
+ <div class="notice notice-error">
81
+ <p><?php echo( 'Please active <strong>LP version ' . LP_ADDON_WISHLIST_REQUIRE_VER . ' or later</strong> before active <strong>' . self::$addon_info['Name'] . '</strong>' ); ?></p>
82
+ </div>
83
+ <?php
84
+ }
85
+ }
86
+
87
+ new LP_Addon_Wishlist_Preload();
readme.txt CHANGED
@@ -1,16 +1,17 @@
1
- === LearnPress - Course Wishlist ===
2
  Contributors: thimpress, tunnhn, kendy73
3
- Donate link:
4
- Tags: lms, elearning, e-learning, learning management system, education, course, courses, quiz, quizzes, questions, training, guru, sell courses
5
- Requires at least: 3.8
6
- Tested up to: 5.2.2
7
- Stable tag: 3.0.2
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
 
10
 
11
- LearnPress Wishlist add wishlist feature to your LearnPress course in your site.
12
 
13
- == Description ==
14
 
15
  **LearnPress** is a <a href="http://thimpress.com/learnpress">WordPress LMS Plugin</a> by ThimPress.
16
 
@@ -18,43 +19,52 @@ LearnPress Wishlist bring wishlist feature for LearnPress. It allows you to add
18
 
19
  Want to see it in action? See our [Educational WordPress Theme](http://themeforest.net/item/education-wordpress-theme-education-wp/14058034?utm_source=wporg&utm_medium=wishlist&ref=thimpress&utm_campaign=learnpress "Educational WordPress Theme").
20
 
21
- **Other free add-ons for LearnPress are available in WordPress:**
22
 
23
- - <a href="https://wordpress.org/plugins/learnpress-course-review/" target="_blank">LearnPress Course Review</a> - review course for enrolled students.
24
- - <a href="https://wordpress.org/plugins/learnpress-import-export/" target="_blank">LearnPress Import Export</a> - export or import course or courses out-of-box.
25
- - <a href="https://wordpress.org/plugins/learnpress-prerequisites-courses/" target="_blank">LearnPress Prerequisites Courses</a> - require student to pass some courses in order to enroll other course.
26
- - <a href="https://wordpress.org/plugins/learnpress-bbpress" target="_blank">LearnPress bbPress</a> - add bbPress Forum support for LearnPress.
27
- - <a href="https://wordpress.org/plugins/learnpress-buddypress" target="_blank">LearnPress BuddyPress</a> - add BuddyPress support for LearnPress.
28
 
29
  **Premium Plugins (add-ons) for LearnPress WordPress LMS Plugin**
30
 
31
- - <a href="http://thimpress.com/shop/certificates-add-on-for-learnpress/" target="_blank">Certificates add-on for LearnPress</a> - adding drag & drop certificates builder as well as selecting designed certificate for each LMS course, your student will get particular certificate when they finished a course.
32
- - <a href="http://thimpress.com/shop/co-instructors-add-on-for-learnpress/" target="_blank">Co-instructors add-on for LearnPress</a> - multiple instructors support for each LMS course.
33
- - <a href="http://thimpress.com/shop/collections-add-on-for-learnpress/" target="_blank">Collections add-on for LearnPress</a> - making LMS courses collection by selecting number of courses, this is helpful if you want to combine multiple LMS courses into a collection for a group of skills.
34
- - <a href="http://thimpress.com/shop/stripe-add-on-for-learnpress/" target="_blank">Stripe Payment method for LearnPress</a> - Stripe payment method for LearnPress WordPress LMS Plugin.
35
  - <a href="http://thimpress.com/shop/woocommerce-add-on-for-learnpress/" target="_blank">WooCommerce add-on for LearnPress</a> - using WooCommerce as payment gateway for LearnPrss WordPress LMS Plugin.
36
 
37
- == Installation ==
38
 
39
- **From your WordPress dashboard**
40
- 1. Visit 'Plugin > Add new'.
41
- 2. Search for 'LearnPress Wishlist'.
42
- 3. Activate LearnPress from your Plugins page.
43
 
44
- **From WordPress.org**
45
- 1. Search, select and download LearnPress Wishlist.
46
- 2. Activate the plugin through the 'Plugins' menu in WordPress Dashboard.
47
 
48
- == Frequently Asked Questions ==
49
 
50
- Check out <a href="http://docs.thimpress.com/learnpress" target="_blank">LearnPress</a> sites.
51
 
52
- == Screenshots ==
53
 
54
- 1. LearnPress Prerequisite screenshot.
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
 
 
58
  = 3.0.2 =
59
  + Fixed js error when click Wishlist button.
60
 
@@ -75,15 +85,15 @@ Check out <a href="http://docs.thimpress.com/learnpress" target="_blank">LearnPr
75
  = 1.0 =
76
  + Compatible with LearnPress version 1.0
77
 
78
- = 0.9.1 =
79
- 1. Updated language file
80
 
81
- = 0.9.0 =
82
- The first beta release.
83
 
84
- == Upgrade Notice ==
85
  Later :)
86
 
87
- == Other note ==
88
- <a href="http://docs.thimpress.com/learnpress" target="_blank">Documentation</a> is available in ThimPress site.
89
- <a href="https://github.com/LearnPress/LearnPress/" target="_blank">LearnPress github repo.</a>
1
+ === LearnPress - Course Wishlist ===
2
  Contributors: thimpress, tunnhn, kendy73
3
+ Donate link:
4
+ Tags: lms, elearning, e-learning, learning management system, education, course, courses, quiz, quizzes, questions, training, guru, sell courses
5
+ Requires at least: 3.8
6
+ Tested up to: 5.9
7
+ Requires PHP: 7.0
8
+ Stable tag: 4.0.2
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
12
+ LearnPress Wishlist add wishlist feature to your LearnPress course in your site.
13
 
14
+ == Description ==
15
 
16
  **LearnPress** is a <a href="http://thimpress.com/learnpress">WordPress LMS Plugin</a> by ThimPress.
17
 
19
 
20
  Want to see it in action? See our [Educational WordPress Theme](http://themeforest.net/item/education-wordpress-theme-education-wp/14058034?utm_source=wporg&utm_medium=wishlist&ref=thimpress&utm_campaign=learnpress "Educational WordPress Theme").
21
 
22
+ **Other free add-ons for LearnPress are available in WordPress:**
23
 
24
+ - <a href="https://wordpress.org/plugins/learnpress-course-review/" target="_blank">LearnPress Course Review</a> - review course for enrolled students.
25
+ - <a href="https://wordpress.org/plugins/learnpress-import-export/" target="_blank">LearnPress Import Export</a> - export or import course or courses out-of-box.
26
+ - <a href="https://wordpress.org/plugins/learnpress-prerequisites-courses/" target="_blank">LearnPress Prerequisites Courses</a> - require student to pass some courses in order to enroll other course.
27
+ - <a href="https://wordpress.org/plugins/learnpress-bbpress" target="_blank">LearnPress bbPress</a> - add bbPress Forum support for LearnPress.
28
+ - <a href="https://wordpress.org/plugins/learnpress-buddypress" target="_blank">LearnPress BuddyPress</a> - add BuddyPress support for LearnPress.
29
 
30
  **Premium Plugins (add-ons) for LearnPress WordPress LMS Plugin**
31
 
32
+ - <a href="http://thimpress.com/shop/certificates-add-on-for-learnpress/" target="_blank">Certificates add-on for LearnPress</a> - adding drag & drop certificates builder as well as selecting designed certificate for each LMS course, your student will get particular certificate when they finished a course.
33
+ - <a href="http://thimpress.com/shop/co-instructors-add-on-for-learnpress/" target="_blank">Co-instructors add-on for LearnPress</a> - multiple instructors support for each LMS course.
34
+ - <a href="http://thimpress.com/shop/collections-add-on-for-learnpress/" target="_blank">Collections add-on for LearnPress</a> - making LMS courses collection by selecting number of courses, this is helpful if you want to combine multiple LMS courses into a collection for a group of skills.
35
+ - <a href="http://thimpress.com/shop/stripe-add-on-for-learnpress/" target="_blank">Stripe Payment method for LearnPress</a> - Stripe payment method for LearnPress WordPress LMS Plugin.
36
  - <a href="http://thimpress.com/shop/woocommerce-add-on-for-learnpress/" target="_blank">WooCommerce add-on for LearnPress</a> - using WooCommerce as payment gateway for LearnPrss WordPress LMS Plugin.
37
 
38
+ == Installation ==
39
 
40
+ **From your WordPress dashboard**
41
+ 1. Visit 'Plugin > Add new'.
42
+ 2. Search for 'LearnPress Wishlist'.
43
+ 3. Activate LearnPress from your Plugins page.
44
 
45
+ **From WordPress.org**
46
+ 1. Search, select and download LearnPress Wishlist.
47
+ 2. Activate the plugin through the 'Plugins' menu in WordPress Dashboard.
48
 
49
+ == Frequently Asked Questions ==
50
 
51
+ Check out <a href="http://docs.thimpress.com/learnpress" target="_blank">LearnPress</a> sites.
52
 
53
+ == Screenshots ==
54
 
55
+ 1. LearnPress Prerequisite screenshot.
56
 
57
  == Changelog ==
58
 
59
+ = 4.0.2 =
60
+ ~ Added: API wishlist.
61
+
62
+ = 4.0.1 =
63
+ + Fix minor bug.
64
+
65
+ = 4.0.0 =
66
+ + Fix compatible LP4
67
+
68
  = 3.0.2 =
69
  + Fixed js error when click Wishlist button.
70
 
85
  = 1.0 =
86
  + Compatible with LearnPress version 1.0
87
 
88
+ = 0.9.1 =
89
+ 1. Updated language file
90
 
91
+ = 0.9.0 =
92
+ The first beta release.
93
 
94
+ == Upgrade Notice ==
95
  Later :)
96
 
97
+ == Other note ==
98
+ <a href="http://docs.thimpress.com/learnpress" target="_blank">Documentation</a> is available in ThimPress site.
99
+ <a href="https://github.com/LearnPress/LearnPress/" target="_blank">LearnPress github repo.</a>
templates/button.php CHANGED
@@ -1,23 +1,32 @@
1
- <?php
2
- /**
3
- * Template for displaying button to toggle course wishlist on/off.
4
- *
5
- * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/button.php.
6
- *
7
- * @author ThimPress
8
- * @package LearnPress/Wishlist/Templates
9
- * @version 3.0.1
10
- */
11
-
12
- // Prevent loading this file directly
13
- defined( 'ABSPATH' ) || exit;
14
-
15
- printf(
16
- '<button class="learn-press-course-wishlist learn-press-course-wishlist-button-%2$d wishlist-button %s" data-id="%s" data-nonce="%s" title="%s" data-text="%s">%s</button>',
17
- join( " ", $classes ),
18
- $course_id,
19
- wp_create_nonce( 'course-toggle-wishlist' ),
20
- $title,
21
- __( 'Processing...', 'learnpress-wishlist' ),
22
- $state == 'on' ? __( 'Remove from Wishlist', 'learnpress-wishlist' ) : __( 'Add to Wishlist', 'learnpress-wishlist' )
23
- );
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template for displaying button to toggle course wishlist on/off.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/button.php.
6
+ *
7
+ * @author ThimPress
8
+ * @package LearnPress/Wishlist/Templates
9
+ * @version 3.0.1
10
+ */
11
+
12
+ // Prevent loading this file directly
13
+ defined( 'ABSPATH' ) || exit;
14
+ if (!isset($classes) || !isset($course_id) || !isset($title) || !isset($state)) {
15
+ return;
16
+ }
17
+ if ( version_compare( LEARNPRESS_VERSION, '4.0.0-beta-0', '>=' ) ) {
18
+ $lp_version = 'lp4';
19
+ } else {
20
+ $lp_version = 'lp3';
21
+ }
22
+
23
+
24
+ printf(
25
+ '<button class="'.$lp_version.' learn-press-course-wishlist lp-button gray learn-press-course-wishlist-button-%2$d wishlist-button %s" data-id="%s" data-nonce="%s" title="%s" data-text="%s">%s</button>',
26
+ join( " ", $classes ),
27
+ $course_id,
28
+ wp_create_nonce( 'course-toggle-wishlist' ),
29
+ $title,
30
+ __( 'Processing...', 'learnpress-wishlist' ),
31
+ $state == 'on' ? __( 'Remove from Wishlist', 'learnpress-wishlist' ) : __( 'Add to Wishlist', 'learnpress-wishlist' )
32
+ );
templates/loop/title.php CHANGED
@@ -1,20 +1,21 @@
1
- <?php
2
- /**
3
- * Template for displaying loop wishlist title.
4
- *
5
- * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/loop/title.php.
6
- *
7
- * @author ThimPress
8
- * @package LearnPress/Wishlist/Templates
9
- * @version 3.0.1
10
- */
11
-
12
- /**
13
- * Prevent loading this file directly
14
- */
15
- defined( 'ABSPATH' ) || exit();
16
- global $post;
17
- $course = learn_press_get_course( $post );
18
- ?>
19
- <?php echo $course->get_image(); ?>
20
- <h3><?php the_title(); ?></h3>
 
1
+ <?php
2
+
3
+ /**
4
+ * Template for displaying loop wishlist title.
5
+ *
6
+ * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/loop/title.php.
7
+ *
8
+ * @author ThimPress
9
+ * @package LearnPress/Wishlist/Templates
10
+ * @version 3.0.1
11
+ */
12
+
13
+ /**
14
+ * Prevent loading this file directly
15
+ */
16
+ defined( 'ABSPATH' ) || exit();
17
+ global $post;;
18
+ $course = learn_press_get_course( $post->ID );
19
+ ?>
20
+ <?php echo $course->get_image(); ?>
21
+ <h3><?php the_title(); ?></h3>
templates/user-wishlist.php CHANGED
@@ -1,30 +1,31 @@
1
- <?php
2
- /**
3
- * Template for displaying the list of course is in wishlist.
4
- *
5
- * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/user-wishlist.php.
6
- *
7
- * @author ThimPress
8
- * @package LearnPress/Wishlist/Templates
9
- * @version 3.0.1
10
- */
11
-
12
- // Prevent loading this file directly
13
- defined( 'ABSPATH' ) || exit;
14
-
15
- global $post;
16
- $has_courses = $wishlist ? true : false;
17
- ?>
18
-
19
- <div id="learn-press-profile-tab-course-wishlist" class="<?php echo $has_courses ? 'has-courses' : ''; ?>">
20
- <?php if ( $has_courses ) { ?>
21
- <ul class="learn-press-courses profile-courses courses-list learn-press-wishlist-courses">
22
- <?php foreach ( $wishlist as $post ) { ?>
23
- <?php learn_press_course_wishlist_template( 'wishlist-content.php' ); ?>
24
- <?php } ?>
25
- </ul>
26
- <?php } ?>
27
- <?php learn_press_display_message( apply_filters( 'learn_press_wishlist_empty_course', __( 'No courses in your wishlist!', 'learnpress-wishlist' ) ) ); ?>
28
- </div>
29
- <?php
30
- wp_reset_postdata();
 
1
+ <?php
2
+ /**
3
+ * Template for displaying the list of course is in wishlist.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/user-wishlist.php.
6
+ *
7
+ * @author ThimPress
8
+ * @package LearnPress/Wishlist/Templates
9
+ * @version 3.0.1
10
+ */
11
+
12
+ // Prevent loading this file directly
13
+ defined( 'ABSPATH' ) || exit;
14
+
15
+ global $post;
16
+ $has_courses = $wishlist ? true : false;
17
+ ?>
18
+
19
+ <div id="learn-press-profile-tab-course-wishlist" class="<?php echo $has_courses ? 'has-courses' : ''; ?>">
20
+ <?php if ( $has_courses ) { ?>
21
+ <ul class="learn-press-courses profile-courses courses-list learn-press-wishlist-courses">
22
+ <?php foreach ( $wishlist as $post ) {
23
+ ?>
24
+ <?php learn_press_course_wishlist_template( 'wishlist-content.php' ); ?>
25
+ <?php } ?>
26
+ </ul>
27
+ <?php } ?>
28
+ <?php learn_press_display_message( apply_filters( 'learn_press_wishlist_empty_course', __( 'No courses in your wishlist!', 'learnpress-wishlist' ) ) ); ?>
29
+ </div>
30
+ <?php
31
+ wp_reset_postdata();
templates/wishlist-content.php CHANGED
@@ -1,28 +1,28 @@
1
- <?php
2
-
3
- /**
4
- * Template for displaying the list of course content is in wishlist.
5
- *
6
- * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/wishlist-content.php.
7
- *
8
- * @author ThimPress
9
- * @package LearnPress/Wishlist/Templates
10
- * @version 3.0.1
11
- */
12
-
13
- // Prevent loading this file directly
14
- defined( 'ABSPATH' ) || exit;
15
-
16
- global $post;
17
- ?>
18
-
19
- <li id="learn-press-tab-wishlist-course-<?php echo $post->ID; ?>" class="course" data-context="tab-wishlist">
20
-
21
- <?php do_action( 'learn_press_before_profile_tab_wishlist_loop_course' ); ?>
22
- <a href="<?php the_permalink(); ?>" class="course-title">
23
- <?php do_action( 'learn_press_wishlist_loop_item_title' ); ?>
24
- </a>
25
- <?php do_action( 'learn_press_after_profile_tab_wishlist_loop_course' ); ?>
26
-
27
- <?php LP_Addon_Wishlist::instance()->wishlist_button( $post->ID ); ?>
28
- </li>
1
+ <?php
2
+
3
+ /**
4
+ * Template for displaying the list of course content is in wishlist.
5
+ *
6
+ * This template can be overridden by copying it to yourtheme/learnpress/addons/wishlist/wishlist-content.php.
7
+ *
8
+ * @author ThimPress
9
+ * @package LearnPress/Wishlist/Templates
10
+ * @version 3.0.1
11
+ */
12
+
13
+ // Prevent loading this file directly
14
+ defined( 'ABSPATH' ) || exit;
15
+
16
+ global $post;
17
+ ?>
18
+
19
+ <li id="learn-press-tab-wishlist-course-<?php echo $post->ID; ?>" class="course" data-context="tab-wishlist">
20
+
21
+ <?php do_action( 'learn_press_before_profile_tab_wishlist_loop_course' ); ?>
22
+ <a href="<?php the_permalink(); ?>" class="course-title">
23
+ <?php do_action( 'learn_press_wishlist_loop_item_title' ); ?>
24
+ </a>
25
+ <?php do_action( 'learn_press_after_profile_tab_wishlist_loop_course' ); ?>
26
+
27
+ <?php LP_Addon_Wishlist::instance()->wishlist_button( $post->ID ); ?>
28
+ </li>