| @@ -1,26 +1,46 @@ | ||
| 1 | 1 | <?php |
| 2 | +/** | |
| 3 | + * Options Action. | |
| 4 | + * | |
| 5 | + * @package ULTP\Notice | |
| 6 | + * @since v.1.0.0 | |
| 7 | + */ | |
| 2 | 8 | namespace ULTP; |
| 3 | 9 | |
| 4 | 10 | defined('ABSPATH') || exit; |
| 5 | 11 | |
| 12 | +/** | |
| 13 | + * Options class. | |
| 14 | + */ | |
| 6 | 15 | class Options{ |
| 16 | + | |
| 17 | + /** | |
| 18 | + * Setup class. | |
| 19 | + * | |
| 20 | + * @since v.1.0.0 | |
| 21 | + */ | |
| 7 | 22 | public function __construct() { |
| 23 | + add_action( 'admin_init', array( $this, 'handle_external_redirects' ) ); | |
| 8 | 24 | add_action( 'admin_menu', array( $this, 'menu_page_callback' ) ); |
| 9 | - add_action( 'admin_init', array( $this, 'register_settings' ) ); | |
| 10 | 25 | add_action( 'in_admin_header', array($this, 'remove_all_notices') ); |
| 11 | - | |
| 12 | 26 | add_filter( 'plugin_row_meta', array( $this, 'plugin_settings_meta' ), 10, 2 ); |
| 13 | 27 | add_filter( 'plugin_action_links_'.ULTP_BASE, array( $this, 'plugin_action_links_callback' ) ); |
| 14 | 28 | } |
| 15 | - | |
| 16 | - | |
| 29 | + | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Plugin Page Menu Add | |
| 33 | + * | |
| 34 | + * @since v.1.0.0 | |
| 35 | + * @return ARRAY | |
| 36 | + */ | |
| 17 | 37 | public function plugin_settings_meta( $links, $file ) { |
| 18 | - if ( strpos( $file, 'ultimate-post.php' ) !== false ) { | |
| 38 | + if (strpos( $file, 'ultimate-post.php' ) !== false ) { | |
| 19 | 39 | $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>' | |
| 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>' | |
| 23 | 43 | ); |
| 24 | 44 | $links = array_merge( $links, $new_links ); |
| 25 | 45 | } |
| 26 | 46 | return $links; |
| @@ -26,61 +46,208 @@ | ||
| 26 | 46 | return $links; |
| 27 | 47 | } |
| 28 | 48 | |
| 29 | 49 | |
| 30 | - public function plugin_action_links_callback ( $links ) { | |
| 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 ) { | |
| 31 | 57 | $upgrade_link = array(); |
| 32 | 58 | $setting_link = array(); |
| 33 | - if(!defined('ULTP_PRO_VER')){ | |
| 59 | + if (!defined('ULTP_PRO_VER')) { | |
| 34 | 60 | $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>' | |
| 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>' | |
| 36 | 62 | ); |
| 37 | 63 | } |
| 38 | - $setting_link['ultp_settings'] = '<a href="'. menu_page_url('ultp-option-settings', false) .'">'. __('Settings', 'wp-megamenu') .'</a>'; | |
| 64 | + $setting_link['ultp_settings'] = '<a href="'. esc_url(admin_url('admin.php?page=ultp-settings#settings')) .'">'. esc_html__('Settings', 'wp-megamenu') .'</a>'; | |
| 39 | 65 | return array_merge( $setting_link, $links, $upgrade_link); |
| 40 | 66 | } |
| 41 | 67 | |
| 42 | 68 | |
| 69 | + /** | |
| 70 | + * Admin Menu Option Page | |
| 71 | + * | |
| 72 | + * @since v.1.0.0 | |
| 73 | + * @return NULL | |
| 74 | + */ | |
| 43 | 75 | public static function menu_page_callback() { |
| 76 | + | |
| 77 | + $ultp_menu_icon = 'data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMSIgZGF0YS1uYW1lPSJMYXllciAxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1MCA0OC4zIj4NCiAgPGRlZnM+DQogICAgPHN0eWxlPg0KICAgICAgLmNscy0xIHsNCiAgICAgICAgZmlsbDogI2E3YWFhZDsNCiAgICAgIH0NCiAgICA8L3N0eWxlPg0KICA8L2RlZnM+DQogIDx0aXRsZT5Qb3N0eCBJY29uIGNtcHJzc2QgU1ZHPC90aXRsZT4NCiAgPGc+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTguODEsOXY4LjlIOC4xOUE2LjE5LDYuMTksMCwwLDAsMiwyMy43N2EzLjE2LDMuMTYsMCwwLDEtMi0yLjk0VjRBMy4xNiwzLjE2LDAsMCwxLDMuMTUuODVIMjBhMy4xOCwzLjE4LDAsMCwxLDMsMi4zMUE2LjIxLDYuMjEsMCwwLDAsMTguODEsOVoiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDUsOVYyM0gzMS4xYTYuMjMsNi4yMywwLDAsMC00LjkzLTQuOTNBNS41NCw1LjU0LDAsMCwwLDI1LDE3Ljk0SDIxLjg1VjlBMy4xNSwzLjE1LDAsMCwxLDIzLjEzLDYuNWEzLjEyLDMuMTIsMCwwLDEsMS40My0uNThsLjA5LDBINDEuODNBMy4xNCwzLjE0LDAsMCwxLDQ1LDlaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwIC0wLjg1KSIvPg0KICAgIDxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTUwLDI5LjE3VjQ2YTMuMTYsMy4xNiwwLDAsMS0zLjE1LDMuMTVIMzBhMy4xOCwzLjE4LDAsMCwxLTMtMi4zMUE2LjIyLDYuMjIsMCwwLDAsMzEuMjEsNDFWMjZINDYuODVhMy4zLDMuMywwLDAsMSwxLjE0LjIxQTMuMTYsMy4xNiwwLDAsMSw1MCwyOS4xN1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogICAgPHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMjguMTYsMjQuMTNWNDFhMy4xMywzLjEzLDAsMCwxLTEuMjksMi41NCwzLDMsMCwwLDEtMS40Ny41OGwwLDBIOC4xOUEzLjE1LDMuMTUsMCwwLDEsNSw0MVYyNGEzLjE3LDMuMTcsMCwwLDEsMy4xNS0zSDI1YTMuMTIsMy4xMiwwLDAsMSwxLjE0LjIyLDMuMjQsMy4yNCwwLDAsMSwxLjksMi4xQTMuNjMsMy42MywwLDAsMSwyOC4xNiwyNC4xM1oiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTAuODUpIi8+DQogIDwvZz4NCjwvc3ZnPg0K'; | |
| 44 | 78 | add_menu_page( |
| 45 | - esc_html__( 'Post Blocks', 'ultimate-post' ), | |
| 46 | - esc_html__( 'Post Blocks', 'ultimate-post' ), | |
| 79 | + esc_html__( 'PostX', 'ultimate-post' ), | |
| 80 | + esc_html__( 'PostX', 'ultimate-post' ), | |
| 47 | 81 | 'manage_options', |
| 48 | 82 | 'ultp-settings', |
| 49 | - '', | |
| 50 | - ULTP_URL.'assets/img/menu-panel.svg' | |
| 83 | + array(self::class, 'tab_page_content'), | |
| 84 | + $ultp_menu_icon, | |
| 85 | + 58.5 | |
| 51 | 86 | ); |
| 52 | 87 | |
| 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(); | |
| 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 | + ); | |
| 63 | 95 | |
| 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 ); | |
| 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 | + ); | |
| 68 | 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 | + } | |
| 69 | 161 | } |
| 70 | 162 | |
| 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' ); | |
| 163 | + | |
| 164 | + public function handle_external_redirects() { | |
| 165 | + if ( empty( $_GET['page'] ) ) { | |
| 166 | + return; | |
| 76 | 167 | } |
| 168 | + | |
| 169 | + if ( 'go_postx_pro' === $_GET['page'] ) { | |
| 170 | + wp_redirect( esc_url(ultimate_post()->get_premium_link('', 'postx_dashboard_menu')) ); | |
| 171 | + die(); | |
| 172 | + } | |
| 77 | 173 | } |
| 78 | 174 | |
| 175 | + public static function tab_page_content() { | |
| 176 | + $current = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; | |
| 177 | + if ($current) { | |
| 178 | + $pro_active = ultimate_post()->is_lc_active(); | |
| 179 | + echo '<div class="ultp-settings-tab-wrap">'; | |
| 180 | + if (!$pro_active) { | |
| 181 | + 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>'; | |
| 182 | + } | |
| 183 | + echo '<div class="ultp-setting-header">'; | |
| 184 | + echo '<div class="ultp-setting-logo">'; | |
| 185 | + 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').'">'; | |
| 186 | + echo '<span>v'. esc_html(ULTP_VER).'</span>'; | |
| 187 | + echo '</div>'; | |
| 188 | + echo '<ul class="ultp-settings-tab">'; | |
| 189 | + echo '<li class="current"><a href="#home">'.esc_html__('Getting Started', 'ultimate-post').'</a></li>'; | |
| 190 | + if (ultimate_post()->get_setting('ultp_templates') != 'false') { | |
| 191 | + echo '<li><a href="'.esc_url(admin_url( 'edit.php?post_type=ultp_templates' )).'">'.esc_html__('Saved Template', 'ultimate-post').'</a></li>'; | |
| 192 | + } | |
| 193 | + if (ultimate_post()->get_setting('ultp_builder') != 'false') { | |
| 194 | + echo '<li><a href="#builder">'.esc_html__('Site Builder', 'ultimate-post').'</a></li>'; | |
| 195 | + } | |
| 196 | + echo '<li><a href="#templatekit">'.esc_html__('Template kits', 'ultimate-post').'</a></li>'; | |
| 197 | + echo '<li><a href="#addons">'.esc_html__('Addons', 'ultimate-post').'</a></li>'; | |
| 198 | + echo '<li><a href="#blocks">'.esc_html__('Blocks', 'ultimate-post').'</a></li>'; | |
| 199 | + echo '<li><a href="#settings">'.esc_html__('Settings', 'ultimate-post').'</a></li>'; | |
| 200 | + echo '<li><a href="#tutorials">'.esc_html__('Tutorials', 'ultimate-post').'</a></li>'; | |
| 201 | + echo '</ul>'; | |
| 202 | + echo '</div>'; | |
| 203 | + echo '<ul class="ultp-settings-content">'; | |
| 204 | + echo '<li class="current" data-tab="#home">'; | |
| 205 | + require_once ULTP_PATH . 'classes/options/Getting_Started.php'; | |
| 206 | + echo '</li>'; | |
| 207 | + echo '<li data-tab="#addons">'; | |
| 208 | + require_once ULTP_PATH . 'classes/options/Addons.php'; | |
| 209 | + new \ULTP\Option_Addons(); | |
| 210 | + echo '</li>'; | |
| 211 | + echo '<li data-tab="#blocks">'; | |
| 212 | + require_once ULTP_PATH . 'classes/options/Blocks.php'; | |
| 213 | + new \ULTP\Option_Blocks(); | |
| 214 | + echo '</li>'; | |
| 215 | + if (ultimate_post()->get_setting('ultp_builder') != 'false') { | |
| 216 | + echo '<li data-tab="#builder">'; | |
| 217 | + echo '<div id="ultp-builder-condition"></div>'; | |
| 218 | + echo '</li>'; | |
| 219 | + } | |
| 220 | + echo '<li data-tab="#templatekit">'; | |
| 221 | + echo '<div id="ultp-dashboard-templatekit"></div>'; | |
| 222 | + echo '</li>'; | |
| 223 | + | |
| 224 | + echo '<li data-tab="#settings">'; | |
| 225 | + require_once ULTP_PATH . 'classes/options/Settings.php'; | |
| 226 | + $obj = new \ULTP\Option_Settings(); | |
| 227 | + $obj->create_admin_page(); | |
| 228 | + echo '</li>'; | |
| 229 | + echo '<li data-tab="#tutorials">'; | |
| 230 | + require_once ULTP_PATH . 'classes/options/Tutorials.php'; | |
| 231 | + echo '</li>'; | |
| 232 | + echo '<ul>'; | |
| 233 | + echo '</div>'; | |
| 234 | + } | |
| 235 | + } | |
| 236 | + | |
| 79 | 237 | /** |
| 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' ) ); | |
| 238 | + * Remove All Notification From Menu Page | |
| 239 | + * | |
| 240 | + * @since v.1.0.0 | |
| 241 | + * @return NULL | |
| 242 | + */ | |
| 243 | + public static function remove_all_notices() { | |
| 244 | + if ( isset($_GET['page']) ) { | |
| 245 | + $page = sanitize_key($_GET['page']); | |
| 246 | + if ( $page === 'ultp-settings' || | |
| 247 | + $page === 'ultp-license' ) { | |
| 248 | + remove_all_actions( 'admin_notices' ); | |
| 249 | + remove_all_actions( 'all_admin_notices' ); | |
| 250 | + } | |
| 251 | + } | |
| 84 | 252 | } |
| 85 | -} | |
| 86 | - | |
| 253 | +} | |