| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly! |
| 4 |
} |
| 5 |
|
| 6 |
if ( ! class_exists( 'WPSC_Onboarding_Step_Categories' ) ) : |
| 7 |
|
| 8 |
/** |
| 9 |
* Onboarding step 3: Review Ticket Categories. |
| 10 |
* |
| 11 |
* Renders its own simple list + "Add Category" form (not the existing Settings |
| 12 |
* screen's table/modal), but posts to the existing 'wpsc_set_add_category' AJAX |
| 13 |
* action so categories are still created through the one existing code path - |
| 14 |
* no category storage/logic is duplicated here. |
| 15 |
*/ |
| 16 |
final class WPSC_Onboarding_Step_Categories { |
| 17 |
|
| 18 |
const STEP_ID = 'categories'; |
| 19 |
|
| 20 |
/** |
| 21 |
* Render step body |
| 22 |
* |
| 23 |
* @param string $step_id - step id. |
| 24 |
* @return void |
| 25 |
*/ |
| 26 |
public static function render( $step_id ) { |
| 27 |
|
| 28 |
$categories = WPSC_Category::find( array( 'items_per_page' => 0 ) )['results']; |
| 29 |
?> |
| 30 |
<div class="wpsc-onboarding-step"> |
| 31 |
<h2><?php esc_attr_e( 'Review Ticket Categories', 'supportcandy' ); ?></h2> |
| 32 |
<p class="wpsc-onboarding-step-desc"> |
| 33 |
<?php esc_attr_e( 'Categories help you organize tickets by topic, such as Billing, Technical Support, Sales, or General Questions. A default "General" category is already set up - add more if it fits your business, or continue as-is.', 'supportcandy' ); ?> |
| 34 |
</p> |
| 35 |
|
| 36 |
<ul class="wpsc-onboarding-pill-list"> |
| 37 |
<?php foreach ( $categories as $category ) : ?> |
| 38 |
<li><?php echo esc_html( $category->name ); ?></li> |
| 39 |
<?php endforeach; ?> |
| 40 |
</ul> |
| 41 |
|
| 42 |
<form action="#" onsubmit="return false;" class="wpsc-frm-onboarding-add-category"> |
| 43 |
<div class="wpsc-onboarding-inline-form"> |
| 44 |
<input type="text" name="label" placeholder="<?php esc_attr_e( 'e.g. Billing', 'supportcandy' ); ?>" autocomplete="off"> |
| 45 |
<button |
| 46 |
type="button" |
| 47 |
class="wpsc-button normal primary" |
| 48 |
onclick="wpsc_onboarding_add_category(this, '<?php echo esc_attr( wp_create_nonce( 'wpsc_set_add_category' ) ); ?>');"> |
| 49 |
<?php esc_attr_e( 'Add Category', 'supportcandy' ); ?> |
| 50 |
</button> |
| 51 |
</div> |
| 52 |
</form> |
| 53 |
|
| 54 |
<?php WPSC_Onboarding::render_step_footer( $step_id ); ?> |
| 55 |
</div> |
| 56 |
<?php |
| 57 |
wp_die(); |
| 58 |
} |
| 59 |
} |
| 60 |
endif; |
| 61 |
|