Version Description
- Compatible with LearnPress version 1.0
Download this release
Release Info
Developer | tunnhn |
Plugin | LearnPress – Course Wishlist |
Version | 1.0 |
Comparing to | |
See all releases |
Code changes from version 0.9.3 to 1.0
- incs/class-lp-addon-wishlist.php +250 -0
- init.php → incs/lp-wishlist-functions.php +7 -98
- lang/default.pot +0 -34
- lang/id_ID.po +0 -34
- languages/learnpress-wishlist-vi.mo +0 -0
- languages/learnpress-wishlist-vi.po +76 -0
- languages/learnpress-wishlist.pot +55 -0
- learnpress-wishlist.php +9 -26
- readme.txt +8 -2
- source/wishlist.css +47 -3
- source/wishlist.js +48 -39
- template/button.php +0 -18
- template/user-wishlist.php +0 -19
- template/wishlist-content.php +0 -12
- templates/button.php +16 -0
- templates/user-wishlist.php +25 -0
- templates/wishlist-content.php +14 -0
incs/class-lp-addon-wishlist.php
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( !defined( 'ABSPATH' ) ) {
|
4 |
+
exit; // Exit if accessed directly
|
5 |
+
}
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class LP_Addon_Wishlist
|
9 |
+
*/
|
10 |
+
class LP_Addon_Wishlist {
|
11 |
+
/**
|
12 |
+
* @var bool
|
13 |
+
*/
|
14 |
+
protected static $_instance = false;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
protected $_tab_slug = 'wishlist';
|
20 |
+
|
21 |
+
/**
|
22 |
+
* LP_Addon_Wishlist constructor.
|
23 |
+
*/
|
24 |
+
function __construct() {
|
25 |
+
|
26 |
+
if ( !function_exists( 'learn_press_load_plugin_text_domain' ) ) {
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
$this->_tab_slug = sanitize_title( __( 'wishlist', 'learnpress-wishlist' ) );
|
31 |
+
add_action( 'init', array( $this, 'init' ) );
|
32 |
+
|
33 |
+
//add_action( 'learn_press_entry_footer_archive', array( $this, 'wishlist_button' ), 10 );
|
34 |
+
//add_action( 'learn_press_course_landing_content', array( $this, 'wishlist_button' ), 10 );
|
35 |
+
//add_action( 'learn_press_course_learning_content', array( $this, 'wishlist_button' ), 10 );
|
36 |
+
|
37 |
+
add_action( 'learn_press_content_learning_summary', array( $this, 'wishlist_button' ), 100 );
|
38 |
+
add_filter( 'learn_press_user_profile_tabs', array( $this, 'wishlist_tab' ), 100, 2 );
|
39 |
+
add_filter( 'learn_press_profile_tab_endpoints', array( $this, 'profile_tab_endpoints' ) );
|
40 |
+
add_action( 'plugins_loaded', array( __CLASS__, 'load_text_domain' ) );
|
41 |
+
add_action( 'init', array( $this, 'require_functions' ) );
|
42 |
+
//add_action( 'learn_press_after_wishlist_course_title', array( $this, 'wishlist_button' ), 10 );
|
43 |
+
|
44 |
+
// assets
|
45 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'wishlist_scripts' ) );
|
46 |
+
|
47 |
+
// ajax actions
|
48 |
+
//add_action( 'wp_ajax_learn_press_toggle_course_wishlist', array( $this, 'toggle_course_wishlist' ) );
|
49 |
+
LP_Request_Handler::register_ajax( 'toggle_course_wishlist', array( $this, 'toggle_course_wishlist' ) );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
function require_functions() {
|
54 |
+
include_once dirname( __FILE__ ) . '/lp-wishlist-functions.php';
|
55 |
+
}
|
56 |
+
|
57 |
+
function init() {
|
58 |
+
define( 'WISHLIST_THEME_TMPL', learn_press_template_path() . '/addons/wishlist/' );
|
59 |
+
|
60 |
+
$endpoint = preg_replace( '!_!', '-', $this->get_tab_slug() );
|
61 |
+
LP()->query_vars[$endpoint] = $endpoint;
|
62 |
+
add_rewrite_endpoint( $endpoint, EP_ROOT | EP_PAGES );
|
63 |
+
}
|
64 |
+
|
65 |
+
function profile_tab_endpoints( $endpoints ) {
|
66 |
+
$endpoints[] = $this->get_tab_slug();
|
67 |
+
return $endpoints;
|
68 |
+
}
|
69 |
+
|
70 |
+
function toggle_course_wishlist() {
|
71 |
+
sleep( 1 );
|
72 |
+
$nonce = !empty( $_POST['nonce'] ) ? $_POST['nonce'] : null;
|
73 |
+
if ( !wp_verify_nonce( $nonce, 'course-toggle-wishlist' ) ) {
|
74 |
+
die ( __( 'You have not permission to do this action', 'learnpress-wishlist' ) );
|
75 |
+
}
|
76 |
+
|
77 |
+
$course_id = !empty( $_POST['course_id'] ) ? absint( $_POST['course_id'] ) : 0;
|
78 |
+
$user_id = get_current_user_id();
|
79 |
+
|
80 |
+
if ( ( get_post_type( $course_id ) != 'lp_course' ) || !$user_id ) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
$state = !empty( $_POST['state'] ) ? $_POST['state'] : false;
|
84 |
+
$wishlist = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
|
85 |
+
if ( $state === false ) {
|
86 |
+
$state = in_array( $course_id, $wishlist ) ? 'off' : 'on';
|
87 |
+
}
|
88 |
+
$pos = array_search( $course_id, $wishlist );
|
89 |
+
if ( $state == 'on' ) {
|
90 |
+
if ( $pos === false ) {
|
91 |
+
$wishlist[] = $course_id;
|
92 |
+
}
|
93 |
+
} else {
|
94 |
+
if ( $pos !== false ) {
|
95 |
+
unset( $wishlist[$pos] );
|
96 |
+
}
|
97 |
+
}
|
98 |
+
if ( sizeof( $wishlist ) ) {
|
99 |
+
update_user_meta( $user_id, '_lpr_wish_list', $wishlist );
|
100 |
+
} else {
|
101 |
+
delete_user_meta( $user_id, '_lpr_wish_list' );
|
102 |
+
}
|
103 |
+
learn_press_send_json(
|
104 |
+
array(
|
105 |
+
'state' => $state,
|
106 |
+
'course_id' => $course_id,
|
107 |
+
'user_id' => $user_id,
|
108 |
+
'title' => $this->_get_state_title( $state ),
|
109 |
+
'message' => '',
|
110 |
+
'button_text' => $state != 'on' ? __( 'Add to Wishlist', 'learnpress-wishlist' ) : __( 'Remove from Wishlist', 'learnpress-wishlist' )
|
111 |
+
)
|
112 |
+
);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @param string $state
|
117 |
+
*
|
118 |
+
* @return mixed
|
119 |
+
*/
|
120 |
+
private function _get_state_title( $state = 'on' ) {
|
121 |
+
return $state == 'on' ? __( 'Remove this course from your wishlist', 'learnpress-wishlist' ) : __( 'Add this course to your wishlist', 'learnpress-wishlist' );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @param string $state
|
126 |
+
*
|
127 |
+
* @return mixed
|
128 |
+
*/
|
129 |
+
private function _get_state_message( $state = 'on' ) {
|
130 |
+
return $state == 'on' ? __( 'This course added to your wishlist', 'learnpress-wishlist' ) : __( 'This course removed from your wishlist', 'learnpress-wishlist' );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Wishlist scripts processing
|
135 |
+
*/
|
136 |
+
function wishlist_scripts() {
|
137 |
+
wp_enqueue_style( 'course-wishlist-style', untrailingslashit( plugins_url( '/', LP_ADDON_WISHLIST_FILE ) ) . '/source/wishlist.css' );
|
138 |
+
wp_enqueue_script( 'course-wishlist-script', untrailingslashit( plugins_url( '/', LP_ADDON_WISHLIST_FILE ) ) . '/source/wishlist.js', array( 'jquery' ) );
|
139 |
+
}
|
140 |
+
|
141 |
+
/*
|
142 |
+
* Show wishlist button
|
143 |
+
*/
|
144 |
+
function wishlist_button( $course_id = null ) {
|
145 |
+
$user_id = get_current_user_id();
|
146 |
+
if ( !$course_id ) {
|
147 |
+
$course_id = get_the_ID();
|
148 |
+
}
|
149 |
+
|
150 |
+
// If user or course are invalid then return.
|
151 |
+
if ( !$user_id || !$course_id ) {
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
|
155 |
+
$classes = array( 'course-wishlist' /* dashicons dashicons-heart heartbeat'*/ );
|
156 |
+
$state = learn_press_user_wishlist_has_course( $course_id, $user_id ) ? 'on' : 'off';
|
157 |
+
|
158 |
+
if ( $state == 'on' ) {
|
159 |
+
$classes[] = 'on';
|
160 |
+
}
|
161 |
+
$classes = apply_filters( 'learn_press_course_wishlist_button_classes', $classes, $course_id );
|
162 |
+
$title = $this->_get_state_title( $state );
|
163 |
+
|
164 |
+
// fetch template
|
165 |
+
learn_press_course_wishlist_template( 'button.php', compact( 'user_id', 'course_id', 'classes', 'title', 'state' ) );
|
166 |
+
}
|
167 |
+
|
168 |
+
function get_tab_slug() {
|
169 |
+
return apply_filters( 'learn_press_course_wishlist_tab_slug', $this->_tab_slug, $this );
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Add Wishlist tab to user profile
|
174 |
+
*
|
175 |
+
* @param $tabs
|
176 |
+
* @param $user
|
177 |
+
*
|
178 |
+
* @return mixed
|
179 |
+
*/
|
180 |
+
function wishlist_tab( $tabs, $user ) {
|
181 |
+
$tabs[$this->get_tab_slug()] = array(
|
182 |
+
'title' => __( 'Wishlist', 'learnpress-wishlist' ),
|
183 |
+
'callback' => array( $this, 'wishlist_tab_content' )
|
184 |
+
);
|
185 |
+
return $tabs;
|
186 |
+
}
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Display content of tab Wishlist
|
190 |
+
*
|
191 |
+
* @param $tab
|
192 |
+
* @param $user
|
193 |
+
* @param $tabs
|
194 |
+
*/
|
195 |
+
function wishlist_tab_content( $tab, $tabs, $user ) {
|
196 |
+
learn_press_course_wishlist_template(
|
197 |
+
'user-wishlist.php',
|
198 |
+
array(
|
199 |
+
'user' => $user,
|
200 |
+
'wishlist' => $this->get_wishlist_courses( $user->id )
|
201 |
+
)
|
202 |
+
);
|
203 |
+
}
|
204 |
+
|
205 |
+
function get_wishlist_courses( $user_id ) {
|
206 |
+
$pid = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
|
207 |
+
|
208 |
+
$args = array(
|
209 |
+
'post_type' => 'lp_course',
|
210 |
+
'post__in' => $pid,
|
211 |
+
'post_status' => 'publish',
|
212 |
+
'ignore_sticky_posts' => true,
|
213 |
+
'posts_per_page' => - 1
|
214 |
+
);
|
215 |
+
$query = new WP_Query( $args );
|
216 |
+
$wishlist = array();
|
217 |
+
global $post;
|
218 |
+
if ( $query->have_posts() ) :
|
219 |
+
while ( $query->have_posts() ) : $query->the_post();
|
220 |
+
$wishlist[$post->ID] = $post;
|
221 |
+
endwhile;
|
222 |
+
endif;
|
223 |
+
wp_reset_postdata();
|
224 |
+
|
225 |
+
return $wishlist;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* @return bool|LP_Addon_Wishlist
|
230 |
+
*/
|
231 |
+
static function instance() {
|
232 |
+
if ( !self::$_instance ) {
|
233 |
+
self::$_instance = new self();
|
234 |
+
}
|
235 |
+
return self::$_instance;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Load text domain for addon
|
240 |
+
*/
|
241 |
+
static function load_text_domain() {
|
242 |
+
if( function_exists('learn_press_load_plugin_text_domain')){ learn_press_load_plugin_text_domain(LP_ADDON_WISHLIST_PATH, true ); }
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
add_action( 'learn_press_ready', array( 'LP_Addon_Wishlist', 'instance' ) );
|
247 |
+
|
248 |
+
function learn_press_course_wishlist_template( $name, $args = null ) {
|
249 |
+
learn_press_get_template( $name, $args, WISHLIST_THEME_TMPL, WISHLIST_TMPL );
|
250 |
+
}
|
init.php → incs/lp-wishlist-functions.php
RENAMED
@@ -1,100 +1,24 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
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 |
-
|
27 |
-
|
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 |
-
|
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 ) {
|
@@ -152,7 +76,7 @@ if ( !function_exists( 'learn_press_buddypress_is_active' ) ) {
|
|
152 |
}
|
153 |
}
|
154 |
|
155 |
-
if ( learn_press_buddypress_is_active()
|
156 |
|
157 |
/*
|
158 |
* Set up sub admin bar wishlist
|
@@ -215,20 +139,5 @@ if ( learn_press_buddypress_is_active() && 1==2 ) {
|
|
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 |
-
|
1 |
<?php
|
2 |
|
3 |
+
function learn_press_user_wishlist_has_course( $course_id = null, $user_id = null ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
if ( !$course_id ) {
|
5 |
$course_id = get_the_ID();
|
6 |
}
|
7 |
|
8 |
+
if ( !$user_id ) {
|
9 |
+
$user_id = get_current_user_id();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
}
|
|
|
|
|
|
|
11 |
|
12 |
+
$wish_list = (array) get_user_meta( $user_id, '_lpr_wish_list', true );
|
13 |
+
return in_array( $course_id, $wish_list );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
15 |
|
|
|
16 |
/**
|
17 |
* Update user's wish list
|
18 |
*
|
19 |
* @param $user_id
|
20 |
* @param $course_id
|
21 |
*/
|
|
|
22 |
add_action( 'learn_press_after_take_course', 'learn_press_update_wish_list', 10, 2 );
|
23 |
function learn_press_update_wish_list( $user_id, $course_id ) {
|
24 |
if ( !$user_id || !$course_id ) {
|
76 |
}
|
77 |
}
|
78 |
|
79 |
+
if ( learn_press_buddypress_is_active() ) {
|
80 |
|
81 |
/*
|
82 |
* Set up sub admin bar wishlist
|
139 |
}
|
140 |
}
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
+
|
lang/default.pot
DELETED
@@ -1,34 +0,0 @@
|
|
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
DELETED
@@ -1,34 +0,0 @@
|
|
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!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/learnpress-wishlist-vi.mo
ADDED
Binary file
|
languages/learnpress-wishlist-vi.po
ADDED
@@ -0,0 +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 ""
|
languages/learnpress-wishlist.pot
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: 2016-03-23 15:48+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 |
+
#: incs/class-lp-addon-wishlist.php:25
|
21 |
+
msgid "wishlist"
|
22 |
+
msgstr ""
|
23 |
+
|
24 |
+
#: incs/class-lp-addon-wishlist.php:69
|
25 |
+
msgid "You have not permission to do this action"
|
26 |
+
msgstr ""
|
27 |
+
|
28 |
+
#: incs/class-lp-addon-wishlist.php:115
|
29 |
+
msgid "Remove this course from your wishlist"
|
30 |
+
msgstr ""
|
31 |
+
|
32 |
+
#: incs/class-lp-addon-wishlist.php:115
|
33 |
+
msgid "Add this course to your wishlist"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: incs/class-lp-addon-wishlist.php:124
|
37 |
+
msgid "This course added to your wishlist"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: incs/class-lp-addon-wishlist.php:124
|
41 |
+
msgid "This course removed from your wishlist"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: incs/class-lp-addon-wishlist.php:176 incs/lp-wishlist-functions.php:47
|
45 |
+
#: incs/lp-wishlist-functions.php:93 incs/lp-wishlist-functions.php:107
|
46 |
+
msgid "Wishlist"
|
47 |
+
msgstr ""
|
48 |
+
|
49 |
+
#: incs/lp-wishlist-functions.php:129
|
50 |
+
msgid "Your wishlist"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: template/user-wishlist.php:22
|
54 |
+
msgid "No courses in your wishlist!"
|
55 |
+
msgstr ""
|
learnpress-wishlist.php
CHANGED
@@ -3,37 +3,20 @@
|
|
3 |
Plugin Name: LearnPress Courses Wishlist
|
4 |
Plugin URI: http://thimpress.com/learnpress
|
5 |
Description: Wishlist feature
|
6 |
-
Author:
|
7 |
-
Version: 0
|
8 |
Author URI: http://thimpress.com
|
9 |
Tags: learnpress
|
|
|
|
|
10 |
*/
|
11 |
if ( !defined( 'ABSPATH' ) ) {
|
12 |
exit; // Exit if accessed directly
|
13 |
}
|
14 |
|
15 |
-
define( '
|
16 |
-
|
17 |
-
|
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 |
|
|
|
|
3 |
Plugin Name: LearnPress Courses Wishlist
|
4 |
Plugin URI: http://thimpress.com/learnpress
|
5 |
Description: Wishlist feature
|
6 |
+
Author: ThimPress
|
7 |
+
Version: 1.0
|
8 |
Author URI: http://thimpress.com
|
9 |
Tags: learnpress
|
10 |
+
Text Domain: learnpress-wishlist
|
11 |
+
Domain Path: /languages/
|
12 |
*/
|
13 |
if ( !defined( 'ABSPATH' ) ) {
|
14 |
exit; // Exit if accessed directly
|
15 |
}
|
16 |
|
17 |
+
define( 'LP_ADDON_WISHLIST_FILE', __FILE__ );
|
18 |
+
define( 'LP_ADDON_WISHLIST_PATH', dirname( __FILE__ ) );
|
19 |
+
define( 'WISHLIST_TMPL', LP_ADDON_WISHLIST_PATH . '/templates/' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
// include class
|
22 |
+
require_once( LP_ADDON_WISHLIST_PATH . '/incs/class-lp-addon-wishlist.php' );
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== LearnPress Wishlist - WordPress extension for LearnPress ===
|
2 |
-
Contributors: thimpress,
|
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
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -34,6 +34,9 @@ Want to see it in action? See our [Educational WordPress Theme](http://themefore
|
|
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**
|
@@ -55,6 +58,9 @@ Check out <a href="http://docs.thimpress.com/learnpress" target="_blank">LearnPr
|
|
55 |
|
56 |
== Changelog ==
|
57 |
|
|
|
|
|
|
|
58 |
= 0.9.1 =
|
59 |
1. Updated language file
|
60 |
|
1 |
=== LearnPress Wishlist - WordPress extension for LearnPress ===
|
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: 4.2.2
|
7 |
+
Stable tag: 1.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
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 |
+
**Credit**
|
38 |
+
halink0803
|
39 |
+
|
40 |
== Installation ==
|
41 |
|
42 |
**From your WordPress dashboard**
|
58 |
|
59 |
== Changelog ==
|
60 |
|
61 |
+
= 1.0 =
|
62 |
+
+ Compatible with LearnPress version 1.0
|
63 |
+
|
64 |
= 0.9.1 =
|
65 |
1. Updated language file
|
66 |
|
source/wishlist.css
CHANGED
@@ -1,8 +1,52 @@
|
|
1 |
-
|
2 |
color: #d3d3d3;
|
|
|
3 |
cursor: pointer;
|
|
|
4 |
}
|
5 |
-
.course-
|
6 |
color: #ff0084;
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
}
|
1 |
+
/*.course-wishlist {
|
2 |
color: #d3d3d3;
|
3 |
+
transition: all 1s;
|
4 |
cursor: pointer;
|
5 |
+
vertical-align: middle;
|
6 |
}
|
7 |
+
.course-wishlist.on {
|
8 |
color: #ff0084;
|
9 |
+
}
|
10 |
+
|
11 |
+
.course-wishlist:hover {
|
12 |
+
color: #ff0084;
|
13 |
+
}
|
14 |
+
.course-wishlist.on:hover {
|
15 |
+
color: #d3d3d3;
|
16 |
+
}*/
|
17 |
+
#learn-press-profile-tab-course-wishlist.has-courses .learn-press-message{
|
18 |
+
display: none;
|
19 |
+
}
|
20 |
+
.course-wishlist.heartbeat{
|
21 |
+
animation-name: course-wishlist-heartbeat;
|
22 |
+
animation-duration: 1s;
|
23 |
+
animation-timing-function: ease-out;
|
24 |
+
animation-delay: 3s;
|
25 |
+
animation-direction: alternate;
|
26 |
+
animation-iteration-count: infinite;
|
27 |
+
animation-fill-mode: none;
|
28 |
+
animation-play-state: running;
|
29 |
+
}
|
30 |
+
|
31 |
+
.course-wishlist.heartbeat.ajaxload{
|
32 |
+
animation-duration: 0.3s;
|
33 |
+
animation-name: course-wishlist-heartbeat-ajaxload;
|
34 |
+
animation-delay: 0s;
|
35 |
+
}
|
36 |
+
|
37 |
+
@keyframes course-wishlist-heartbeat {
|
38 |
+
0% {
|
39 |
+
transform: scale(1);
|
40 |
+
}
|
41 |
+
100% {
|
42 |
+
transform: scale(1.2);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
@keyframes course-wishlist-heartbeat-ajaxload {
|
46 |
+
0% {
|
47 |
+
transform: scale(1);
|
48 |
+
}
|
49 |
+
100% {
|
50 |
+
transform: scale(1.5);
|
51 |
+
}
|
52 |
}
|
source/wishlist.js
CHANGED
@@ -1,44 +1,53 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
$.ajax({
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
17 |
},
|
18 |
-
success: function(){
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$this.removeClass('loading')
|
39 |
}
|
40 |
});
|
41 |
-
}
|
|
|
|
|
|
|
42 |
});
|
43 |
-
|
44 |
-
});
|
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')) {
|
10 |
+
return;
|
11 |
+
}
|
12 |
+
$button.addClass('ajaxload').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 = LearnPress.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')
|
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);
|
|
template/button.php
DELETED
@@ -1,18 +0,0 @@
|
|
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
DELETED
@@ -1,19 +0,0 @@
|
|
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
DELETED
@@ -1,12 +0,0 @@
|
|
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates/button.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for displaying button to toggle course wishlist on/off
|
4 |
+
*
|
5 |
+
* @author ThimPress
|
6 |
+
*/
|
7 |
+
defined( 'ABSPATH' ) || exit();
|
8 |
+
printf(
|
9 |
+
'<button class="learn-press-course-wishlist-button-%2$d %s" data-id="%s" data-nonce="%s" title="%s" data-text="%s">%s</button>',
|
10 |
+
join( " ", $classes ),
|
11 |
+
$course_id,
|
12 |
+
wp_create_nonce( 'course-toggle-wishlist' ),
|
13 |
+
$title,
|
14 |
+
__( 'Processing', 'learnpress-wishlist' ),
|
15 |
+
$state == 'on' ? __( 'Remove from Wishlist', 'learnpress-wishlist' ) : __( 'Add to Wishlist', 'learnpress-wishlist' )
|
16 |
+
);
|
templates/user-wishlist.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for displaying the list of course is in wishlist
|
4 |
+
*
|
5 |
+
* @author ThimPress
|
6 |
+
*/
|
7 |
+
|
8 |
+
defined( 'ABSPATH' ) || exit();
|
9 |
+
|
10 |
+
global $post;
|
11 |
+
|
12 |
+
$has_courses = $wishlist ? true : false;
|
13 |
+
?>
|
14 |
+
<div id="learn-press-profile-tab-course-wishlist" class="<?php echo $has_courses ? 'has-courses' : '';?>">
|
15 |
+
<?php if ( $has_courses ) : ?>
|
16 |
+
<ul class="learn-press-wishlist-courses">
|
17 |
+
<?php foreach( $wishlist as $post ) { ?>
|
18 |
+
<?php learn_press_course_wishlist_template( 'wishlist-content.php' ); ?>
|
19 |
+
<?php } ?>
|
20 |
+
</ul>
|
21 |
+
<?php endif;?>
|
22 |
+
<?php learn_press_display_message( apply_filters( 'learn_press_wishlist_empty_course', __( 'No courses in your wishlist!', 'learnpress-wishlist' ) ) ); ?>
|
23 |
+
</div>
|
24 |
+
<?php
|
25 |
+
wp_reset_postdata();
|
templates/wishlist-content.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Template for displaying the list of course is in wishlist
|
4 |
+
*
|
5 |
+
* @author ThimPress
|
6 |
+
*/
|
7 |
+
|
8 |
+
defined( 'ABSPATH' ) || exit();
|
9 |
+
global $post;
|
10 |
+
?>
|
11 |
+
<li id="learn-press-tab-wishlist-course-<?php echo $post->ID;?>" data-context="tab-wishlist">
|
12 |
+
<a href="<?php echo esc_url( get_permalink() );?>" rel="bookmark"><?php echo get_the_title();?></a>
|
13 |
+
<?php LP_Addon_Wishlist::instance()->wishlist_button( $post->ID );?>
|
14 |
+
</li>
|