PluginProbe
Ultimate Post Kit / trunk
Ultimate Post Kit vtrunk
4.2.1 4.2.2 4.2.3 4.5.0 4.5.2 4.5.3 4.2.0 4.1.18 4.1.17 4.1.16 4.1.15 4.1.14 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 All 145 releases
ultimate-post-kit / ultimate-post-kit.php

ultimate-post-kit.php in Ultimate Post Kit trunk, at ultimate-post-kit.php

228 lines 7.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Ultimate Post Kit
5 * Plugin URI: https://postkit.pro/
6 * Description: <a href="https://postkit.pro/">Ultimate Post Kit</a> is a packed of post related elementor widgets. This plugin gives you post related widget features for elementor page builder plugin.
7 * Version: 4.5.3
8 * Author: BdThemes
9 * Author URI: https://bdthemes.com/
10 * Text Domain: ultimate-post-kit
11 * Domain Path: /languages
12 * License: GPL3
13 * Elementor requires at least: 4.0.0
14 * Elementor tested up to: 4.2.2
15 */
16
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit;
19 }
20
21 // Some pre define value for easy use
22 define( 'BDTUPK_VER', '4.5.3' );
23
24 /**
25 * Minimum Pro version this Free/Core release is API compatible with.
26 *
27 * Required on Core/Base file changes. The Pro add-on extends base classes and
28 * calls helpers that live here, so whenever those signatures change a matching
29 * Pro must be released and this constant bumped to it. An older Pro is only
30 * warned about, never blocked, so the Free plugin stays fully functional on
31 * its own.
32 */
33 define( 'BDTUPK_PRO_REQUIRED_VERSION', '4.5.2' );
34
35 define( 'BDTUPK__FILE__', __FILE__ );
36
37 /**
38 * Loads translations
39 *
40 * @return void
41 */
42
43 // Translations for plugins hosted on WordPress.org load automatically since WP 4.6.
44
45
46 if ( ! function_exists( '_is_upk_pro_installed' ) ) {
47
48 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on across the plugin family / feedback SDK; renaming would break integration.
49 function _is_upk_pro_installed() {
50
51 if ( ! function_exists( 'get_plugins' ) ) {
52 require_once ABSPATH . 'wp-admin/includes/plugin.php';
53 }
54
55 $file_path = 'ultimate-post-kit-pro/ultimate-post-kit-pro.php';
56 $installed_plugins = get_plugins();
57
58 return isset( $installed_plugins[ $file_path ] );
59 }
60 }
61
62 if ( ! function_exists( '_is_upk_pro_activated' ) ) {
63
64 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on across the plugin family / feedback SDK; renaming would break integration.
65 function _is_upk_pro_activated() {
66
67 if ( ! function_exists( 'get_plugins' ) ) {
68 require_once ABSPATH . 'wp-admin/includes/plugin.php';
69 }
70
71 $file_path = 'ultimate-post-kit-pro/ultimate-post-kit-pro.php';
72
73 if ( is_plugin_active( $file_path ) ) {
74 return true;
75 }
76
77 return false;
78 }
79 }
80
81 if ( ! function_exists( '_is_upk_pro_version_sufficient' ) ) {
82
83 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- matches the established _is_upk_* helper naming used across the plugin family.
84 function _is_upk_pro_version_sufficient() {
85
86 // Pro is not loaded, so there is nothing to be incompatible with.
87 if ( ! defined( 'BDTUPK_PRO_VER' ) ) {
88 return true;
89 }
90
91 return version_compare( BDTUPK_PRO_VER, BDTUPK_PRO_REQUIRED_VERSION, '>=' );
92 }
93 }
94
95 // Helper function here
96 require_once ( dirname( __FILE__ ) . '/includes/helper.php' );
97
98 if ( ! _is_upk_pro_activated() ) {
99 require_once BDTUPK_INC_PATH . 'class-pro-widget-map.php';
100 }
101
102 if ( function_exists( 'upk_license_validation' ) && true !== upk_license_validation() ) {
103 require_once BDTUPK_INC_PATH . 'class-pro-widget-map.php';
104 }
105
106 require_once ( dirname( __FILE__ ) . '/includes/utils.php' );
107
108 // Widgets filters here
109 require_once ( BDTUPK_INC_PATH . 'ultimate-post-kit-filters.php' );
110
111
112 /**
113 * Plugin load here correctly
114 * Also loaded the language file from here
115 */
116 function ultimate_post_kit_load_plugin() {
117
118 if ( ! did_action( 'elementor/loaded' ) ) {
119 add_action( 'admin_notices', 'ultimate_post_kit_fail_load' );
120
121 return;
122 }
123
124 // An outdated Pro is warned about but never blocked; Free must keep working.
125 if ( ! _is_upk_pro_version_sufficient() ) {
126 add_action( 'admin_notices', 'ultimate_post_kit_pro_version_not_sufficient' );
127 }
128
129 require_once( dirname( __FILE__ ) . '/includes/setup-wizard/init.php' );
130
131 // Element pack widget and assets loader
132 require_once ( BDTUPK_PATH . 'loader.php' );
133 }
134
135 add_action( 'plugins_loaded', 'ultimate_post_kit_load_plugin' );
136
137
138 /**
139 * Warn when the installed Pro add-on is older than this Free/Core release
140 * expects. Pro is still loaded, so nothing breaks silently on the front end.
141 */
142 function ultimate_post_kit_pro_version_not_sufficient() {
143 if ( ! current_user_can( 'update_plugins' ) ) {
144 return;
145 }
146
147 $admin_message = '<p>' . sprintf(
148 /* translators: 1: installed Ultimate Post Kit Pro version, 2: minimum required Ultimate Post Kit Pro version */
149 esc_html__( 'Ops! Ultimate Post Kit Pro %1$s is older than this version of the Free/Core plugin supports. Please update Ultimate Post Kit Pro to at least version %2$s.', 'ultimate-post-kit' ),
150 esc_html( BDTUPK_PRO_VER ),
151 esc_html( BDTUPK_PRO_REQUIRED_VERSION )
152 ) . '</p>';
153
154 echo '<div class="error">' . wp_kses_post( $admin_message ) . '</div>';
155 }
156
157 /**
158 * Check Elementor installed and activated correctly
159 */
160 function ultimate_post_kit_fail_load() {
161 $screen = get_current_screen();
162 if ( isset( $screen->parent_file ) && 'plugins.php' === $screen->parent_file && 'update' === $screen->id ) {
163 return;
164 }
165
166 $plugin = 'elementor/elementor.php';
167
168 if ( _is_elementor_installed() ) {
169 if ( ! current_user_can( 'activate_plugins' ) ) {
170 return;
171 }
172 $activation_url = wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin . '&amp;plugin_status=all&amp;paged=1&amp;s', 'activate-plugin_' . $plugin );
173 $admin_message = '<p>' . esc_html__( 'Ops! Ultimate Post Kit not working because you need to activate the Elementor plugin first.', 'ultimate-post-kit' ) . '</p>';
174 $admin_message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $activation_url, esc_html__( 'Activate Elementor Now', 'ultimate-post-kit' ) ) . '</p>';
175 } else {
176 if ( ! current_user_can( 'install_plugins' ) ) {
177 return;
178 }
179 $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
180 $admin_message = '<p>' . esc_html__( 'Ops! Ultimate Post Kit not working because you need to install the Elementor plugin', 'ultimate-post-kit' ) . '</p>';
181 $admin_message .= '<p>' . sprintf( '<a href="%s" class="button-primary">%s</a>', $install_url, esc_html__( 'Install Elementor Now', 'ultimate-post-kit' ) ) . '</p>';
182 }
183
184 echo '<div class="error">' . wp_kses_post( $admin_message ) . '</div>';
185 }
186
187 /**
188 * Check the elementor installed or not
189 */
190 if ( ! function_exists( '_is_elementor_installed' ) ) {
191
192 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- established function name relied on across the plugin family / feedback SDK; renaming would break integration.
193 function _is_elementor_installed() {
194 $file_path = 'elementor/elementor.php';
195 $installed_plugins = get_plugins();
196
197 return isset( $installed_plugins[ $file_path ] );
198 }
199 }
200
201
202
203 /**
204 * Review Automation Integration
205 */
206
207 if ( ! function_exists( 'ultimate_post_kit_reviews_bootstrap' ) ) {
208 function ultimate_post_kit_reviews_bootstrap() {
209
210 require_once BDTUPK_INC_PATH . 'feedback-hub/start.php';
211
212 ultimate_post_kit_reviews_init( array(
213 'sdk_version' => '1.0.0',
214 'plugin_name' => 'Ultimate Post Kit',
215 'plugin_icon' => BDTUPK_ASSETS_URL . 'images/logo.svg',
216 'slug' => 'ultimate_post_kit_options',
217 'menu' => array(
218 'slug' => 'ultimate_post_kit_options',
219 ),
220 'review_url' => 'https://bdt.to/ultimate-post-kit-elementor-addons-review',
221 'plugin_title' => 'Yay! Great that you\'re using Ultimate Post Kit',
222 'plugin_msg' => '<p>Loved using Ultimate Post Kit on your website? Share your experience in a review and help us spread the love to everyone right now. Good words will help the community.</p>',
223 ) );
224
225 }
226 add_action( 'admin_init', 'ultimate_post_kit_reviews_bootstrap' );
227 }
228