| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: PopupKit |
| 5 |
* Description: Powerful popup builder with ready templates and easy customization. |
| 6 |
* Requires at least: 6.2 |
| 7 |
* Requires PHP: 7.4 |
| 8 |
* Plugin URI: https://wpmet.com/plugin/popupkit |
| 9 |
* Author: Wpmet |
| 10 |
* Version: 2.3.3 |
| 11 |
* Author URI: https://wpmet.com/ |
| 12 |
* License: GPL-3.0-or-later |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 14 |
* |
| 15 |
* Text Domain: popup-builder-block |
| 16 |
* Domain Path: /languages |
| 17 |
* |
| 18 |
*/ |
| 19 |
|
| 20 |
// Exit if accessed directly. |
| 21 |
if (!defined('ABSPATH')) { |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Final class for the Popup Builder Block plugin. |
| 27 |
* |
| 28 |
* @since 1.0.0 |
| 29 |
*/ |
| 30 |
final class PopupBuilderBlock { |
| 31 |
/** |
| 32 |
* The version number of the Popup Builder Block plugin. |
| 33 |
* |
| 34 |
* @var string |
| 35 |
*/ |
| 36 |
const VERSION = '2.3.3'; |
| 37 |
|
| 38 |
/** |
| 39 |
* \PopupKit class constructor. |
| 40 |
* private for singleton |
| 41 |
* |
| 42 |
* @return void |
| 43 |
* @since 1.0.0 |
| 44 |
*/ |
| 45 |
public function __construct() { |
| 46 |
// Plugins helper constants |
| 47 |
$this->helper_constants(); |
| 48 |
|
| 49 |
// Load after plugin activation |
| 50 |
register_activation_hook(__FILE__, array($this, 'activated_plugin')); |
| 51 |
|
| 52 |
// Load after plugin deactivation |
| 53 |
register_deactivation_hook(__FILE__, array($this, 'deactivated_plugin')); |
| 54 |
|
| 55 |
// Add popup link to the plugin action links |
| 56 |
add_filter('plugin_action_links', array( $this, 'add_popup_link'), 10, 2 ); |
| 57 |
|
| 58 |
// Hook into the plugin_row_meta filter |
| 59 |
add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); |
| 60 |
|
| 61 |
// Load the scoped vendor autoload file |
| 62 |
if ( file_exists( POPUP_BUILDER_BLOCK_PLUGIN_DIR . 'scoped/vendor/scoper-autoload.php' ) ) { |
| 63 |
require_once POPUP_BUILDER_BLOCK_PLUGIN_DIR . 'scoped/vendor/scoper-autoload.php'; |
| 64 |
} |
| 65 |
|
| 66 |
// Plugin actions |
| 67 |
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) ); |
| 68 |
|
| 69 |
// Plugin unfiltered file support |
| 70 |
add_action( 'init', array( $this, 'process_libs' ) ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Helper method for plugin constants. |
| 75 |
* |
| 76 |
* @return void |
| 77 |
* @since 1.0.0 |
| 78 |
*/ |
| 79 |
public function helper_constants() { |
| 80 |
define('POPUP_BUILDER_BLOCK_PLUGIN_VERSION', self::VERSION); |
| 81 |
define('POPUP_BUILDER_BLOCK_PLUGIN_URL', trailingslashit(plugin_dir_url(__FILE__))); |
| 82 |
define('POPUP_BUILDER_BLOCK_PLUGIN_DIR', trailingslashit(plugin_dir_path(__FILE__))); |
| 83 |
define('POPUP_BUILDER_BLOCK_INC_DIR', POPUP_BUILDER_BLOCK_PLUGIN_DIR . 'includes/'); |
| 84 |
define('POPUP_BUILDER_BLOCK_DIR', POPUP_BUILDER_BLOCK_PLUGIN_DIR . 'build/blocks/'); |
| 85 |
define('POPUP_BUILDER_BLOCK_API_URL', 'https://wpmet.com/plugin/popupkit/wp-content/plugins/'); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* Add popup link to the plugin action links. |
| 90 |
* |
| 91 |
* @param array $plugin_actions An array of plugin action links. |
| 92 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
| 93 |
* @return array An array of plugin action links. |
| 94 |
* @since 1.0.0 |
| 95 |
*/ |
| 96 |
public function add_popup_link( $plugin_actions, $plugin_file ) { |
| 97 |
$plugin_slug = 'popup-builder-block'; |
| 98 |
$plugin_name = "{$plugin_slug}/{$plugin_slug}.php"; |
| 99 |
|
| 100 |
if ( $plugin_file === $plugin_name ) { |
| 101 |
// Add "Build Popup" link at the beginning |
| 102 |
$menu_link = 'admin.php?page=popupkit#campaigns'; |
| 103 |
$settings_link = sprintf( |
| 104 |
'<a href="%s">%s</a>', |
| 105 |
esc_url( $menu_link ), |
| 106 |
esc_html__( 'Build Popup', 'popup-builder-block' ) |
| 107 |
); |
| 108 |
|
| 109 |
array_unshift( $plugin_actions, $settings_link ); |
| 110 |
// Add "Get PopupKit Pro" link at the end |
| 111 |
if ( ! class_exists( 'PopupBuilderBlockPro' ) ) { |
| 112 |
$popup_kit_pro_link = sprintf( |
| 113 |
'<a href="%1$s" target="_blank" style="font-weight: 700; color: #b32d2e;">%2$s</a>', |
| 114 |
'https://wpmet.com/ftopro', |
| 115 |
esc_html__( 'Get PopupKit Pro', 'popup-builder-block' ) |
| 116 |
); |
| 117 |
|
| 118 |
$plugin_actions['get_popupkit_pro'] = $popup_kit_pro_link; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
return $plugin_actions; |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* Plugin row meta. |
| 127 |
* |
| 128 |
* Adds row meta links to the plugin list table |
| 129 |
* |
| 130 |
* Fired by `plugin_row_meta` filter. |
| 131 |
* |
| 132 |
* @since 2.0.2 |
| 133 |
*/ |
| 134 |
public function plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 135 |
if ( plugin_basename( __FILE__ ) === $plugin_file ) { |
| 136 |
$row_meta = [ |
| 137 |
'docs' => '<a href="https://wpmet.com/doc/popupkit/" aria-label="' . esc_attr( esc_html__( 'View PopupKit Documentation', 'popup-builder-block' ) ) . '" target="_blank">' . esc_html__( 'Docs & FAQs', 'popup-builder-block' ) . '</a>', |
| 138 |
'video' => '<a href="https://tinyurl.com/35pc4dcc" aria-label="' . esc_attr( esc_html__( 'View PopupKit Video Tutorials', 'popup-builder-block' ) ) . '" target="_blank">' . esc_html__( 'Video Tutorials', 'popup-builder-block' ) . '</a>', |
| 139 |
]; |
| 140 |
|
| 141 |
$plugin_meta = array_merge( $plugin_meta, $row_meta ); |
| 142 |
} |
| 143 |
|
| 144 |
return $plugin_meta; |
| 145 |
} |
| 146 |
|
| 147 |
/** |
| 148 |
* Activated plugin method. |
| 149 |
* |
| 150 |
* @return void |
| 151 |
* @since 1.0.0 |
| 152 |
*/ |
| 153 |
public function activated_plugin() { |
| 154 |
// Manually register CPT before flushing |
| 155 |
\PopupBuilderBlock\Hooks\Cpt::popup_builder_cpt(); |
| 156 |
\PopupBuilderBlock\Helpers\DataBase::createDB(); |
| 157 |
|
| 158 |
// Record first install time once, used for deactivation feedback "active days". |
| 159 |
if ( ! get_option( 'popupkit_installed_time' ) ) { |
| 160 |
update_option( 'popupkit_installed_time', time() ); |
| 161 |
} |
| 162 |
|
| 163 |
flush_rewrite_rules(); |
| 164 |
} |
| 165 |
|
| 166 |
/** |
| 167 |
* Deactivated plugin method. |
| 168 |
* |
| 169 |
* @return void |
| 170 |
* @since 1.0.0 |
| 171 |
*/ |
| 172 |
public function deactivated_plugin() { |
| 173 |
$timestamp = wp_next_scheduled('pbb_daily_event'); |
| 174 |
if($timestamp) wp_unschedule_event($timestamp, 'pbb_daily_event'); |
| 175 |
|
| 176 |
flush_rewrite_rules(); |
| 177 |
} |
| 178 |
|
| 179 |
/** |
| 180 |
* Plugins loaded method. |
| 181 |
* loads our others classes and textdomain. |
| 182 |
* |
| 183 |
* @return void |
| 184 |
* @since 1.0.0 |
| 185 |
*/ |
| 186 |
public function plugins_loaded() { |
| 187 |
/** |
| 188 |
* Fires before the initialization of the PopupKit plugin. |
| 189 |
* |
| 190 |
* This action hook allows developers to perform additional tasks before the PopupKit plugin has been initialized. |
| 191 |
* @since 1.0.0 |
| 192 |
*/ |
| 193 |
do_action( 'popup_builder_block/before_init' ); |
| 194 |
|
| 195 |
/** |
| 196 |
* Initializes the Popup Builder Block admin functionality. |
| 197 |
* |
| 198 |
* This function creates an instance of the PopupBuilderBlock\Admin\Admin class and initializes the admin functionality for the Popup Builder Block plugin. |
| 199 |
* |
| 200 |
* @since 1.0.0 |
| 201 |
*/ |
| 202 |
new PopupBuilderBlock\Admin\Admin(); |
| 203 |
new PopupBuilderBlock\Config\Init(); |
| 204 |
new PopupBuilderBlock\Hooks\Init(); |
| 205 |
new PopupBuilderBlock\Routes\Init(); |
| 206 |
} |
| 207 |
|
| 208 |
/** |
| 209 |
* Process libs method. |
| 210 |
* |
| 211 |
* @return void |
| 212 |
* @since 1.0.0 |
| 213 |
*/ |
| 214 |
public function process_libs() { |
| 215 |
new PopupBuilderBlock\Libs\UnfilteredFileSupport(); |
| 216 |
new PopupBuilderBlock\Libs\UtilityPackages(); |
| 217 |
} |
| 218 |
} |
| 219 |
|
| 220 |
/** |
| 221 |
* Kickoff the plugin |
| 222 |
* |
| 223 |
* @since 1.0.0 |
| 224 |
* |
| 225 |
*/ |
| 226 |
new PopupBuilderBlock(); |
| 227 |
|