PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.8.7
Post Grid Gutenberg Blocks – PostX v2.8.7
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.8.7, at classes/Options.php

281 lines 12.9 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/', 'postx_plugins_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('', 'postx_plugins_pro')).'" target="_blank"><span style="color: #e83838; font-weight: bold;">'.esc_html__('Go Pro', 'ultimate-post').'</span></a>'
62 );
63 }
64 $setting_link['ultp_settings'] = '<a href="'. esc_url(admin_url('admin.php?page=ultp-settings#settings')) .'">'. esc_html__('Settings', 'wp-megamenu') .'</a>';
65 return array_merge( $setting_link, $links, $upgrade_link);
66 }
67
68
69 /**
70 * Admin Menu Option Page
71 *
72 * @since v.1.0.0
73 * @return NULL
74 */
75 public static function menu_page_callback() {
76
77 $ultp_menu_icon = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA0OC4zIj4NCiAgPGRlZnM+DQogICAgPHN0eWxlPg0KICAgICAgLmNscy0xIHsNCiAgICAgICAgZmlsbDogI2E3YWFhZDsNCiAgICAgIH0NCiAgICA8L3N0eWxlPg0KICA8L2RlZnM+DQogIDx0aXRsZT5Qb3N0eCBJY29uIGNtcHJzc2QgU1ZHPC90aXRsZT4NCiAgPGc+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTguODEsOXY4LjlIOC4xOUE2LjE5LDYuMTksMCwwLDAsMiwyMy43N2EzLjE2LDMuMTYsMCwwLDEtMi0yLjk0VjRBMy4xNiwzLjE2LDAsMCwxLDMuMTUuODVIMjBhMy4xOCwzLjE4LDAsM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 'ultimate-post' ),
80 esc_html__( 'PostX', 'ultimate-post' ),
81 'manage_options',
82 'ultp-settings',
83 array(self::class, 'tab_page_content'),
84 $ultp_menu_icon,
85 58.5
86 );
87
88 add_submenu_page(
89 'ultp-settings',
90 esc_html__( 'Getting Started', 'ultimate-post' ),
91 esc_html__( 'Getting Started', 'ultimate-post' ),
92 'manage_options',
93 'ultp-settings'
94 );
95
96 if (ultimate_post()->get_setting('ultp_templates') == 'true') {
97 add_submenu_page(
98 'ultp-settings',
99 esc_html__( 'Saved Templates', 'ultimate-post' ),
100 esc_html__( 'Saved Templates', 'ultimate-post' ),
101 'manage_options',
102 'edit.php?post_type=ultp_templates',
103 ''
104 );
105 }
106
107 if (ultimate_post()->get_setting('ultp_builder') == 'true') {
108 add_submenu_page(
109 'ultp-settings',
110 esc_html__( 'Site Builder', 'ultimate-post' ),
111 esc_html__( 'Site Builder', 'ultimate-post' ),
112 'manage_options',
113 'admin.php?page=ultp-settings#builder',
114 ''
115 );
116 }
117
118 $menu_lists = array(
119 array(
120 'name' => esc_html__( 'Template Kits', 'ultimate-post' ),
121 'slug' => 'templatekit'
122 ),
123 array(
124 'name' => esc_html__( 'Addons', 'ultimate-post' ),
125 'slug' => 'addons'
126 ),
127 array(
128 'name' => esc_html__( 'Blocks', 'ultimate-post' ),
129 'slug' => 'blocks'
130 ),
131 array(
132 'name' => esc_html__( 'Settings', 'ultimate-post' ),
133 'slug' => 'settings'
134 ),
135 array(
136 'name' => esc_html__( 'Tutorials', 'ultimate-post' ),
137 'slug' => 'tutorials'
138 ),
139 );
140 foreach ($menu_lists as $key => $val) {
141 add_submenu_page(
142 'ultp-settings',
143 $val['name'],
144 $val['name'],
145 'manage_options',
146 'ultp-settings#' . $val['slug'],
147 array(__CLASS__, 'render_main')
148 );
149 }
150
151 if (!ultimate_post()->is_lc_active()) {
152 add_submenu_page(
153 'ultp-settings',
154 '',
155 '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . esc_html__( 'Go Pro', 'ultimate-post' ),
156 'manage_options',
157 'go_postx_pro',
158 array(self::class, 'handle_external_redirects')
159 );
160 }
161
162 if (ultimate_post()->get_setting('init_setup') != 'yes') {
163 add_submenu_page(
164 'ultp-settings',
165 esc_html__('Initital Setup', 'ultimate-post'),
166 esc_html__('Initital Setup', 'ultimate-post'),
167 'manage_options',
168 'ultp-initial-setup-wizard',
169 array(__CLASS__, 'initial_setup')
170 );
171 }
172 }
173
174 /**
175 * Initial Plugin Setting
176 *
177 * * @since v.2.4.4
178 * @return STRING
179 */
180 public static function initial_setup() { ?>
181 <div class="ultp-initial-setting-wrap" id="ultp-initial-setting"></div>
182 <?php }
183
184
185 public function handle_external_redirects() {
186 if ( empty( $_GET['page'] ) ) {
187 return;
188 }
189
190 if ( 'go_postx_pro' === $_GET['page'] ) {
191 wp_redirect( esc_url(ultimate_post()->get_premium_link('', 'postx_dashboard_menu')) );
192 die();
193 }
194 }
195
196 public static function tab_page_content() {
197 $current = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
198 if ($current) {
199 $pro_active = ultimate_post()->is_lc_active();
200 echo '<div class="ultp-settings-tab-wrap">';
201
202 if (date('U') < strtotime('18-2-2023')) {
203 echo '<div class="ultp-setting-hellobar"><span class="dashicons dashicons-bell ultp-ring"></span><strong> Offer: </strong> Enjoy a flat <b>30% off</b> with the coupon code <b>POSTX30K</b> to celebrate our 30,000+ active installs! - <a href="'.esc_url(ultimate_post()->get_premium_link( 'https://www.wpxpo.com/postx/pricing/', 'dashboard-topbar')).'" target="_blank">'.esc_html__('Grab Your Discount Now!', 'ultimate-post').'</a></div>';
204 } else {
205 if (!$pro_active) {
206 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/', 'dashboard-topbar')).'" target="_blank">'.esc_html__('See what’s new', 'ultimate-post').'</a></div>';
207 }
208 }
209
210 echo '<div class="ultp-setting-header">';
211 echo '<div class="ultp-setting-logo">';
212 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').'">';
213 echo '<span>v'. esc_html(ULTP_VER).'</span>';
214 echo '</div>';
215 echo '<ul class="ultp-settings-tab">';
216 echo '<li class="current"><a href="#home">'.esc_html__('Getting Started', 'ultimate-post').'</a></li>';
217 if (ultimate_post()->get_setting('ultp_templates') != 'false') {
218 echo '<li><a href="'.esc_url(admin_url( 'edit.php?post_type=ultp_templates' )).'">'.esc_html__('Saved Template', 'ultimate-post').'</a></li>';
219 }
220 if (ultimate_post()->get_setting('ultp_builder') != 'false') {
221 echo '<li><a href="#builder">'.esc_html__('Site Builder', 'ultimate-post').'</a></li>';
222 }
223 echo '<li><a href="#templatekit">'.esc_html__('Template kits', 'ultimate-post').'</a></li>';
224 echo '<li><a href="#addons">'.esc_html__('Addons', 'ultimate-post').'</a></li>';
225 echo '<li><a href="#blocks">'.esc_html__('Blocks', 'ultimate-post').'</a></li>';
226 echo '<li><a href="#settings">'.esc_html__('Settings', 'ultimate-post').'</a></li>';
227 echo '<li><a href="#tutorials">'.esc_html__('Tutorials', 'ultimate-post').'</a></li>';
228 echo '</ul>';
229 echo '</div>';
230 echo '<ul class="ultp-settings-content">';
231 echo '<li class="current" data-tab="#home">';
232 require_once ULTP_PATH . 'classes/options/Getting_Started.php';
233 echo '</li>';
234 echo '<li data-tab="#addons">';
235 require_once ULTP_PATH . 'classes/options/Addons.php';
236 new \ULTP\Option_Addons();
237 echo '</li>';
238 echo '<li data-tab="#blocks">';
239 require_once ULTP_PATH . 'classes/options/Blocks.php';
240 new \ULTP\Option_Blocks();
241 echo '</li>';
242 if (ultimate_post()->get_setting('ultp_builder') != 'false') {
243 echo '<li data-tab="#builder">';
244 echo '<div id="ultp-builder-condition"></div>';
245 echo '</li>';
246 }
247 echo '<li data-tab="#templatekit">';
248 echo '<div id="ultp-dashboard-templatekit"></div>';
249 echo '</li>';
250
251 echo '<li data-tab="#settings">';
252 require_once ULTP_PATH . 'classes/options/Settings.php';
253 $obj = new \ULTP\Option_Settings();
254 $obj->create_admin_page();
255 echo '</li>';
256 echo '<li data-tab="#tutorials">';
257 require_once ULTP_PATH . 'classes/options/Tutorials.php';
258 echo '</li>';
259 echo '<ul>';
260 echo '</div>';
261 }
262 }
263
264 /**
265 * Remove All Notification From Menu Page
266 *
267 * @since v.1.0.0
268 * @return NULL
269 */
270 public static function remove_all_notices() {
271 if ( isset($_GET['page']) ) {
272 $page = sanitize_key($_GET['page']);
273 if ( $page === 'ultp-settings' ||
274 $page === 'ultp-license' ||
275 $page === 'ultp-initial-setup-wizard' ) {
276 remove_all_actions( 'admin_notices' );
277 remove_all_actions( 'all_admin_notices' );
278 }
279 }
280 }
281 }