| 1 |
<?php |
| 2 |
/** |
| 3 |
* @author ThimPress |
| 4 |
* @package LearnPress/Admin/Views |
| 5 |
* @version 1.0.0 |
| 6 |
*/ |
| 7 |
|
| 8 |
use LearnPress\Helpers\Template; |
| 9 |
use LearnPress\TemplateHooks\Admin\AdminTemplate; |
| 10 |
use LearnPress\TemplateHooks\Admin\Tools\AdminCourseTools; |
| 11 |
use LearnPress\TemplateHooks\TemplateAJAX; |
| 12 |
|
| 13 |
defined( 'ABSPATH' ) or die(); |
| 14 |
?> |
| 15 |
|
| 16 |
<div id="learn-press-reset-user-item" class="card lp-max-width-768"> |
| 17 |
<h2><?php echo esc_html__( 'Reset Item Progress', 'learnpress' ); ?></h2> |
| 18 |
<p><?php echo esc_html__( 'This action will reset progress of a specific lesson, quiz, or other course item.', 'learnpress' ); ?></p> |
| 19 |
<?php |
| 20 |
echo sprintf( |
| 21 |
'<button type="button" |
| 22 |
data-template="#lp-tmpl-select-items-to-reset-progress" |
| 23 |
data-message-resetting="%1$s" |
| 24 |
data-message-choose="%2$s" |
| 25 |
class="lp-button button lp-btn-show-popup-items-to-select lp-btn-choose-item-to-reset-progress"> |
| 26 |
%2$s |
| 27 |
</button>', |
| 28 |
esc_html__( 'Resetting item progress', 'learnpress' ), |
| 29 |
esc_html__( 'Choose data to reset progress', 'learnpress' ) |
| 30 |
); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 31 |
|
| 32 |
$item_types = learn_press_course_get_support_item_types(); |
| 33 |
$options_html = sprintf( '<option value="">%s</option>', esc_html__( 'All', 'learnpress' ) ); |
| 34 |
foreach ( $item_types as $type_key => $type_label ) { |
| 35 |
$options_html .= sprintf( |
| 36 |
'<option value="%s">%s</option>', |
| 37 |
esc_attr( $type_key ), |
| 38 |
esc_html( $type_label ) |
| 39 |
); |
| 40 |
} |
| 41 |
|
| 42 |
$html_fields = sprintf( |
| 43 |
'<div class="filter-field"> |
| 44 |
<label>%1$s</label> |
| 45 |
<select |
| 46 |
class="lp-filter-item-type lp-filter-field" |
| 47 |
name="lp-item-type"> |
| 48 |
%2$s |
| 49 |
</select> |
| 50 |
</div> |
| 51 |
<div class="filter-field"> |
| 52 |
<label>%3$s</label> |
| 53 |
<input |
| 54 |
class="lp-search-item lp-filter-field" |
| 55 |
type="text" name="lp-search-item" placeholder="%4$s"> |
| 56 |
</div> |
| 57 |
<div class="filter-field"> |
| 58 |
<label>%5$s</label> |
| 59 |
<input |
| 60 |
class="lp-seach-course lp-filter-field" |
| 61 |
type="text" name="lp-search-course" placeholder="%6$s"> |
| 62 |
</div> |
| 63 |
<div class="filter-field"> |
| 64 |
<label>%7$s</label> |
| 65 |
<input |
| 66 |
class="lp-search-user lp-filter-field" |
| 67 |
type="text" name="lp-search-user" placeholder="%8$s"> |
| 68 |
</div>', |
| 69 |
esc_html__( 'Item type', 'learnpress' ), |
| 70 |
$options_html, |
| 71 |
esc_html__( 'Item', 'learnpress' ), |
| 72 |
esc_attr__( 'Search item by title', 'learnpress' ), |
| 73 |
esc_html__( 'Course\'s Item', 'learnpress' ), |
| 74 |
esc_attr__( 'Search by title', 'learnpress' ), |
| 75 |
esc_html__( 'Student', 'learnpress' ), |
| 76 |
esc_attr__( 'Search by name or email', 'learnpress' ), |
| 77 |
); |
| 78 |
|
| 79 |
$html_filter_fields = AdminTemplate::html_form_filter( |
| 80 |
[ |
| 81 |
'fields' => $html_fields, |
| 82 |
'form_classes' => 'lp-form-filter-reset-item-progress', |
| 83 |
] |
| 84 |
); |
| 85 |
|
| 86 |
$html_items = TemplateAJAX::load_content_via_ajax( |
| 87 |
[ |
| 88 |
'id_url' => 'items-to-reset-progress', |
| 89 |
'enableScrollToView' => false, |
| 90 |
'paged' => 1, |
| 91 |
], |
| 92 |
[ |
| 93 |
/* @use AdminCourseTools::render_items_to_reset_progress */ |
| 94 |
'class' => AdminCourseTools::class, |
| 95 |
'method' => 'render_items_to_reset_progress', |
| 96 |
] |
| 97 |
); |
| 98 |
|
| 99 |
$tabs = [ |
| 100 |
'items' => __( 'Items', 'learnpress' ), |
| 101 |
]; |
| 102 |
|
| 103 |
$section = [ |
| 104 |
'wrap-script-template' => '<script type="text/template" id="lp-tmpl-select-items-to-reset-progress">', |
| 105 |
'popup' => AdminTemplate::html_popup_items_to_select_clone( |
| 106 |
$tabs, |
| 107 |
$html_items, |
| 108 |
$html_filter_fields, |
| 109 |
[ |
| 110 |
'classes' => 'lp-popup-select-items-to-reset-progress', |
| 111 |
'btn-add-label' => __( 'Reset data progress', 'learnpress' ), |
| 112 |
'btn-add-classes' => 'lp-btn-reset-items-progress', |
| 113 |
'btn-add-attrs' => sprintf( |
| 114 |
'data-message-confirm="%s"', |
| 115 |
esc_html__( 'Are you sure you want to reset data progress choosed?', 'learnpress' ) |
| 116 |
), |
| 117 |
'btn-custom' => sprintf( |
| 118 |
'<button type="button" |
| 119 |
data-message-confirm="%s" |
| 120 |
class="lp-button lp-btn-reset-all-items-progress"> |
| 121 |
%s |
| 122 |
</button>', |
| 123 |
esc_html__( |
| 124 |
'Are you sure you want to reset all data progress by filter?', |
| 125 |
'learnpress' |
| 126 |
), |
| 127 |
__( 'Reset all data progress', 'learnpress' ) |
| 128 |
), |
| 129 |
] |
| 130 |
), |
| 131 |
'wrap-script-template-end' => '</script>', |
| 132 |
]; |
| 133 |
|
| 134 |
echo Template::combine_components( $section ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 135 |
?> |
| 136 |
</div> |
| 137 |
|