demo-sites.php
1 year ago
get-started.php
2 years ago
upgrade-pro.php
1 year ago
website-starter.php
6 days ago
demo-sites.php
226 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | use IlluminateAgnostic\Arr\Support\Arr; |
| 5 | use Kubio\DemoSites\DemoSitesRepository; |
| 6 | |
| 7 | if ( ! current_user_can( 'edit_theme_options' ) ) { |
| 8 | ?> |
| 9 | <div class="tab-page"> |
| 10 | <div class="limited-width"> |
| 11 | <div class="kubio-admin-page-section"> |
| 12 | <div class="kubio-admin-page-section-header"> |
| 13 | <?php esc_html_e( 'You need a higher level of permission.', 'kubio' ); ?> |
| 14 | </div> |
| 15 | <div class="kubio-admin-page-section-content"> |
| 16 | <p><?php esc_html_e( 'Current user is not allowed to import starter sites. This feature is available only for administrators', 'kubio' ); ?></p> |
| 17 | </div> |
| 18 | </div> |
| 19 | </div> |
| 20 | </div> |
| 21 | <?php |
| 22 | return; |
| 23 | } else { |
| 24 | $kubio_demo_sites_display_pro_badge = apply_filters( 'kubio/demo-sites/display-pro-badge', true ); |
| 25 | ?> |
| 26 | |
| 27 | <div class="kubio-admin-page-section"> |
| 28 | <div class="<?php kubio_admin_page_class( 'templates-wrapper' ); ?>"> |
| 29 | <div id="kubio-templates-list" class="<?php kubio_admin_page_component_class( 'templates' ); ?>"> |
| 30 | <?php if ( empty( DemoSitesRepository::getDemos() ) ) : ?> |
| 31 | <h2><?php esc_html_e( 'Retrieving starter sites...', 'kubio' ); ?></h2> |
| 32 | <?php endif; ?> |
| 33 | <?php foreach ( DemoSitesRepository::getDemos() as $demo ) : ?> |
| 34 | <div class="<?php kubio_admin_page_component_class( 'template' ); ?>" |
| 35 | data-demo-site="<?php echo esc_attr( Arr::get( $demo, 'slug', '' ) ); ?>"> |
| 36 | |
| 37 | <?php if ( Arr::get( $demo, 'is_pro', '' ) && $kubio_demo_sites_display_pro_badge ) : ?> |
| 38 | <div class="<?php kubio_admin_page_component_class( 'pro-badge' ); ?>">PRO</div> |
| 39 | <?php endif; ?> |
| 40 | |
| 41 | <div class="<?php kubio_admin_page_component_class( 'template-image' ); ?>"> |
| 42 | <?php // phpcs:disable ?> |
| 43 | <img src="<?php echo esc_url( Arr::get( $demo, 'thumb', kubio_url( '/static/admin-pages/' ) ) ); ?>" |
| 44 | alt="image"> |
| 45 | <?php if ( Arr::get( $demo, 'preview', 'null' ) ) : ?> |
| 46 | |
| 47 | <div class="<?php kubio_admin_page_component_class( 'template-image-overlay' ); ?>"> |
| 48 | <a href="<?php echo esc_url( Arr::get( $demo, 'preview' ) ); ?>" target="_blank"> |
| 49 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!-- Font Awesome Pro 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) --><path d="M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"/></svg> |
| 50 | <span><?php esc_html_e( 'Preview', 'kubio' ); ?></span> |
| 51 | </a> |
| 52 | </div> |
| 53 | <?php endif; ?> |
| 54 | <?php // phpcs:enable ?> |
| 55 | </div> |
| 56 | |
| 57 | <div class="<?php kubio_admin_page_component_class( 'template-body' ); ?>"> |
| 58 | <div class="<?php kubio_admin_page_component_class( 'template-title' ); ?>"> |
| 59 | <?php echo esc_html( Arr::get( $demo, 'name', __( 'Untitled', 'kubio' ) ) ); ?> |
| 60 | </div> |
| 61 | |
| 62 | <div class="<?php kubio_admin_page_component_class( 'template-buttons' ); ?>"> |
| 63 | <button class="button button-primary" |
| 64 | data-slug="<?php echo esc_attr( Arr::get( $demo, 'slug', '' ) ); ?>"> |
| 65 | <?php esc_html_e( 'Import site', 'kubio' ); ?> |
| 66 | </button> |
| 67 | |
| 68 | |
| 69 | <a href="<?php echo esc_url( kubio_try_demo_url( Arr::get( $demo, 'slug', '' ) ) ); ?>" target="_blank" |
| 70 | rel="nofollow" |
| 71 | class="button "> |
| 72 | <?php esc_html_e( 'Try Online', 'kubio' ); ?> |
| 73 | </a> |
| 74 | |
| 75 | </div> |
| 76 | |
| 77 | </div> |
| 78 | </div> |
| 79 | <?php endforeach; ?> |
| 80 | </div> |
| 81 | <div id="kubio-template-installing" |
| 82 | class="<?php kubio_admin_page_component_class( 'template-installing', array( 'hidden' ) ); ?>"> |
| 83 | <div class="<?php kubio_admin_page_component_class( 'template-installing-wrapper' ); ?>"> |
| 84 | <div class="kubio-admin-row nowrap"> |
| 85 | <div class="<?php kubio_admin_page_component_class( 'template-installing-image-col' ); ?>"> |
| 86 | <div class="<?php kubio_admin_page_component_class( 'template-image' ); ?>"> |
| 87 | <img/> |
| 88 | </div> |
| 89 | </div> |
| 90 | <div class="<?php kubio_admin_page_component_class( 'template-installing-info-col' ); ?>"> |
| 91 | <h1 data-title></h1> |
| 92 | |
| 93 | <div data-info |
| 94 | class="<?php kubio_admin_page_component_class( 'template-installing-info' ); ?>"> |
| 95 | <h2><?php esc_html_e( 'You are about to import a demo site', 'kubio' ); ?></h2> |
| 96 | <ul> |
| 97 | <li> |
| 98 | <?php esc_html_e( 'Current pages will be moved to trash. You can restore the content back at any time.', 'kubio' ); ?> |
| 99 | </li> |
| 100 | <li> |
| 101 | <?php esc_html_e( 'Posts, pages, images, widgets, menus and other theme settings will get imported.', 'kubio' ); ?> |
| 102 | </li> |
| 103 | <li class="text-danger"> |
| 104 | <?php esc_html_e( 'Your current design will be completely overwritten by the new template. This process is irreversible. If you wish to be able to go back to the current design, please create a backup of your site before proceeding with the import.', 'kubio' ); ?> |
| 105 | </li> |
| 106 | </ul> |
| 107 | |
| 108 | <div class="hidden" data-plugins> |
| 109 | <hr/> |
| 110 | <h2><?php esc_html_e( 'The following plugins will be installed as they are part of the demo', 'kubio' ); ?></h2> |
| 111 | <ul data-plugins-list |
| 112 | class="<?php kubio_admin_page_component_class( 'template-plugins-list' ); ?>"> |
| 113 | </ul> |
| 114 | </div> |
| 115 | </div> |
| 116 | <div data-progress |
| 117 | class="<?php kubio_admin_page_component_class( 'template-installing-progress', array( 'hidden' ) ); ?>"> |
| 118 | |
| 119 | <ul data-progress-list> |
| 120 | <li data-installing-plugins> |
| 121 | <?php esc_html_e( 'Installing required plugins', 'kubio' ); ?> |
| 122 | </li> |
| 123 | <li data-preparing-for-import> |
| 124 | <?php esc_html_e( 'Preparing for demo site import', 'kubio' ); ?> |
| 125 | </li> |
| 126 | <li data-importing-content> |
| 127 | <?php esc_html_e( 'Importing content', 'kubio' ); ?> |
| 128 | </li> |
| 129 | </ul> |
| 130 | |
| 131 | <div data-importing-errors |
| 132 | class="<?php kubio_admin_page_component_class( 'template-installing-errors', array( 'hidden' ) ); ?>"> |
| 133 | <p><?php esc_html_e( 'Errors', 'kubio' ); ?></p> |
| 134 | <div data-importing-errors-content> |
| 135 | |
| 136 | </div> |
| 137 | </div> |
| 138 | </div> |
| 139 | |
| 140 | <h2 data-available-pro-only |
| 141 | class="hidden" |
| 142 | style="text-align: right"> |
| 143 | <?php esc_html_e( 'Available only with Kubio PRO', 'kubio' ); ?> |
| 144 | </h2> |
| 145 | |
| 146 | <div data-install-buttons |
| 147 | class="<?php kubio_admin_page_component_class( 'template-installing-buttons' ); ?>"> |
| 148 | <button class="button " data-cancel-import> |
| 149 | <?php esc_html_e( 'Cancel', 'kubio' ); ?> |
| 150 | </button> |
| 151 | <button id="import-button" class="button button-primary"> |
| 152 | <?php esc_html_e( 'Import site', 'kubio' ); ?> |
| 153 | </button> |
| 154 | <a target="_blank" href="<?php echo esc_url( kubio_get_site_url_for( 'features', array( 'source' => 'demos' ) ) ); ?>" |
| 155 | class="button button-primary hidden" data-check-pro-features> |
| 156 | <?php esc_html_e( 'Check all PRO features', 'kubio' ); ?> |
| 157 | </a> |
| 158 | </div> |
| 159 | |
| 160 | <div data-install-success-buttons |
| 161 | class="<?php kubio_admin_page_component_class( 'template-installing-success-buttons', array( 'hidden' ) ); ?>"> |
| 162 | <div class="kubio-admin-row"> |
| 163 | <div class="kubio-admin-col"> |
| 164 | <p><?php esc_html_e( 'Demo site imported sucessfuly', 'kubio' ); ?></p> |
| 165 | </div> |
| 166 | <div class="kubio-admin-col"> |
| 167 | |
| 168 | <a target="_blank" href="<?php echo esc_url( site_url() ); ?>" |
| 169 | class="button " t> |
| 170 | <?php esc_html_e( 'View site', 'kubio' ); ?> |
| 171 | </a> |
| 172 | <a href="<?php echo esc_url( add_query_arg( 'page', 'kubio', admin_url( 'admin.php' ) ) ); ?>" |
| 173 | class="button button-primary"> |
| 174 | <?php esc_html_e( 'Start editing', 'kubio' ); ?> |
| 175 | </a> |
| 176 | |
| 177 | </div> |
| 178 | </div> |
| 179 | |
| 180 | |
| 181 | </div> |
| 182 | |
| 183 | </div> |
| 184 | </div> |
| 185 | <?php kubio_print_continous_loading_bar( true ); ?> |
| 186 | </div> |
| 187 | </div> |
| 188 | </div> |
| 189 | </div> |
| 190 | |
| 191 | <?php |
| 192 | |
| 193 | function kubio_admin_page_templates_js_init() { |
| 194 | $demos = DemoSitesRepository::getDemos(); |
| 195 | |
| 196 | $plugins_states = DemoSitesRepository::getPluginsStates(); |
| 197 | |
| 198 | $data = array( |
| 199 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 200 | 'demos' => $demos, |
| 201 | 'ajax_nonce' => wp_create_nonce( 'kubio-ajax-demo-site-verification' ), |
| 202 | 'texts' => array( |
| 203 | 'importing_template' => '%s', |
| 204 | 'plugins_states' => array( |
| 205 | 'ACTIVE' => esc_html__( 'Active', 'kubio' ), |
| 206 | 'INSTALLED' => esc_html__( 'Installed', 'kubio' ), |
| 207 | 'NOT_INSTALLED' => esc_html__( 'Not Installed', 'kubio' ), |
| 208 | ), |
| 209 | 'import_stopped' => esc_html__( 'Import stopped', 'kubio' ), |
| 210 | ), |
| 211 | 'plugins_states' => $plugins_states, |
| 212 | ); |
| 213 | |
| 214 | $data = apply_filters( 'kubio/admin-page/templates-js-init', $data ); |
| 215 | |
| 216 | wp_add_inline_script( |
| 217 | 'kubio-admin-area', |
| 218 | sprintf( 'kubio.adminArea.initDemoImport(%s)', wp_json_encode( $data ) ), |
| 219 | 'after' |
| 220 | ); |
| 221 | } |
| 222 | |
| 223 | add_action( 'admin_footer', 'kubio_admin_page_templates_js_init', 0 ); |
| 224 | |
| 225 | } |
| 226 |