| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Maxi Blocks |
| 5 |
* Plugin URI: https://maxiblocks.com/ |
| 6 |
* Description: A powerful page builder for WordPress Gutenberg with a vast library of free web templates, icons & patterns. Open source and free to build. Anything you create with Maxi Blocks is yours to keep. There's no lock-in, no domain restrictions or license keys to keep track of. All blocks and features are free to use. Save time, get advanced designs & more with the Pro template library upgrade. |
| 7 |
* Author: Maxi Blocks |
| 8 |
* Author URI: https://maxiblocks.com/go/plugin-author |
| 9 |
* Version: 1.3 |
| 10 |
* Requires at least: 6.2 |
| 11 |
* License: GPL v2 or later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt |
| 13 |
*/ |
| 14 |
|
| 15 |
// Exit if accessed directly. |
| 16 |
if (!defined('ABSPATH')) { |
| 17 |
exit(); |
| 18 |
} |
| 19 |
|
| 20 |
define('MAXI_PLUGIN_DIR_PATH', plugin_dir_path(__FILE__)); |
| 21 |
define('MAXI_PLUGIN_DIR_FILE', __FILE__); |
| 22 |
define('MAXI_PLUGIN_URL_PATH', plugin_dir_url(__FILE__)); |
| 23 |
define('MAXI_PLUGIN_VERSION', get_file_data(__FILE__, array('Version' => 'Version'), false)['Version']); |
| 24 |
|
| 25 |
|
| 26 |
//====================================================================== |
| 27 |
// Init |
| 28 |
//====================================================================== |
| 29 |
|
| 30 |
require_once(MAXI_PLUGIN_DIR_PATH . 'core/admin/maxi-allowed-html-tags.php'); |
| 31 |
|
| 32 |
// Temporally removing patterns download |
| 33 |
add_filter('should_load_remote_block_patterns', '__return_false'); |
| 34 |
|
| 35 |
/* Enabled option */ |
| 36 |
|
| 37 |
if (!get_option('maxi_enable')) { |
| 38 |
add_option('maxi_enable', 'enabled'); |
| 39 |
} |
| 40 |
|
| 41 |
function maxi_get_option() |
| 42 |
{ |
| 43 |
echo esc_attr(get_option('maxi_enable')); |
| 44 |
die(); |
| 45 |
} |
| 46 |
|
| 47 |
function maxi_insert_block() |
| 48 |
{ |
| 49 |
if (isset($_POST['maxi_title']) && isset($_POST['maxi_content'])) {//phpcs:ignore |
| 50 |
$this_title = sanitize_title($_POST['maxi_title']);//phpcs:ignore |
| 51 |
$this_content = sanitize_text_field($_POST['maxi_content']);//phpcs:ignore |
| 52 |
|
| 53 |
if ($this_content && $this_title) { |
| 54 |
// $has_reusable_block = get_posts( array( |
| 55 |
// 'name' => $_POST['maxi_title'], |
| 56 |
// 'post_type' => 'wp_block', |
| 57 |
// 'posts_per_page' => 1 |
| 58 |
// ) ); |
| 59 |
|
| 60 |
// if ( ! $has_reusable_block ) { |
| 61 |
// No reusable block like ours detected. |
| 62 |
wp_insert_post([ |
| 63 |
'post_content' => $this_content, |
| 64 |
'post_title' => $this_title, |
| 65 |
'post_type' => 'wp_block', |
| 66 |
'post_status' => 'publish', |
| 67 |
'comment_status' => 'closed', |
| 68 |
'ping_status' => 'closed', |
| 69 |
'guid' => sprintf( |
| 70 |
'%s/wp_block/%s', |
| 71 |
site_url(), |
| 72 |
sanitize_title($this_title) |
| 73 |
), |
| 74 |
]); |
| 75 |
echo 'success'; |
| 76 |
//} //if ( ! $has_reusable_block ) |
| 77 |
//else {echo 'You already have Block with the same name';} |
| 78 |
} else { |
| 79 |
echo 'JSON Error'; |
| 80 |
} |
| 81 |
} |
| 82 |
wp_die(); |
| 83 |
} //function maxi_insert_block() |
| 84 |
|
| 85 |
// remove noopener noreferrer from gutenberg links |
| 86 |
function maxi_links_control($rel, $link) |
| 87 |
{ |
| 88 |
return false; |
| 89 |
} |
| 90 |
add_filter('wp_targeted_link_rel', 'maxi_links_control', 10, 2); |
| 91 |
|
| 92 |
add_action('wp_ajax_maxi_get_option', 'maxi_get_option', 9, 1); |
| 93 |
add_action('wp_ajax_maxi_insert_block', 'maxi_insert_block', 10, 2); |
| 94 |
|
| 95 |
|
| 96 |
//====================================================================== |
| 97 |
// MaxiBlocks Core |
| 98 |
//====================================================================== |
| 99 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-core.php'; |
| 100 |
if (class_exists('MaxiBlocks_Core')) { |
| 101 |
MaxiBlocks_Core::register(); |
| 102 |
} |
| 103 |
|
| 104 |
//====================================================================== |
| 105 |
// MaxiBlocks DB |
| 106 |
//====================================================================== |
| 107 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-db.php'; |
| 108 |
if (class_exists('MaxiBlocks_DB')) { |
| 109 |
MaxiBlocks_DB::register(); |
| 110 |
} |
| 111 |
|
| 112 |
//====================================================================== |
| 113 |
// MaxiBlocks Blocks |
| 114 |
//====================================================================== |
| 115 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-blocks.php'; |
| 116 |
if (class_exists('MaxiBlocks_Blocks')) { |
| 117 |
MaxiBlocks_Blocks::register(); |
| 118 |
} |
| 119 |
|
| 120 |
//====================================================================== |
| 121 |
// MaxiBlocks Styles |
| 122 |
//====================================================================== |
| 123 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-styles.php'; |
| 124 |
if (class_exists('MaxiBlocks_Styles')) { |
| 125 |
MaxiBlocks_Styles::register(); |
| 126 |
} |
| 127 |
|
| 128 |
//====================================================================== |
| 129 |
// MaxiBlocks Style Cards |
| 130 |
//====================================================================== |
| 131 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-style-cards.php'; |
| 132 |
if (class_exists('MaxiBlocks_StyleCards')) { |
| 133 |
MaxiBlocks_StyleCards::register(); |
| 134 |
} |
| 135 |
|
| 136 |
//====================================================================== |
| 137 |
// MaxiBlocks Image Crop |
| 138 |
//====================================================================== |
| 139 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-image-crop.php'; |
| 140 |
if (class_exists('MaxiBlocks_ImageCrop')) { |
| 141 |
MaxiBlocks_ImageCrop::register(); |
| 142 |
} |
| 143 |
|
| 144 |
//====================================================================== |
| 145 |
// MaxiBlocks API |
| 146 |
//====================================================================== |
| 147 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-api.php'; |
| 148 |
if (class_exists('MaxiBlocks_API')) { |
| 149 |
MaxiBlocks_API::register(); |
| 150 |
} |
| 151 |
|
| 152 |
//====================================================================== |
| 153 |
// MaxiBlocks Page Template |
| 154 |
//====================================================================== |
| 155 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-page-template.php'; |
| 156 |
if (class_exists('MaxiBlocks_PageTemplate')) { |
| 157 |
add_action('plugins_loaded', array( 'MaxiBlocks_PageTemplate', 'register' )); |
| 158 |
} |
| 159 |
|
| 160 |
//====================================================================== |
| 161 |
// MaxiBlocks Dashboard |
| 162 |
//====================================================================== |
| 163 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/admin/class-maxi-dashboard.php'; |
| 164 |
if (class_exists('MaxiBlocks_Dashboard')) { |
| 165 |
MaxiBlocks_Dashboard::register(); |
| 166 |
} |
| 167 |
|
| 168 |
//====================================================================== |
| 169 |
// MaxiBlocks Dynamic Content |
| 170 |
//====================================================================== |
| 171 |
require_once MAXI_PLUGIN_DIR_PATH . 'core/class-maxi-dynamic-content.php'; |
| 172 |
if (class_exists('MaxiBlocks_DynamicContent')) { |
| 173 |
MaxiBlocks_DynamicContent::register(); |
| 174 |
} |
| 175 |
|