PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.41
Post Grid Gutenberg Blocks – PostX v5.0.41
5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 All 238 releases
← All changes | classes/Options.php +341 -71 2.1.15.0.41 View file →
@@ -1,86 +1,356 @@
1 1 <?php
2 +
3 +/**
4 + * Options Action.
5 + *
6 + * @package ULTP\Notice
7 + * @since v.1.0.0
8 + */
9 +
2 10 namespace ULTP;
3 11
4 -defined('ABSPATH') || exit;
12 +use ULTP\Includes\Durbin\Xpo;
5 13
6 -class Options{
7 - public function __construct() {
8 - add_action( 'admin_menu', array( $this, 'menu_page_callback' ) );
9 - add_action( 'admin_init', array( $this, 'register_settings' ) );
10 - add_action( 'in_admin_header', array($this, 'remove_all_notices') );
11 -
12 - add_filter( 'plugin_row_meta', array( $this, 'plugin_settings_meta' ), 10, 2 );
13 - add_filter( 'plugin_action_links_'.ULTP_BASE, array( $this, 'plugin_action_links_callback' ) );
14 - }
14 +defined( 'ABSPATH' ) || exit;
15 15
16 +/**
17 + * Options class.
18 + *
19 + * Handles plugin options and settings for Ultimate Post.
20 + *
21 + * @package ULTP\Options
22 + * @since 4.0.0
23 + */
24 +class Options {
16 25
17 - public function plugin_settings_meta( $links, $file ) {
18 - if ( strpos( $file, 'ultimate-post.php' ) !== false ) {
19 - $new_links = array(
20 - 'ultp_docs' => '<a href="https://docs.wpxpo.com/" target="_blank">'.__('Docs', 'ultimate-post').'</a>',
21 - 'ultp_tutorial' => '<a href="https://www.youtube.com/watch?v=JZxIflYKOuM&list=PLPidnGLSR4qcAwVwIjMo1OVaqXqjUp_s4" target="_blank">'.__('Tutorials', 'ultimate-post').'</a>',
22 - 'ultp_support' => '<a href="https://www.wpxpo.com/contact/?utm_campaign=go_premium" target="_blank">'.__('Support', 'ultimate-post').'</a>'
23 - );
24 - $links = array_merge( $links, $new_links );
25 - }
26 - return $links;
27 - }
26 + /**
27 + * Setup class.
28 + *
29 + * @since v.1.0.0
30 + */
31 + public function __construct() {
32 + add_action( 'admin_init', array( $this, 'handle_external_redirects' ) );
33 + add_action( 'admin_menu', array( $this, 'menu_page_callback' ) );
34 + add_action( 'admin_footer', array( $this, 'sync_addon_submenu_visibility' ) );
35 + add_action( 'in_admin_header', array( $this, 'remove_all_notices' ) );
36 + add_filter( 'plugin_row_meta', array( $this, 'plugin_settings_meta' ), 10, 2 );
37 + add_filter( 'plugin_action_links_' . ULTP_BASE, array( $this, 'plugin_action_links_callback' ) );
38 + }
28 39
29 40
30 - public function plugin_action_links_callback ( $links ) {
31 - $upgrade_link = array();
32 - $setting_link = array();
33 - if(!defined('ULTP_PRO_VER')){
34 - $upgrade_link = array(
35 - 'ultp_pro' => '<a href="https://www.wpxpo.com/gutenberg-post-blocks/?utm_campaign=go_premium" target="_blank"><span style="color: #e83838; font-weight: bold;">'.__('Go Pro', 'ultimate-post').'</span></a>'
36 - );
37 - }
38 - $setting_link['ultp_settings'] = '<a href="'. menu_page_url('ultp-option-settings', false) .'">'. __('Settings', 'wp-megamenu') .'</a>';
39 - return array_merge( $setting_link, $links, $upgrade_link);
40 - }
41 + /**
42 + * Adds extra links to the plugin row meta on the plugins page.
43 + *
44 + * @param array $links Existing plugin meta links.
45 + * @param string $file Plugin file path.
46 + * @return array Modified plugin meta links.
47 + */
48 + public function plugin_settings_meta( $links, $file ) {
49 + if ( strpos( $file, 'ultimate-post.php' ) !== false ) {
50 + $new_links = array(
51 + 'ultp_docs' => '<a href="https://wpxpo.com/docs/" target="_blank">' . esc_html__( 'Docs', 'ultimate-post' ) . '</a>',
52 + 'ultp_tutorial' => '<a href="https://www.youtube.com/watch?v=JZxIflYKOuM&list=PLPidnGLSR4qcAwVwIjMo1OVaqXqjUp_s4" target="_blank">' . esc_html__( 'Tutorials', 'ultimate-post' ) . '</a>',
53 + 'ultp_support' => '<a href="' . esc_url(
54 + Xpo::generate_utm_link(
55 + array(
56 + 'url' => 'https://www.wpxpo.com/contact/',
57 + 'utmKey' => 'plugin_dir_support',
58 + )
59 + )
60 + ) . '" target="_blank">' . esc_html__( 'Support', 'ultimate-post' ) . '</a>',
61 + );
62 + $links = array_merge( $links, $new_links );
63 + }
64 + return $links;
65 + }
41 66
67 + /**
68 + * Adds quick action links below the plugin name.
69 + *
70 + * @param array $links Default plugin action links.
71 + * @return array Modified plugin action links.
72 + */
73 + public function plugin_action_links_callback( $links ) {
74 + $offer_config = array(
75 + array(
76 + 'start' => '2026-07-06 00:00 Asia/Dhaka',
77 + 'end' => '2026-08-01 23:59 Asia/Dhaka',
78 + 'text' => __(
79 + 'Summer Sale - Up to 50% OFF',
80 + 'ultimate-post'
81 + ),
82 + 'utmKey' => 'summer_sale_meta',
83 + ),
84 + array(
85 + 'start' => '2026-09-02 00:00 Asia/Dhaka',
86 + 'end' => '2026-10-10 23:59 Asia/Dhaka',
87 + 'text' => __(
88 + 'Get Pro at $39',
89 + 'ultimate-post'
90 + ),
91 + 'utmKey' => 'base_price_meta',
92 + ),
93 + );
42 94
43 - public static function menu_page_callback() {
44 - add_menu_page(
45 - esc_html__( 'Post Blocks', 'ultimate-post' ),
46 - esc_html__( 'Post Blocks', 'ultimate-post' ),
47 - 'manage_options',
48 - 'ultp-settings',
49 - '',
50 - ULTP_URL.'assets/img/menu-panel.svg'
51 - );
95 + $setting_link = array(
96 + 'ultp_options' => '<a href="' . esc_url( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) . '">' . esc_html__( 'Starter Sites', 'ultimate-post' ) . '</a>',
97 + );
52 98
53 - require_once ULTP_PATH . 'classes/options/Overview.php';
54 - require_once ULTP_PATH . 'classes/options/Features.php';
55 - require_once ULTP_PATH . 'classes/options/Addons.php';
56 - require_once ULTP_PATH . 'classes/options/Settings.php';
57 - require_once ULTP_PATH . 'classes/options/Contact.php';
58 - new \ULTP\Options_Overview();
59 - new \ULTP\Options_Features();
60 - new \ULTP\Options_Addons();
61 - new \ULTP\Options_Settings();
62 - new \ULTP\Options_Contact();
99 + $upgrade_link = array();
63 100
64 - if( !function_exists('ultimate_post_pro') ){
65 - global $submenu;
66 - $upgrade_link = 'https://www.wpxpo.com/gutenberg-post-blocks/?ultp=plugins';
67 - $submenu['ultp-settings'][] = array( '<span class="ultp-dashboard-upgrade"><span class="dashicons dashicons-update"></span> Upgrade</span>', 'manage_options', $upgrade_link );
68 - }
69 - }
101 + // Free user or expired license user.
102 + if ( ! defined( 'ULTP_PRO_VER' ) || Xpo::is_lc_expired() ) {
70 103
71 - // Remove All Notification From Menu Page
72 - public static function remove_all_notices() {
73 - if ( isset( $_GET['page'] ) && ( $_GET['page'] === 'ultp-settings' || $_GET['page'] === 'ultp-features' || $_GET['page'] === 'ultp-addons' || $_GET['page'] === 'ultp-option-settings' || $_GET['page'] === 'ultp-contact' || $_GET['page'] === 'ultp-license' ) ) {
74 - remove_all_actions( 'admin_notices' );
75 - remove_all_actions( 'all_admin_notices' );
76 - }
77 - }
104 + $license_key = Xpo::get_lc_key() ?? '';
78 105
79 - /**
80 - * Register a setting and its sanitization callback.
81 - */
82 - public static function register_settings() {
83 - register_setting( 'ultp_options', 'ultp_options', array( self::class, 'sanitize' ) );
84 - }
106 + if ( Xpo::is_lc_expired() ) {
107 + $text = esc_html__( 'Renew License', 'ultimate-post' );
108 + $url = 'https://account.wpxpo.com/checkout/?edd_license_key=' . $license_key;
109 + } else {
110 +
111 + $text = esc_html__( 'Upgrade to Pro', 'ultimate-post' );
112 + $url = Xpo::generate_utm_link(
113 + array(
114 + 'utmKey' => 'sub_menu',
115 + )
116 + );
117 +
118 + foreach ( $offer_config as $offer ) {
119 + $current_time = gmdate( 'U' );
120 + $notice_start = gmdate( 'U', strtotime( $offer['start'] ) );
121 + $notice_end = gmdate( 'U', strtotime( $offer['end'] ) );
122 + if ( $current_time >= $notice_start && $current_time <= $notice_end ) {
123 + $url = Xpo::generate_utm_link(
124 + array(
125 + 'utmKey' => $offer['utmKey'],
126 + )
127 + );
128 + $text = $offer['text'];
129 + break;
130 + }
131 + }
132 + }
133 +
134 + $upgrade_link['ultp_pro'] = '<a style="color: #0062ff; font-weight: bold;" target="_blank" href="' . esc_url( $url ) . '">' . esc_html( $text ) . '</a>';
135 + }
136 +
137 + return array_merge( $setting_link, $links, $upgrade_link );
138 + }
139 +
140 +
141 + /**
142 + * Add admin menu option page and submenus.
143 + *
144 + * @since v.1.0.0
145 + * @return void No return value.
146 + */
147 + public static function menu_page_callback() {
148 + $ultp_menu_icon = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA0OC4zIj4NCiAgPGRlZnM+DQogICAgPHN0eWxlPg0KICAgICAgLmNscy0xIHsNCiAgICAgICAgZmlsbDogI2E3YWFhZDsNCiAgICAgIH0NCiAgICA8L3N0eWxlPg0KICA8L2RlZnM+DQogIDx0aXRsZT5Qb3N0eCBJY29uIGNtcHJzc2QgU1ZHPC90aXRsZT4NCiAgPGc+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTguODEsOXY4LjlIOC4xOUE2LjE5LDYuMTksMCwwLDAsMiwyMy43N2EzLjE2LDMuMTYsMCwwLDEtMi0yLjk0VjRBMy4xNiwzLjE2LDAsMCwxLDMuMTUuODVIMjBhMy4xOCwzLjE4LDAsMCwxLDMsMi4zMUE2LjIxLDYuMjEsMCwwLDAsMTguODEsOVoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDUsOVYyM0gzMS4xYTYuMjMsNi4yMywwLDAsMC00LjkzLTQuOTNBNS41NCw1LjU0LDAsMCwwLDI1LDE3Ljk0SDIxLjg1VjlBMy4xNSwzLjE1LDAsMCwxLDIzLjEzLDYuNWEzLjEyLDMuMTIsMCwwLDEsMS40My0uNThsLjA5LDBINDEuODNBMy4xNCwzLjE0LDAsMCwxLDQ1LDlaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0wLjg1KSIvPg0KICAgIDxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTUwLDI5LjE3VjQ2YTMuMTYsMy4xNiwwLDAsMS0zLjE1LDMuMTVIMzBhMy4xOCwzLjE4LDAsMCwxLTMtMi4zMUE2LjIyLDYuMjIsMCwwLDAsMzEuMjEsNDFWMjZINDYuODVhMy4zLDMuMywwLDAsMSwxLjE0LjIxQTMuMTYsMy4xNiwwLDAsMSw1MCwyOS4xN1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMjguMTYsMjQuMTNWNDFhMy4xMywzLjEzLDAsMCwxLTEuMjksMi41NCwzLDMsMCwwLDEtMS40Ny41OGwwLDBIOC4xOUEzLjE1LDMuMTUsMCwwLDEsNSw0MVYyNGEzLjE3LDMuMTcsMCwwLDEsMy4xNS0zSDI1YTMuMTIsMy4xMiwwLDAsMSwxLjE0LjIyLDMuMjQsMy4yNCwwLDAsMSwxLjksMi4xQTMuNjMsMy42MywwLDAsMSwyOC4xNiwyNC4xM1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogIDwvZz4NCjwvc3ZnPg0K';
149 + $menupage_cap = apply_filters( 'ultp_menu_page_capability', 'manage_options' );
150 + add_menu_page(
151 + __( 'PostX', 'ultimate-post' ),
152 + __( 'PostX', 'ultimate-post' ),
153 + $menupage_cap,
154 + 'ultp-settings',
155 + array( self::class, 'ultp_dashboard' ),
156 + $ultp_menu_icon,
157 + 58.5
158 + );
159 +
160 + add_submenu_page(
161 + 'ultp-settings',
162 + __( 'PostX Dashboard', 'ultimate-post' ),
163 + __( 'Getting Started', 'ultimate-post' ),
164 + $menupage_cap,
165 + 'ultp-settings'
166 + );
167 +
168 + $menu_lists = array(
169 + 'startersites' => esc_html__( 'Starter Sites', 'ultimate-post' ),
170 + 'builder' => esc_html__( 'Site Builder', 'ultimate-post' ),
171 + 'saved-templates' => esc_html__( 'Saved Templates', 'ultimate-post' ),
172 + 'custom-font' => esc_html__( 'Custom Font', 'ultimate-post' ),
173 + 'addons' => esc_html__( 'Add-ons', 'ultimate-post' ),
174 + 'blocks' => esc_html__( 'Blocks', 'ultimate-post' ),
175 + 'settings' => esc_html__( 'Settings', 'ultimate-post' ),
176 + );
177 + if ( defined( 'ULTP_PRO_VER' ) ) {
178 + $menu_lists['license'] = esc_html__( 'License ', 'ultimate-post' );
179 + }
180 +
181 + foreach ( $menu_lists as $key => $val ) {
182 + add_submenu_page(
183 + 'ultp-settings',
184 + $val,
185 + $val,
186 + $menupage_cap,
187 + 'ultp-settings#' . $key,
188 + array( __CLASS__, 'render_main' )
189 + );
190 + }
191 + add_submenu_page(
192 + 'ultp-settings',
193 + esc_html__( 'Initial Setup', 'ultimate-post' ),
194 + esc_html__( 'Initial Setup', 'ultimate-post' ),
195 + $menupage_cap,
196 + 'ultp-setup-wizard',
197 + array( __CLASS__, 'ultp_wizard_page' )
198 + );
199 +
200 + $pro_link = '';
201 + $pro_link_text = '';
202 +
203 + // Check if current date is between November 5th and December 10th
204 + $current_date = current_time( 'Y-m-d' );
205 + $start_date = date( 'Y' ) . '-01-01'; // January 1st of current year
206 + $end_date = date( 'Y' ) . '-02-15'; // February 15th of current year
207 + $menu_pro_text_period = ( $current_date >= $start_date && $current_date <= $end_date );
208 +
209 + if ( ! Xpo::is_lc_active() ) {
210 + $pro_link = Xpo::generate_utm_link(
211 + array(
212 + 'utmKey' => 'sub_menu',
213 + )
214 + );
215 + $pro_link_text = $menu_pro_text_period ? __( 'New Year Offer!', 'ultimate-post' ) : __( 'Upgrade to Pro', 'ultimate-post' );
216 + } elseif ( Xpo::is_lc_expired() ) {
217 + $license_key = Xpo::get_lc_key();
218 + $pro_link = 'https://account.wpxpo.com/checkout/?edd_license_key=' . $license_key;
219 + $pro_link_text = __( 'Renew License', 'ultimate-post' );
220 + }
221 +
222 + if ( ! empty( $pro_link ) ) {
223 + ob_start();
224 + ?>
225 + <a href="<?php echo esc_url( $pro_link ); ?>" target="_blank" class="ultp-go-pro">
226 + <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
227 + <path d="M2.86 6.553a.5.5 0 01.823-.482l3.02 2.745c.196.178.506.13.64-.098L9.64 4.779a.417.417 0 01.72 0l2.297 3.939a.417.417 0 00.64.098l3.02-2.745a.5.5 0 01.823.482l-1.99 8.63a.833.833 0 01-.813.646H5.663a.833.833 0 01-.812-.646L2.86 6.553z" stroke="currentColor" stroke-width="1.5"></path>
228 + </svg>
229 + <span><?php echo esc_html( $pro_link_text ); ?></span>
230 + </a>
231 + <?php
232 + $submenu_content = ob_get_clean();
233 +
234 + add_submenu_page(
235 + 'ultp-settings',
236 + '',
237 + $submenu_content,
238 + 'manage_options',
239 + 'ultp-pro',
240 + array( self::class, 'handle_external_redirects' )
241 + );
242 + }
243 +
244 + add_theme_page(
245 + __( 'Starter Sites', 'ultimate-post' ),
246 + __( 'Starter Sites', 'ultimate-post' ),
247 + $menupage_cap,
248 + 'ultp-startersites',
249 + array( self::class, 'handle_external_redirects' )
250 + );
251 + }
252 +
253 + /**
254 + * Sync addon-backed WordPress submenu items with addon enabled status.
255 + *
256 + * @since v.4.1.7
257 + * @return void No return value.
258 + */
259 + public function sync_addon_submenu_visibility() {
260 + $settings = ultimate_post()->get_setting();
261 + $submenus = array(
262 + 'builder' => 'ultp_builder',
263 + 'saved-templates' => 'ultp_templates',
264 + 'custom-font' => 'ultp_custom_font',
265 + );
266 +
267 + foreach ( $submenus as $slug => $setting_key ) {
268 + $submenus[ $slug ] = isset( $settings[ $setting_key ] ) && $settings[ $setting_key ] !== 'false';
269 + }
270 + ?>
271 + <script>
272 + ( function() {
273 + const postxAddonSubmenus = <?php echo wp_json_encode( $submenus ); ?>;
274 +
275 + Object.keys( postxAddonSubmenus ).forEach( function( slug ) {
276 + const link = document.querySelector( '#adminmenu a[href*="page=ultp-settings#' + slug + '"]' );
277 + const item = link ? link.closest( 'li' ) : null;
278 +
279 + if ( ! item ) {
280 + return;
281 + }
282 +
283 + item.id = 'postx-submenu-' + slug;
284 + item.style.display = postxAddonSubmenus[ slug ] ? '' : 'none';
285 + } );
286 + }() );
287 + </script>
288 + <?php
289 + }
290 +
291 + /**
292 + * Handle external redirects for menu and pro links.
293 + *
294 + * @since v.1.0.0
295 + * @return void No return value.
296 + */
297 + public function handle_external_redirects() {
298 + if (empty($_GET['page'])) { // @codingStandardsIgnoreLine
299 + return;
300 + }
301 + $_page = sanitize_key( $_GET['page'] );
302 + if ('ultp-startersites' === $_page) { // @codingStandardsIgnoreLine
303 + exit( wp_safe_redirect( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) );
304 + } else if ('go_postx_pro' === $_page) { // @codingStandardsIgnoreLine
305 + wp_redirect(
306 + Xpo::generate_utm_link(
307 + array(
308 + 'utmKey' => 'dashboard_go_pro',
309 + )
310 + )
311 + );
312 + die();
313 + }
314 + }
315 +
316 + /**
317 + * Render the wizard page.
318 + *
319 + * @since v.2.4.4
320 + */
321 + public static function ultp_wizard_page() {
322 + ?>
323 + <div class="ultp-wizard-page-wrap" id="ultp-wizard-page"></div>
324 + <?php
325 + }
326 +
327 + /**
328 + * Render the dashboard page.
329 + *
330 + * @since v.1.0.0
331 + * @return void No return value.
332 + */
333 + public static function ultp_dashboard() {
334 + echo '<div id="ultp-dashboard"></div>';
335 + }
336 +
337 + /**
338 + * Remove all notifications from menu page.
339 + *
340 + * @since v.1.0.0
341 + * @return void No return value.
342 + */
343 + public static function remove_all_notices() {
344 + if (isset($_GET['page'])) { // @codingStandardsIgnoreLine
345 + $page = sanitize_key($_GET['page']); // @codingStandardsIgnoreLine
346 + if (
347 + $page === 'ultp-settings' ||
348 + $page === 'ultp-license' ||
349 + $page === 'ultp-setup-wizard'
350 + ) {
351 + remove_all_actions( 'admin_notices' );
352 + remove_all_actions( 'all_admin_notices' );
353 + }
354 + }
355 + }
85 356 }
86 -