| 1 |
<?php |
| 2 |
/* |
| 3 |
* Plugin Name: Blocks to Shortcode |
| 4 |
* Plugin URI: https://pluginenvision.com/plugins/blocks-to-shortcode |
| 5 |
* Description: Use gutenberg blocks in anywhere using blocks to shortcode. |
| 6 |
* Version: 0.12 |
| 7 |
* Requires at least: 6.2 |
| 8 |
* Requires PHP: 7.2 |
| 9 |
* Author: Plugin Envision |
| 10 |
* Author URI: https://pluginenvision.com |
| 11 |
* License: GPLv3 or later |
| 12 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 13 |
* Text Domain: blocks-to-shortcode |
| 14 |
*/ |
| 15 |
|
| 16 |
if ( !defined( 'ABSPATH' ) ) { exit; } |
| 17 |
|
| 18 |
if( function_exists( 'btsc_fs' ) ){ |
| 19 |
btsc_fs()->set_basename( false, __FILE__ ); |
| 20 |
}else{ |
| 21 |
define( 'BTSC_VERSION', isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '0.12' ); |
| 22 |
define( 'BTSC_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 23 |
define( 'BTSC_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 24 |
define( 'BTSC_HAS_FS', file_exists( BTSC_DIR_PATH . 'vendor/freemius/start.php' ) ); |
| 25 |
|
| 26 |
if( BTSC_HAS_FS ){ |
| 27 |
require_once BTSC_DIR_PATH . 'includes/premium.php'; |
| 28 |
} |
| 29 |
|
| 30 |
function btscWusul(){ |
| 31 |
if( BTSC_HAS_FS ){ |
| 32 |
return btsc_fs()->can_use_premium_code(); |
| 33 |
}else{ |
| 34 |
return false; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
require_once BTSC_DIR_PATH . 'includes/Register.php'; |
| 39 |
require_once BTSC_DIR_PATH . 'includes/Helper.php'; |
| 40 |
|
| 41 |
if( !class_exists( 'BTSCPlugin' ) ){ |
| 42 |
class BTSCPlugin{ |
| 43 |
public function __construct(){ |
| 44 |
add_action( 'init', [ $this, 'onInit' ] ); |
| 45 |
add_action( 'enqueue_block_assets', [ $this, 'enqueueBlockAssets' ] ); |
| 46 |
add_action( 'enqueue_block_editor_assets', [ $this, 'enqueueBlockEditorAssets' ] ); |
| 47 |
} |
| 48 |
|
| 49 |
function onInit(){ |
| 50 |
register_block_type( __DIR__ . '/build' ); |
| 51 |
} |
| 52 |
|
| 53 |
function enqueueBlockAssets(){ |
| 54 |
wp_register_style( 'aos', BTSC_DIR_URL . 'public/css/aos.css', [], '2.3.1' ); |
| 55 |
wp_register_script( 'aos', BTSC_DIR_URL . 'public/js/aos.js', [], '2.3.1', false ); |
| 56 |
wp_set_script_translations( 'aos', 'blocks-to-shortcode', BTSC_DIR_PATH . 'languages' ); |
| 57 |
} |
| 58 |
|
| 59 |
function enqueueBlockEditorAssets(){ |
| 60 |
wp_set_script_translations( 'btsc-shortcode-selector-editor-script', 'blocks-to-shortcode', BTSC_DIR_PATH . 'languages' ); |
| 61 |
|
| 62 |
$inline_js = "const btscAdminUrl = '" . esc_url( admin_url() ) . "'; const btscWusul = '" . btscWusul() . "';"; |
| 63 |
wp_add_inline_script( 'btsc-shortcode-selector-editor-script', $inline_js ); |
| 64 |
} |
| 65 |
} |
| 66 |
new BTSCPlugin(); |
| 67 |
} |
| 68 |
} |
| 69 |
|