PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.9.2
Post Grid Gutenberg Blocks – PostX v2.9.2
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 2.1.2 All 237 releases
ultimate-post / classes / Options.php

Options.php in Post Grid Gutenberg Blocks – PostX 2.9.2, at classes/Options.php

287 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Options Action.
4 *
5 * @package ULTP\Notice
6 * @since v.1.0.0
7 */
8 namespace ULTP;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Options class.
14 */
15 class Options{
16
17 /**
18 * Setup class.
19 *
20 * @since v.1.0.0
21 */
22 public function __construct() {
23 add_action( 'admin_init', array( $this, 'handle_external_redirects' ) );
24 add_action( 'admin_menu', array( $this, 'menu_page_callback' ) );
25 add_action( 'in_admin_header', array($this, 'remove_all_notices') );
26 add_filter( 'plugin_row_meta', array( $this, 'plugin_settings_meta' ), 10, 2 );
27 add_filter( 'plugin_action_links_'.ULTP_BASE, array( $this, 'plugin_action_links_callback' ) );
28 }
29
30
31 /**
32 * Plugin Page Menu Add
33 *
34 * @since v.1.0.0
35 * @return ARRAY
36 */
37 public function plugin_settings_meta( $links, $file ) {
38 if (strpos( $file, 'ultimate-post.php' ) !== false ) {
39 $new_links = array(
40 'ultp_docs' => '<a href="https://docs.wpxpo.com/" target="_blank">'.esc_html__('Docs', 'ultimate-post').'</a>',
41 'ultp_tutorial' => '<a href="https://www.youtube.com/watch?v=JZxIflYKOuM&list=PLPidnGLSR4qcAwVwIjMo1OVaqXqjUp_s4" target="_blank">'.esc_html__('Tutorials', 'ultimate-post').'</a>',
42 'ultp_support' => '<a href="'.esc_url(ultimate_post()->get_premium_link( 'https://www.wpxpo.com/contact/', 'plugin_dir_support')).'" target="_blank">'.esc_html__('Support', 'ultimate-post').'</a>'
43 );
44 $links = array_merge( $links, $new_links );
45 }
46 return $links;
47 }
48
49
50 /**
51 * Settings Pro Update Link
52 *
53 * @since v.1.0.0
54 * @return ARRAY
55 */
56 public function plugin_action_links_callback( $links ) {
57 $upgrade_link = array();
58 $setting_link = array();
59 if (!defined('ULTP_PRO_VER')) {
60 $upgrade_link = array(
61 'ultp_pro' => '<a href="'.esc_url(ultimate_post()->get_premium_link('', 'plugin_dir_pro')).'" target="_blank"><span style="color: #e83838; font-weight: bold;">'.esc_html__('Get PostX Pro', 'ultimate-post').'</span></a>'
62 );
63 $notice = ultimate_post()->get_notice_data('plugin');
64 if (count($notice) > 0) {
65 $current_time = date('U');
66 if ($current_time > strtotime($notice['start']) && $current_time < strtotime($notice['end'])) {
67 $upgrade_link['ultp_pro'] = '<a href="'.esc_url(ultimate_post()->get_premium_link('', 'plugin_dir_pro')).'" target="_blank"><span style="color: #e83838; font-weight: bold;">'.$notice['content'].'</span></a>';
68 }
69 }
70 }
71 $setting_link['ultp_settings'] = '<a href="'. esc_url(admin_url('admin.php?page=ultp-settings#settings')) .'">'. esc_html__('Settings', 'wp-megamenu') .'</a>';
72 return array_merge( $setting_link, $links, $upgrade_link);
73 }
74
75
76 /**
77 * Admin Menu Option Page
78 *
79 * @since v.1.0.0
80 * @return NULL
81 */
82 public static function menu_page_callback() {
83
84 $ultp_menu_icon = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA0OC4zIj4NCiAgPGRlZnM+DQogICAgPHN0eWxlPg0KICAgICAgLmNscy0xIHsNCiAgICAgICAgZmlsbDogI2E3YWFhZDsNCiAgICAgIH0NCiAgICA8L3N0eWxlPg0KICA8L2RlZnM+DQogIDx0aXRsZT5Qb3N0eCBJY29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LDEsMy4xNS0zSDI1YTMuMTIsMy4xMiwwLDAsMSwxLjE0LjIyLDMuMjQsMy4yNCwwLDAsMSwxLjksMi4xQTMuNjMsMy42MywwLDAsMSwyOC4xNiwyNC4xM1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogIDwvZz4NCjwvc3ZnPg0K';
85 add_menu_page(
86 esc_html__( 'PostX', 'ultimate-post' ),
87 esc_html__( 'PostX', 'ultimate-post' ),
88 'manage_options',
89 'ultp-settings',
90 array(self::class, 'tab_page_content'),
91 $ultp_menu_icon,
92 58.5
93 );
94
95 add_submenu_page(
96 'ultp-settings',
97 esc_html__( 'Getting Started', 'ultimate-post' ),
98 esc_html__( 'Getting Started', 'ultimate-post' ),
99 'manage_options',
100 'ultp-settings'
101 );
102
103 if (ultimate_post()->get_setting('ultp_templates') == 'true') {
104 add_submenu_page(
105 'ultp-settings',
106 esc_html__( 'Saved Templates', 'ultimate-post' ),
107 esc_html__( 'Saved Templates', 'ultimate-post' ),
108 'manage_options',
109 'edit.php?post_type=ultp_templates',
110 ''
111 );
112 }
113
114 if (ultimate_post()->get_setting('ultp_builder') == 'true') {
115 add_submenu_page(
116 'ultp-settings',
117 esc_html__( 'Site Builder', 'ultimate-post' ),
118 esc_html__( 'Site Builder', 'ultimate-post' ),
119 'manage_options',
120 'admin.php?page=ultp-settings#builder',
121 ''
122 );
123 }
124
125 $menu_lists = array(
126 array(
127 'name' => esc_html__( 'Template Kits', 'ultimate-post' ),
128 'slug' => 'templatekit'
129 ),
130 array(
131 'name' => esc_html__( 'Addons', 'ultimate-post' ),
132 'slug' => 'addons'
133 ),
134 array(
135 'name' => esc_html__( 'Blocks', 'ultimate-post' ),
136 'slug' => 'blocks'
137 ),
138 array(
139 'name' => esc_html__( 'Settings', 'ultimate-post' ),
140 'slug' => 'settings'
141 ),
142 array(
143 'name' => esc_html__( 'Tutorials', 'ultimate-post' ),
144 'slug' => 'tutorials'
145 ),
146 );
147 foreach ($menu_lists as $key => $val) {
148 add_submenu_page(
149 'ultp-settings',
150 $val['name'],
151 $val['name'],
152 'manage_options',
153 'ultp-settings#' . $val['slug'],
154 array(__CLASS__, 'render_main')
155 );
156 }
157
158 if (!ultimate_post()->is_lc_active()) {
159 add_submenu_page(
160 'ultp-settings',
161 '',
162 '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . esc_html__( 'Go Pro', 'ultimate-post' ),
163 'manage_options',
164 'go_postx_pro',
165 array(self::class, 'handle_external_redirects')
166 );
167 }
168
169 if (ultimate_post()->get_setting('init_setup') != 'yes') {
170 add_submenu_page(
171 'ultp-settings',
172 esc_html__('Initital Setup', 'ultimate-post'),
173 esc_html__('Initital Setup', 'ultimate-post'),
174 'manage_options',
175 'ultp-initial-setup-wizard',
176 array(__CLASS__, 'initial_setup')
177 );
178 }
179 }
180
181 /**
182 * Initial Plugin Setting
183 *
184 * * @since v.2.4.4
185 * @return STRING
186 */
187 public static function initial_setup() { ?>
188 <div class="ultp-initial-setting-wrap" id="ultp-initial-setting"></div>
189 <?php }
190
191
192 public function handle_external_redirects() {
193 if ( empty( $_GET['page'] ) ) {
194 return;
195 }
196
197 if ( 'go_postx_pro' === $_GET['page'] ) {
198 wp_redirect( ultimate_post()->get_premium_link('', 'dashboard_go_pro'));
199 die();
200 }
201 }
202
203 public static function tab_page_content() {
204 $current = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
205 if ($current) {
206 $pro_active = ultimate_post()->is_lc_active();
207 echo '<div class="ultp-settings-tab-wrap">';
208 if (strtotime('16-4-2023') < strtotime('28-4-2023') && !$pro_active) {
209 echo '<div class="ultp-setting-hellobar"><span class="dashicons dashicons-bell ultp-ring"></span><strong> EID Offer: </strong>Enjoy Up To <b> 50% OFF</b> on PostX Pro! - <a href="'.esc_url(ultimate_post()->get_premium_link( '', 'menu_topbar')).'" target="_blank">'.esc_html__('GET IT NOW!', 'ultimate-post').'</a></div>';
210 } else {
211 if (!$pro_active) {
212 echo '<div class="ultp-setting-hellobar"><span class="dashicons dashicons-bell ultp-ring"></span><strong> New : </strong> PostX Dynamic Site Builder is Live - <a href="'.esc_url(ultimate_post()->get_premium_link( 'https://www.wpxpo.com/postx-dynamic-site-builder/', 'menu_topbar')).'" target="_blank">'.esc_html__('See what’s new', 'ultimate-post').'</a></div>';
213 }
214 }
215
216 echo '<div class="ultp-setting-header">';
217 echo '<div class="ultp-setting-logo">';
218 echo '<img class="ultp-setting-header-img" loading="lazy" src="'.esc_url(ULTP_URL.'assets/img/logo-option.svg').'" alt="'.esc_html__('PostX', 'ultimate-post').'">';
219 echo '<span>v'. esc_html(ULTP_VER).'</span>';
220 echo '</div>';
221 echo '<ul class="ultp-settings-tab">';
222 echo '<li class="current"><a href="#home">'.esc_html__('Getting Started', 'ultimate-post').'</a></li>';
223 if (ultimate_post()->get_setting('ultp_templates') != 'false') {
224 echo '<li><a href="'.esc_url(admin_url( 'edit.php?post_type=ultp_templates' )).'">'.esc_html__('Saved Template', 'ultimate-post').'</a></li>';
225 }
226 if (ultimate_post()->get_setting('ultp_builder') != 'false') {
227 echo '<li><a href="#builder">'.esc_html__('Site Builder', 'ultimate-post').'</a></li>';
228 }
229 echo '<li><a href="#templatekit">'.esc_html__('Template kits', 'ultimate-post').'</a></li>';
230 echo '<li><a href="#addons">'.esc_html__('Addons', 'ultimate-post').'</a></li>';
231 echo '<li><a href="#blocks">'.esc_html__('Blocks', 'ultimate-post').'</a></li>';
232 echo '<li><a href="#settings">'.esc_html__('Settings', 'ultimate-post').'</a></li>';
233 echo '<li><a href="#tutorials">'.esc_html__('Tutorials', 'ultimate-post').'</a></li>';
234 echo '</ul>';
235 echo '</div>';
236 echo '<ul class="ultp-settings-content">';
237 echo '<li class="current" data-tab="#home">';
238 require_once ULTP_PATH . 'classes/options/Getting_Started.php';
239 echo '</li>';
240 echo '<li data-tab="#addons">';
241 require_once ULTP_PATH . 'classes/options/Addons.php';
242 new \ULTP\Option_Addons();
243 echo '</li>';
244 echo '<li data-tab="#blocks">';
245 require_once ULTP_PATH . 'classes/options/Blocks.php';
246 new \ULTP\Option_Blocks();
247 echo '</li>';
248 if (ultimate_post()->get_setting('ultp_builder') != 'false') {
249 echo '<li data-tab="#builder">';
250 echo '<div id="ultp-builder-condition"></div>';
251 echo '</li>';
252 }
253 echo '<li data-tab="#templatekit">';
254 echo '<div id="ultp-dashboard-templatekit"></div>';
255 echo '</li>';
256
257 echo '<li data-tab="#settings">';
258 require_once ULTP_PATH . 'classes/options/Settings.php';
259 $obj = new \ULTP\Option_Settings();
260 $obj->create_admin_page();
261 echo '</li>';
262 echo '<li data-tab="#tutorials">';
263 require_once ULTP_PATH . 'classes/options/Tutorials.php';
264 echo '</li>';
265 echo '<ul>';
266 echo '</div>';
267 }
268 }
269
270 /**
271 * Remove All Notification From Menu Page
272 *
273 * @since v.1.0.0
274 * @return NULL
275 */
276 public static function remove_all_notices() {
277 if ( isset($_GET['page']) ) {
278 $page = sanitize_key($_GET['page']);
279 if ( $page === 'ultp-settings' ||
280 $page === 'ultp-license' ||
281 $page === 'ultp-initial-setup-wizard' ) {
282 remove_all_actions( 'admin_notices' );
283 remove_all_actions( 'all_admin_notices' );
284 }
285 }
286 }
287 }