| Total Complexity | 76 |
| Total Lines | 843 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Complex classes like GetPaid_Admin_Setup_Wizard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use GetPaid_Admin_Setup_Wizard, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 20 | class GetPaid_Admin_Setup_Wizard { |
||
| 21 | |||
| 22 | /** @var string Current Step */ |
||
| 23 | private $step = ''; |
||
| 24 | |||
| 25 | /** @var array Steps for the setup wizard */ |
||
| 26 | private $steps = array(); |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Hook in tabs. |
||
| 30 | */ |
||
| 31 | public function __construct() { |
||
| 32 | if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) { |
||
| 33 | add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
||
| 34 | add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
||
| 35 | |||
| 36 | // add default content action |
||
| 37 | add_action( 'geodir_wizard_content_dummy_data', array( __CLASS__, 'content_dummy_data' ) ); |
||
| 38 | add_action( 'geodir_wizard_content_sidebars', array( __CLASS__, 'content_sidebars' ) ); |
||
| 39 | add_action( 'geodir_wizard_content_menus', array( __CLASS__, 'content_menus' ) ); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Add admin menus/screens. |
||
| 45 | */ |
||
| 46 | public function admin_menus() { |
||
| 47 | add_dashboard_page( '', '', 'manage_options', 'gp-setup', '' ); |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Show the setup wizard. |
||
| 52 | * |
||
| 53 | * @since 2.0.0 |
||
| 54 | */ |
||
| 55 | public function setup_wizard() { |
||
| 117 | } |
||
| 118 | |||
| 119 | /** |
||
| 120 | * Setup Wizard Header. |
||
| 121 | * |
||
| 122 | * @since 2.0.0 |
||
| 123 | */ |
||
| 124 | public function setup_wizard_header() { |
||
| 125 | ?> |
||
| 126 | <!DOCTYPE html> |
||
| 127 | <html <?php language_attributes(); ?> class="bsui"> |
||
| 128 | <head> |
||
| 129 | <meta name="viewport" content="width=device-width"/> |
||
| 130 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
||
| 131 | <title><?php esc_html_e( 'GetPaid › Setup Wizard', 'invoicing' ); ?></title> |
||
| 132 | <?php |
||
| 133 | |||
| 134 | wp_register_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array( ), WPINV_VERSION ); |
||
| 135 | wp_enqueue_style( 'font-awesome' ); |
||
| 136 | do_action( 'admin_print_styles' ); ?> |
||
| 137 | <?php do_action( 'admin_head' ); ?> |
||
| 138 | <style> |
||
| 139 | body,p{ |
||
| 140 | font-size: 16px; |
||
| 141 | font-weight: normal; |
||
| 142 | } |
||
| 143 | |||
| 144 | <?php |
||
| 145 | $aui_settings = AyeCode_UI_Settings::instance(); |
||
| 146 | echo $aui_settings::css_primary('#009874',true); |
||
| 147 | ?> |
||
| 148 | |||
| 149 | |||
| 150 | </style> |
||
| 151 | </head> |
||
| 152 | <body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;"> |
||
| 153 | <?php |
||
| 154 | if(isset($_REQUEST['step'])){ |
||
| 155 | $this->setup_wizard_steps(); |
||
| 156 | }else{ |
||
| 157 | echo "<div class='mb-3'> </div>"; |
||
| 158 | } |
||
| 159 | |||
| 160 | ?> |
||
| 161 | <h1 class="h2 text-center pb-3"> |
||
| 162 | <a class=" text-decoration-none" href="https://wpgetpaid.com/"> |
||
| 163 | <span class="text-black-50"> |
||
| 164 | <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" /> |
||
| 165 | </span> |
||
| 166 | </a> |
||
| 167 | </h1> |
||
| 168 | <?php |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Output the steps. |
||
| 173 | * |
||
| 174 | * @since 2.0.0 |
||
| 175 | */ |
||
| 176 | public function setup_wizard_steps() { |
||
| 195 | <?php |
||
| 196 | } |
||
| 197 | |||
| 198 | /** |
||
| 199 | * Output the content for the current step. |
||
| 200 | * |
||
| 201 | * @since 2.0.0 |
||
| 202 | */ |
||
| 203 | public function setup_wizard_content() { |
||
| 204 | echo '<div class="gp-setup-content rowx mw-100 text-center mb-3">'; |
||
| 205 | echo '<div class="col-5 m-auto">'; |
||
| 206 | echo '<div class="card shadow-sm">'; |
||
| 207 | call_user_func( $this->steps[ $this->step ]['view'], $this ); |
||
| 208 | echo '</div>'; |
||
| 209 | echo '</div>'; |
||
| 210 | echo '</div>'; |
||
| 211 | } |
||
| 212 | |||
| 213 | /** |
||
| 214 | * Setup Wizard Footer. |
||
| 215 | * |
||
| 216 | * @since 2.0.0 |
||
| 217 | */ |
||
| 218 | public function setup_wizard_footer() { |
||
| 219 | ?> |
||
| 220 | <?php if ( 'next_steps' === $this->step ){ ?> |
||
| 221 | <p class="gd-return-to-dashboard-wrap"><a class="gd-return-to-dashboard btn btn-link d-block text-muted" |
||
| 222 | href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'invoicing' ); ?></a> |
||
| 223 | </p> |
||
| 224 | <?php }else{ ?> |
||
| 225 | <p class="gd-return-to-dashboard-wrap"><a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" |
||
| 226 | class="btn btn-link d-block text-muted"><?php esc_html_e( 'Skip this step', 'invoicing' ); ?></a></p> |
||
| 227 | <?php } ?> |
||
| 228 | </body> |
||
| 229 | </html> |
||
| 230 | <?php |
||
| 231 | } |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Introduction step. |
||
| 235 | * |
||
| 236 | * @since 2.0.0 |
||
| 237 | */ |
||
| 238 | public function setup_introduction() { |
||
| 239 | ?> |
||
| 240 | <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1"><?php esc_html_e( 'Welcome to GetPaid!', 'invoicing' ); ?></h1> |
||
| 241 | <div class="card-body text-muted "> |
||
| 242 | <p class=""><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p> |
||
| 243 | <hr class="mt-4 pt-3 pb-0" /> |
||
| 244 | <p class="small"><?php _e( 'This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes<b/>.', 'invoicing' ); ?></p> |
||
| 245 | </div> |
||
| 246 | <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0"> |
||
| 247 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" |
||
| 248 | class="btn btn-primary button-next"><?php esc_html_e( 'Let\'s go!', 'invoicing' ); ?></a> |
||
| 249 | <a href="<?php echo esc_url( admin_url() ); ?>" |
||
| 250 | class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a> |
||
| 251 | </div> |
||
| 252 | |||
| 253 | |||
| 254 | </div> |
||
| 255 | <div class="card shadow-sm my-5"> |
||
| 256 | <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1"><?php esc_html_e( 'GetPaid Features & Addons!', 'invoicing' ); ?></h1> |
||
| 257 | <div class="card-body text-muted overflow-hidden"> |
||
| 258 | <p class=""><?php _e( 'Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing' ); ?></p> |
||
| 259 | <hr class=""> |
||
| 260 | |||
| 261 | <div class="row row row-cols-2 text-left"> |
||
| 262 | <div class="col mt-3"> |
||
| 263 | <div class="media"> |
||
| 264 | <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg';?>" class="mr-3" alt="..."> |
||
| 265 | <div class="media-body"> |
||
| 266 | <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Buy Now Buttons','invoicing');?></h6> |
||
| 267 | <small><?php _e('Sell via buy now buttons anywhere on your site','invoicing');?></small> |
||
| 268 | </div> |
||
| 269 | </div> |
||
| 270 | </div> |
||
| 271 | <div class="col mt-3"> |
||
| 272 | <div class="media"> |
||
| 273 | <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg';?>" class="mr-3" alt="..."> |
||
| 274 | <div class="media-body"> |
||
| 275 | <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via payment form','invoicing');?></h6> |
||
| 276 | <small><?php _e('Payment forms are conversion-optimized checkout forms','invoicing');?></small> |
||
| 277 | </div> |
||
| 278 | </div> |
||
| 279 | </div> |
||
| 280 | <div class="col mt-3"> |
||
| 281 | <div class="media"> |
||
| 282 | <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg';?>" class="mr-3" alt="..."> |
||
| 283 | <div class="media-body"> |
||
| 284 | <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice','invoicing');?></h6> |
||
| 285 | <small><?php _e('Create and send invoices for just about anything from the WOrdPress dashboard','invoicing');?></small> |
||
| 286 | </div> |
||
| 287 | </div> |
||
| 288 | </div> |
||
| 289 | <div class="col mt-3"> |
||
| 290 | <div class="media"> |
||
| 291 | <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg';?>" class="mr-3" alt="..."> |
||
| 292 | <div class="media-body"> |
||
| 293 | <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways','invoicing');?></h6> |
||
| 294 | <small><?php _e('On average our gateways are over 66% cheaper than our competition','invoicing');?></small> |
||
| 295 | </div> |
||
| 296 | </div> |
||
| 297 | </div> |
||
| 298 | </div> |
||
| 299 | |||
| 300 | <div class="mt-5"> |
||
| 301 | <a href="https://wpgetpaid.com/features-list/" |
||
| 302 | class="btn btn-primary"><?php esc_html_e( 'View All Features!', 'invoicing' ); ?></a> |
||
| 303 | </div> |
||
| 304 | <div class="mt-5 mx-n4 py-4" style="background:#eafaf6;"> |
||
| 305 | <h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e('More with Membership!','invoicing');?></h4> |
||
| 306 | <div class="row row-cols-2 text-left px-5"> |
||
| 307 | <div class="col"> |
||
| 308 | <ul class="list-unstyled"> |
||
| 309 | <li class="my-2"><i class="far fa-check-circle text-success"></i> PDF Invoices</li> |
||
| 310 | <li class="my-2"><i class="far fa-check-circle text-success"></i> Gravity Forms</li> |
||
| 311 | <li class="my-2"><i class="far fa-check-circle text-success"></i> Contact form 7</li> |
||
| 312 | <li class="my-2"><i class="far fa-check-circle text-success"></i> AffiliateWP Integration</li> |
||
| 313 | </ul> |
||
| 314 | </div> |
||
| 315 | <div class="col"> |
||
| 316 | <ul class="list-unstyled"> |
||
| 317 | <li class="my-2"><i class="far fa-check-circle text-success"></i> Ninja forms</li> |
||
| 318 | <li class="my-2"><i class="far fa-check-circle text-success"></i> Digital Downloads</li> |
||
| 319 | <li class="my-2"><i class="far fa-check-circle text-success"></i> Wallet</li> |
||
| 320 | </ul> |
||
| 321 | </div> |
||
| 322 | </div> |
||
| 323 | |||
| 324 | <h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From','invoicing');?></h5> |
||
| 325 | <h1 class="mt-0 font-weight-bold text-dark mb-4 display-3">$49</h1> |
||
| 326 | |||
| 327 | <div class="mt-2"> |
||
| 328 | <a href="https://wpgetpaid.com/downloads/membership/" |
||
| 329 | class="btn btn-primary"><?php esc_html_e( 'Buy Membership Now!', 'invoicing' ); ?></a> |
||
| 330 | </div> |
||
| 331 | |||
| 332 | |||
| 333 | </div> |
||
| 334 | |||
| 335 | </div> |
||
| 336 | <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0"> |
||
| 337 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" |
||
| 338 | class="btn btn-outline-primary button-next"><?php esc_html_e( 'Launch the Setup Wizard!', 'invoicing' ); ?></a> |
||
| 339 | <a href="https://docs.wpgetpaid.com/" |
||
| 340 | class="btn btn-outline-primary ml-4"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a> |
||
| 341 | <a href="<?php echo esc_url( admin_url() ); ?>" |
||
| 342 | class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a> |
||
| 343 | </div> |
||
| 344 | <?php |
||
| 345 | } |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Get the URL for the next step's screen. |
||
| 349 | * |
||
| 350 | * @param string step slug (default: current step) |
||
| 351 | * |
||
| 352 | * @return string URL for next step if a next step exists. |
||
| 353 | * Admin URL if it's the last step. |
||
| 354 | * Empty string on failure. |
||
| 355 | * @since 3.0.0 |
||
| 356 | */ |
||
| 357 | public function get_next_step_link( $step = '' ) { |
||
| 358 | if ( ! $step ) { |
||
| 359 | $step = $this->step; |
||
| 360 | } |
||
| 361 | |||
| 362 | $keys = array_keys( $this->steps ); |
||
| 363 | if ( end( $keys ) === $step ) { |
||
| 364 | return admin_url(); |
||
| 365 | } |
||
| 366 | |||
| 367 | $step_index = array_search( $step, $keys ); |
||
| 368 | if ( false === $step_index ) { |
||
| 369 | return ''; |
||
| 370 | } |
||
| 371 | |||
| 372 | return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] )); |
||
| 373 | } |
||
| 374 | |||
| 375 | /** |
||
| 376 | * Setup maps api. |
||
| 377 | * |
||
| 378 | * @since 2.0.0 |
||
| 379 | */ |
||
| 380 | public function setup_business() { |
||
| 381 | ?> |
||
| 382 | <form method="post" class="text-left card-body" action="options.php"> |
||
| 383 | <?php |
||
| 384 | |||
| 385 | settings_fields( 'wpinv_settings' ); |
||
| 386 | |||
| 387 | // override http referer to make it send back to the next step |
||
| 388 | ?> |
||
| 389 | <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>"> |
||
| 390 | |||
| 391 | <table class="gp-setup-maps w-100 " cellspacing="0"> |
||
| 392 | |||
| 393 | <tbody> |
||
| 394 | |||
| 395 | <?php |
||
| 396 | |||
| 397 | global $wp_settings_fields; |
||
| 398 | |||
| 399 | $page = 'wpinv_settings_general_main'; |
||
| 400 | $section = 'wpinv_settings_general_main'; |
||
| 401 | if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
||
| 402 | return; |
||
| 403 | } |
||
| 404 | |||
| 405 | $settings = $wp_settings_fields[ $page ][ $section ]; |
||
| 406 | |||
| 407 | // unset title |
||
| 408 | unset($settings["wpinv_settings[location_settings]"]); |
||
| 409 | |||
| 410 | $this->output_fields($settings); |
||
| 411 | ?> |
||
| 412 | |||
| 413 | |||
| 414 | </tbody> |
||
| 415 | </table> |
||
| 416 | |||
| 417 | |||
| 418 | <p class="gp-setup-actions step text-center mt-4"> |
||
| 419 | <input type="submit" class="btn btn-primary button-next" |
||
| 420 | value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
||
| 421 | </p> |
||
| 422 | </form> |
||
| 423 | <?php |
||
| 424 | } |
||
| 425 | |||
| 426 | public function output_fields($settings){ |
||
| 427 | |||
| 428 | if ( empty($settings)) { |
||
| 429 | return; |
||
| 430 | } |
||
| 431 | |||
| 432 | //print_r($settings); |
||
| 433 | foreach ( (array) $settings as $key => $field ) { |
||
| 434 | |||
| 435 | |||
| 436 | $class = ''; |
||
| 437 | |||
| 438 | if ( ! empty( $field['args']['class'] ) ) { |
||
| 439 | $class = esc_attr( $field['args']['class'] ); |
||
| 440 | } |
||
| 441 | |||
| 442 | // echo '<div class="form-group '.$class.'">'; |
||
| 443 | |||
| 444 | |||
| 445 | if ( ! empty( $field['args']['label_for'] ) ) { |
||
| 446 | $for = ' for="' . esc_attr( $field['args']['label_for'] ) . '" '; |
||
| 447 | } else { |
||
| 448 | $for = ''; |
||
| 449 | } |
||
| 450 | |||
| 451 | $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
||
| 452 | $value = wpinv_get_option( $field['args']['id'], $value ); |
||
| 453 | |||
| 454 | if($field['callback'] == 'wpinv_text_callback' || $field['callback'] == 'wpinv_number_callback' ){ |
||
| 455 | |||
| 456 | |||
| 457 | // hide the logo inputs, we need to set them as hidden so they don't blank the current values. |
||
| 458 | $help_text = isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : ''; |
||
| 459 | $type = $field['callback'] == 'wpinv_number_callback' ? 'number' : 'text'; |
||
| 460 | $label = isset($field['args']['name']) ? esc_attr($field['args']['name']) : ''; |
||
| 461 | |||
| 462 | if(in_array($field['id'],array('wpinv_settings[logo]','wpinv_settings[logo_width]','wpinv_settings[logo_height]'))){ |
||
| 463 | $type = 'hidden'; |
||
| 464 | $help_text = ''; |
||
| 465 | $label = ''; |
||
| 466 | } |
||
| 467 | |||
| 468 | echo aui()->input(array( |
||
| 469 | 'type' => $type, |
||
| 470 | 'id' => isset($field['args']['id']) ? esc_attr($field['args']['id']) : '', |
||
| 471 | 'name' => isset($field['id']) ? esc_attr($field['id']) : '', |
||
| 472 | 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
||
| 473 | 'required' => false, |
||
| 474 | 'help_text' => $help_text, |
||
| 475 | 'label' => $label, |
||
| 476 | 'label_type' => 'floating' |
||
| 477 | )); |
||
| 478 | }elseif($field['callback'] == 'wpinv_select_callback' || $field['callback'] == 'wpinv_country_states_callback'){ |
||
| 479 | |||
| 480 | if($field['id']=='wpinv_settings[default_state]'){ |
||
| 481 | $country_value = wpinv_get_option( 'wpinv_settings[default_country]', 'US'); |
||
| 482 | $options = wpinv_get_country_states($country_value);//echo $value .'###'.$country_value; |
||
| 483 | }else{ |
||
| 484 | $options = isset($field['args']['options']) ? $field['args']['options'] : array(); |
||
| 485 | } |
||
| 486 | |||
| 487 | //print_r($options );echo '###'; |
||
| 488 | |||
| 489 | echo aui()->select( array( |
||
| 490 | 'id' => isset($field['args']['id']) ? esc_attr($field['args']['id']) : '', |
||
| 491 | 'name' => isset($field['id']) ? esc_attr($field['id']) : '', |
||
| 492 | 'placeholder' => '', |
||
| 493 | // 'title' => $site_title, |
||
| 494 | 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
||
| 495 | 'required' => false, |
||
| 496 | 'help_text' => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '', |
||
| 497 | 'label' => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '', |
||
| 498 | 'options' => $options, |
||
| 499 | 'select2' => true, |
||
| 500 | 'label_type' => 'floating' |
||
| 501 | // 'wrap_class' => isset( $field->css_class ) ? $field->css_class : '', |
||
| 502 | ) ); |
||
| 503 | }elseif($field['callback'] == 'wpinv_textarea_callback'){ |
||
| 504 | $textarea = aui()->textarea( array( |
||
| 505 | 'id' => isset($field['args']['id']) ? esc_attr($field['args']['id']) : '', |
||
| 506 | 'name' => isset($field['id']) ? esc_attr($field['id']) : '', |
||
| 507 | 'placeholder' => '', |
||
| 508 | // 'title' => $site_title, |
||
| 509 | 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
||
| 510 | 'required' => false, |
||
| 511 | 'help_text' => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '', |
||
| 512 | 'label' => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '', |
||
| 513 | 'rows' => '4', |
||
| 514 | 'label_type' => 'floating' |
||
| 515 | // 'wrap_class' => isset( $field->css_class ) ? $field->css_class : '', |
||
| 516 | ) ); |
||
| 517 | |||
| 518 | // bug fixed in AUI 0.1.51 for name stripping [] |
||
| 519 | $textarea = str_replace(sanitize_html_class($field['args']['id']),esc_attr($field['args']['id']),$textarea ); |
||
| 520 | |||
| 521 | echo $textarea; |
||
| 522 | } |
||
| 523 | |||
| 524 | //echo "<div>"; |
||
| 525 | |||
| 526 | } |
||
| 527 | } |
||
| 528 | |||
| 529 | /** |
||
| 530 | * Save Maps Settings. |
||
| 531 | * |
||
| 532 | * @since 2.0.0 |
||
| 533 | */ |
||
| 534 | public function setup_business_save() { |
||
| 535 | |||
| 536 | // nothing required here as options.php will send to next step |
||
| 537 | //check_admin_referer( 'gp-setup' ); |
||
| 538 | |||
| 539 | //print_r($_POST);exit; |
||
| 540 | // wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
||
| 541 | // exit; |
||
| 542 | } |
||
| 543 | |||
| 544 | /** |
||
| 545 | * Default Location settings. |
||
| 546 | * |
||
| 547 | * @since 2.0.0 |
||
| 548 | */ |
||
| 549 | public function setup_currency() { |
||
| 550 | |||
| 551 | ?> |
||
| 552 | |||
| 553 | <form method="post" class="text-left card-body" action="options.php"> |
||
| 554 | <?php |
||
| 555 | |||
| 556 | |||
| 557 | settings_fields( 'wpinv_settings' ); |
||
| 558 | |||
| 559 | // override http referer to make it send back to the next step |
||
| 560 | ?> |
||
| 561 | <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>"> |
||
| 562 | |||
| 563 | <table class="gp-setup-maps w-100 " cellspacing="0"> |
||
| 564 | |||
| 565 | <tbody> |
||
| 566 | |||
| 567 | <?php |
||
| 568 | |||
| 569 | global $wp_settings_fields; |
||
| 570 | |||
| 571 | $page = 'wpinv_settings_general_currency_section'; |
||
| 572 | $section = 'wpinv_settings_general_currency_section'; |
||
| 573 | if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
||
| 574 | return; |
||
| 575 | } |
||
| 576 | |||
| 577 | $settings = $wp_settings_fields[ $page ][ $section ]; |
||
| 578 | |||
| 579 | // print_r($settings);exit; |
||
| 580 | |||
| 581 | $this->output_fields($settings); |
||
| 582 | ?> |
||
| 583 | |||
| 584 | |||
| 585 | </tbody> |
||
| 586 | </table> |
||
| 587 | |||
| 588 | |||
| 589 | <p class="gp-setup-actions step text-center mt-4"> |
||
| 590 | <input type="submit" class="btn btn-primary" |
||
| 591 | value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
||
| 592 | </p> |
||
| 593 | </form> |
||
| 594 | |||
| 595 | <?php |
||
| 596 | } |
||
| 597 | |||
| 598 | |||
| 599 | /** |
||
| 600 | * Save Default Location Settings. |
||
| 601 | * |
||
| 602 | * @since 2.0.0 |
||
| 603 | */ |
||
| 604 | public function setup_currency_save() { |
||
| 605 | check_admin_referer( 'gp-setup' ); |
||
| 606 | |||
| 607 | $generalSettings = new GeoDir_Settings_General(); |
||
| 608 | $settings = $generalSettings->get_settings( 'location' ); |
||
| 609 | GeoDir_Admin_Settings::save_fields( $settings ); |
||
| 610 | |||
| 611 | do_action( 'geodir_setup_wizard_default_location_saved', $settings ); |
||
| 612 | |||
| 613 | wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
||
| 614 | exit; |
||
| 615 | } |
||
| 616 | |||
| 617 | /** |
||
| 618 | * Dummy Data setup. |
||
| 619 | * |
||
| 620 | * @since 2.0.0 |
||
| 621 | */ |
||
| 622 | public function setup_recommend() { |
||
| 623 | |||
| 624 | ?> |
||
| 625 | <form method="post" class="text-center card-body"> |
||
| 626 | <div class="gd-wizard-recommend"> |
||
| 627 | |||
| 628 | <h2 class="gd-settings-title h3 "><?php _e( "Recommend Plugins", "geodirectory" ); ?></h2> |
||
| 629 | |||
| 630 | <p><?php _e( "Below are a few of our own plugins that may help you.", "geodirectory" ); ?></p> |
||
| 631 | |||
| 632 | |||
| 633 | <?php |
||
| 634 | |||
| 635 | include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
||
| 636 | |||
| 637 | $recommend_wp_plugins = self::get_recommend_wp_plugins(); |
||
| 638 | |||
| 639 | // $status = install_plugin_install_status( array("slug"=>"two-factor","version"=>"")); |
||
| 640 | // print_r($status); |
||
| 641 | |||
| 642 | if ( ! empty( $recommend_wp_plugins ) ) { |
||
| 643 | |||
| 644 | ?> |
||
| 645 | <ul class="list-group"> |
||
| 646 | <?php |
||
| 647 | foreach ( $recommend_wp_plugins as $plugin ) { |
||
| 648 | $status = install_plugin_install_status( array( "slug" => $plugin['slug'], "version" => "" ) ); |
||
| 649 | $plugin_status = isset( $status['status'] ) ? $status['status'] : ''; |
||
| 650 | ?> |
||
| 651 | <li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left"> |
||
| 652 | <span class="mr-auto"><?php echo esc_attr($plugin['name']); ?></span> |
||
| 653 | <div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status"> |
||
| 654 | <span class="sr-only">Loading...</span> |
||
| 655 | </div> |
||
| 656 | <div class="custom-control custom-switch mr-n2"> |
||
| 657 | <input type="checkbox" class="custom-control-input" <?php if( is_plugin_active( $plugin['slug'] ) ){echo "checked";} ?> onclick="if(jQuery(this).is(':checked')){}else{}"> |
||
| 658 | <label class="custom-control-label" for="ac-setting-updates"></label> |
||
| 659 | </div> |
||
| 660 | <small class="w-100"><?php echo esc_attr($plugin['desc'] );?></small> |
||
| 661 | </li> |
||
| 662 | <?php |
||
| 663 | } |
||
| 664 | ?> |
||
| 665 | </ul> |
||
| 666 | <?php |
||
| 667 | |||
| 668 | } |
||
| 669 | |||
| 670 | |||
| 671 | |||
| 672 | ?> |
||
| 673 | |||
| 674 | |||
| 675 | |||
| 676 | </div> |
||
| 677 | |||
| 678 | <p class="gp-setup-actions step text-center mt-4"> |
||
| 679 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="btn btn-primary"><?php esc_attr_e( 'Continue', 'invoicing' ); ?></a> |
||
| 680 | </p> |
||
| 681 | </form> |
||
| 682 | <?php |
||
| 683 | } |
||
| 684 | |||
| 685 | /** |
||
| 686 | * A list of recommended wp.org plugins. |
||
| 687 | * @return array |
||
| 688 | */ |
||
| 689 | public static function get_recommend_wp_plugins(){ |
||
| 690 | $plugins = array( |
||
| 691 | 'ayecode-connect' => array( |
||
| 692 | 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
||
| 693 | 'slug' => 'ayecode-connect', |
||
| 694 | 'name' => 'AyeCode Connect', |
||
| 695 | 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ), |
||
| 696 | ), |
||
| 697 | 'ninja-forms' => array( |
||
| 698 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
||
| 699 | 'slug' => 'invoicing-quotes', |
||
| 700 | 'name' => 'Customer Quotes', |
||
| 701 | 'desc' => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'), |
||
| 702 | ), |
||
| 703 | 'userswp' => array( |
||
| 704 | 'url' => 'https://wordpress.org/plugins/userswp/', |
||
| 705 | 'slug' => 'userswp', |
||
| 706 | 'name' => 'UsersWP', |
||
| 707 | 'desc' => __('Frontend user login and registration as well as slick profile pages.','geodirectory'), |
||
| 708 | ), |
||
| 709 | ); |
||
| 710 | |||
| 711 | return $plugins; |
||
| 712 | } |
||
| 713 | |||
| 714 | /** |
||
| 715 | * Dummy data save. |
||
| 716 | * |
||
| 717 | * This is done via ajax so we just pass onto the next step. |
||
| 718 | * |
||
| 719 | * @since 2.0.0 |
||
| 720 | */ |
||
| 721 | public function setup_recommend_save() { |
||
| 722 | check_admin_referer( 'gp-setup' ); |
||
| 723 | wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
||
| 724 | exit; |
||
| 725 | } |
||
| 726 | |||
| 727 | /** |
||
| 728 | * Dummy Data setup. |
||
| 729 | * |
||
| 730 | * @since 2.0.0 |
||
| 731 | */ |
||
| 732 | public function setup_payments() { |
||
| 733 | ?> |
||
| 734 | <form method="post" class="text-center card-body"> |
||
| 735 | <div class="gp-wizard-payments"> |
||
| 736 | |||
| 737 | <h2 class="gd-settings-title h3 "><?php _e( "Gateway Setup", "geodirectory" ); ?></h2> |
||
| 738 | |||
| 739 | <p><?php _e( "Below are a few gateways that can be setup in a few seconds.", "geodirectory" ); ?><br><?php _e( "We have 20+ Gateways that can be setup later.", "geodirectory" ); ?></p> |
||
| 740 | |||
| 741 | <ul class="list-group"> |
||
| 742 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
||
| 743 | <span class="mr-auto"><img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg';?>" class="ml-n2" alt="Stripe"></span> |
||
| 744 | <div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status"> |
||
| 745 | <span class="sr-only">Loading...</span> |
||
| 746 | </div> |
||
| 747 | <span class="btn btn-sm btn-outline-primary">Connect</span> |
||
| 748 | </li> |
||
| 749 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
||
| 750 | <span class="mr-auto"><img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp';?>" class="" alt="PayPal" height="25"></span> |
||
| 751 | <div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status"> |
||
| 752 | <span class="sr-only">Loading...</span> |
||
| 753 | </div> |
||
| 754 | <span class="btn btn-sm btn-outline-primary">Connect</span> |
||
| 755 | </li> |
||
| 756 | <li class="list-group-item d-flex justify-content-between align-items-center"> |
||
| 757 | <span class="mr-auto">Test Gateway</span> |
||
| 758 | <div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status"> |
||
| 759 | <span class="sr-only">Loading...</span> |
||
| 760 | </div> |
||
| 761 | <div class="custom-control custom-switch"> |
||
| 762 | <input type="checkbox" class="custom-control-input" id="ac-setting-updates" checked="" onclick="if(jQuery(this).is(':checked')){}else{}"> |
||
| 763 | <label class="custom-control-label" for="ac-setting-updates"></label> |
||
| 764 | </div> |
||
| 765 | </li> |
||
| 766 | </ul> |
||
| 767 | |||
| 768 | <?php |
||
| 769 | |||
| 770 | |||
| 771 | |||
| 772 | |||
| 773 | |||
| 774 | ?> |
||
| 775 | |||
| 776 | |||
| 777 | </div> |
||
| 778 | |||
| 779 | <p class="gp-setup-actions step text-center mt-4"> |
||
| 780 | <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="btn btn-primary"><?php esc_attr_e( 'Continue', 'invoicing' ); ?></a> |
||
| 781 | </p> |
||
| 782 | </form> |
||
| 783 | <?php |
||
| 784 | } |
||
| 785 | |||
| 786 | /** |
||
| 787 | * Dummy data save. |
||
| 788 | * |
||
| 789 | * This is done via ajax so we just pass onto the next step. |
||
| 790 | * |
||
| 791 | * @since 2.0.0 |
||
| 792 | */ |
||
| 793 | public function setup_payments_save() { |
||
| 797 | } |
||
| 798 | |||
| 799 | /** |
||
| 800 | * Final step. |
||
| 801 | * |
||
| 802 | * @since 2.0.0 |
||
| 803 | */ |
||
| 804 | public function setup_ready() { |
||
| 843 | </div> |
||
| 844 | </div> |
||
| 845 | </div> |
||
| 846 | <?php |
||
| 847 | } |
||
| 848 | |||
| 849 | /** |
||
| 850 | * Actions on the final step. |
||
| 851 | * |
||
| 852 | * @since 2.0.0 |
||
| 853 | */ |
||
| 854 | private function setup_ready_actions() { |
||
| 863 | } |
||
| 864 | } |
||
| 865 | |||
| 866 | |||
| 867 | } |
||
| 870 |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.