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 +24 -151 4.4.14.4.8 View file →
@@ -21,46 +21,11 @@
21 21 protected function __construct() {
22 22 add_action( 'admin_menu', array( $this, 'admin_menu' ) );
23 23 add_action( 'admin_init', array( $this, 'setup_wizard' ) );
24 24 add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
25 -
26 - $actions = array(
27 - 'setup-create-pages' => 'create_pages',
28 - 'get-price-format' => 'get_price_format',
29 - );
30 -
31 - foreach ( $actions as $action => $callback ) {
32 - LP_Request::register_ajax( $action, array( $this, $callback ) );
33 - }
34 25 }
35 26
36 27 /**
37 - * Create static pages action
38 - */
39 - public function create_pages() {
40 - if ( ! wp_verify_nonce( LP_Request::get_string( '_wpnonce', 'setup-create-pages' ) ) ) {
41 - die();
42 - }
43 -
44 - $settings = LP_Request::get( 'settings' );
45 - foreach ( $settings['pages'] as $page => $page_id ) {
46 - if ( empty( $page_id ) ) {
47 - $_REQUEST['settings']['pages'][ $page ] = $this->create_page( $page );
48 - }
49 - }
50 -
51 - LP_Request::$ajax_shutdown = false;
52 - }
53 -
54 - /**
55 - * Get sample format price
56 - */
57 - public static function get_price_format() {
58 - self::instance()->save();
59 - die();
60 - }
61 -
62 - /**
63 28 * Create page by type.
64 29 *
65 30 * @param string $page
66 31 *
@@ -96,11 +61,13 @@
96 61 /**
97 62 * Add an empty menu item for validating page.
98 63 */
99 64 public function admin_menu() {
100 - if ( 'lp-setup' !== LP_Request::get_string( 'page' ) || ! current_user_can( 'install_plugins' ) ) {
65 + if ( 'lp-setup' !== LP_Request::get_param( 'page' )
66 + || ! current_user_can( 'install_plugins' ) ) {
101 67 return;
102 68 }
69 +
103 70 add_dashboard_page( '', '', 'manage_options', 'lp-setup', '' );
104 71 }
105 72
106 73 /**
@@ -106,64 +73,13 @@
106 73 /**
107 74 * Display setup page a ignore anything else in the rest
108 75 */
109 76 public function setup_wizard() {
110 - if ( 'lp-setup' !== LP_Request::get_string( 'page' ) || ! current_user_can( 'install_plugins' ) ) {
77 + if ( 'lp-setup' !== LP_Request::get_param( 'page' )
78 + || ! current_user_can( 'install_plugins' ) ) {
111 79 return;
112 80 }
113 81
114 - if ( 'finish' === LP_Request::get_string( 'step' ) ) {
115 - update_option( 'learn_press_setup_wizard_completed', 'yes' );
116 - }
117 -
118 - $this->save();
119 -
120 - // Refresh new changes
121 - // LP_Settings::instance()->refresh();
122 -
123 - $assets = LP_Admin_Assets::instance();
124 -
125 - // tungnx: fix error with Woocommerce
126 - remove_action( 'admin_enqueue_scripts', array( 'Automattic\WooCommerce\Admin\Loader', 'register_scripts' ) );
127 - remove_action( 'admin_enqueue_scripts', array( 'Automattic\WooCommerce\Admin\Loader', 'load_scripts' ), 15 );
128 - remove_action(
129 - 'admin_enqueue_scripts',
130 - array(
131 - 'Automattic\WooCommerce\Admin\Features\Features',
132 - 'load_scripts',
133 - ),
134 - 15
135 - );
136 - // End fix
137 - // @do_action( 'admin_enqueue_scripts' );
138 -
139 - wp_enqueue_style( 'buttons' );
140 - wp_enqueue_style( 'common' );
141 - wp_enqueue_style( 'forms' );
142 - wp_enqueue_style( 'themes' );
143 - wp_enqueue_style( 'dashboard' );
144 - wp_enqueue_style( 'widgets' );
145 - wp_enqueue_style( 'lp-admin', $assets->url( 'css/admin/admin.css' ) );
146 - wp_enqueue_style( 'lp-setup', $assets->url( 'css/admin/setup.css' ) );
147 - wp_enqueue_style( 'lp-select2', $assets->url( 'src/css/vendor/select2.min.css' ) );
148 - wp_enqueue_style( 'lp-tom-select', $assets->url( 'src/css/vendor/tom-select.min.css' ) );
149 -
150 - wp_enqueue_script( 'lp-select2', $assets->url( 'src/js/vendor/select2.full.min.js' ) );
151 - wp_enqueue_script( 'lp-utils', $assets->url( 'js/dist/utils.js' ) );
152 - wp_enqueue_script( 'lp-admin', $assets->url( 'js/dist/admin/admin.js' ), uniqid(), true );
153 - wp_enqueue_script( 'drop-down-page', $assets->url( 'src/js/admin/share/dropdown-pages.js' ), uniqid(), true );
154 - wp_register_script(
155 - 'lp-setup',
156 - $assets->url( 'js/dist/admin/pages/setup.js' ),
157 - array( 'jquery', 'lp-admin' ),
158 - uniqid(),
159 - true
160 - );
161 - wp_localize_script( 'lp-setup', 'lpGlobalSettings', learn_press_global_script_params() );
162 - $lp_admin_assets = LP_Admin_Assets::instance();
163 - wp_localize_script( 'lp-setup', 'lpDataAdmin', $lp_admin_assets->localize_data_global(), [ 'id' => 'lpDataAdmin' ] );
164 - wp_localize_script( 'lp-setup', 'lpData', $lp_admin_assets->localize_data_global(), [ 'id' => 'lpDataAdmin' ] );
165 - wp_enqueue_script( 'lp-setup' );
166 82 learn_press_admin_view( 'setup/header' );
167 83 learn_press_admin_view( 'setup/content', array( 'steps' => $this->get_steps() ) );
168 84 learn_press_admin_view( 'setup/footer' );
169 85
@@ -170,57 +86,8 @@
170 86 die();
171 87 }
172 88
173 89 /**
174 - * @TODO tungnx - need review
175 - */
176 - public function save() {
177 - $step = LP_Request::get_string( 'lp-setup-step' );
178 -
179 - if ( ! wp_verify_nonce( LP_Request::get_string( 'lp-setup-nonce' ), 'lp-setup-step-' . $step ) ) {
180 - return;
181 - }
182 -
183 - $postdata = LP_Request::get_param( 'settings' );
184 - $steps = array( 'payment', 'pages', 'currency', 'emails' );
185 -
186 - if ( ( 'yes' !== LP_Request::get_param( 'skip' ) ) && in_array( $step, $steps ) ) {
187 - if ( array_key_exists( 'paypal', $postdata ) ) {
188 - update_option( 'learn_press_paypal', $postdata['paypal'] );
189 - }
190 -
191 - if ( array_key_exists( 'currency', $postdata ) ) {
192 - foreach ( $postdata['currency'] as $k => $v ) {
193 - update_option( 'learn_press_' . $k, $v );
194 - }
195 - }
196 -
197 - if ( array_key_exists( 'pages', $postdata ) ) {
198 - foreach ( $postdata['pages'] as $k => $v ) {
199 - update_option( 'learn_press_' . $k, $v );
200 - }
201 - }
202 -
203 - if ( array_key_exists( 'emails', $postdata ) ) {
204 - if ( ! empty( $postdata['emails']['enable'] ) && ( $postdata['emails']['enable'] === 'yes' ) ) {
205 - $emails = LP_Emails::instance()->emails;
206 -
207 - if ( $emails ) {
208 - foreach ( $emails as $email ) {
209 - $response[ $email->id ] = $email->enable( true );
210 - }
211 - }
212 - }
213 - }
214 -
215 - $lp_settings_cache = new LP_Settings_Cache( true );
216 - $lp_settings_cache->clean_lp_settings();
217 - }
218 -
219 - do_action( 'learn-press/setup-wizard/update-settings', $postdata, $step );
220 - }
221 -
222 - /**
223 90 * Return array of all steps are available when running setup wizard.
224 91 *
225 92 * @return array
226 93 */
@@ -232,28 +99,26 @@
232 99 array(
233 100 'welcome' => array(
234 101 'title' => __( 'Welcome', 'learnpress' ),
235 102 'callback' => array( $this, 'step_welcome' ),
236 - 'next_button' => __( 'Run Setup Wizard', 'learnpress' ),
103 + 'next_button' => __( 'Get Started', 'learnpress' ),
237 104 ),
105 + 'learning-experience' => array(
106 + 'title' => __( 'Learning Experience', 'learnpress' ),
107 + 'callback' => array( $this, 'step_learning_experience' ),
108 + ),
238 109 'pages' => array(
239 110 'title' => __( 'Pages', 'learnpress' ),
240 111 'callback' => array( $this, 'step_pages' ),
241 112 ),
242 - // 'currency' => array(
243 - // 'title' => __( 'Currency', 'learnpress' ),
244 - // 'callback' => array( $this, 'step_currency' ),
245 - // 'back_button' => false,
246 - // 'skip_prev_button' => false
247 - // ),
248 113 'payment' => array(
249 - 'title' => __( 'Payment', 'learnpress' ),
114 + 'title' => __( 'Payment & Currency', 'learnpress' ),
250 115 'callback' => array( $this, 'step_payment' ),
251 116 ),
252 - // 'emails' => array(
253 - // 'title' => __( 'Emails', 'learnpress' ),
254 - // 'callback' => array( $this, 'step_emails' )
255 - // ),
117 + 'emails' => array(
118 + 'title' => __( 'Emails', 'learnpress' ),
119 + 'callback' => array( $this, 'step_emails' ),
120 + ),
256 121 'finish' => array(
257 122 'title' => __( 'Finish', 'learnpress' ),
258 123 'callback' => array( $this, 'step_finish' ),
259 124 ),
@@ -280,9 +145,9 @@
280 145 *
281 146 * @return mixed|string
282 147 */
283 148 public function get_current_step( $key = true ) {
284 - $current = LP_Request::get_string( 'step' );
149 + $current = LP_Request::get_param( 'step' );
285 150 $steps = $this->get_steps();
286 151
287 152 if ( empty( $steps[ $current ] ) ) {
288 153 $key_steps = array_keys( $steps );
@@ -393,8 +258,15 @@
393 258 learn_press_admin_view( 'setup/steps/welcome' );
394 259 }
395 260
396 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 + /**
397 269 * Currency step content.
398 270 */
399 271 public function step_currency() {
400 272 learn_press_admin_view( 'setup/steps/currency' );
@@ -413,8 +285,9 @@
413 285 }
414 286
415 287 public function step_finish() {
416 288 learn_press_admin_view( 'setup/steps/finish' );
289 + update_option( 'learn_press_setup_wizard_completed', 'yes' );
417 290 }
418 291
419 292 public function scripts() {
420 293 }