set_basename( false, __FILE__ ); } else { /** * DO NOT REMOVE THIS IF, IT IS ESSENTIAL FOR THE * `function_exists` CALL ABOVE TO PROPERLY WORK. */ define( 'ABB_VERSION', isset( $_SERVER['HTTP_HOST'] ) && 'localhost' === $_SERVER['HTTP_HOST'] ? time() : '2.0.0' ); define( 'ABB_DIR_URL', plugin_dir_url( __FILE__ ) ); define( 'ABB_DIR_PATH', plugin_dir_path( __FILE__ ) ); define( 'ABB_HAS_PRO', file_exists( dirname(__FILE__) . '/vendor/freemius/start.php' ) ); if ( ABB_HAS_PRO ) { require_once ABB_DIR_PATH . 'includes/fs.php'; }else{ require_once ABB_DIR_PATH . 'includes/fs-lite.php'; } function abbIsPremium(){ return ABB_HAS_PRO ? abb_fs()->can_use_premium_code() : false; } // ... Your plugin's main file logic ... if (ABB_HAS_PRO) { require_once ABB_DIR_PATH . 'includes/LicenseActivation.php'; } if( !class_exists( 'ABBAlertBoxPlugin' ) ){ class ABBAlertBoxPlugin{ public function __construct(){ add_action( 'init', [$this, 'onInit'] ); add_action( 'enqueue_block_assets', [$this, 'enqueueBlockAssets'] ); add_action('enqueue_block_editor_assets', [$this, "enqueueBlockEditorAssets"]); add_filter( 'default_title', [$this, 'defaultTitle'], 10, 2 ); add_filter( 'default_content', [$this, 'defaultContent'], 10, 2 ); } function defaultTitle( $title, $post ) { if ( 'page' === $post->post_type && isset( $_GET['title'] ) ) { return sanitize_text_field( wp_unslash( $_GET['title'] ) ); } return $title; } function defaultContent( $content, $post ) { if ( 'page' === $post->post_type && isset( $_GET['content'] ) ) { return wp_unslash( $_GET['content'] ); } return $content; } function enqueueBlockEditorAssets() { wp_add_inline_script( 'abb-alert-box-editor-script', 'const abbpipecheck = ' . wp_json_encode(abbIsPremium()).';', 'before'); } function enqueueBlockAssets(){ global $post ; $blocks = parse_blocks($post->post_content); foreach ($blocks as $block) { if ($block['blockName'] === 'abb/alert-box') { $icon = isset($block['attrs']['icon']) ? $block['attrs']['icon'] : null; $svg = isset($icon['svg']) ? trim($icon['svg']) : ''; if (empty($svg)) { wp_enqueue_style( 'fontAwesome', ABB_DIR_URL . 'public/css/font-awesome.min.css', [], '6.4.2' ); } } } } function onInit(){ register_block_type( __DIR__ . '/build' ); } } new ABBAlertBoxPlugin(); } } require_once ABB_DIR_PATH . '/includes/Menu.php'; // Constant old codes