PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/admin/class-lp-setup-wizard.php +21 -136 4.4.54.4.8 View file →
@@ -73,63 +73,13 @@
73 73 /**
74 74 * Display setup page a ignore anything else in the rest
75 75 */
76 76 public function setup_wizard() {
77 - if ( 'lp-setup' !== LP_Request::get_param( 'page' ) || ! current_user_can( 'install_plugins' ) ) {
77 + if ( 'lp-setup' !== LP_Request::get_param( 'page' )
78 + || ! current_user_can( 'install_plugins' ) ) {
78 79 return;
79 80 }
80 81
81 - if ( 'finish' === LP_Request::get_param( 'step' ) ) {
82 - update_option( 'learn_press_setup_wizard_completed', 'yes' );
83 - }
84 -
85 - $this->save();
86 -
87 - // Refresh new changes
88 - // LP_Settings::instance()->refresh();
89 -
90 - $assets = LP_Admin_Assets::instance();
91 -
92 - // tungnx: fix error with Woocommerce
93 - remove_action( 'admin_enqueue_scripts', array( 'Automattic\WooCommerce\Admin\Loader', 'register_scripts' ) );
94 - remove_action( 'admin_enqueue_scripts', array( 'Automattic\WooCommerce\Admin\Loader', 'load_scripts' ), 15 );
95 - remove_action(
96 - 'admin_enqueue_scripts',
97 - array(
98 - 'Automattic\WooCommerce\Admin\Features\Features',
99 - 'load_scripts',
100 - ),
101 - 15
102 - );
103 - // End fix
104 - // @do_action( 'admin_enqueue_scripts' );
105 -
106 - wp_enqueue_style( 'buttons' );
107 - wp_enqueue_style( 'common' );
108 - wp_enqueue_style( 'forms' );
109 - wp_enqueue_style( 'themes' );
110 - wp_enqueue_style( 'dashboard' );
111 - wp_enqueue_style( 'widgets' );
112 - wp_enqueue_style( 'lp-admin', $assets->url( 'css/admin/admin.css' ) );
113 - wp_enqueue_style( 'lp-setup', $assets->url( 'css/admin/setup.css' ) );
114 - //wp_enqueue_style( 'lp-select2', $assets->url( 'src/css/vendor/select2.min.css' ) );
115 - wp_enqueue_style( 'lp-tom-select', $assets->url( 'src/css/vendor/tom-select.min.css' ) );
116 -
117 - //wp_enqueue_script( 'lp-select2', $assets->url( 'src/js/vendor/select2.full.min.js' ) );
118 - wp_enqueue_script( 'lp-utils', $assets->url( 'js/dist/utils.js' ) );
119 - wp_enqueue_script( 'lp-admin', $assets->url( 'js/dist/admin/admin.js' ), uniqid(), true );
120 - wp_register_script(
121 - 'lp-setup',
122 - $assets->url( 'js/dist/admin/pages/setup.js' ),
123 - array( 'jquery', 'lp-admin' ),
124 - uniqid(),
125 - true
126 - );
127 - wp_localize_script( 'lp-setup', 'lpGlobalSettings', learn_press_global_script_params() );
128 - $lp_admin_assets = LP_Admin_Assets::instance();
129 - wp_localize_script( 'lp-setup', 'lpDataAdmin', $lp_admin_assets->localize_data_global(), [ 'id' => 'lpDataAdmin' ] );
130 - wp_localize_script( 'lp-setup', 'lpData', $lp_admin_assets->localize_data_global(), [ 'id' => 'lpDataAdmin' ] );
131 - wp_enqueue_script( 'lp-setup' );
132 82 learn_press_admin_view( 'setup/header' );
133 83 learn_press_admin_view( 'setup/content', array( 'steps' => $this->get_steps() ) );
134 84 learn_press_admin_view( 'setup/footer' );
135 85
@@ -136,79 +86,8 @@
136 86 die();
137 87 }
138 88
139 89 /**
140 - * @TODO tungnx - need review
141 - */
142 - public function save() {
143 - // Check is request post
144 - $posts = $_POST;
145 - if ( empty( $posts ) ) {
146 - return;
147 - }
148 -
149 - $step = LP_Request::get_param( 'lp-setup-step' );
150 -
151 - if ( ! wp_verify_nonce( LP_Request::get_param( 'lp-setup-nonce' ), 'lp-setup-step-' . $step ) ) {
152 - return;
153 - }
154 -
155 - $postdata = LP_Request::get_param( 'settings' );
156 - $steps = array( 'payment', 'pages', 'currency', 'emails' );
157 -
158 - if ( $this->get_current_step() === 'pages' ) {
159 - $key_pages = [
160 - 'learn_press_courses_page_id',
161 - 'learn_press_instructors_page_id',
162 - 'learn_press_single_instructor_page_id',
163 - 'learn_press_profile_page_id',
164 - 'learn_press_checkout_page_id',
165 - 'learn_press_become_a_teacher_page_id',
166 - 'learn_press_term_conditions_page_id',
167 - 'learn_press_logout_redirect_page_id',
168 - ];
169 - foreach ( $key_pages as $key ) {
170 - if ( isset( $_POST[ $key ] ) ) {
171 - update_option( $key, sanitize_text_field( $_POST[ $key ] ) );
172 - }
173 - }
174 - }
175 -
176 - if ( ( 'yes' !== LP_Request::get_param( 'skip' ) )
177 - && ! empty( $postdata )
178 - && in_array( $step, $steps ) ) {
179 - if ( array_key_exists( 'paypal', $postdata ) ) {
180 - update_option( 'learn_press_paypal', $postdata['paypal'] );
181 - }
182 -
183 - if ( array_key_exists( 'currency', $postdata ) ) {
184 - foreach ( $postdata['currency'] as $k => $v ) {
185 - update_option( 'learn_press_' . $k, $v );
186 - }
187 - }
188 -
189 - if ( array_key_exists( 'emails', $postdata ) ) {
190 - if ( ! empty( $postdata['emails']['enable'] ) && ( $postdata['emails']['enable'] === 'yes' ) ) {
191 - $emails = LP_Emails::instance()->emails;
192 -
193 - if ( $emails ) {
194 - foreach ( $emails as $email ) {
195 - $response[ $email->id ] = $email->enable( true );
196 - }
197 - }
198 - }
199 - }
200 - }
201 -
202 - $lp_settings_cache = new LP_Settings_Cache( true );
203 - $lp_settings_cache->clean_lp_settings();
204 -
205 - do_action( 'learn-press/setup-wizard/update-settings', $postdata, $step );
206 -
207 - wp_send_json_success();
208 - }
209 -
210 - /**
211 90 * Return array of all steps are available when running setup wizard.
212 91 *
213 92 * @return array
214 93 */
@@ -220,28 +99,26 @@
220 99 array(
221 100 'welcome' => array(
222 101 'title' => __( 'Welcome', 'learnpress' ),
223 102 'callback' => array( $this, 'step_welcome' ),
224 - 'next_button' => __( 'Run Setup Wizard', 'learnpress' ),
103 + 'next_button' => __( 'Get Started', 'learnpress' ),
225 104 ),
105 + 'learning-experience' => array(
106 + 'title' => __( 'Learning Experience', 'learnpress' ),
107 + 'callback' => array( $this, 'step_learning_experience' ),
108 + ),
226 109 'pages' => array(
227 110 'title' => __( 'Pages', 'learnpress' ),
228 111 'callback' => array( $this, 'step_pages' ),
229 112 ),
230 - // 'currency' => array(
231 - // 'title' => __( 'Currency', 'learnpress' ),
232 - // 'callback' => array( $this, 'step_currency' ),
233 - // 'back_button' => false,
234 - // 'skip_prev_button' => false
235 - // ),
236 113 'payment' => array(
237 - 'title' => __( 'Payment', 'learnpress' ),
114 + 'title' => __( 'Payment & Currency', 'learnpress' ),
238 115 'callback' => array( $this, 'step_payment' ),
239 116 ),
240 - // 'emails' => array(
241 - // 'title' => __( 'Emails', 'learnpress' ),
242 - // 'callback' => array( $this, 'step_emails' )
243 - // ),
117 + 'emails' => array(
118 + 'title' => __( 'Emails', 'learnpress' ),
119 + 'callback' => array( $this, 'step_emails' ),
120 + ),
244 121 'finish' => array(
245 122 'title' => __( 'Finish', 'learnpress' ),
246 123 'callback' => array( $this, 'step_finish' ),
247 124 ),
@@ -268,9 +145,9 @@
268 145 *
269 146 * @return mixed|string
270 147 */
271 148 public function get_current_step( $key = true ) {
272 - $current = LP_Request::get_string( 'step' );
149 + $current = LP_Request::get_param( 'step' );
273 150 $steps = $this->get_steps();
274 151
275 152 if ( empty( $steps[ $current ] ) ) {
276 153 $key_steps = array_keys( $steps );
@@ -381,8 +258,15 @@
381 258 learn_press_admin_view( 'setup/steps/welcome' );
382 259 }
383 260
384 261 /**
262 + * Learning Experience step content.
263 + */
264 + public function step_learning_experience() {
265 + learn_press_admin_view( 'setup/steps/learning-experience' );
266 + }
267 +
268 + /**
385 269 * Currency step content.
386 270 */
387 271 public function step_currency() {
388 272 learn_press_admin_view( 'setup/steps/currency' );
@@ -401,8 +285,9 @@
401 285 }
402 286
403 287 public function step_finish() {
404 288 learn_press_admin_view( 'setup/steps/finish' );
289 + update_option( 'learn_press_setup_wizard_completed', 'yes' );
405 290 }
406 291
407 292 public function scripts() {
408 293 }