Changeset 220756
- Timestamp:
- 03/13/2024 12:01:18 PM (21 months ago)
- Location:
- blockstrap/0.1.5
- Files:
-
- 1 added
- 6 edited
- 1 copied
-
. (copied) (copied from blockstrap/0.1.4)
-
classes/class-blockstrap-admin.php (modified) (26 diffs)
-
classes/class-blockstrap-theme-support.php (modified) (5 diffs)
-
functions.php (modified) (1 diff)
-
inc/helper-functions.php (added)
-
inc/plugin-functions.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
blockstrap/0.1.5/classes/class-blockstrap-admin.php
r215341 r220756 16 16 17 17 /** 18 * Variable declaration for the option slug. 19 * 20 * @var string $option_slug The slug used for the options. 21 */ 22 public $option_key = 'blockstrap_options'; 23 24 /** 18 25 * Constructor. 19 26 * … … 35 42 36 43 // Page install on activation 37 add_action('admin_init', array( $this, 'maybe_add_pages' ) ); 38 44 add_action( 'admin_init', array( $this, 'maybe_add_pages' ) ); 45 46 // GeoDirectory filters 47 if ( defined( 'GEODIRECTORY_VERSION' ) ) { 48 add_filter( 'geodir_default_dummy_data_type', array( $this, 'gd_set_default_dummy_data_type' ), 10, 2 ); 49 add_filter( 'geodir_recommend_wp_plugins', array( $this, 'gd_recommend_wp_plugins' ) ); 50 } 51 52 // maybe update option to single key 53 $this->maybe_convert_options(); 54 55 } 56 57 /** 58 * This can be set in child themes to set the GD dummy data default type. 59 * 60 * @param $type 61 * @param $post_type 62 * 63 * @return mixed 64 */ 65 public function gd_set_default_dummy_data_type( $type, $post_type ) { 66 67 return $type; 68 } 69 70 71 /** 72 * Removes the "ninjs-forms" plugin from the list of recommended WordPress plugins. 73 * 74 * @param array $plugins The array of recommended WordPress plugins. 75 * 76 * @return array The updated array of recommended WordPress plugins with "ninjs-forms" plugin removed. 77 */ 78 public function gd_recommend_wp_plugins( $plugins ) { 79 80 // remove ninja forms as we have our own built-in contact form. 81 unset( $plugins['ninja-forms'] ); 82 83 $plugins['blockstrap-page-builder-blocks'] = array( 84 'url' => 'https://wordpress.org/plugins/blockstrap-page-builder-blocks/', 85 'slug' => 'blockstrap-page-builder-blocks', 86 'name' => 'Blockstrap Page Builder', 87 'file' => 'blockstrap-page-builder-blocks/blockstrap-page-builder-blocks.php', 88 'desc' => __( 'Required to display page template blocks, the theme will be blank without this.', 'blockstrap' ), 89 'required' => true, 90 ); 91 92 return $plugins; 39 93 } 40 94 … … 44 98 * @return void 45 99 */ 46 public function maybe_add_pages() {100 public function maybe_add_pages() { 47 101 $pages = $this->get_demo_pages(); 48 102 49 103 if ( ! empty( $pages ) ) { 50 104 $theme_slug = sanitize_title_with_dashes( $this->get_theme_title() ); 51 if ( ! get_option( 'blockstrap_demo_pages_installed_' . $theme_slug ) ) {105 if ( ! blockstrap_get_option( 'blockstrap_demo_pages_installed_' . $theme_slug ) ) { 52 106 foreach ( $pages as $page ) { 53 if (!$this->demo_page_exists( $page['slug'] )){107 if ( ! $this->demo_page_exists( $page['slug'] ) ) { 54 108 $page_id = $this->add_demo_page( $page ); 55 109 } 56 110 } 57 update_option( 'blockstrap_demo_pages_installed_' . $theme_slug, true ); 58 } 59 111 blockstrap_update_option( 'blockstrap_demo_pages_installed_' . $theme_slug, true ); 112 } 60 113 } 61 114 } 62 115 63 116 /** 117 * Get the array of demo pages. 118 * 119 * @return array[] 120 */ 121 public function get_demo_pages() { 122 return array(); 123 } 124 125 /** 126 * Get the theme title. 127 * 128 * @return string|null 129 */ 130 public function get_theme_title() { 131 return __( 'BlockStrap', 'blockstrap' ); 132 } 133 134 /** 135 * Check if demo page exists and return the ID if so. 136 * 137 * @param $page_slug 138 * 139 * @return int|string 140 */ 141 public function demo_page_exists( $page_slug ) { 142 $theme_slug = get_template(); 143 $option_key = 'blockstrap_demo_pages'; 144 $page_status = blockstrap_get_option( $option_key ); 145 146 return isset( $page_status[ $theme_slug ][ $page_slug ] ) ? absint( $page_status[ $theme_slug ][ $page_slug ] ) : ''; 147 } 148 149 /** 150 * Add a demo page from arguments. 151 * 152 * @param $page 153 * 154 * @return false|int|WP_Error 155 */ 156 public function add_demo_page( $page ) { 157 158 $theme_slug = get_template(); 159 $option_key = 'blockstrap_demo_pages'; 160 $page_status = blockstrap_get_option( $option_key ); 161 $page_status = empty( $page_status ) ? array() : $page_status; 162 $page_slug = esc_attr( $page['slug'] ); 163 164 $page_id = wp_insert_post( 165 array( 166 'post_title' => $page['title'], 167 'post_name' => $page['slug'], 168 'post_content' => $page['desc'], 169 'post_status' => 'publish', 170 'post_type' => 'page', 171 ) 172 ); 173 174 if ( is_wp_error( $page_id ) ) { 175 return false; 176 } else { 177 $page_status[ $theme_slug ][ $page_slug ] = $page_id; 178 blockstrap_update_option( $option_key, $page_status ); 179 180 if ( ! empty( $page['is_blog'] ) ) { 181 update_option( 'page_for_posts', $page_id ); 182 update_option( 'show_on_front', 'page' ); 183 184 if ( ! get_option( 'page_on_front' ) ) { 185 update_option( 'page_on_front', 2 ); // if page on front not set then it will show blog page on front. 186 } 187 } elseif ( ! empty( $page['is_front'] ) ) { 188 update_option( 'page_on_front', $page_id ); // this is probably not needed as the theme can set the front page anyway. 189 update_option( 'show_on_front', 'page' ); 190 } 191 } 192 193 return $page_id; 194 195 } 196 197 /** 64 198 * Load AUI on our settings page. 65 199 * … … 76 210 77 211 /** 212 * Returns the count of required plugins that are not activated. 213 * 214 * @return int The count of required plugins that are not activated. 215 */ 216 public function required_plugins_count() { 217 $count = 0; 218 $required_plugins = $this->get_required_plugins(); 219 220 foreach ( $required_plugins as $slug => $name ) { 221 $active = is_plugin_active( $slug . '/' . $slug . '.php' ); 222 if ( ! $active ) { 223 $count++; 224 } 225 } 226 227 return $count; 228 } 229 230 /** 78 231 * Register the menu item. 79 232 * @return void 80 233 */ 81 234 public function register_menu_page() { 235 $notifications_count = self::required_plugins_count(); 236 82 237 add_submenu_page( 83 238 'themes.php', 84 239 __( 'BlockStrap Settings', 'blockstrap' ), 85 __( 'Theme Setup', 'blockstrap' ),240 ! empty( $notifications_count ) ? __( 'Theme Setup', 'blockstrap' ) . ' <span class="awaiting-mod">' . absint( $notifications_count ) . '</span>' : __( 'Theme Setup', 'blockstrap' ), 86 241 'manage_options', 87 242 'blockstrap', … … 102 257 <div class="d-flex align-items-center"> 103 258 <h1 class="text-dark "><?php echo esc_html( $this->get_theme_title() ); ?></h1> 104 <span class="badge bg-faded-info fs-sm mb-2 ms-2">v<?php echo esc_html( $this->get_version() ); ?></span> 259 <span 260 class="badge bg-faded-info fs-sm mb-2 ms-2">v<?php echo esc_html( $this->get_version() ); ?></span> 105 261 </div> 106 262 … … 128 284 129 285 /** 130 * Get the theme title.131 *132 * @return string|null133 */134 public function get_theme_title() {135 return __( 'BlockStrap', 'blockstrap' );136 }137 138 /**139 286 * Get the required pages HTML output. 140 287 * … … 145 292 ?> 146 293 <div class="col"> 147 <div class="card h-100 mw-100"> 148 <h3 class="h4 text-dark"><?php _e( 'Optional Pages', 'blockstrap' ); ?></h3> 149 <ul class="list-group list-group-flush"> 150 151 <?php 152 153 if ( empty( $pages ) ) { 154 echo aui()->alert( 155 array( 156 'type' => 'info', 157 'content' => __( 'No demo pages for this theme', 'blockstrap' ), 158 'class' => 'mb-3 text-left text-start', 159 ) 160 ); 161 } else { 162 foreach ( $pages as $slug => $page ) { 163 $active = $this->demo_page_exists( $slug ); 164 165 $exists = false;// !$active ? get_page_by_path($slug) : false; 166 ?> 167 <li class="list-group-item d-flex justify-content-between align-items-center"> 168 <span class="mr-auto me-auto"><?php echo esc_html( $page['title'] ); ?></span> 294 <div class="card h-100 mw-100"> 295 <h3 class="h4 text-dark"><?php _e( 'Optional Pages', 'blockstrap' ); ?></h3> 296 <ul class="list-group list-group-flush"> 297 298 <?php 299 300 if ( empty( $pages ) ) { 301 echo aui()->alert( 302 array( 303 'type' => 'info', 304 'content' => __( 'No demo pages for this theme', 'blockstrap' ), 305 'class' => 'mb-3 text-left text-start', 306 ) 307 ); 308 } else { 309 foreach ( $pages as $slug => $page ) { 310 $active = $this->demo_page_exists( $slug ); 311 312 $exists = false;// !$active ? get_page_by_path($slug) : false; 313 ?> 314 <li class="list-group-item d-flex justify-content-between align-items-center"> 315 <span class="mr-auto me-auto"><?php echo esc_html( $page['title'] ); ?></span> 316 <?php 317 if ( $exists ) { 318 echo '<i class="fas fa-exclamation-triangle mr-2 me-2 text-warning fa-lg c-pointer" data-bs-toggle="tooltip" data-bs-title="' . __( 'Page with same slug exists', 'blockstrap' ) . '"></i>'; 319 } 320 321 if ( $active && false ) { 322 $link = get_permalink( $active ); 323 echo '<a class="bs-demo-link" href="' . esc_url( $link ) . '" target="_blank" ><i class="fas fa-external-link-alt mr-2 me-2 text-muted fa-lg c-pointer" data-bs-toggle="tooltip" data-bs-title="' . __( 'Page with same slug exists', 'blockstrap' ) . '"></i></a>'; 324 } 325 ?> 326 <div class="spinner-border spinner-border-sm mr-2 me-2 d-none text-muted" role="status"> 327 <span class="visually-hidden">Loading...</span> 328 </div> 329 <div class="form-check form-switch mb-0"> 330 <input class="form-check-input" type="checkbox" role="switch" 331 id="blockstrap-req-plugin-<?php echo esc_attr( $slug ); ?>" 332 <?php 333 if ( $active ) { 334 echo 'checked'; 335 } 336 337 if ( $exists ) { 338 echo ' disabled '; 339 } 340 ?> 341 onclick="blockstrap_admin_toggle_demo_page(this,'<?php echo esc_attr( $slug ); ?>',!jQuery(this).is(':checked'));"> 342 </div> 343 </li> 169 344 <?php 170 if ( $exists ) { 171 echo '<i class="fas fa-exclamation-triangle mr-2 me-2 text-warning fa-lg c-pointer" data-bs-toggle="tooltip" data-bs-title="' . __( 'Page with same slug exists', 'blockstrap' ) . '"></i>'; 172 } 173 174 if ( $active && false ) { 175 $link = get_permalink( $active ); 176 echo '<a class="bs-demo-link" href="' . esc_url( $link ) . '" target="_blank" ><i class="fas fa-external-link-alt mr-2 me-2 text-muted fa-lg c-pointer" data-bs-toggle="tooltip" data-bs-title="' . __( 'Page with same slug exists', 'blockstrap' ) . '"></i></a>'; 177 } 178 ?> 179 <div class="spinner-border spinner-border-sm mr-2 me-2 d-none text-muted" role="status"> 180 <span class="visually-hidden">Loading...</span> 181 </div> 182 <div class="form-check form-switch mb-0"> 183 <input class="form-check-input" type="checkbox" role="switch" id="blockstrap-req-plugin-<?php echo esc_attr( $slug ); ?>" 184 <?php 185 if ( $active ) { 186 echo 'checked'; 187 } 188 189 if ( $exists ) { 190 echo ' disabled '; 191 } 192 ?> 193 onclick="blockstrap_admin_toggle_demo_page(this,'<?php echo esc_attr( $slug ); ?>',!jQuery(this).is(':checked'));"> 194 </div> 195 </li> 196 <?php 345 } 197 346 } 198 } 199 200 ?> 201 </ul> 202 </div> 347 348 ?> 349 </ul> 350 </div> 203 351 </div> 204 352 <?php … … 212 360 public function get_required_plugins_html() { 213 361 $required_plugins = $this->get_required_plugins(); 362 $border_class = self::required_plugins_count() ? 'border-danger' : ''; 214 363 ?> 215 364 <div class="col"> 216 <div class="card h-100 mw-100"> 217 <h3 class="h4 text-dark"><?php _e( 'Required Plugins', 'blockstrap' ); ?></h3> 365 <div class="card h-100 mw-100 p-0 bs-required-plugin-card <?php echo $border_class; ?>"> 366 <h5 class="card-header h4 text-dark"><?php _e( 'Required Plugins', 'blockstrap' ); ?></h5> 367 <div class="card-body"> 218 368 <ul class="list-group list-group-flush"> 219 369 … … 228 378 </div> 229 379 <div class="form-check form-switch mb-0"> 230 <input class="form-check-input" type="checkbox" role="switch" id="blockstrap-req-plugin-<?php echo esc_attr( $slug ); ?>" 231 <?php 232 if ( $active ) { 233 echo 'checked';} 234 ?> 235 onclick="blockstrap_admin_toggle_plugin_activation(this,'<?php echo esc_attr( $slug ); ?>',!jQuery(this).is(':checked'));"> 380 <input class="form-check-input" type="checkbox" role="switch" 381 id="blockstrap-req-plugin-<?php echo esc_attr( $slug ); ?>" 382 <?php 383 if ( $active ) { 384 echo 'checked'; 385 } 386 ?> 387 onclick="blockstrap_admin_toggle_plugin_activation(this,'<?php echo esc_attr( $slug ); ?>',!jQuery(this).is(':checked'));"> 236 388 </div> 237 389 </li> … … 240 392 ?> 241 393 </ul> 242 </div>243 </div>244 <?php245 246 $this->get_setting_js();247 }248 249 /**250 * Get the required plugins HTML output.251 *252 * @return void253 */254 public function get_recaptcha_html() {255 $keys = get_option('blockstrap_recaptcha_keys');256 $site_key = isset($keys['site_key']) ? esc_attr($keys['site_key']) : '';257 $site_secret = isset($keys['site_secret']) ? esc_attr($keys['site_secret']) : '';258 ?>259 <div class="col mt-5">260 <div class="card h-100 mw-100 p-0">261 <h5 class="card-header h4 text-dark"><?php _e( 'Recaptcha Keys', 'blockstrap' ); ?></h5>262 <div class="card-body">263 <div class="alert alert-info" role="alert">264 <?php _e( 'Please enter your Google recaptcha <b>v2 Tickbox</b> keys. (this helps protect the contact form block)', 'blockstrap' ); ?>265 <a href="https://www.google.com/recaptcha/admin" target="_blank"> <?php _e( 'Get Keys', 'blockstrap' ); ?> <i class="fas fa-external-link-alt"></i></a>266 </div>267 <form class="w-100" onsubmit="blockstrap_admin_save_recaptcha_keys(this);return false;">268 <div class="mb-3">269 <label for="gc-site-key" class="form-label"><?php _e( 'Site Key', 'blockstrap' ); ?></label>270 <input type="text" class="form-control" name="site_key" id="gc-site-key" value="<?php echo esc_attr($site_key); ?>">271 </div>272 <div class="mb-3">273 <label for="gc-secret-key" class="form-label"><?php _e( 'Secret Key', 'blockstrap' ); ?></label>274 <input type="password" class="form-control" name="site_secret" id="gc-secret-key" value="<?php echo esc_attr($site_secret); ?>">275 </div>276 <button type="submit" class="btn btn-primary"> <span class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span>277 <?php _e( 'Save', 'blockstrap' ); ?></button>278 </form>279 394 </div> 280 395 </div> 281 396 </div> 282 397 <?php 398 399 $this->get_setting_js(); 400 } 401 402 /** 403 * Get the required plugins details array. 404 * 405 * @return array 406 */ 407 public function get_required_plugins() { 408 return array( 409 'blockstrap-page-builder-blocks' => __( 'BlockStrap Builder', 'blockstrap' ), 410 ); 283 411 } 284 412 … … 300 428 * @param $deactivate 301 429 */ 302 function blockstrap_admin_save_recaptcha_keys($this) {430 function blockstrap_admin_save_recaptcha_keys($this) { 303 431 304 432 var data = { … … 313 441 data: data, 314 442 // dataType: 'html' 315 beforeSend: function () {443 beforeSend: function () { 316 444 jQuery($this).find('.btn-primary').prop('disabled', true).find('.spinner-border').removeClass('d-none'); 317 445 }, 318 success: function (data) {446 success: function (data) { 319 447 if (data.success) { 320 448 jQuery($this).find('.btn-primary').prop('disabled', false).find('.spinner-border').addClass('d-none'); 321 aui_toast('blockstrap_recaptcha_keys_success', 'success', data.data);449 aui_toast('blockstrap_recaptcha_keys_success', 'success', data.data); 322 450 323 451 } else { … … 327 455 } 328 456 }, 329 error: function (xhr) { // if error occured457 error: function (xhr) { // if error occured 330 458 alert("Error occured.please try again"); 331 459 }, 332 complete: function () {460 complete: function () { 333 461 jQuery($this).find('.btn-primary').prop('disabled', false).find('.spinner-border').addClass('d-none'); 334 462 … … 344 472 * @param $deactivate 345 473 */ 346 function blockstrap_admin_toggle_plugin_activation($this, $plugin,$deactivate){474 function blockstrap_admin_toggle_plugin_activation($this, $plugin, $deactivate) { 347 475 348 476 var data = { … … 358 486 data: data, 359 487 // dataType: 'html' 360 beforeSend: function () {488 beforeSend: function () { 361 489 jQuery($this).prop('disabled', true).parent().parent().find('.spinner-border').removeClass('d-none'); 362 490 }, 363 success: function (data) {491 success: function (data) { 364 492 if (data.success) { 365 493 jQuery($this).prop('disabled', false).parent().parent().find('.spinner-border').addClass('d-none'); 366 494 if ($deactivate) { 367 aui_toast('blockstrap_plugin_deactivation_success', 'success', data.data);368 } else{369 aui_toast('blockstrap_plugin_activation_success', 'success', data.data);495 aui_toast('blockstrap_plugin_deactivation_success', 'success', data.data); 496 } else { 497 aui_toast('blockstrap_plugin_activation_success', 'success', data.data); 370 498 } 371 499 } else { 372 500 let $checked = !!data.deactivate; 373 501 jQuery($this).prop('disabled', false).prop('checked', $checked).parent().parent().find('.spinner-border').addClass('d-none'); 374 aui_toast('blockstrap_plugin_management_error_' +$plugin,'error', data.data);502 aui_toast('blockstrap_plugin_management_error_' + $plugin, 'error', data.data); 375 503 } 376 504 }, 377 error: function (xhr) { // if error occured505 error: function (xhr) { // if error occured 378 506 alert("Error occured.please try again"); 379 507 }, 380 complete: function () {508 complete: function () { 381 509 jQuery($this).prop('disabled', false).parent().parent().find('.spinner-border').addClass('d-none'); 510 blockstrap_admin_toggle_required_plugins_border(); 382 511 }, 383 512 }); 513 } 514 515 /** 516 * Toggles the required plugins border class. 517 * 518 * @return {void} 519 */ 520 function blockstrap_admin_toggle_required_plugins_border() { 521 // Total number of checkboxes 522 var totalCheckboxes = jQuery('.bs-required-plugin-card .form-check-input').length; 523 // Number of checkboxes that are checked 524 var checkedCheckboxes = jQuery('.bs-required-plugin-card .form-check-input:checked').length; 525 526 // Check if all checkboxes are checked 527 if(totalCheckboxes === checkedCheckboxes) { 528 jQuery('.bs-required-plugin-card').removeClass('border-danger'); 529 } else { 530 jQuery('.bs-required-plugin-card').addClass('border-danger'); 531 } 384 532 } 385 533 … … 391 539 * @param $delete 392 540 */ 393 function blockstrap_admin_toggle_demo_page($this, $page_slug,$delete){541 function blockstrap_admin_toggle_demo_page($this, $page_slug, $delete) { 394 542 395 543 var data = { … … 405 553 data: data, 406 554 // dataType: 'html' 407 beforeSend: function () {555 beforeSend: function () { 408 556 jQuery($this).prop('disabled', true).parent().parent().find('.spinner-border').removeClass('d-none'); 409 557 }, 410 success: function (data) {558 success: function (data) { 411 559 if (data.success) { 412 560 jQuery($this).prop('disabled', false).parent().parent().find('.spinner-border').addClass('d-none'); 413 561 if ($delete) { 414 aui_toast('blockstrap_page_deactivation_success', 'success', data.data);415 } else{416 aui_toast('blockstrap_page_activation_success', 'success', data.data);562 aui_toast('blockstrap_page_deactivation_success', 'success', data.data); 563 } else { 564 aui_toast('blockstrap_page_activation_success', 'success', data.data); 417 565 } 418 566 } else { 419 567 let $checked = !!data.delete; 420 568 jQuery($this).prop('disabled', false).prop('checked', $checked).parent().parent().find('.spinner-border').addClass('d-none'); 421 aui_toast('blockstrap_page_management_error', 'error', data.data);569 aui_toast('blockstrap_page_management_error', 'error', data.data); 422 570 } 423 571 }, 424 error: function (xhr) { // if error occured572 error: function (xhr) { // if error occured 425 573 let $checked = !!data.delete; 426 574 jQuery($this).prop('disabled', false).prop('checked', $checked).parent().parent().find('.spinner-border').addClass('d-none'); 427 575 alert("Error occured.please try again"); 428 576 }, 429 complete: function () {577 complete: function () { 430 578 jQuery($this).prop('disabled', false).parent().parent().find('.spinner-border').addClass('d-none'); 431 579 }, … … 438 586 439 587 /** 440 * Get the required plugins details array. 441 * 442 * @return array 443 */ 444 public function get_required_plugins() { 445 return array( 446 'blockstrap-page-builder-blocks' => __( 'BlockStrap Builder', 'blockstrap' ), 447 ); 448 } 449 450 /** 451 * Get the array of demo pages. 452 * 453 * @return array[] 454 */ 455 public function get_demo_pages() { 456 return array(); 588 * Get the required plugins HTML output. 589 * 590 * @return void 591 */ 592 public function get_recaptcha_html() { 593 $keys = blockstrap_get_option( 'blockstrap_recaptcha_keys' ); 594 $site_key = isset( $keys['site_key'] ) ? esc_attr( $keys['site_key'] ) : ''; 595 $site_secret = isset( $keys['site_secret'] ) ? esc_attr( $keys['site_secret'] ) : ''; 596 ?> 597 <div class="col mt-5"> 598 <div class="card h-100 mw-100 p-0"> 599 <h5 class="card-header h4 text-dark"><?php _e( 'Recaptcha Keys', 'blockstrap' ); ?></h5> 600 <div class="card-body"> 601 <div class="alert alert-info" role="alert"> 602 <?php _e( 'Please enter your Google recaptcha <b>v2 Tickbox</b> keys. (this helps protect the contact form block)', 'blockstrap' ); ?> 603 <a href="https://www.google.com/recaptcha/admin" 604 target="_blank"> <?php _e( 'Get Keys', 'blockstrap' ); ?> <i 605 class="fas fa-external-link-alt"></i></a> 606 </div> 607 <form class="w-100" onsubmit="blockstrap_admin_save_recaptcha_keys(this);return false;"> 608 <div class="mb-3"> 609 <label for="gc-site-key" class="form-label"><?php _e( 'Site Key', 'blockstrap' ); ?></label> 610 <input type="text" class="form-control" name="site_key" id="gc-site-key" 611 value="<?php echo esc_attr( $site_key ); ?>"> 612 </div> 613 <div class="mb-3"> 614 <label for="gc-secret-key" 615 class="form-label"><?php _e( 'Secret Key', 'blockstrap' ); ?></label> 616 <input type="password" class="form-control" name="site_secret" id="gc-secret-key" 617 value="<?php echo esc_attr( $site_secret ); ?>"> 618 </div> 619 <button type="submit" class="btn btn-primary"><span 620 class="spinner-border spinner-border-sm d-none" role="status" aria-hidden="true"></span> 621 <?php _e( 'Save', 'blockstrap' ); ?></button> 622 </form> 623 </div> 624 </div> 625 </div> 626 <?php 457 627 } 458 628 … … 467 637 ob_start(); 468 638 include $path; 639 469 640 return ob_get_clean(); 470 641 } … … 540 711 541 712 /** 542 * Check if demo page exists and return the ID if so.543 *544 * @param $page_slug545 *546 * @return int|string547 */548 public function demo_page_exists( $page_slug ) {549 $theme_slug = get_template();550 $option_key = 'blockstrap_demo_pages';551 $page_status = get_option( $option_key );552 return isset( $page_status[ $theme_slug ][ $page_slug ] ) ? absint( $page_status[ $theme_slug ][ $page_slug ] ) : '';553 }554 555 /**556 713 * The AJAX function that will add or remove the demo pages. 557 714 * … … 579 736 $theme_slug = get_template(); 580 737 $option_key = 'blockstrap_demo_pages'; 581 $page_status = get_option( $option_key );738 $page_status = blockstrap_get_option( $option_key ); 582 739 $page_id = $this->demo_page_exists( $page_slug ); 583 740 … … 587 744 wp_trash_post( $page_id ); 588 745 unset( $page_status[ $theme_slug ][ $page_slug ] ); 589 update_option( $option_key, $page_status );746 blockstrap_update_option( $option_key, $page_status ); 590 747 } 591 748 … … 595 752 } else { 596 753 if ( ! $page_id ) { 597 $page_id = $this-> add_demo_page( $page );754 $page_id = $this->add_demo_page( $page ); 598 755 599 756 if ( is_wp_error( $page_id ) ) { … … 617 774 618 775 /** 619 * Add a demo page from arguments.620 *621 * @param $page622 *623 * @return false|int|WP_Error624 */625 public function add_demo_page( $page ) {626 627 $theme_slug = get_template();628 $option_key = 'blockstrap_demo_pages';629 $page_status = get_option( $option_key );630 $page_slug = esc_attr( $page['slug'] );631 632 $page_id = wp_insert_post(633 array(634 'post_title' => $page['title'],635 'post_name' => $page['slug'],636 'post_content' => $page['desc'],637 'post_status' => 'publish',638 'post_type' => 'page',639 )640 );641 642 if ( is_wp_error( $page_id ) ) {643 return false;644 }else{645 $page_status[ $theme_slug ][ $page_slug ] = $page_id;646 update_option( $option_key, $page_status );647 648 if ( ! empty( $page['is_blog'] ) ) {649 update_option( 'page_for_posts', $page_id );650 update_option('show_on_front', 'page');651 652 if ( ! get_option( 'page_on_front' ) ) {653 update_option( 'page_on_front', 2 ); // if page on front not set then it will show blog page on front.654 }655 } elseif ( ! empty( $page['is_front'] ) ) {656 update_option( 'page_on_front', $page_id ); // this is probably not needed as the theme can set the front page anyway.657 update_option('show_on_front', 'page');658 }659 }660 661 return $page_id;662 663 664 }665 666 /**667 776 * The AJAX function that will save the recaptcha keys. 668 777 * … … 677 786 } 678 787 679 680 788 parse_str( $_POST['form_data'], $data ); 681 // print_r($data ); 682 683 if(isset($data['site_key']) && isset($data['site_secret'])) { 684 update_option('blockstrap_recaptcha_keys',array( 685 'site_key' => sanitize_html_class($data['site_key']), 686 'site_secret' => sanitize_html_class($data['site_secret']), 687 )); 789 790 if ( isset( $data['site_key'] ) && isset( $data['site_secret'] ) ) { 791 blockstrap_update_option( 792 'blockstrap_recaptcha_keys', 793 array( 794 'site_key' => sanitize_html_class( $data['site_key'] ), 795 'site_secret' => sanitize_html_class( $data['site_secret'] ), 796 ) 797 ); 688 798 wp_send_json_success( __( 'Keys Saved', 'blockstrap' ) ); 689 } else{799 } else { 690 800 wp_send_json_error( 'Something went wrong' ); 691 801 } 692 693 802 } else { 694 803 wp_send_json_error( 'You do not have permission for this.' ); … … 698 807 } 699 808 809 810 /** 811 * Maybe update single options to our new one array of options. 812 * 813 * @return void 814 */ 815 public function maybe_convert_options() { 816 $options = blockstrap_get_options(); 817 818 if ( empty( $options ) ) { 819 $theme_slug = sanitize_title_with_dashes( $this->get_theme_title() ); 820 821 $keys = array( 822 'blockstrap_recaptcha_keys', 823 'blockstrap_demo_pages_installed_' . $theme_slug, 824 'directory_geodirectory_dismiss', 825 'directory_theme_v3', 826 'school_theme_v2', 827 ); 828 829 foreach ( $keys as $key ) { 830 blockstrap_update_option( $key, get_option( $key ) ); 831 } 832 } 833 } 834 700 835 } 701 836 -
blockstrap/0.1.5/classes/class-blockstrap-theme-support.php
r215341 r220756 28 28 29 29 // load only if theme is not blockstrap 30 if ( ! defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ) {30 if ( ! defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) ) { 31 31 add_action( 'admin_notices', array( __CLASS__, 'plugin_notice' ) ); 32 32 } … … 40 40 public static function plugin_notice() { 41 41 42 // bail if the user should not be here 43 if ( ! current_user_can( 'edit_theme_options' ) ) { 44 return; 45 } 46 47 // nonce check for dismiss action 48 if ( isset( $_REQUEST['blockstrap_plugin_notice_dismiss'] ) ) { 49 check_admin_referer( 'blockstrap_plugin_notice_dismiss' ); 50 blockstrap_update_option( 'blockstrap_plugin_notice_dismiss', time() ); 51 } 52 53 // bail if already dismissed 54 if ( blockstrap_get_option( 'blockstrap_plugin_notice_dismiss' ) ) { 55 return; 56 } 57 42 58 $pathpluginurl = WP_PLUGIN_DIR . '/blockstrap-page-builder-blocks/blockstrap-page-builder-blocks.php'; 43 59 44 60 $installed = file_exists( $pathpluginurl ); 45 61 62 $dismiss_url = wp_nonce_url( 63 add_query_arg( 64 array( 65 'blockstrap_plugin_notice_dismiss' => 'true', 66 ) 67 ), 68 'blockstrap_plugin_notice_dismiss' 69 ); 70 46 71 if ( $installed ) { 47 72 48 $activate_url = wp_nonce_url(73 $activate_url = wp_nonce_url( 49 74 add_query_arg( 50 75 array( 51 76 'action' => 'activate', 52 'plugin' => 'blockstrap-page-builder-blocks/blockstrap-page-builder-blocks.php',77 'plugin' => 'blockstrap-page-builder-blocks/blockstrap-page-builder-blocks.php', 53 78 ), 54 79 admin_url( 'plugins.php' ) … … 62 87 63 88 printf( 64 '<div class="%1$s"><h3>%2$s</h3><p>%3$s</p><p><a href="%4$s" class="button button-primary">%5$s</a> </p></div>',89 '<div class="%1$s"><h3>%2$s</h3><p>%3$s</p><p><a href="%4$s" class="button button-primary">%5$s</a> <a href="%6$s" class="">%7$s</a> </p></div>', 65 90 esc_attr( $class ), 66 91 esc_html( $name ), 67 92 esc_html( $install_message ), 68 esc_url_raw( $activate_url ), 69 esc_html__( 'Activate BlockStrap Blocks Plugin', 'blockstrap' ) 70 ); 71 }else{ 72 $install_url = wp_nonce_url( 93 esc_url( $activate_url ), 94 esc_html__( 'Activate BlockStrap Blocks Plugin', 'blockstrap' ), 95 esc_url( $dismiss_url ), 96 esc_html__( 'Dismiss', 'blockstrap' ) 97 ); 98 } else { 99 $install_url = wp_nonce_url( 73 100 add_query_arg( 74 101 array( 75 102 'action' => 'install-plugin', 76 'plugin' => 'blockstrap-page-builder-blocks',103 'plugin' => 'blockstrap-page-builder-blocks', 77 104 ), 78 105 admin_url( 'update.php' ) … … 94 121 ); 95 122 } 96 97 123 98 124 } … … 189 215 190 216 // Menus 191 //add_theme_support( 'menus' );217 // add_theme_support( 'menus' ); 192 218 193 219 // remove wp-container-X inline CSS helpers -
blockstrap/0.1.5/functions.php
r215341 r220756 29 29 30 30 function blockstrap_load_admin() { 31 global $blockstrap_admin; 31 32 if ( is_admin() ) { 32 33 if ( class_exists( 'BlockStrap_Admin_Child' ) ) { 33 new BlockStrap_Admin_Child();34 } else if ( class_exists( 'BlockStrap_Admin' ) ) {35 new BlockStrap_Admin();34 $blockstrap_admin = new BlockStrap_Admin_Child(); 35 } elseif ( class_exists( 'BlockStrap_Admin' ) ) { 36 $blockstrap_admin = new BlockStrap_Admin(); 36 37 } 37 38 } 38 39 } 39 40 add_action( 'after_setup_theme', 'blockstrap_load_admin' ); 41 42 // Helper functions 43 require_once 'inc/helper-functions.php'; 40 44 41 45 // Theme support. -
blockstrap/0.1.5/inc/plugin-functions.php
r189286 r220756 1 1 <?php 2 2 3 // load only if theme is not blockstrap 4 if ( defined( 'BLOCKSTRAP_BLOCKS_VERSION' ) && ! defined( 'GEODIRECTORY_VERSION' ) ) { 5 add_action( 'admin_notices', 'blockstrap_theme_plugin_suggestions' ); 6 } 3 // add admin notice if required plugins not active/installed 4 add_action( 'admin_notices', 'blockstrap_theme_plugin_suggestions' ); 7 5 8 6 if ( ! function_exists( 'blockstrap_theme_plugin_suggestions' ) ) { … … 13 11 */ 14 12 function blockstrap_theme_plugin_suggestions() { 13 global $blockstrap_admin; 15 14 16 if ( isset( $_REQUEST['blockstrap_geodirectory_dismiss'] ) && check_admin_referer( 'blockstrap_geodirectory_nonce' ) ) { 17 update_option( 'blockstrap_geodirectory_dismiss', time() ); 18 } 19 20 $no_gd = get_option( 'blockstrap_geodirectory_dismiss' ); 21 22 // if accepted v3 then bail 23 if ( $no_gd ) { 15 // Bail if not loaded 16 if ( empty( $blockstrap_admin ) ) { 24 17 return; 25 18 } 26 19 27 $install_url = wp_nonce_url( 28 add_query_arg( 20 $required_plugins_count = $blockstrap_admin->required_plugins_count(); 21 22 if ( $required_plugins_count && (!isset($_REQUEST['page']) || ( isset($_REQUEST['page'])) && $_REQUEST['page'] !== 'blockstrap' ) ) { 23 $setup_url = add_query_arg( 29 24 array( 30 'action' => 'install-plugin', 31 'plugin' => 'geodirectory', 25 'page' => 'blockstrap', 32 26 ), 33 admin_url( 'update.php' ) 34 ), 35 'install-plugin_geodirectory' 36 ); 27 admin_url( 'themes.php' ) 28 ); 37 29 38 $dismiss_url = wp_nonce_url( 39 add_query_arg( 40 array( 41 'blockstrap_geodirectory_dismiss' => 1, 42 ) 43 ), 44 'blockstrap_geodirectory_nonce' 45 ); 30 printf( 31 '<div class="%1$s"><h3 class="h5 font-bold mt-2">%2$s</h3><p>%3$s</p><p><a href="%4$s" class="button button-primary">%5$s</a></p></div>', 32 'notice notice-warning is-dismissible', 33 esc_attr( __( 'Required Plugins', 'blockstrap' ) ), 34 /* translators: The theme active theme name */ 35 esc_html( sprintf( __( '%s theme requires some plugins for complete functionality', 'blockstrap' ), $blockstrap_admin->get_theme_title() ) ), 36 esc_url_raw( $setup_url ), 37 esc_html__( 'Setup Theme', 'blockstrap' ) 38 ); 39 } 46 40 47 $class = 'notice notice-info is-dismissible';48 $name = __( 'GeoDirectory', 'blockstrap' );49 $install_message = __( 'BlockStrap works great with GeoDirectory to create a fast and modern listing directory.', 'blockstrap' );50 51 printf(52 '<div class="%1$s"><h3>%2$s</h3><p>%3$s</p><p><a href="%4$s" class="button button-primary">%5$s</a> <a href="%6$s" class="button button-secondary">%7$s</a> </p></div>',53 esc_attr( $class ),54 esc_html( $name ),55 esc_html( $install_message ),56 esc_url_raw( $install_url ),57 esc_html__( 'Install GeoDirectory', 'blockstrap' ),58 esc_url_raw( $dismiss_url ),59 esc_html__( 'No thanks', 'blockstrap' )60 );61 41 } 62 42 } -
blockstrap/0.1.5/readme.txt
r215341 r220756 4 4 Requires at least: 6.0 5 5 Requires PHP: 7.2 6 Version: 0.1. 46 Version: 0.1.5 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 14 14 15 15 == Changelog == 16 17 = 0.1.5 = 18 * Required plugins flow changed slightly for better UX - CHANGED 19 * Helper functions introduced for getting and updating theme setting options - ADDED 16 20 17 21 = 0.1.4 = -
blockstrap/0.1.5/style.css
r215341 r220756 4 4 Author URI: https://ayecode.io 5 5 Theme URI: https://wpblockstrap.com 6 Version: 0.1. 46 Version: 0.1.5 7 7 Description: Introducing BlockStrap, a revolutionary WordPress theme that marries the streamlined agility of Bootstrap with the cutting-edge functionality of WordPress Full Site Editing (FSE). Crafted for performance, BlockStrap is all about simplicity, speed, and elegance. With Bootstrap's responsive design and WordPress FSE's real-time customization, you can effortlessly create a stunning look across all devices. Its lightweight build ensures rapid loading times, while a plethora of customization options allows for a unique expression of your brand's identity. Whether you're an individual, business, or creative agency, BlockStrap's blend of design and functionality offers a modern and efficient solution for your online presence. Explore the endless possibilities with BlockStrap today! 8 8 Tags: full-site-editing, blog, food-and-drink, two-columns, editor-style, block-styles
Note: See TracChangeset
for help on using the changeset viewer.