PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.1.34
Post Grid Gutenberg Blocks – PostX v4.1.34
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 4.1.34, at classes/Options.php

240 lines 8.5 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 use ULTP\Includes\Durbin\Xpo;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Options class.
16 */
17 class Options {
18
19 /**
20 * Setup class.
21 *
22 * @since v.1.0.0
23 */
24 public function __construct() {
25 add_action( 'admin_init', array( $this, 'handle_external_redirects' ) );
26 add_action( 'admin_menu', array( $this, 'menu_page_callback' ) );
27 add_action( 'in_admin_header', array( $this, 'remove_all_notices' ) );
28 add_filter( 'plugin_action_links_' . ULTP_BASE, array( $this, 'plugin_action_links_callback' ) );
29 add_filter( 'plugin_row_meta', array( $this, 'plugin_settings_meta' ), 10, 2 );
30 }
31
32
33 /**
34 * Plugin Page Menu Add
35 *
36 * @since v.1.0.0
37 * @return ARRAY
38 */
39 public function plugin_settings_meta( $links, $file ) {
40 if ( strpos( $file, 'ultimate-post.php' ) !== false ) {
41 $new_links = array(
42 'ultp_docs' => '<a href="https://wpxpo.com/docs/" target="_blank">' . esc_html__( 'Docs', 'ultimate-post' ) . '</a>',
43 'ultp_tutorial' => '<a href="https://www.youtube.com/watch?v=JZxIflYKOuM&list=PLPidnGLSR4qcAwVwIjMo1OVaqXqjUp_s4" target="_blank">' . esc_html__( 'Tutorials', 'ultimate-post' ) . '</a>',
44 'ultp_support' => '<a href="' . esc_url(
45 Xpo::generate_utm_link(
46 array(
47 'url' => 'https://www.wpxpo.com/contact/',
48 'utmKey' => 'plugin_dir_support',
49 )
50 )
51 ) . '" target="_blank">' . esc_html__( 'Support', 'ultimate-post' ) . '</a>',
52 );
53 $links = array_merge( $links, $new_links );
54 }
55 return $links;
56 }
57
58
59 /**
60 * Settings Pro Update Link
61 *
62 * @since v.1.0.0
63 * @return ARRAY
64 */
65 public function plugin_action_links_callback( $links ) {
66 $setting_link = array();
67 $setting_link['ultp_options'] = '<a href="' . esc_url( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) . '">' . esc_html__( 'Starter Sites', 'ultimate-post' ) . '</a>';
68 $upgrade_link = array();
69 if ( ! defined( 'ULTP_PRO_VER' ) || Xpo::is_lc_expired() ) {
70 $url = ! defined( 'ULTP_PRO_VER' ) ? Xpo::generate_utm_link(
71 array(
72 'utmKey' => 'plugin_dir_pro',
73 )
74 ) : 'https://account.wpxpo.com/checkout/?edd_license_key=' . Xpo::get_lc_key();
75
76 $text = ! defined( 'ULTP_PRO_VER' ) ? esc_html__( 'Switch to Pro', 'ultimate-post' ) : esc_html__( 'Renew License', 'ultimate-post' );
77 $upgrade_link['ultp_pro'] = '<a style="color: #e83838; font-weight: bold;" target="_blank" href="' . esc_url( $url ) . '">' . $text . '</a>';
78 }
79 return array_merge( $setting_link, $links, $upgrade_link );
80 }
81
82
83 /**
84 * Admin Menu Option Page
85 *
86 * @since v.1.0.0
87 * @return NULL
88 */
89 public static function menu_page_callback() {
90 $ultp_menu_icon = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA0OC4zIj4NCiAgPGRlZnM+DQogICAgPHN0eWxlPg0KICAgICAgLmNscy0xIHsNCiAgICAgICAgZmlsbDogI2E3YWFhZDsNCiAgICAgIH0NCiAgIC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UEzLjE1LDMuMTUsMCwwLDEsNSw0MVYyNGEzLjE3LDMuMTcsMCwwLDEsMy4xNS0zSDI1YTMuMTIsMy4xMiwwLDAsMSwxLjE0LjIyLDMuMjQsMy4yNCwwLDAsMSwxLjksMi4xQTMuNjMsMy42MywwLDAsMSwyOC4xNiwyNC4xM1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogIDwvZz4NCjwvc3ZnPg0K';
91 $menupage_cap = apply_filters( 'ultp_menu_page_capability', 'manage_options' );
92 add_menu_page(
93 __( 'PostX', 'ultimate-post' ),
94 __( 'PostX', 'ultimate-post' ),
95 $menupage_cap,
96 'ultp-settings',
97 array( self::class, 'ultp_dashboard' ),
98 $ultp_menu_icon,
99 58.5
100 );
101
102 add_submenu_page(
103 'ultp-settings',
104 __( 'PostX Dashboard', 'ultimate-post' ),
105 __( 'Getting Started', 'ultimate-post' ),
106 $menupage_cap,
107 'ultp-settings'
108 );
109
110 $menu_lists = array(
111 'builder' => esc_html__( 'Site Builder', 'ultimate-post' ),
112 'startersites' => esc_html__( 'Starter Sites', 'ultimate-post' ),
113 'blocks' => esc_html__( 'Blocks', 'ultimate-post' ),
114 'integrations' => esc_html__( 'Integrations', 'ultimate-post' ),
115 );
116 if ( defined('ULTP_PRO_VER') ) {
117 $menu_lists['license'] = esc_html__( 'License', 'ultimate-post' );
118 }
119
120 foreach ( $menu_lists as $key => $val ) {
121 add_submenu_page(
122 'ultp-settings',
123 $val,
124 $val,
125 $menupage_cap,
126 'ultp-settings#' . $key,
127 array( __CLASS__, 'render_main' )
128 );
129 }
130 add_submenu_page(
131 'ultp-settings',
132 esc_html__( 'Initial Setup', 'ultimate-post' ),
133 esc_html__( 'Initial Setup', 'ultimate-post' ),
134 $menupage_cap,
135 'ultp-setup-wizard',
136 array( __CLASS__, 'ultp_wizard_page' )
137 );
138
139 $pro_link = '';
140 $pro_link_text = '';
141 if ( ! Xpo::is_lc_active() ) {
142 $pro_link = Xpo::generate_utm_link(
143 array(
144 'utmKey' => 'sub_menu',
145 )
146 );
147 $pro_link_text = __( 'Upgrade to Pro', 'ultimate-post' );
148 } elseif ( Xpo::is_lc_expired() ) {
149 $license_key = Xpo::get_lc_key();
150 $pro_link = 'https://account.wpxpo.com/checkout/?edd_license_key=' . $license_key;
151 $pro_link_text = __( 'Renew License', 'ultimate-post' );
152 }
153
154 if ( ! empty( $pro_link ) ) {
155 ob_start();
156 ?>
157 <a href="<?php echo esc_url( $pro_link ); ?>" target="_blank" class="ultp-go-pro">
158 <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
159 <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>
160 </svg>
161 <span><?php echo esc_html( $pro_link_text ); ?></span>
162 </a>
163 <?php
164 $submenu_content = ob_get_clean();
165
166 add_submenu_page(
167 'ultp-settings',
168 '',
169 $submenu_content,
170 'manage_options',
171 'ultp-pro',
172 array( self::class, 'handle_external_redirects' )
173 );
174
175 }
176
177 add_theme_page(
178 __( 'Starter Sites', 'ultimate-post' ),
179 __( 'Starter Sites', 'ultimate-post' ),
180 $menupage_cap,
181 'ultp-startersites',
182 array( self::class, 'handle_external_redirects' )
183 );
184 }
185
186 public function handle_external_redirects() {
187 if ( empty( $_GET['page'] ) ) { // @codingStandardsIgnoreLine
188 return;
189 }
190 $_page = sanitize_key( $_GET['page'] );
191 if ( 'ultp-startersites' === $_page ) { // @codingStandardsIgnoreLine
192 exit( wp_safe_redirect( admin_url( 'admin.php?page=ultp-settings#startersites' ) ) );
193 } else if ( 'go_postx_pro' === $_page ) { // @codingStandardsIgnoreLine
194 wp_redirect(
195 Xpo::generate_utm_link(
196 array(
197 'utmKey' => 'dashboard_go_pro',
198 )
199 )
200 );
201 die();
202 }
203 }
204
205 /**
206 * wizard page
207 *
208 * * @since v.2.4.4
209 *
210 * @return STRING
211 */
212 public static function ultp_wizard_page() {
213 ?>
214 <div class="ultp-wizard-page-wrap" id="ultp-wizard-page"></div>
215 <?php
216 }
217
218 public static function ultp_dashboard() {
219 echo '<div id="ultp-dashboard"></div>';
220 }
221
222 /**
223 * Remove All Notification From Menu Page
224 *
225 * @since v.1.0.0
226 * @return NULL
227 */
228 public static function remove_all_notices() {
229 if ( isset($_GET['page']) ) { // @codingStandardsIgnoreLine
230 $page = sanitize_key($_GET['page']); // @codingStandardsIgnoreLine
231 if ( $page === 'ultp-settings' ||
232 $page === 'ultp-license' ||
233 $page === 'ultp-setup-wizard' ) {
234 remove_all_actions( 'admin_notices' );
235 remove_all_actions( 'all_admin_notices' );
236 }
237 }
238 }
239 }
240