| 1 |
<?php |
| 2 |
/** |
| 3 |
* Template tool create indexs fo tables database. |
| 4 |
* |
| 5 |
* @template html-create-indexs-tables |
| 6 |
* @author tungnx |
| 7 |
* @package learnpress/admin/views/tools/database |
| 8 |
* @version 1.0.0 |
| 9 |
* @since 4.0.3 |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) or die(); |
| 13 |
$lp_db_sessions = LP_Sessions_DB::getInstance(); |
| 14 |
global $wpdb; |
| 15 |
$clean_tables = array( |
| 16 |
'learnpress_sessions', |
| 17 |
) |
| 18 |
?> |
| 19 |
|
| 20 |
<div class="card" id="lp-tool-clean-database"> |
| 21 |
<h2><?php echo sprintf( '%s', __( 'Clean data system', 'learnpress' ) ); ?></h2> |
| 22 |
<p><?php _e( 'Remove old data, not use or expire', 'learnpress' ); ?></p> |
| 23 |
<div class="tools-prepare__message"></div> |
| 24 |
<div id="tools-select__id" class="tools-select__data"> |
| 25 |
<ul class="clean-table"> |
| 26 |
<?php |
| 27 |
foreach ( $clean_tables as $clean_table ) : |
| 28 |
$color_code = '#ffffff'; |
| 29 |
$rows = $lp_db_sessions->count_row_db_sessions(); |
| 30 |
if ( $rows > 500 ) { |
| 31 |
$color_code = '#ff0000'; |
| 32 |
} |
| 33 |
?> |
| 34 |
<li style="background-color: <?php echo esc_attr( $color_code ); ?>"> |
| 35 |
<input type="checkbox" id="clean-table__<?php echo esc_attr( $clean_table ); ?>" name="clean-table__<?php echo esc_attr( $clean_table ); ?>" value="<?php echo esc_attr( $clean_table ); ?>" > |
| 36 |
<label for="clean-table__<?php echo esc_attr( $clean_table ); ?>"> |
| 37 |
<?php echo sprintf( '%s (%d) %s', $clean_table, $lp_db_sessions->count_row_db_sessions(), __( 'rows expire', 'learnpress' ) ); ?> |
| 38 |
</label> |
| 39 |
<br> |
| 40 |
</li> |
| 41 |
<?php endforeach; ?> |
| 42 |
</ul> |
| 43 |
</div> |
| 44 |
<p class="tools-button"> |
| 45 |
<button type="button" class="button lp-btn lp-btn-clean-db"><?php esc_html_e( 'Delete', 'learnpress' ); ?></button> |
| 46 |
</p> |
| 47 |
|
| 48 |
<div class="wrapper-lp-loading" style="display: none"> |
| 49 |
<?php |
| 50 |
$i = 0; |
| 51 |
foreach ( $clean_tables as $clean_table ) : |
| 52 |
$i++; |
| 53 |
$rows = $lp_db_sessions->count_row_db_sessions(); |
| 54 |
?> |
| 55 |
<div class="progressbar__item step-<?php echo esc_attr( $i ); ?>" data-total="<?php echo esc_attr( $rows ); ?>"> |
| 56 |
<div class="progressbar__container"> |
| 57 |
<div class="progressbar__content"> |
| 58 |
<h4><?php echo esc_html( 'Table name: ' . $clean_table . '' ); ?></h4> |
| 59 |
<div class="progressbar__indexs"> |
| 60 |
<span class="progressbar__rows"> |
| 61 |
<?php echo esc_html( '0 / ' . $rows . ' expire' ); ?> |
| 62 |
</span> |
| 63 |
<span class="progressbar__percent"> |
| 64 |
( 0% ) |
| 65 |
</span> |
| 66 |
</div> |
| 67 |
</div> |
| 68 |
<div class="progressbar__value"></div> |
| 69 |
</div> |
| 70 |
</div> |
| 71 |
<div class="lp-tool__message"></div> |
| 72 |
<?php endforeach; ?> |
| 73 |
</div> |
| 74 |
|
| 75 |
</div> |
| 76 |
|
| 77 |
|