PluginProbe
Post Grid Gutenberg Blocks – PostX / 3.2.2
Post Grid Gutenberg Blocks – PostX v3.2.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 3.2.2, at classes/Options.php

203 lines 8.7 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 // add_filter( 'ultp_plugin_notice', array( $this, 'plugin_notice_callback' ) );
29 }
30
31 /**
32 * Dashboard Notice Data
33 *
34 * @since v.3.1.8
35 * @param NULL
36 * @return NULL
37 */
38 public function plugin_notice_callback() {
39 return array(
40 'start' => '12-2-2023', // Date format "d-m-Y" [08-02-2019]
41 'end' => '22-3-2023',
42 'content' => 'Upgrade 30% off Sale!!!'
43 );
44 }
45
46
47 /**
48 * Plugin Page Menu Add
49 *
50 * @since v.1.0.0
51 * @return ARRAY
52 */
53 public function plugin_settings_meta( $links, $file ) {
54 if (strpos( $file, 'ultimate-post.php' ) !== false ) {
55 $new_links = array(
56 'ultp_docs' => '<a href="https://wpxpo.com/docs/" target="_blank">'.esc_html__('Docs', 'ultimate-post').'</a>',
57 'ultp_tutorial' => '<a href="https://www.youtube.com/watch?v=JZxIflYKOuM&list=PLPidnGLSR4qcAwVwIjMo1OVaqXqjUp_s4" target="_blank">'.esc_html__('Tutorials', 'ultimate-post').'</a>',
58 '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>'
59 );
60 $links = array_merge( $links, $new_links );
61 }
62 return $links;
63 }
64
65
66 /**
67 * Settings Pro Update Link
68 *
69 * @since v.1.0.0
70 * @return ARRAY
71 */
72 public function plugin_action_links_callback( $links ) {
73 $upgrade_link = array();
74 $setting_link = array();
75 if ( !defined('ULTP_PRO_VER') ) {
76 $upgrade_link = array(
77 '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>'
78 );
79
80 $notice = apply_filters( 'ultp_plugin_notice', array() );
81
82 if ( count($notice) > 0 ) {
83 $current_time = date('U');
84 if ( $current_time > strtotime($notice['start']) && $current_time < strtotime($notice['end']) ) {
85 $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>';
86 }
87 }
88 }
89 $setting_link['ultp_settings'] = '<a href="'. esc_url(admin_url('admin.php?page=ultp-settings#settings')) .'">'. esc_html__('Settings', 'ultimate-post') .'</a>';
90 return array_merge( $setting_link, $links, $upgrade_link);
91 }
92
93
94 /**
95 * Admin Menu Option Page
96 *
97 * @since v.1.0.0
98 * @return NULL
99 */
100 public static function menu_page_callback() {
101 $ultp_menu_icon = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXll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OS4xN1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMjguMTYsMjQuMTNWNDFhMy4xMywzLjEzLDAsMCwxLTEuMjksMi41NCwzLDMsMCwwLDEtMS40Ny41OGwwLDBIOC4xOUEzLjE1LDMuMTUsMCwwLDEsNSw0MVYyNGEzLjE3LDMuMTcsMCwwLDEsMy4xNS0zSDI1YTMuMTIsMy4xMiwwLDAsMSwxLjE0LjIyLDMuMjQsMy4yNCwwLDAsMSwxLjksMi4xQTMuNjMsMy42MywwLDAsMSwyOC4xNiwyNC4xM1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogIDwvZz4NCjwvc3ZnPg0K';
102 add_menu_page(
103 __( 'PostX', 'ultimate-post' ),
104 __( 'PostX', 'ultimate-post' ),
105 'manage_options',
106 'ultp-settings',
107 array(self::class, 'tab_page_content'),
108 $ultp_menu_icon,
109 58.5
110 );
111
112 add_submenu_page(
113 'ultp-settings',
114 __( 'PostX Dashboard', 'ultimate-post' ),
115 __( 'Getting Started', 'ultimate-post' ),
116 'manage_options',
117 'ultp-settings'
118 );
119
120 $menu_lists = array(
121 'builder' => esc_html__( 'Site Builder', 'ultimate-post' ),
122 'templatekit' => esc_html__( 'Template Kits', 'ultimate-post' ),
123 'saved-templates' => esc_html__( 'Saved Templates', 'ultimate-post' ),
124 'custom-font' => esc_html__( 'Custom Font', 'ultimate-post' ),
125 'addons' => esc_html__( 'Addons', 'ultimate-post' ),
126 'blocks' => esc_html__( 'Blocks', 'ultimate-post' ),
127 'settings' => esc_html__( 'Settings', 'ultimate-post' ),
128 'tutorials' => esc_html__( 'Tutorials', 'ultimate-post' ),
129 'license' => esc_html__( 'License', 'ultimate-post' ),
130 'support' => esc_html__( 'Quick Support', 'ultimate-post' )
131 );
132 foreach ( $menu_lists as $key => $val ) {
133 add_submenu_page(
134 'ultp-settings',
135 $val,
136 $val,
137 'manage_options',
138 'ultp-settings#' . $key,
139 array(__CLASS__, 'render_main')
140 );
141 }
142 add_submenu_page(
143 'ultp-settings',
144 esc_html__( 'Initial Setup', 'ultimate-post' ),
145 esc_html__( 'Initial Setup', 'ultimate-post' ),
146 'manage_options',
147 'ultp-initial-setup-wizard',
148 array(__CLASS__, 'initial_setup')
149 );
150 if ( !ultimate_post()->is_lc_active() ) {
151 add_submenu_page(
152 'ultp-settings',
153 '',
154 '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . esc_html__( 'Upgrade to Pro', 'ultimate-post' ),
155 'manage_options',
156 'go_postx_pro',
157 array(self::class, 'handle_external_redirects')
158 );
159 }
160 }
161
162 public function handle_external_redirects() {
163 if ( empty( $_GET['page'] ) ) {
164 return;
165 }
166 if ( 'go_postx_pro' === $_GET['page'] ) {
167 wp_redirect( ultimate_post()->get_premium_link('', 'dashboard_go_pro'));
168 die();
169 }
170 }
171
172 /**
173 * Initial Plugin Setting
174 *
175 * * @since v.2.4.4
176 * @return STRING
177 */
178 public static function initial_setup() { ?>
179 <div class="ultp-initial-setting-wrap" id="ultp-initial-setting"></div>
180 <?php }
181
182 public static function tab_page_content() {
183 echo '<div id="ultp-dashboard"></div>';
184 }
185
186 /**
187 * Remove All Notification From Menu Page
188 *
189 * @since v.1.0.0
190 * @return NULL
191 */
192 public static function remove_all_notices() {
193 if ( isset($_GET['page']) ) {
194 $page = sanitize_key($_GET['page']);
195 if ( $page === 'ultp-settings' ||
196 $page === 'ultp-license' ||
197 $page === 'ultp-initial-setup-wizard' ) {
198 remove_all_actions( 'admin_notices' );
199 remove_all_actions( 'all_admin_notices' );
200 }
201 }
202 }
203 }