| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Thim Elementor Kit |
| 4 |
* Description: It is page builder for the Elementor page builder. |
| 5 |
* Author: ThimPress |
| 6 |
* Version: 1.2.3 |
| 7 |
* Author URI: http://thimpress.com |
| 8 |
* Requires at least: 6.3 |
| 9 |
* Tested up to: 6.5.5 |
| 10 |
* Requires PHP: 7.4 |
| 11 |
* Text Domain: thim-elementor-kit |
| 12 |
* Domain Path: /languages/ |
| 13 |
* Elementor tested up to: 3.22.3 |
| 14 |
* Requires Plugins: elementor |
| 15 |
*/ |
| 16 |
|
| 17 |
use Elementor\Core\Files\Manager as Files_Manager; |
| 18 |
use Elementor\Plugin; |
| 19 |
|
| 20 |
defined( 'ABSPATH' ) || exit; |
| 21 |
|
| 22 |
define( 'THIM_EKIT_VERSION', '1.2.3' ); |
| 23 |
const THIM_EKIT_PLUGIN_FILE = __FILE__; |
| 24 |
define( 'THIM_EKIT_PLUGIN_PATH', plugin_dir_path( THIM_EKIT_PLUGIN_FILE ) ); |
| 25 |
define( 'THIM_EKIT_PLUGIN_URL', plugin_dir_url( THIM_EKIT_PLUGIN_FILE ) ); |
| 26 |
define( 'THIM_EKIT_PLUGIN_BASE', plugin_basename( THIM_EKIT_PLUGIN_FILE ) ); |
| 27 |
define( 'THIM_EKIT_DEV', false ); |
| 28 |
|
| 29 |
/** |
| 30 |
* Class Thim Elementor Kits Plugin |
| 31 |
* |
| 32 |
* @author Nhamdv from ThimPress <daonham95@gmail.com> |
| 33 |
*/ |
| 34 |
if ( ! class_exists( 'Thim_EL_Kit' ) ) { |
| 35 |
final class Thim_EL_Kit { |
| 36 |
protected static $instance = null; |
| 37 |
|
| 38 |
public function __construct() { |
| 39 |
add_action( 'plugins_loaded', array( $this, 'load_textdomain' ), 99 ); |
| 40 |
|
| 41 |
if ( ! $this->elementor_is_active() ) { |
| 42 |
add_action( 'admin_notices', array( $this, 'required_plugins_notice' ) ); |
| 43 |
|
| 44 |
return; |
| 45 |
} |
| 46 |
|
| 47 |
if ( defined( 'THIM_EKIT_PRO_VERSION' ) ) { |
| 48 |
add_action( 'admin_notices', array( $this, 'notice_thim_elementor_kit_pro' ) ); |
| 49 |
} |
| 50 |
|
| 51 |
$this->includes(); |
| 52 |
|
| 53 |
do_action( 'thim_ekit_loaded' ); |
| 54 |
} |
| 55 |
|
| 56 |
protected function includes() { |
| 57 |
// Utilities |
| 58 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/utilities/singleton-trait.php'; |
| 59 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/utilities/class-response.php'; |
| 60 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/utilities/class-elementor.php'; |
| 61 |
// Group Add Control |
| 62 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/utilities/group-control-trait.php'; |
| 63 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/utilities/login-register-trait.php'; |
| 64 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/utilities/widget-loop-trait.php'; |
| 65 |
|
| 66 |
// Include |
| 67 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-dashboard.php'; |
| 68 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-settings.php'; |
| 69 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-post-type.php'; |
| 70 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-enqueue-scripts.php'; |
| 71 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-rest-api.php'; |
| 72 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-shortcode.php'; |
| 73 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-structured-data.php'; |
| 74 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/class-functions.php'; |
| 75 |
|
| 76 |
// Elementor |
| 77 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/elementor/class-elementor.php'; |
| 78 |
|
| 79 |
// Modules, must load on hook plugins_loaded to check class exists. |
| 80 |
add_action( 'plugins_loaded', [ $this, 'included_files_when_plugins_loaded' ] ); |
| 81 |
// Include old, when all plugins extend move self to hook plugins_loaded will remove. |
| 82 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/modules/class-init.php'; |
| 83 |
|
| 84 |
// Upgrade. |
| 85 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/upgrade/class-init.php'; |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* Include files when plugins loaded. |
| 90 |
* |
| 91 |
* @return void |
| 92 |
* @since 1.2.0 |
| 93 |
*/ |
| 94 |
public function included_files_when_plugins_loaded() { |
| 95 |
require_once THIM_EKIT_PLUGIN_PATH . 'inc/modules/class-init.php'; |
| 96 |
} |
| 97 |
|
| 98 |
public function load_textdomain() { |
| 99 |
load_plugin_textdomain( 'thim-elementor-kit', false, basename( THIM_EKIT_PLUGIN_PATH ) . '/languages' ); |
| 100 |
} |
| 101 |
|
| 102 |
public function register_activation_hook() { |
| 103 |
if ( $this->elementor_is_active() ) { |
| 104 |
if ( Plugin::$instance->files_manager instanceof Files_Manager ) { |
| 105 |
Plugin::$instance->files_manager->clear_cache(); |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
public function elementor_is_active() { |
| 111 |
return defined( 'ELEMENTOR_VERSION' ); |
| 112 |
} |
| 113 |
|
| 114 |
public function required_plugins_notice() { |
| 115 |
$screen = get_current_screen(); |
| 116 |
|
| 117 |
if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) { |
| 118 |
return; |
| 119 |
} |
| 120 |
|
| 121 |
$plugin = 'elementor/elementor.php'; |
| 122 |
|
| 123 |
$installed_plugins = get_plugins(); |
| 124 |
$is_elementor_installed = isset( $installed_plugins[ $plugin ] ); |
| 125 |
|
| 126 |
if ( $is_elementor_installed ) { |
| 127 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
| 128 |
return; |
| 129 |
} |
| 130 |
|
| 131 |
$activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', |
| 132 |
'activate-plugin_' . $plugin ); |
| 133 |
|
| 134 |
$message = sprintf( '<p>%s</p>', |
| 135 |
esc_html__( 'Thim Elementor Kit requires Elementor to be activated.', 'thim-elementor-kit' ) ); |
| 136 |
$message .= sprintf( '<p><a href="%s" class="button-primary">%s</a></p>', $activation_url, |
| 137 |
esc_html__( 'Activate Elementor Now', 'thim-elementor-kit' ) ); |
| 138 |
} else { |
| 139 |
if ( ! current_user_can( 'install_plugins' ) ) { |
| 140 |
return; |
| 141 |
} |
| 142 |
|
| 143 |
$install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), |
| 144 |
'install-plugin_elementor' ); |
| 145 |
|
| 146 |
$message = sprintf( '<p>%s</p>', |
| 147 |
esc_html__( 'Thim Elementor Kit requires Elementor to be installed.', 'thim-elementor-kit' ) ); |
| 148 |
$message .= sprintf( '<p><a href="%s" class="button-primary">%s</a></p>', $install_url, |
| 149 |
esc_html__( 'Install Elementor Now', 'thim-elementor-kit' ) ); |
| 150 |
} |
| 151 |
|
| 152 |
printf( '<div class="notice notice-error is-dismissible"><p>%s</p></div>', wp_kses_post( $message ) ); |
| 153 |
} |
| 154 |
|
| 155 |
public function notice_thim_elementor_kit_pro() { |
| 156 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
| 157 |
return; |
| 158 |
} |
| 159 |
|
| 160 |
// Deactive Thim Elementor Kit Pro. |
| 161 |
deactivate_plugins( 'thim-elementor-kit-pro/thim-elementor-kit-pro.php' ); |
| 162 |
|
| 163 |
$deactivate_url = wp_nonce_url( admin_url( 'plugins.php?action=deactivate&plugin=thim-elementor-kit-pro/thim-elementor-kit-pro.php' ), |
| 164 |
'deactivate-plugin_thim-elementor-kit-pro/thim-elementor-kit-pro.php' ); |
| 165 |
?> |
| 166 |
<div class="notice notice-error is-dismissible"> |
| 167 |
<p><?php |
| 168 |
esc_html_e( 'Thim Elementor Kit Pro is merged into Thim Elementor Kit. Please deactivate Thim Elementor Kit Pro to avoid conflicts.', |
| 169 |
'thim-elementor-kit' ); ?></p> |
| 170 |
<p><a href="<?php |
| 171 |
echo esc_url( $deactivate_url ); ?>" class="button-primary"><?php |
| 172 |
esc_html_e( 'Deactivate Thim Elementor Kit Pro', 'thim-elementor-kit' ); ?></a></p> |
| 173 |
</div> |
| 174 |
<?php |
| 175 |
} |
| 176 |
|
| 177 |
public static function instance() { |
| 178 |
if ( is_null( self::$instance ) ) { |
| 179 |
self::$instance = new self(); |
| 180 |
} |
| 181 |
|
| 182 |
return self::$instance; |
| 183 |
} |
| 184 |
|
| 185 |
public function __clone() { |
| 186 |
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'thim-elementor-kit' ), '1.0' ); |
| 187 |
} |
| 188 |
|
| 189 |
public function __wakeup() { |
| 190 |
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'thim-elementor-kit' ), '1.0' ); |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
// Update CSS Print Method in Elementor. |
| 196 |
register_activation_hook( |
| 197 |
__FILE__, |
| 198 |
function () { |
| 199 |
Thim_EL_Kit::instance()->register_activation_hook(); |
| 200 |
} |
| 201 |
); |
| 202 |
|
| 203 |
// If Multilsite. |
| 204 |
// if ( function_exists( 'is_multisite' ) && is_multisite() ) { |
| 205 |
// add_action( |
| 206 |
// 'plugins_loaded', |
| 207 |
// function() { |
| 208 |
// Thim_EL_Kit::instance(); |
| 209 |
// }, |
| 210 |
// 90 |
| 211 |
// ); |
| 212 |
// } else { |
| 213 |
Thim_EL_Kit::instance(); |
| 214 |
// } |
| 215 |
|