| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
defined('BLOCKSPARE_TB_VERSION') || define('BLOCKSPARE_TB_VERSION', '0.1.0'); |
| 7 |
defined('BLOCKSPARE_TB_PATH') || define('BLOCKSPARE_TB_PATH', BLOCKSPARE_PLUGIN_DIR . 'inc/theme-builder/'); |
| 8 |
defined('BLOCKSPARE_TB_URL') || define('BLOCKSPARE_TB_URL', BLOCKSPARE_PLUGIN_URL . 'inc/theme-builder/'); |
| 9 |
defined('BLOCKSPARE_TB_BASENAME') || define('BLOCKSPARE_TB_BASENAME', BLOCKSPARE_PLUGIN_BASE); |
| 10 |
|
| 11 |
|
| 12 |
$blockspare_tb_files = array( |
| 13 |
// Post type + taxonomy. |
| 14 |
'class-blockspare-tb-post-type.php', |
| 15 |
'class-blockspare-tb-taxonomy.php', |
| 16 |
|
| 17 |
// Conditions engine. |
| 18 |
'class-blockspare-tb-condition-interface.php', |
| 19 |
'conditions/class-blockspare-tb-condition-entire-site.php', |
| 20 |
'conditions/class-blockspare-tb-condition-front-page.php', |
| 21 |
'conditions/class-blockspare-tb-condition-single.php', |
| 22 |
'conditions/class-blockspare-tb-condition-archive.php', |
| 23 |
'conditions/class-blockspare-tb-condition-category.php', |
| 24 |
'conditions/class-blockspare-tb-condition-author.php', |
| 25 |
'conditions/class-blockspare-tb-condition-tag.php', |
| 26 |
'conditions/class-blockspare-tb-condition-date-archive.php', |
| 27 |
'conditions/class-blockspare-tb-condition-search.php', |
| 28 |
'conditions/class-blockspare-tb-condition-404.php', |
| 29 |
'class-blockspare-tb-condition-registry.php', |
| 30 |
|
| 31 |
// Admin. |
| 32 |
'class-blockspare-tb-admin-menu.php', |
| 33 |
'class-blockspare-tb-assets.php', |
| 34 |
|
| 35 |
// Frontend. |
| 36 |
'class-blockspare-tb-template-loader.php', |
| 37 |
|
| 38 |
// REST. |
| 39 |
'class-blockspare-tb-templates-controller.php', |
| 40 |
'class-blockspare-tb-conditions-controller.php', |
| 41 |
|
| 42 |
// Orchestrator — must load last, it references all of the above. |
| 43 |
'class-blockspare-tb-plugin.php', |
| 44 |
); |
| 45 |
|
| 46 |
foreach ($blockspare_tb_files as $blockspare_tb_file) { |
| 47 |
require_once BLOCKSPARE_TB_PATH . $blockspare_tb_file; |
| 48 |
} |
| 49 |
unset($blockspare_tb_files, $blockspare_tb_file); |
| 50 |
|
| 51 |
|
| 52 |
add_action('plugins_loaded', array('Blockspare_TB_Plugin', 'instance')); |
| 53 |
|
| 54 |
register_activation_hook( |
| 55 |
BLOCKSPARE_BASE_FILE, |
| 56 |
function () { |
| 57 |
$post_type = new Blockspare_TB_Template_Post_Type(); |
| 58 |
$post_type->register(); |
| 59 |
|
| 60 |
$taxonomy = new Blockspare_TB_Template_Type_Taxonomy(); |
| 61 |
$taxonomy->register(); |
| 62 |
|
| 63 |
flush_rewrite_rules(); |
| 64 |
} |
| 65 |
); |
| 66 |
|
| 67 |
register_deactivation_hook( |
| 68 |
BLOCKSPARE_BASE_FILE, |
| 69 |
function () { |
| 70 |
flush_rewrite_rules(); |
| 71 |
} |
| 72 |
); |
| 73 |
|
| 74 |
add_filter('admin_url', function ($url, $path, $blog_id) { |
| 75 |
//blockspare_template |
| 76 |
if ($path === 'post-new.php?post_type=blockspare_template') { |
| 77 |
return admin_url('admin.php?page=blockspare-theme-builder'); |
| 78 |
} |
| 79 |
|
| 80 |
return $url; |
| 81 |
}, 10, 3); |
| 82 |
|