LearnPress – Course Wishlist - Version 0.9.3

Version Description

Later :)

Download this release

Release Info

Developer tunnhn
Plugin Icon 128x128 LearnPress – Course Wishlist
Version 0.9.3
Comparing to
See all releases

Version 0.9.3

init.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !defined( 'ABSPATH' ) ) {
4
+ exit; // Exit if accessed directly
5
+ }
6
+ define( 'WISHLIST_TMPL', LPR_WISHLIST_PATH . '/template/' );
7
+ define( 'WISHLIST_THEME_TMPL', learn_press_template_path() . '/addons/course-wishlist/' );
8
+
9
+ function learn_press_course_wishlist_template( $name, $args = null ) {
10
+ learn_press_get_template( $name, $args, WISHLIST_THEME_TMPL, WISHLIST_TMPL );
11
+ }
12
+
13
+ /*
14
+ * Show wishlist button
15
+ */
16
+ add_action( 'learn_press_entry_footer_archive', 'learn_press_course_wishlist_button', 10 );
17
+ add_action( 'learn_press_course_landing_content', 'learn_press_course_wishlist_button', 10 );
18
+ add_action( 'learn_press_course_learning_content', 'learn_press_course_wishlist_button', 10 );
19
+ function learn_press_course_wishlist_button( $course_id = null ) {
20
+ $user_id = get_current_user_id();
21
+
22
+ if ( !$course_id ) {
23
+ $course_id = get_the_ID();
24
+ }
25
+
26
+ // If user or course are invalid then return.
27
+ if ( !$user_id || !$course_id ) {
28
+ return;
29
+ }
30
+
31
+ learn_press_course_wishlist_template( 'button.php', array( 'user_id' => $user_id, 'course_id' => $course_id ) );
32
+
33
+ }
34
+
35
+ /*
36
+ * Wishlist scripts processing
37
+ */
38
+ function learn_press_wishlist_scripts() {
39
+ wp_enqueue_style( 'course-wishlist-style', untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/source/wishlist.css' );
40
+ wp_enqueue_script( 'course-wishlist-script', untrailingslashit( plugins_url( '/', __FILE__ ) ) . '/source/wishlist.js', array( 'jquery' ), '1.0.0', true );
41
+ }
42
+
43
+ add_action( 'wp_enqueue_scripts', 'learn_press_wishlist_scripts' );
44
+
45
+ /**
46
+ * Add course to wishlist
47
+ */
48
+ add_action( 'wp_ajax_add_wish_list', 'learn_press_add_wish_list' );
49
+ add_action( 'wp_ajax_nopriv_add_wish_list', 'learn_press_add_wish_list' );
50
+ function learn_press_add_wish_list() {
51
+
52
+ $course_id = $_POST['course_id'];
53
+ $user_id = get_current_user_id();
54
+ $wish_list = get_user_meta( $user_id, '_lpr_wish_list', true );
55
+
56
+ if ( !$wish_list ) {
57
+ $wish_list = array();
58
+ }
59
+
60
+ if ( !in_array( $course_id, $wish_list ) ) {
61
+ array_push( $wish_list, $course_id );
62
+ }
63
+ update_user_meta( $user_id, '_lpr_wish_list', $wish_list );
64
+ die;
65
+ }
66
+
67
+ /**
68
+ * Remove course from wishlist
69
+ */
70
+ add_action( 'wp_ajax_remove_wish_list', 'learn_press_remove_wish_list' );
71
+ add_action( 'wp_ajax_nopriv_remove_wish_list', 'learn_press_remove_wish_list' );
72
+
73
+ function learn_press_remove_wish_list() {
74
+
75
+ $course_id = $_POST['course_id'];
76
+ $user_id = get_current_user_id();
77
+ $wish_list = get_user_meta( $user_id, '_lpr_wish_list', true );
78
+
79
+ if ( !$wish_list ) {
80
+ $wish_list = array();
81
+ }
82
+ $key = array_search( $course_id, $wish_list );
83
+ if ( $key !== false ) {
84
+ unset( $wish_list[$key] );
85
+ }
86
+ update_user_meta( $user_id, '_lpr_wish_list', $wish_list );
87
+ die;
88
+ }
89
+
90
+
91
+ /**
92
+ * Update user's wish list
93
+ *
94
+ * @param $user_id
95
+ * @param $course_id
96
+ */
97
+
98
+ add_action( 'learn_press_after_take_course', 'learn_press_update_wish_list', 10, 2 );
99
+ function learn_press_update_wish_list( $user_id, $course_id ) {
100
+ if ( !$user_id || !$course_id ) {
101
+ return;
102
+ }
103
+ $wish_list = get_user_meta( $user_id, '_lpr_wish_list', true );
104
+ if ( !$wish_list ) {
105
+ $wish_list = array();
106
+ }
107
+ $key = array_search( $course_id, $wish_list );
108
+ if ( $key !== false ) {
109
+ unset( $wish_list[$key] );
110
+ }
111
+ update_user_meta( $user_id, '_lpr_wish_list', $wish_list );
112
+ }
113
+
114
+ /*
115
+ * Add wishlist tab into profile page
116
+ */
117
+ add_filter( 'learn_press_profile_tabs', 'learn_press_wishlist_tab', 10, 2 );
118
+ function learn_press_wishlist_tab( $tabs, $user ) {
119
+ $content = '';
120
+
121
+ $tabs[35] = array(
122
+ 'tab_id' => 'user_wishlist',
123
+ 'tab_name' => __( 'Wishlist', 'learnpress_wishlist' ),
124
+ 'tab_content' => apply_filters( 'learn_press_user_wishlist_tab_content', $content, $user )
125
+ );
126
+ // Private customize
127
+ if ( $user->ID != get_current_user_id() ) {
128
+ unset ( $tabs[35] );
129
+ }
130
+ return $tabs;
131
+ }
132
+
133
+ /*
134
+ * Setup wishlist tab content
135
+ */
136
+ add_filter( 'learn_press_user_wishlist_tab_content', 'learn_press_user_wishlist_tab_content', 10, 2 );
137
+ function learn_press_user_wishlist_tab_content( $content, $user ) {
138
+ ob_start();
139
+ //learn_press_get_template( 'addons/course-wishlist/user-wishlist.php', array( 'user' => $user ) );
140
+ learn_press_course_wishlist_template( 'user-wishlist.php', array( 'user' => $user ) );
141
+ $content .= ob_get_clean();
142
+ return $content;
143
+ }
144
+
145
+ if ( !function_exists( 'learn_press_buddypress_is_active' ) ) {
146
+ function learn_press_buddypress_is_active() {
147
+ if ( !function_exists( 'is_plugin_active' ) ) {
148
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
149
+ }
150
+
151
+ return class_exists( 'BuddyPress' ) && is_plugin_active( 'buddypress/bp-loader.php' );
152
+ }
153
+ }
154
+
155
+ if ( learn_press_buddypress_is_active() && 1==2 ) {
156
+
157
+ /*
158
+ * Set up sub admin bar wishlist
159
+ */
160
+ add_filter( 'learn_press_bp_courses_bar', 'learn_press_bp_courses_bar_wishlist', 20 );
161
+ function learn_press_bp_courses_bar_wishlist( $wp_admin_nav ) {
162
+
163
+ $courses_slug = apply_filters( 'learn_press_bp_courses_slug', '' );
164
+ $courses_link = learn_press_get_current_bp_link();
165
+
166
+ $wp_admin_nav[] = array(
167
+ 'parent' => 'my-account-' . $courses_slug,
168
+ 'id' => 'my-account-' . $courses_slug . '-wishlist',
169
+ 'title' => __( 'Wishlist', 'learnpress_wishlist' ),
170
+ 'href' => trailingslashit( $courses_link . 'wishlist' )
171
+ );
172
+ return $wp_admin_nav;
173
+ }
174
+
175
+ /*
176
+ * Setup sub navigation wishlist
177
+ */
178
+ if ( bp_is_my_profile() || current_user_can( 'manage_options' ) ) {
179
+ add_filter( 'learn_press_bp_courses_sub_navs', 'learn_press_bp_courses_nav_wishlist' );
180
+
181
+ function learn_press_bp_courses_nav_wishlist( $sub_navs ) {
182
+ $nav_wishlist = array(
183
+ 'name' => __( 'Wishlist', 'learnpress_wishlist' ),
184
+ 'slug' => 'wishlist',
185
+ 'show_for_displayed_user' => false,
186
+ 'position' => 10,
187
+ 'screen_function' => 'learn_press_bp_courses_wishlist',
188
+ 'parent_url' => learn_press_get_current_bp_link(),
189
+ 'parent_slug' => apply_filters( 'learn_press_bp_courses_slug', '' ),
190
+ );
191
+ array_push( $sub_navs, $nav_wishlist );
192
+ return $sub_navs;
193
+ }
194
+
195
+ function learn_press_bp_courses_wishlist() {
196
+ add_action( 'bp_template_title', 'learn_press_bp_courses_wishlist_title' );
197
+ add_action( 'bp_template_content', 'learn_press_bp_courses_wishlist_content' );
198
+ bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
199
+ }
200
+
201
+ /*
202
+ * Setup title of navigation all
203
+ */
204
+ function learn_press_bp_courses_wishlist_title() {
205
+ echo __( 'Your wishlist', 'learnpress_wishlist' );
206
+ }
207
+
208
+ /*
209
+ * Setup content of navigation all
210
+ */
211
+ function learn_press_bp_courses_wishlist_content() {
212
+ global $bp;
213
+ echo apply_filters( 'learn_press_user_wishlist_tab_content', '', get_user_by( 'id', $bp->displayed_user->id ) );
214
+ }
215
+ }
216
+ }
217
+
218
+ function learn_press_get_wishlist_courses( $user_id ) {
219
+ $pid = get_user_meta( $user_id, '_lpr_wish_list', true );
220
+ if ( !$pid ) {
221
+ $pid = array( 0 );
222
+ }
223
+ $arr_query = array(
224
+ 'post_type' => 'lpr_course',
225
+ 'post__in' => $pid,
226
+ 'post_status' => 'publish',
227
+ 'ignore_sticky_posts' => true,
228
+ 'posts_per_page' => - 1
229
+ );
230
+ $my_query = new WP_Query( $arr_query );
231
+ return $my_query;
232
+ }
233
+
234
+ add_action( 'learn_press_after_wishlist_course_title', 'learn_press_course_wishlist_button', 10 );
lang/default.pot ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 2015-08-01 16:30+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
+ #: init.php:128 init.php:165 init.php:179
21
+ msgid "Wishlist"
22
+ msgstr ""
23
+
24
+ #: init.php:201
25
+ msgid "Your wishlist"
26
+ msgstr ""
27
+
28
+ #: template/user-wishlist.php:4
29
+ msgid "All Wishlist"
30
+ msgstr ""
31
+
32
+ #: template/user-wishlist.php:13
33
+ msgid "No courses in your wishlist!"
34
+ msgstr ""
lang/id_ID.po ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #
5
+ # Translators:
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: LearnPress\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2015-07-25 14:46+0700\n"
11
+ "PO-Revision-Date: 2015-08-01 17:33+0000\n"
12
+ "Last-Translator: Muhammad Yahya Muhaimin, S.Kom. <surat.pribadiku@gmail.com>\n"
13
+ "Language-Team: Indonesian (Indonesia) (http://www.transifex.com/wp-translations/learnpress/language/id_ID/)\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=UTF-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "Language: id_ID\n"
18
+ "Plural-Forms: nplurals=1; plural=0;\n"
19
+
20
+ #: init.php:128 init.php:165 init.php:179
21
+ msgid "Wishlist"
22
+ msgstr "Daftar Keinginan"
23
+
24
+ #: init.php:201
25
+ msgid "Your wishlist"
26
+ msgstr "Daftar Keinginan Anda"
27
+
28
+ #: template/user-wishlist.php:4
29
+ msgid "All Wishlist"
30
+ msgstr "Semua Daftar Keinginan"
31
+
32
+ #: template/user-wishlist.php:13
33
+ msgid "No courses in your wishlist!"
34
+ msgstr "Tidak ada mata kuliah dalam daftar keinginan Anda!"
learnpress-wishlist.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: LearnPress Courses Wishlist
4
+ Plugin URI: http://thimpress.com/learnpress
5
+ Description: Wishlist feature
6
+ Author: thimpress
7
+ Version: 0.9.3
8
+ Author URI: http://thimpress.com
9
+ Tags: learnpress
10
+ */
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit; // Exit if accessed directly
13
+ }
14
+
15
+ define( 'LPR_WISHLIST_PATH', dirname( __FILE__ ) );
16
+ /**
17
+ * Register wishlist addon
18
+ */
19
+ function learn_press_register_wishlist() {
20
+ require_once( LPR_WISHLIST_PATH . '/init.php' );
21
+ }
22
+ add_action( 'learn_press_register_add_ons', 'learn_press_register_wishlist' );
23
+
24
+
25
+ add_action('plugins_loaded','learnpress_wishlist_translations');
26
+ function learnpress_wishlist_translations(){
27
+ $textdomain = 'learnpress_wishlist';
28
+ $locale = apply_filters("plugin_locale", get_locale(), $textdomain);
29
+ $lang_dir = dirname( __FILE__ ) . '/lang/';
30
+ $mofile = sprintf( '%s.mo', $locale );
31
+ $mofile_local = $lang_dir . $mofile;
32
+ $mofile_global = WP_LANG_DIR . '/plugins/' . $mofile;
33
+ if ( file_exists( $mofile_global ) ) {
34
+ load_textdomain( $textdomain, $mofile_global );
35
+ } else {
36
+ load_textdomain( $textdomain, $mofile_local );
37
+ }
38
+ }
39
+
readme.txt ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === LearnPress Wishlist - WordPress extension for LearnPress ===
2
+ Contributors: thimpress, kendy73, tunnhn, halink0803
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: 4.2.2
7
+ Stable tag: 0.9.3
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
+
17
+ LearnPress Wishlist bring wishlist feature for LearnPress. It allows you to add your favorite course to a list to take later. We have created the LearnPress WordPress LMS plugin with add-ons structure in mind as well as keeping it as lightweight as possible, so together with other add-ons, Wishlist will help to complete LearnPress much more. Check out other add-ons for LearnPress below.
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
+ = 0.9.1 =
59
+ 1. Updated language file
60
+
61
+ = 0.9.0 =
62
+ The first beta release.
63
+
64
+ == Upgrade Notice ==
65
+ Later :)
66
+
67
+ == Other note ==
68
+ <a href="http://docs.thimpress.com/learnpress" target="_blank">Documentation</a> is available in ThimPress site.
69
+ <a href="https://github.com/LearnPress/LearnPress/" target="_blank">LearnPress github repo.</a>
source/wishlist.css ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ .course-wishlist {
2
+ color: #d3d3d3;
3
+ cursor: pointer;
4
+ }
5
+ .course-wishlisted {
6
+ color: #ff0084;
7
+ cursor: pointer;
8
+ }
source/wishlist.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function ($) {
2
+ $("[class*='course-wishlist']").click(function (event) {
3
+ event.preventDefault();
4
+ var $this = $(this);
5
+ if( $this.hasClass('loading') ) return;
6
+ $this.addClass('loading');
7
+ $this.toggleClass('course-wishlist');
8
+ $this.toggleClass('course-wishlisted');
9
+ $class = $this.attr('class');
10
+ if ($this.hasClass('course-wishlisted')) {
11
+ $.ajax({
12
+ type : "POST",
13
+ url : ajaxurl,
14
+ data : {
15
+ action : 'add_wish_list',
16
+ course_id: $this.attr('course-id')
17
+ },
18
+ success: function(){
19
+ $this.removeClass('loading')
20
+ },
21
+ error: function(){
22
+ $this.removeClass('loading')
23
+ }
24
+ });
25
+ }
26
+ if ($this.hasClass('course-wishlist')) {
27
+ $.ajax({
28
+ type : "POST",
29
+ url : ajaxurl,
30
+ data : {
31
+ action : 'remove_wish_list',
32
+ course_id: $this.attr('course-id')
33
+ },
34
+ success: function(){
35
+ $this.removeClass('loading')
36
+ },
37
+ error: function(){
38
+ $this.removeClass('loading')
39
+ }
40
+ });
41
+ }
42
+ });
43
+
44
+ });
template/button.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $wish_list = get_user_meta( $user_id, '_lpr_wish_list', true );
4
+ if ( !$wish_list ) {
5
+ $wish_list = array();
6
+ }
7
+ if ( in_array( $course_id, $wish_list ) ) {
8
+ $class = 'course-wishlisted';
9
+ } else {
10
+ $class = 'course-wishlist';
11
+ }
12
+ do_action('learn_press_before_wishlist_button');
13
+ printf(
14
+ '<span class="dashicons dashicons-heart %s" course-id="%s"></span>',
15
+ $class,
16
+ $course_id
17
+ );
18
+ do_action('learn_press_after_wishlist_button');
template/user-wishlist.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ do_action( 'learn_press_before_all_wishlist' );
4
+ echo '<h3>' . __( 'All Wishlist', 'learnpress_wishlist' ) . '</h3>';
5
+ do_action( 'learn_press_before_wishlist_course' );
6
+ $my_query = learn_press_get_wishlist_courses( $user->ID );
7
+ if ( $my_query->have_posts() ) :
8
+ while ( $my_query->have_posts() ) : $my_query->the_post();
9
+ learn_press_get_template( 'addons/course-wishlist/wishlist-content.php' );
10
+ endwhile;
11
+ else :
12
+ do_action( 'learn_press_before_no_wishlist_course' );
13
+ echo '<p>' . __( 'No courses in your wishlist!', 'learnpress_wishlist' ) . '</p>';
14
+ do_action( 'learn_press_after_no_wishlist_course' );
15
+ endif;
16
+ do_action( 'learn_press_after_wishlist_course' );
17
+ wp_reset_postdata();
18
+
19
+ do_action( 'learn_press_after_all_wishlist' );
template/wishlist-content.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <?php
3
+ do_action( 'learn_press_before_wishlist_course_title' );
4
+ the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
5
+ do_action( 'learn_press_after_wishlist_course_title' );
6
+
7
+ do_action( 'learn_press_before_wishlist_course_content' );
8
+ the_excerpt();
9
+ do_action( 'learn_press_after_wishlist_course_content' );
10
+
11
+ ?>
12
+ </div>