| 1 |
<?php |
| 2 |
/** |
| 3 |
* Blocks manager screen. |
| 4 |
* |
| 5 |
* @package GutSliderBlocks |
| 6 |
* |
| 7 |
* @var GutSlider_Admin $admin Admin controller. |
| 8 |
* @var array $blocks Decorated block definitions. |
| 9 |
* @var int $total Total block count. |
| 10 |
* @var int $enabled Enabled block count. |
| 11 |
* @var string $current Current page slug. |
| 12 |
* @var bool $has_pro Whether the Pro plugin is active. |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
require GUTSLIDER_DIR . '/admin/views/header.php'; |
| 20 |
?> |
| 21 |
|
| 22 |
<div class="gs-shell gs-stack" data-gs-blocks> |
| 23 |
|
| 24 |
<div class="gs-page-head"> |
| 25 |
<div> |
| 26 |
<h1 class="gs-page-title"><?php esc_html_e( 'Blocks', 'slider-blocks' ); ?></h1> |
| 27 |
<p class="gs-page-sub"> |
| 28 |
<?php esc_html_e( 'Switch off what you do not need. Disabled blocks are never registered, so they add nothing to the editor or the front end.', 'slider-blocks' ); ?> |
| 29 |
</p> |
| 30 |
</div> |
| 31 |
<div class="gs-count" data-gs-counter> |
| 32 |
<?php |
| 33 |
printf( |
| 34 |
/* translators: 1: enabled block count, 2: total block count. */ |
| 35 |
esc_html__( '%1$d of %2$d enabled', 'slider-blocks' ), |
| 36 |
(int) $enabled, |
| 37 |
(int) $total |
| 38 |
); |
| 39 |
?> |
| 40 |
</div> |
| 41 |
</div> |
| 42 |
|
| 43 |
<div class="gs-toolbar"> |
| 44 |
<div class="gs-search"> |
| 45 |
<svg class="gs-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true" focusable="false"> |
| 46 |
<circle cx="11" cy="11" r="7" /><path d="m20 20-3.5-3.5" /> |
| 47 |
</svg> |
| 48 |
<input |
| 49 |
type="search" |
| 50 |
class="gs-search__input" |
| 51 |
data-gs-search |
| 52 |
placeholder="<?php esc_attr_e( 'Search blocks…', 'slider-blocks' ); ?>" |
| 53 |
aria-label="<?php esc_attr_e( 'Search blocks', 'slider-blocks' ); ?>" |
| 54 |
autocomplete="off" |
| 55 |
/> |
| 56 |
<kbd class="gs-kbd gs-search__kbd">/</kbd> |
| 57 |
</div> |
| 58 |
|
| 59 |
<div class="gs-segment" role="tablist" aria-label="<?php esc_attr_e( 'Filter blocks', 'slider-blocks' ); ?>"> |
| 60 |
<?php |
| 61 |
$gs_filters = array( |
| 62 |
'all' => __( 'All', 'slider-blocks' ), |
| 63 |
'free' => __( 'Free', 'slider-blocks' ), |
| 64 |
'pro' => __( 'Pro', 'slider-blocks' ), |
| 65 |
'enabled' => __( 'Enabled', 'slider-blocks' ), |
| 66 |
'disabled' => __( 'Disabled', 'slider-blocks' ), |
| 67 |
); |
| 68 |
?> |
| 69 |
<?php foreach ( $gs_filters as $gs_key => $gs_label ) : ?> |
| 70 |
<button |
| 71 |
type="button" |
| 72 |
role="tab" |
| 73 |
class="gs-segment__btn<?php echo ( 'all' === $gs_key ) ? ' is-active' : ''; ?>" |
| 74 |
data-gs-filter="<?php echo esc_attr( $gs_key ); ?>" |
| 75 |
aria-selected="<?php echo ( 'all' === $gs_key ) ? 'true' : 'false'; ?>" |
| 76 |
> |
| 77 |
<?php echo esc_html( $gs_label ); ?> |
| 78 |
</button> |
| 79 |
<?php endforeach; ?> |
| 80 |
</div> |
| 81 |
|
| 82 |
<div class="gs-toolbar__actions"> |
| 83 |
<button type="button" class="gs-btn gs-btn--quiet gs-btn--sm" data-gs-bulk="on"> |
| 84 |
<?php esc_html_e( 'Enable all', 'slider-blocks' ); ?> |
| 85 |
</button> |
| 86 |
<button type="button" class="gs-btn gs-btn--quiet gs-btn--sm" data-gs-bulk="off"> |
| 87 |
<?php esc_html_e( 'Disable all', 'slider-blocks' ); ?> |
| 88 |
</button> |
| 89 |
</div> |
| 90 |
</div> |
| 91 |
|
| 92 |
<div class="gs-grid gs-grid--cards" data-gs-grid> |
| 93 |
<?php foreach ( $blocks as $gs_block ) : ?> |
| 94 |
<?php |
| 95 |
$gs_is_pro = ! empty( $gs_block['is_pro'] ); |
| 96 |
$gs_locked = ! empty( $gs_block['locked'] ); |
| 97 |
$gs_on = ! empty( $gs_block['enabled'] ); |
| 98 |
$gs_demo = 'https://demos.gutslider.com/' . $gs_block['demo_slug']; |
| 99 |
$gs_toggle = 'gs-toggle-' . sanitize_html_class( $gs_block['name'] ); |
| 100 |
$gs_classes = 'gs-block'; |
| 101 |
$gs_classes .= $gs_is_pro ? ' is-pro' : ' is-free'; |
| 102 |
$gs_classes .= $gs_locked ? ' is-locked' : ''; |
| 103 |
$gs_classes .= $gs_on ? ' is-on' : ' is-off'; |
| 104 |
?> |
| 105 |
<article |
| 106 |
class="<?php echo esc_attr( $gs_classes ); ?>" |
| 107 |
data-gs-block="<?php echo esc_attr( $gs_block['name'] ); ?>" |
| 108 |
data-gs-tier="<?php echo $gs_is_pro ? 'pro' : 'free'; ?>" |
| 109 |
data-gs-locked="<?php echo $gs_locked ? '1' : '0'; ?>" |
| 110 |
data-gs-initial="<?php echo $gs_on ? '1' : '0'; ?>" |
| 111 |
data-gs-name="<?php echo esc_attr( strtolower( $gs_block['title'] . ' ' . $gs_block['description'] ) ); ?>" |
| 112 |
> |
| 113 |
<div class="gs-block__head"> |
| 114 |
<h3 class="gs-block__title"><?php echo esc_html( $gs_block['title'] ); ?></h3> |
| 115 |
<?php if ( $gs_is_pro ) : ?> |
| 116 |
<span class="gs-tag gs-tag--pro"><?php esc_html_e( 'Pro', 'slider-blocks' ); ?></span> |
| 117 |
<?php else : ?> |
| 118 |
<span class="gs-tag"><?php esc_html_e( 'Free', 'slider-blocks' ); ?></span> |
| 119 |
<?php endif; ?> |
| 120 |
</div> |
| 121 |
|
| 122 |
<p class="gs-block__text"><?php echo esc_html( $gs_block['description'] ); ?></p> |
| 123 |
|
| 124 |
<div class="gs-block__foot"> |
| 125 |
<a class="gs-link gs-link--sm" href="<?php echo esc_url( $gs_demo ); ?>" target="_blank" rel="noopener noreferrer"> |
| 126 |
<?php esc_html_e( 'Demo', 'slider-blocks' ); ?> |
| 127 |
<svg class="gs-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"> |
| 128 |
<path d="M14 4h6v6M20 4l-8 8M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" /> |
| 129 |
</svg> |
| 130 |
</a> |
| 131 |
|
| 132 |
<?php if ( $gs_locked ) : ?> |
| 133 |
<a class="gs-lock" href="https://gutslider.com/pricing" target="_blank" rel="noopener noreferrer"> |
| 134 |
<svg class="gs-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"> |
| 135 |
<rect x="4" y="10" width="16" height="11" rx="2" /><path d="M8 10V7a4 4 0 0 1 8 0v3" /> |
| 136 |
</svg> |
| 137 |
<?php esc_html_e( 'Unlock', 'slider-blocks' ); ?> |
| 138 |
</a> |
| 139 |
<?php else : ?> |
| 140 |
<label class="gs-switch" for="<?php echo esc_attr( $gs_toggle ); ?>"> |
| 141 |
<span class="screen-reader-text"> |
| 142 |
<?php |
| 143 |
printf( |
| 144 |
/* translators: %s: block title. */ |
| 145 |
esc_html__( 'Enable the %s block', 'slider-blocks' ), |
| 146 |
esc_html( $gs_block['title'] ) |
| 147 |
); |
| 148 |
?> |
| 149 |
</span> |
| 150 |
<input |
| 151 |
type="checkbox" |
| 152 |
id="<?php echo esc_attr( $gs_toggle ); ?>" |
| 153 |
class="gs-switch__input" |
| 154 |
data-gs-toggle="<?php echo esc_attr( $gs_block['name'] ); ?>" |
| 155 |
<?php checked( $gs_on ); ?> |
| 156 |
/> |
| 157 |
<span class="gs-switch__track" aria-hidden="true"><span class="gs-switch__thumb"></span></span> |
| 158 |
</label> |
| 159 |
<?php endif; ?> |
| 160 |
</div> |
| 161 |
</article> |
| 162 |
<?php endforeach; ?> |
| 163 |
</div> |
| 164 |
|
| 165 |
<div class="gs-empty" data-gs-empty hidden> |
| 166 |
<svg class="gs-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true" focusable="false"> |
| 167 |
<circle cx="11" cy="11" r="7" /><path d="m20 20-3.5-3.5" /> |
| 168 |
</svg> |
| 169 |
<p><?php esc_html_e( 'No blocks match your search.', 'slider-blocks' ); ?></p> |
| 170 |
<button type="button" class="gs-btn gs-btn--quiet gs-btn--sm" data-gs-clear-filters> |
| 171 |
<?php esc_html_e( 'Clear filters', 'slider-blocks' ); ?> |
| 172 |
</button> |
| 173 |
</div> |
| 174 |
|
| 175 |
<?php if ( ! $has_pro ) : ?> |
| 176 |
<div class="gs-note"> |
| 177 |
<svg class="gs-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"> |
| 178 |
<rect x="4" y="10" width="16" height="11" rx="2" /><path d="M8 10V7a4 4 0 0 1 8 0v3" /> |
| 179 |
</svg> |
| 180 |
<p> |
| 181 |
<?php esc_html_e( 'Pro blocks are listed so you can see what is available. They activate automatically once GutSlider Pro is installed.', 'slider-blocks' ); ?> |
| 182 |
<a class="gs-link" href="https://gutslider.com/pricing" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'See pricing', 'slider-blocks' ); ?></a> |
| 183 |
</p> |
| 184 |
</div> |
| 185 |
<?php endif; ?> |
| 186 |
</div> |
| 187 |
|
| 188 |
<?php |
| 189 |
require GUTSLIDER_DIR . '/admin/views/footer.php'; |
| 190 |
|