-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpowerpack-lite-elementor.php
More file actions
247 lines (209 loc) · 8.02 KB
/
Copy pathpowerpack-lite-elementor.php
File metadata and controls
247 lines (209 loc) · 8.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/**
* Plugin Name: PowerPack Lite for Elementor
* Plugin URI: https://powerpackelements.com
* Description: Extend Elementor Page Builder with 40+ Creative Widgets and exciting extensions.
* Version: 2.10.4
* Author: PowerPack Addons Team - IdeaBox Creations
* Author URI: http://ideabox.io/
* License: GNU General Public License v2.0
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: powerpack-lite-for-elementor
* Elementor tested up to: 4.0.0
* Elementor Pro tested up to: 4.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( defined( 'POWERPACK_ELEMENTS_VER' ) ) {
return;
}
define( 'POWERPACK_ELEMENTS_LITE_VER', '2.10.4' );
define( 'POWERPACK_ELEMENTS_LITE_PATH', plugin_dir_path( __FILE__ ) );
define( 'POWERPACK_ELEMENTS_LITE_BASE', plugin_basename( __FILE__ ) );
define( 'POWERPACK_ELEMENTS_LITE_URL', plugins_url( '/', __FILE__ ) );
define( 'POWERPACK_ELEMENTS_LITE_ELEMENTOR_VERSION_REQUIRED', '3.5.0' );
define( 'POWERPACK_ELEMENTS_LITE_PHP_VERSION_REQUIRED', '7.4' );
require_once POWERPACK_ELEMENTS_LITE_PATH . 'includes/helper-functions.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'includes/admin/feedback/class-pp-tracking.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'classes/class-pp-admin-settings.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'classes/class-pp-config.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'classes/class-pp-helper.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'classes/class-pp-posts-helper.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'classes/class-pp-wpml.php';
require_once POWERPACK_ELEMENTS_LITE_PATH . 'plugin.php';
if ( did_action( 'elementor/loaded' ) ) {
require_once POWERPACK_ELEMENTS_LITE_PATH . 'classes/class-pp-templates-lib.php';
}
/**
* Check if Elementor is installed
*
* @since 1.0
*/
function powerpack_elements_lite_is_elementor_installed() {
$file_path = 'elementor/elementor.php';
$installed_plugins = get_plugins();
return isset( $installed_plugins[ $file_path ] );
}
/**
* Shows notice to user if Elementor plugin
* is not installed or activated or both
*
* @since 1.0
*/
function powerpack_elements_lite_fail_load() {
$plugin = 'elementor/elementor.php';
if ( powerpack_elements_lite_is_elementor_installed() ) {
if ( ! current_user_can( 'activate_plugins' ) ) {
return;
}
$activation_url = wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin . '&plugin_status=all&paged=1&s', 'activate-plugin_' . $plugin );
$message = __( 'PowerPack requires Elementor plugin to be active. Please activate Elementor to continue.', 'powerpack-lite-for-elementor' );
$button_text = __( 'Activate Elementor', 'powerpack-lite-for-elementor' );
} else {
if ( ! current_user_can( 'install_plugins' ) ) {
return;
}
$activation_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
$message = sprintf(
/* translators: 1: Opening strong tag, 2: Closing strong tag. */
__(
'PowerPack requires the %1$sElementor%2$s plugin to be installed and activated. Please install Elementor to continue.',
'powerpack-lite-for-elementor'
),
'<strong>',
'</strong>'
);
$message = wp_kses_post( $message );
$button_text = __( 'Install Elementor', 'powerpack-lite-for-elementor' );
}
$button = sprintf(
'<p><a href="%1$s" class="button-primary">%2$s</a></p>',
esc_url( $activation_url ),
esc_html( $button_text )
);
?>
<div class="notice notice-error">
<p><?php echo esc_html( $message ); ?></p>
<?php echo wp_kses_post( $button ); ?>
</div>
<?php
}
/**
* Shows notice to user if
* Elementor version if outdated
*
* @since 1.0
*
*/
function powerpack_elements_lite_fail_load_out_of_date() {
if ( ! current_user_can( 'update_plugins' ) ) {
return;
}
$message = sprintf(
/* translators: %s: Minimum required Elementor version number. */
esc_html__( 'PowerPack requires Elementor version at least %s. Please update Elementor to continue.', 'powerpack-lite-for-elementor' ),
POWERPACK_ELEMENTS_LITE_ELEMENTOR_VERSION_REQUIRED
);
printf( '<div class="error"><p>%1$s</p></div>', esc_html( $message ) );
}
/**
* Shows notice to user if minimum PHP
* version requirement is not met
*
* @since 1.0
*
*/
function powerpack_elements_lite_fail_php() {
$message = sprintf(
/* translators: %s: Minimum required PHP version number. */
esc_html__( 'PowerPack requires PHP version %s+ to work properly. The plugin is deactivated for now.', 'powerpack-lite-for-elementor' ),
POWERPACK_ELEMENTS_LITE_PHP_VERSION_REQUIRED
);
printf( '<div class="error"><p>%1$s</p></div>', esc_html( $message ) );
// Remove the activate parameter from the URL to prevent "Plugin activated" message.
// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['activate'] ) ) {
unset( $_GET['activate'] );
}
}
/**
* Deactivates the plugin
*
* @since 1.0
*/
function powerpack_elements_lite_deactivate() {
deactivate_plugins( plugin_basename( __FILE__ ) );
}
add_action( 'plugins_loaded', 'powerpack_elements_lite_init' );
function powerpack_elements_lite_init() {
// Notice if the Elementor is not active
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', 'powerpack_elements_lite_fail_load' );
return;
}
// Check for required Elementor version
if ( ! version_compare( ELEMENTOR_VERSION, POWERPACK_ELEMENTS_LITE_ELEMENTOR_VERSION_REQUIRED, '>=' ) ) {
add_action( 'admin_notices', 'powerpack_elements_lite_fail_load_out_of_date' );
add_action( 'admin_init', 'powerpack_elements_lite_deactivate' );
return;
}
// Check for required PHP version
if ( ! version_compare( PHP_VERSION, POWERPACK_ELEMENTS_LITE_PHP_VERSION_REQUIRED, '>=' ) ) {
add_action( 'admin_notices', 'powerpack_elements_lite_fail_php' );
add_action( 'admin_init', 'powerpack_elements_lite_deactivate' );
return;
}
$is_plugin_activated = get_option( 'pp_plugin_activated' );
if ( current_user_can('activate_plugins') && 'yes' !== $is_plugin_activated ) {
update_option( 'pp_install_date', current_time( 'mysql' ) );
update_option( 'pp_plugin_activated', 'yes' );
}
}
/**
* Check if PowerPack Elements is active
*
* @since 1.2.9.4
*
*/
if ( ! function_exists( 'is_pp_elements_active' ) ) {
function is_pp_elements_active() {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
$plugin = 'powerpack-elements/powerpack-elements.php';
return is_plugin_active( $plugin ) || function_exists( 'pp_init' );
}
}
/**
* Add settings page link to plugin page
*
* @since 1.4.4
*/
function powerpack_elements_lite_add_plugin_page_settings_link( $links ) {
$settings_url = admin_url( 'admin.php?page=powerpack-settings' );
$links[] = sprintf(
'<a href="%1$s">%2$s</a>',
esc_url( $settings_url ),
esc_html__( 'Settings', 'powerpack-lite-for-elementor' )
);
return $links;
}
add_filter( 'plugin_action_links_' . POWERPACK_ELEMENTS_LITE_BASE, 'powerpack_elements_lite_add_plugin_page_settings_link' );
function powerpack_elements_add_description_links( $plugin_meta, $plugin_file ) {
if ( POWERPACK_ELEMENTS_LITE_BASE === $plugin_file ) {
$row_meta = [
'docs' => sprintf(
'<a href="%1$s" aria-label="%2$s" target="_blank" rel="noopener noreferrer">%3$s</a>',
esc_url( 'https://powerpackelements.com/docs/?utm_source=doclink&utm_medium=widget&utm_campaign=lite' ),
esc_attr__( 'View PowerPack Documentation', 'powerpack-lite-for-elementor' ),
esc_html__( 'Docs & FAQs', 'powerpack-lite-for-elementor' )
),
'pro' => sprintf(
'<a href="%1$s" aria-label="%2$s" target="_blank" rel="noopener noreferrer" style="font-weight:bold;">%3$s</a>',
esc_url( 'https://powerpackelements.com/?utm_source=plugin&utm_medium=list&utm_campaign=lite' ),
esc_attr__( 'Upgrade to PowerPack Pro', 'powerpack-lite-for-elementor' ),
esc_html__( 'Go Pro', 'powerpack-lite-for-elementor' )
),
];
$plugin_meta = array_merge( $plugin_meta, $row_meta );
}
return $plugin_meta;
}
add_filter( 'plugin_row_meta', 'powerpack_elements_add_description_links', 10, 4 );