| 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.06 |
| 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 |
define( 'BTSC_VERSION', isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '0.06' ); |
| 19 |
define( 'BTSC_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 20 |
define( 'BTSC_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 21 |
|
| 22 |
if ( !function_exists( 'btsc_fs' ) ) { |
| 23 |
function btsc_fs() { |
| 24 |
global $btsc_fs; |
| 25 |
|
| 26 |
if ( ! isset( $btsc_fs ) ) { |
| 27 |
require_once BTSC_DIR_PATH . 'freemius/start.php'; |
| 28 |
|
| 29 |
$btsc_fs = fs_dynamic_init([ |
| 30 |
'id' => '17080', |
| 31 |
'slug' => 'blocks-to-shortcode', |
| 32 |
'type' => 'plugin', |
| 33 |
'public_key' => 'pk_89794aba7cb1d748d3762c600e885', |
| 34 |
'is_premium' => false, |
| 35 |
'has_addons' => false, |
| 36 |
'has_paid_plans' => false, |
| 37 |
'menu' => [ |
| 38 |
'slug' => 'edit.php?post_type=blocks-to-shortcode', |
| 39 |
'account' => false, |
| 40 |
'contact' => false |
| 41 |
] |
| 42 |
]); |
| 43 |
} |
| 44 |
|
| 45 |
return $btsc_fs; |
| 46 |
} |
| 47 |
|
| 48 |
btsc_fs(); |
| 49 |
do_action( 'btsc_fs_loaded' ); |
| 50 |
} |
| 51 |
|
| 52 |
if( function_exists( 'btsc_fs' ) ){ |
| 53 |
btsc_fs()->set_basename( true, __FILE__ ); |
| 54 |
} |
| 55 |
|
| 56 |
function btscWusul(){ |
| 57 |
return btsc_fs()->can_use_premium_code(); |
| 58 |
} |
| 59 |
|
| 60 |
if( !class_exists( 'BTSCPlugin' ) ){ |
| 61 |
class BTSCPlugin{ |
| 62 |
function __construct(){ |
| 63 |
add_action( 'wp_ajax_btscWusulDekho', [$this, 'btscWusulDekho'] ); |
| 64 |
add_action( 'wp_ajax_nopriv_btscWusulDekho', [$this, 'btscWusulDekho'] ); |
| 65 |
add_action( 'admin_init', [$this, 'registerSettings'] ); |
| 66 |
add_action( 'rest_api_init', [$this, 'registerSettings']); |
| 67 |
} |
| 68 |
|
| 69 |
function registerSettings(){ |
| 70 |
register_setting( 'btscUtils', 'btscUtils', [ |
| 71 |
'show_in_rest' => [ |
| 72 |
'name' => 'btscUtils', |
| 73 |
'schema' => [ 'type' => 'string' ] |
| 74 |
], |
| 75 |
'type' => 'string', |
| 76 |
'default' => wp_json_encode( [ 'nonce' => wp_create_nonce( 'wp_ajax' ) ] ), |
| 77 |
'sanitize_callback' => 'sanitize_text_field' |
| 78 |
] ); |
| 79 |
} |
| 80 |
|
| 81 |
function btscWusulDekho(){ |
| 82 |
$nonce = sanitize_text_field( $_POST['_wpnonce'] ) ?? null; |
| 83 |
|
| 84 |
if( !wp_verify_nonce( $nonce, 'wp_ajax' )){ |
| 85 |
wp_send_json_error( 'Invalid Request' ); |
| 86 |
} |
| 87 |
|
| 88 |
wp_send_json_success( [ 'wusul' => btscWusul() ] ); |
| 89 |
} |
| 90 |
} |
| 91 |
new BTSCPlugin(); |
| 92 |
} |
| 93 |
|
| 94 |
require_once BTSC_DIR_PATH . 'includes/Register.php'; |