| 1 |
<?php |
| 2 |
/* |
| 3 |
* Page Name: Include files |
| 4 |
*/ |
| 5 |
|
| 6 |
use WPCoder\Dashboard\Field; |
| 7 |
|
| 8 |
defined( 'ABSPATH' ) || exit; |
| 9 |
|
| 10 |
$default = Field::getDefault(); |
| 11 |
$count = ! empty( $default['param']['include'] ) ? count( $default['param']['include'] ) : 0; |
| 12 |
|
| 13 |
?> |
| 14 |
|
| 15 |
<h4> |
| 16 |
<span class="wowp-icon wowp-icon-plus"></span> |
| 17 |
<?php esc_html_e( 'Includes', 'wpcoder' ); ?> |
| 18 |
</h4> |
| 19 |
|
| 20 |
<fieldset id="includes-files"> |
| 21 |
|
| 22 |
<?php if ( $count > 0 ) : |
| 23 |
for ( $i = 0; $i < $count; $i ++ ): |
| 24 |
$css_class = ($default['param']['include'][$i] !== 'css') ? ' is-hidden' : ''; |
| 25 |
$js_class = ($default['param']['include'][$i] !== 'js') ? ' is-hidden' : ''; |
| 26 |
?> |
| 27 |
|
| 28 |
<div class="wowp-fields-group"> |
| 29 |
<div class="wowp-field"> |
| 30 |
<label class="label" |
| 31 |
id="include_<?php echo absint( $i ); ?>"><?php esc_html_e( 'Type', 'wpcoder' ); ?></label> |
| 32 |
<?php Field::select( '[include][' . $i . ']', null, [ 'css' => 'css', 'js' => 'js' ] ); ?> |
| 33 |
</div> |
| 34 |
<div class="wowp-field"> |
| 35 |
<label class="label" |
| 36 |
id="include_file_<?php echo absint( $i ); ?>"><?php esc_html_e( 'URL', 'wpcoder' ); ?></label> |
| 37 |
<?php Field::text( '[include_file][' . $i . ']', null, 'url' ); ?> |
| 38 |
</div> |
| 39 |
|
| 40 |
<div class="wowp-field wowp-include-js<?php echo esc_attr($js_class);?>"> |
| 41 |
<label for="file_js_att_<?php echo absint( $i ); ?>" |
| 42 |
class="label"><?php esc_html_e( 'Attribute', 'wpcoder' ); ?></label> |
| 43 |
<?php Field::select( '[file_js_att][' . $i . ']', null, [ |
| 44 |
0 => 'none', |
| 45 |
'defer' => 'defer', |
| 46 |
'async' => 'async' |
| 47 |
] ); ?> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
|
| 51 |
<?php |
| 52 |
endfor; |
| 53 |
endif; ?> |
| 54 |
|
| 55 |
|
| 56 |
</fieldset> |
| 57 |
|
| 58 |
<div class="wowp-fields-group"> |
| 59 |
<?php submit_button( 'Add new', 'primary small', 'add-include', false ); ?> |
| 60 |
<?php submit_button( 'Remove Last', 'small delete', 'remove-include', false ); ?> |
| 61 |
</div> |
| 62 |
|
| 63 |
<template id="clone-includes"> |
| 64 |
<div class="wowp-fields-group"> |
| 65 |
<div class="wowp-field"> |
| 66 |
<label class="label"><?php esc_html_e( 'Type', 'wpcoder' ); ?></label> |
| 67 |
<select name="param[include][]"> |
| 68 |
<option value="css">css</option> |
| 69 |
<option value="js">js</option> |
| 70 |
</select> |
| 71 |
</div> |
| 72 |
<div class="wowp-field"> |
| 73 |
<label class="label"><?php esc_html_e( 'URL', 'wpcoder' ); ?></label> |
| 74 |
<input type="url" name="param[include_file][]"> |
| 75 |
</div> |
| 76 |
|
| 77 |
<div class="wowp-field wowp-include-js is-hidden"> |
| 78 |
<label class="label"><?php esc_html_e( 'Attribute', 'wpcoder' ); ?></label> |
| 79 |
<select name="param[file_js_att][]"> |
| 80 |
<option value="0">none</option> |
| 81 |
<option value="defer">defer</option> |
| 82 |
<option value="async">async</option> |
| 83 |
</select> |
| 84 |
</div> |
| 85 |
|
| 86 |
</div> |
| 87 |
|
| 88 |
</template> |
| 89 |
|
| 90 |
<?php |
| 91 |
|