PluginProbe
HT Builder – WordPress Theme Builder for Elementor / 1.2.4
HT Builder – WordPress Theme Builder for Elementor v1.2.4
1.3.5 1.3.4 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.8 1.0.9 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3
ht-builder / includes / base.php

base.php in HT Builder – WordPress Theme Builder for Elementor 1.2.4, at includes/base.php

216 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HT_Builder\Elementor;
4 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
5
6 class Base {
7
8 const MINIMUM_ELEMENTOR_VERSION = '2.5.0';
9 const MINIMUM_PHP_VERSION = '5.4';
10
11 private static $_instance = null;
12 public static function instance() {
13 if ( is_null( self::$_instance ) ) {
14 self::$_instance = new self();
15 }
16 return self::$_instance;
17 }
18
19 public function __construct() {
20 add_action( 'init', [ $this, 'i18n' ] );
21 add_action( 'plugins_loaded', [ $this, 'init' ] );
22
23 if ( did_action( 'elementor/loaded' ) ) {
24 // After Active Plugin then redirect setting page
25 register_activation_hook( HTBUILDER_PL_ROOT, [ $this, 'plugin_activate_hook'] );
26 add_action('admin_init', [ $this, 'plugin_redirect_option_page' ] );
27 }
28 }
29
30 /*
31 * Load Text Domain
32 */
33 public function i18n() {
34 load_plugin_textdomain( 'ht-builder' );
35 }
36
37 /*
38 * Init Hook in Init
39 */
40 public function init() {
41
42 // Check if Elementor installed and activated
43 if ( ! did_action( 'elementor/loaded' ) ) {
44 add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
45 return;
46 }
47
48 // Check for required Elementor version
49 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
50 add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
51 return;
52 }
53
54 // Check for required PHP version
55 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
56 add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
57 return;
58 }
59
60 // Include File
61 $this->require_include_files();
62
63 // Plugins Setting Page
64 add_filter('plugin_action_links_'.HTBUILDER_PLUGIN_BASE, [ $this, 'plugins_setting_links' ] );
65
66 // Register custom category
67 add_action( 'elementor/elements/categories_registered', [ $this, 'add_category' ] );
68
69 }
70
71 /*
72 * Include File
73 */
74 public function require_include_files(){
75 if ( ! function_exists('is_plugin_active') ){ include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); }
76 if( is_plugin_active('ht-builder-pro/ht-builder.php') ){
77 require ( HTBUILDER_PL_PATH_PRO.'includes/admin/admin-setting.php' );
78 }else{
79 require( __DIR__ . '/admin/admin-setting.php');
80 }
81 require( __DIR__ . '/helper-function.php');
82 require( __DIR__ . '/../classes/class.enqueue_scripts.php');
83 require( __DIR__ . '/admin/template-library.php');
84 if( htbuilder_get_option( 'enablecustomtemplate', 'htbuilder_templatebuilder_tabs', 'on' ) == 'on' ){
85 require( __DIR__ .'/../classes/class.template_builder.php' );
86 require( __DIR__ .'/../classes/class.widgets_control.php' );
87 require( __DIR__ .'/../classes/class.header_footer.php' );
88 }
89
90 if( is_admin() ){
91 require( __DIR__ .'/admin/recommended-plugins/recommendations.php' );
92 }
93 }
94
95 /**
96 * Add custom category.
97 *
98 * @param $elements_manager
99 */
100 public function add_category( $elements_manager ) {
101 $elements_manager->add_category(
102 'ht_builder',
103 [
104 'title' => __( 'HT Builder', 'ht-builder' ),
105 'icon' => 'fa fa-snowflake-o',
106 ]
107 );
108 }
109
110 /**
111 * Admin notice.
112 * Doesn't have Elementor installed or activated.
113 */
114 public function admin_notice_missing_main_plugin() {
115
116 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
117
118 $elementor = 'elementor/elementor.php';
119 if( $this->is_plugins_active( $elementor ) ) {
120 if( ! current_user_can( 'activate_plugins' ) ) {
121 return;
122 }
123 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $elementor . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $elementor );
124 $button_text = '<p><a href="' . $activation_url . '" class="button-primary">' . __( 'Activate Elementor', 'ht-builder' ) . '</a></p>';
125 } else {
126 if( ! current_user_can( 'activate_plugins' ) ) {
127 return;
128 }
129 $activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
130 $button_text = '<p><a href="' . $activation_url . '" class="button-primary">' . __( 'Install Elementor', 'ht-builder' ) . '</a></p>';
131 }
132
133 $message = sprintf(
134 /* translators: 1: Plugin name 2: Elementor */
135 esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'ht-builder' ),
136 '<strong>' . esc_html__( 'HT Builder', 'ht-builder' ) . '</strong>',
137 '<strong>' . esc_html__( 'Elementor', 'ht-builder' ) . '</strong>'
138 );
139 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p>%2$s</div>', $message, $button_text );
140
141 }
142
143 /**
144 * Admin notice.
145 * Elementor required version.
146 */
147 public function admin_notice_minimum_elementor_version() {
148 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
149 $message = sprintf(
150 /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
151 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'ht-builder' ),
152 '<strong>' . esc_html__( 'HT Builder', 'ht-builder' ) . '</strong>',
153 '<strong>' . esc_html__( 'Elementor', 'ht-builder' ) . '</strong>',
154 self::MINIMUM_ELEMENTOR_VERSION
155 );
156 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
157
158 }
159
160 /**
161 * Admin notice.
162 * PHP required version.
163 */
164 public function admin_notice_minimum_php_version() {
165 if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
166 $message = sprintf(
167 /* translators: 1: Plugin name 2: PHP 3: Required PHP version */
168 esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'ht-builder' ),
169 '<strong>' . esc_html__( 'HT Builder', 'ht-builder' ) . '</strong>',
170 '<strong>' . esc_html__( 'PHP', 'ht-builder' ) . '</strong>',
171 self::MINIMUM_PHP_VERSION
172 );
173 printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
174 }
175
176 /*
177 * Check Plugins is Installed or not
178 */
179 public function is_plugins_active( $pl_file_path = NULL ){
180 $installed_plugins_list = get_plugins();
181 return isset( $installed_plugins_list[$pl_file_path] );
182 }
183
184 /*
185 * Add settings link on plugin page.
186 */
187 public function plugins_setting_links( $links ) {
188 $htbuilder_settings_link = '<a href="'.admin_url('admin.php?page=htbuilder').'">'.__( 'Settings', 'ht-builder' ).'</a>';
189 array_unshift( $links, $htbuilder_settings_link );
190
191 if( !is_plugin_active('ht-builder-pro/ht-builder.php') ){
192 $links['htbgo_pro'] = sprintf('<a href="http://hasthemes.com/" target="_blank" style="color: #39b54a; font-weight: bold;">' . __('Go Pro','ht-builder') . '</a>');
193 }
194 return $links;
195 }
196
197 /*
198 * Plugins After Install
199 * Redirect Setting page
200 */
201 public function plugin_activate_hook() {
202 add_option('htbuilder_do_activation_redirect', true);
203 }
204 public function plugin_redirect_option_page() {
205 if ( get_option( 'htbuilder_do_activation_redirect', false ) ) {
206 delete_option('htbuilder_do_activation_redirect');
207 if( !isset( $_GET['activate-multi'] ) ){
208 wp_redirect( admin_url('admin.php?page=htbuilder') );
209 }
210 }
211 }
212
213
214
215 }
216 Base::instance();