Changeset 3424554
- Timestamp:
- 12/21/2025 10:23:47 AM (3 months ago)
- Location:
- blockskit
- Files:
-
- 29 added
- 5 edited
-
tags/1.2.2 (added)
-
tags/1.2.2/assets (added)
-
tags/1.2.2/assets/blockskit-admin-notice.css (added)
-
tags/1.2.2/assets/blockskit-admin-notice.js (added)
-
tags/1.2.2/assets/img (added)
-
tags/1.2.2/assets/img/pro-notice.png (added)
-
tags/1.2.2/block.json (added)
-
tags/1.2.2/blockskit.php (added)
-
tags/1.2.2/build (added)
-
tags/1.2.2/build/index.asset.php (added)
-
tags/1.2.2/build/index.css (added)
-
tags/1.2.2/build/index.js (added)
-
tags/1.2.2/build/style-index.css (added)
-
tags/1.2.2/import (added)
-
tags/1.2.2/import/assets (added)
-
tags/1.2.2/import/assets/demo-import.css (added)
-
tags/1.2.2/import/assets/demo-import.js (added)
-
tags/1.2.2/import/base-install (added)
-
tags/1.2.2/import/base-install/assets (added)
-
tags/1.2.2/import/base-install/assets/base-install.css (added)
-
tags/1.2.2/import/base-install/assets/base-install.js (added)
-
tags/1.2.2/import/base-install/base-install.php (added)
-
tags/1.2.2/import/demo (added)
-
tags/1.2.2/import/demo-import.php (added)
-
tags/1.2.2/import/demo/functions.php (added)
-
tags/1.2.2/includes (added)
-
tags/1.2.2/includes/class-bk-advanced-import-override.php (added)
-
tags/1.2.2/includes/class-blockskit-pro-upgrade-notice.php (added)
-
tags/1.2.2/readme.txt (added)
-
trunk/blockskit.php (modified) (3 diffs)
-
trunk/import/base-install/assets/base-install.js (modified) (1 diff)
-
trunk/import/base-install/base-install.php (modified) (10 diffs)
-
trunk/import/demo-import.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
blockskit/trunk/blockskit.php
r3402294 r3424554 7 7 * Author: blockskitdev 8 8 * Author URI: https://blockskit.com/ 9 * Version: 1.2. 19 * Version: 1.2.2 10 10 * Text Domain: blockskit 11 11 * Domain Path: https://blockskit.com/free 12 * Tested up to: 6. 812 * Tested up to: 6.9 13 13 * 14 14 * Blockskit is free software: you can redistribute it and/or modify … … 32 32 33 33 define( 'BLOCKSKIT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 34 define( 'BLOCKSKIT_PLUGIN_VERSION', '1.2. 1');34 define( 'BLOCKSKIT_PLUGIN_VERSION', '1.2.2'); 35 35 36 36 function create_block_bk_block_init() { … … 46 46 // Blockskit Pro Admin Notice 47 47 require plugin_dir_path( __FILE__ ) . 'includes/class-blockskit-pro-upgrade-notice.php'; 48 49 // Advanced Import Override 50 require plugin_dir_path(__FILE__) . 'includes/class-bk-advanced-import-override.php'; 51 new Bk_Advanced_Import_Override(); -
blockskit/trunk/import/base-install/assets/base-install.js
r3143728 r3424554 1 jQuery( document ).ready( function ( $ ) { 2 $(".ai-demo-import").click(function(){ 3 4 var base_html = direct_install.base_html; 5 $('body').append( base_html ); 1 jQuery(document).ready(function ($) { 2 $(".ai-demo-import").click(function (e) { 6 3 7 } ); 8 $(document.body).on('click', '.close-base-notice' ,function(){ 4 var $item = $(this).closest('.ai-item'); 5 var slug = $item.data('slug').replace('-pro', ''); 6 var name = $item.attr('aria-label') || slug; // Fallback to slug if no label 7 8 name = name.replace(/Pro/g, '').trim(); 9 10 if (name.indexOf('BlocksKit') === -1) { 11 name = 'BlocksKit ' + name; 12 } 13 14 15 16 // Check if theme is not active 17 if (direct_install.active_theme_slug !== slug) { 18 var is_installed = direct_install.installed_themes && direct_install.installed_themes.indexOf(slug) !== -1; 19 20 if (is_installed || (!is_installed && direct_install.installed_themes)) { 21 e.preventDefault(); 22 23 var template = direct_install.popup_template; 24 var btn_text = is_installed ? 'Activate ' + name : 'Install and Activate ' + name; 25 26 // Replace name, slug and button text 27 var html = template.replace(/{{name}}/g, name) 28 .replace(/{{slug}}/g, slug) 29 .replace(/Install and Activate {{name}}/g, btn_text); 30 31 html = template.replace(/{{name}}/g, name).replace(/{{slug}}/g, slug); 32 33 if (is_installed) { 34 html = html.replace(/Install and Activate/g, 'Activate'); 35 } 36 37 $('body').append(html); 38 } 39 } 40 41 }); 42 $(document.body).on('click', '.close-base-notice', function () { 9 43 $(".base-install-notice-outer").remove(); 10 44 }); 11 45 //install base theme 12 $(document.body).on('click', '.install-base-theme' ,function(){ 13 $( this ).addClass( 'updating-message' ); 14 $.ajax({ 46 $(document.body).on('click', '.install-base-theme', function () { 47 $(this).addClass('updating-message'); 48 var slug = $(this).data('slug').replace('-pro', ''); 49 50 $.ajax({ 15 51 type: "POST", 16 52 url: direct_install.ajax_url, 17 53 data: { 18 action : 'install_base_theme', 19 security : direct_install.nonce 20 }, 21 success:function() { 22 $( this ).removeClass( 'updating-message' ); 23 $( '.base-install-prompt' ).remove(); 24 $( '.base-install-success' ).show(); 54 action: 'install_base_theme', 55 security: direct_install.nonce, 56 slug: slug 25 57 }, 26 error: function( xhr, ajaxOptions, thrownError ){ 58 success: function () { 59 $(this).removeClass('updating-message'); 60 $('.base-install-prompt').remove(); 61 $('.base-install-success').show(); 62 63 // Add the new slug to installed list locally so subsequent clicks don't trigger popup 64 if (direct_install.installed_themes) { 65 direct_install.installed_themes.push(slug); 66 } 67 }, 68 error: function (xhr, ajaxOptions, thrownError) { 27 69 console.log(thrownError); 28 70 } 29 71 }); 30 72 }); 31 } );73 }); -
blockskit/trunk/import/base-install/base-install.php
r3338758 r3424554 1 1 <?php 2 2 // Exit if accessed directly 3 if ( !defined( 'ABSPATH' ) ) exit; 3 if (!defined('ABSPATH')) 4 exit; 4 5 /** 5 6 * The Blockskit Import hooks callback functionality of the plugin. 6 7 * 7 8 */ 8 class Bk_Base_Install_Hooks { 9 class Bk_Base_Install_Hooks 10 { 9 11 10 12 /** … … 12 14 * 13 15 */ 14 public function __construct() { 15 add_action( 'wp_ajax_install_base_theme', array( $this, 'install_base_theme' )); 16 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ), 10, 1 ); 17 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 ); 16 public function __construct() 17 { 18 add_action('wp_ajax_install_base_theme', array($this, 'install_base_theme')); 19 add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'), 10, 1); 20 add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 10, 1); 18 21 } 19 22 … … 22 25 * 23 26 */ 24 public function enqueue_styles() { 25 26 wp_enqueue_style( 'bk-base-install', plugin_dir_url( __FILE__ ) . 'assets/base-install.css',array( 'wp-admin' ), '1.0.0', 'all' ); 27 public function enqueue_styles() 28 { 29 30 wp_enqueue_style('bk-base-install', plugin_dir_url(__FILE__) . 'assets/base-install.css', array('wp-admin'), '1.0.0', 'all'); 27 31 } 28 32 … … 31 35 * 32 36 */ 33 public function enqueue_scripts() { 37 public function enqueue_scripts() 38 { 34 39 35 wp_enqueue_script( 'bk-base-install', plugin_dir_url( __FILE__ ) . 'assets/base-install.js', array( 'jquery' ), '1.0.0', true);40 wp_enqueue_script('bk-base-install', plugin_dir_url(__FILE__) . 'assets/base-install.js', array('jquery'), '1.0.0', true); 36 41 37 $base_theme = bk_import_get_base_theme(); 38 $action = __( 'Install and Activate', 'blockskit' ); 39 if( bk_import_base_theme_installed() ){ 40 $action = __( 'Activate', 'blockskit' ); 41 } 42 // Get all installed theme slugs 43 $all_themes = wp_get_themes(); 44 $installed_themes_slugs = array_keys($all_themes); 45 42 46 wp_localize_script( 43 47 'bk-base-install', 44 48 'direct_install', 45 49 array( 46 'ajax_url' => admin_url( 'admin-ajax.php' ), 47 'nonce' => wp_create_nonce( 'direct_theme_install' ), 48 'base_html' => sprintf( 50 'ajax_url' => admin_url('admin-ajax.php'), 51 'nonce' => wp_create_nonce('direct_theme_install'), 52 'installed_themes' => $installed_themes_slugs, 53 'active_theme_slug' => wp_get_theme()->get_stylesheet(), 54 'popup_template' => 49 55 '<div class="base-install-notice-outer"> 50 56 <div class="base-install-notice-inner"> 51 57 <div class="base-install-prompt"> 52 <div class="base-install-content"><h2 class="base-install-title"> %1$s</h2><p>We recommend to %2$s %1$stheme as all our demo works perfectly with this theme. You can still try our demo on any block theme but it might not look as you see on our demo.</p></div>58 <div class="base-install-content"><h2 class="base-install-title">{{name}}</h2><p>We recommend to Install and Activate {{name}} theme as all our demo works perfectly with this theme. You can still try our demo on any block theme but it might not look as you see on our demo.</p></div> 53 59 <div class="base-install-btn"> 54 <a class= "install-base-theme button button-primary">%2$s %1$s</a>60 <a class="install-base-theme button button-primary" data-slug="{{slug}}">Install and Activate {{name}}</a> 55 61 <br> 56 <a class= "close-base-notice close-base-button">Skip</a>62 <a class="close-base-notice close-base-button">Skip</a> 57 63 </div> 58 64 </div> 59 65 <div class="base-install-success"> 60 <div class="base-install-content"><h3>Thank you for installing %1$s. Click on Next to proceed to demo importer.</h3></div>66 <div class="base-install-content"><h3>Thank you for installing {{name}}. Click on Next to proceed to demo importer.</h3></div> 61 67 <div class="base-install-btn"> 62 <a class= "close-base-notice button button-primary">Next</a>68 <a class="close-base-notice button button-primary">Next</a> 63 69 </div> 64 70 </div> … … 72 78 </div> 73 79 </div>', 74 $base_theme['name'],75 $action76 ),77 80 ) 78 81 ); … … 82 85 * Install base theme. 83 86 */ 84 public function install_base_theme(){ 85 check_ajax_referer( 'direct_theme_install', 'security' ); 87 public function install_base_theme() 88 { 89 check_ajax_referer('direct_theme_install', 'security'); 86 90 87 if ( !current_user_can('manage_options')) {88 $error = __( 'Sorry, you are not allowed to install themes on this site.', 'blockskit');89 wp_send_json_error( $error);91 if (!current_user_can('manage_options')) { 92 $error = __('Sorry, you are not allowed to install themes on this site.', 'blockskit'); 93 wp_send_json_error($error); 90 94 } 91 $base_theme = bk_import_get_base_theme(); 92 if ( bk_import_base_theme_installed() ) { 93 switch_theme( $base_theme['slug'] ); 95 96 $slug = isset($_POST['slug']) ? sanitize_text_field($_POST['slug']) : ''; 97 if (empty($slug)) { 98 $base_theme = bk_import_get_base_theme(); 99 $slug = $base_theme['slug']; // Fallback 100 } 101 102 // Check if already installed 103 $theme = wp_get_theme($slug); 104 if ($theme->exists()) { 105 switch_theme($slug); 94 106 wp_send_json_success(); 95 107 } … … 97 109 require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 98 110 include_once ABSPATH . 'wp-admin/includes/theme.php'; 99 111 100 112 $api = themes_api( 101 113 'theme_information', 102 114 array( 103 'slug' => $base_theme['slug'],104 'fields' => array( 'sections' => false),115 'slug' => $slug, 116 'fields' => array('sections' => false), 105 117 ) 106 118 ); 107 108 if ( is_wp_error( $api )) {119 120 if (is_wp_error($api)) { 109 121 $status['errorMessage'] = $api->get_error_message(); 110 wp_send_json_error( $status['errorMessage']);122 wp_send_json_error($status['errorMessage']); 111 123 } 112 124 113 $skin = new WP_Ajax_Upgrader_Skin();114 $upgrader = new Theme_Upgrader( $skin);115 $result = $upgrader->install( $api->download_link);125 $skin = new WP_Ajax_Upgrader_Skin(); 126 $upgrader = new Theme_Upgrader($skin); 127 $result = $upgrader->install($api->download_link); 116 128 117 129 if (is_wp_error($result)) { 118 wp_send_json_error( $result->errors);130 wp_send_json_error($result->errors); 119 131 } 120 132 121 switch_theme( $base_theme['slug']);133 switch_theme($slug); 122 134 wp_send_json_success(); 123 135 die(); … … 129 141 * Checks if base theme installed. 130 142 */ 131 function bk_import_base_theme_installed(){ 143 function bk_import_base_theme_installed() 144 { 132 145 $base_theme = bk_import_get_base_theme(); 133 146 $all_themes = wp_get_themes(); 134 147 $installed_themes = array(); 135 foreach ( $all_themes as $theme ){136 $theme_text_domain = esc_attr ( $theme->get('TextDomain'));148 foreach ($all_themes as $theme) { 149 $theme_text_domain = esc_attr($theme->get('TextDomain')); 137 150 $installed_themes[] = $theme_text_domain; 138 151 } 139 if ( in_array( $base_theme['slug'], $installed_themes, true ) ){152 if (in_array($base_theme['slug'], $installed_themes, true)) { 140 153 return true; 141 154 } 142 155 return false; 143 156 144 157 } 145 158 … … 147 160 * Returns base theme. 148 161 */ 149 function bk_import_get_base_theme(){ 162 function bk_import_get_base_theme() 163 { 150 164 $theme = bk_import_get_theme_slug(); 151 165 $base_theme = array( … … 153 167 'slug' => '', 154 168 ); 155 if ( strpos( $theme, 'blockskit' ) !== false ){169 if (strpos($theme, 'blockskit') !== false) { 156 170 $base_theme['name'] = 'Blockskit Base'; 157 171 $base_theme['slug'] = 'blockskit-base'; 158 172 } 159 173 return $base_theme; 160 174 161 175 } 162 176 -
blockskit/trunk/import/demo-import.php
r3402294 r3424554 1 1 <?php 2 2 // Exit if accessed directly 3 if ( !defined( 'ABSPATH' ) ) exit; 3 if (!defined('ABSPATH')) 4 exit; 4 5 5 define( 'BK_TEMPLATE_URL', plugin_dir_url( __FILE__ ));6 define( 'BK_PATH', plugin_dir_path( __FILE__ ));6 define('BK_TEMPLATE_URL', plugin_dir_url(__FILE__)); 7 define('BK_PATH', plugin_dir_path(__FILE__)); 7 8 8 9 /** … … 10 11 * 11 12 */ 12 function bk_import_get_theme_slug(){ 13 function bk_import_get_theme_slug() 14 { 13 15 $demo_theme = wp_get_theme(); 14 return $demo_theme->get( 'TextDomain');16 return $demo_theme->get('TextDomain'); 15 17 } 16 18 … … 19 21 * 20 22 */ 21 function bk_import_get_theme_screenshot(){ 22 $demo_theme = wp_get_theme(); 23 function bk_import_get_theme_screenshot() 24 { 25 $demo_theme = wp_get_theme(); 23 26 return $demo_theme->get_screenshot(); 24 27 } … … 32 35 * @return bool 33 36 */ 34 function bk_import_theme_check( $needle ){ 35 if( strpos( bk_import_get_theme_slug(), $needle ) !== false ){ 37 function bk_import_theme_check($needle) 38 { 39 if (strpos(bk_import_get_theme_slug(), $needle) !== false) { 36 40 return true; 37 } else{41 } else { 38 42 return false; 39 43 } … … 44 48 * and public-facing site hooks.. 45 49 * 46 */ 50 */ 47 51 require BK_PATH . 'demo/functions.php'; 48 52 49 53 // Base theme installation 50 // if ( get_stylesheet() !== 'blockskit-education' && get_stylesheet() !== 'blockskit-agency' && get_stylesheet() !== 'blockskit-base' ){51 // require BK_PATH . 'base-install/base-install.php'; 54 // if (get_stylesheet() !== 'blockskit-education' && get_stylesheet() !== 'blockskit-agency' && get_stylesheet() !== 'blockskit-base') { 55 require BK_PATH . 'base-install/base-install.php'; 52 56 // } 53 57 … … 58 62 */ 59 63 $plugin_admin = bk_import_hooks(); 60 add_filter( 'advanced_import_demo_lists', array( $plugin_admin,'bk_import_demo_import_lists'), 20, 1);61 add_filter( 'admin_menu', array( $plugin_admin, 'import_menu' ), 10, 1);62 add_filter( 'wp_ajax_bk_import_getting_started', array( $plugin_admin, 'install_advanced_import' ), 10, 1);63 add_filter( 'admin_enqueue_scripts', array( $plugin_admin, 'enqueue_styles' ), 10, 1);64 add_filter( 'admin_enqueue_scripts', array( $plugin_admin, 'enqueue_scripts' ), 10, 1);65 add_filter( 'advanced_export_include_options', array( $plugin_admin, 'bk_import_include_options' ), 10, 1);66 add_action( 'advanced_import_replace_post_ids', array( $plugin_admin, 'bk_import_replace_attachment_ids' ), 30);64 add_filter('advanced_import_demo_lists', array($plugin_admin, 'bk_import_demo_import_lists'), 20, 1); 65 add_filter('admin_menu', array($plugin_admin, 'import_menu'), 10, 1); 66 add_filter('wp_ajax_bk_import_getting_started', array($plugin_admin, 'install_advanced_import'), 10, 1); 67 add_filter('admin_enqueue_scripts', array($plugin_admin, 'enqueue_styles'), 10, 1); 68 add_filter('admin_enqueue_scripts', array($plugin_admin, 'enqueue_scripts'), 10, 1); 69 add_filter('advanced_export_include_options', array($plugin_admin, 'bk_import_include_options'), 10, 1); 70 add_action('advanced_import_replace_post_ids', array($plugin_admin, 'bk_import_replace_attachment_ids'), 30); -
blockskit/trunk/readme.txt
r3402294 r3424554 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4.9 7 Stable tag: 1.2. 17 Stable tag: 1.2.2 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 43 43 44 44 == Changelog == 45 46 = 1.2.2 = 47 * Theme recomendation in demo import updated. 45 48 46 49 = 1.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.