class-redux-welcome.php (9273B)
1 <?php 2 /** 3 * Redux Welcome Class 4 * 5 * @class Redux_Core 6 * @version 4.0.0 7 * @package Redux Framework 8 */ 9 10 if ( ! defined( 'ABSPATH' ) ) { 11 exit; 12 } 13 14 if ( ! class_exists( 'Redux_Welcome', false ) ) { 15 16 /** 17 * Class Redux_Welcome 18 */ 19 class Redux_Welcome { 20 21 /** 22 * Min capacity. 23 * 24 * @var string The capability users should have to view the page 25 */ 26 public $minimum_capability = 'manage_options'; 27 28 /** 29 * Display version. 30 * 31 * @var string 32 */ 33 public $display_version = ''; 34 35 /** 36 * Is loaded. 37 * 38 * @var bool 39 */ 40 public $redux_loaded = false; 41 42 /** 43 * Get things started 44 * 45 * @since 1.4 46 */ 47 public function __construct() { 48 // Load the welcome page even if a Redux panel isn't running. 49 add_action( 'init', array( $this, 'init' ), 999 ); 50 add_action( 'admin_init', array( $this, 'register_options' ) ); 51 } 52 53 /** 54 * Register template option. 55 */ 56 public function register_options() { 57 register_setting( 'redux_templates', 'use_redux_templates' ); 58 register_setting( 'redux_templates', 'use_extendify_templates' ); 59 } 60 61 /** 62 * Class init. 63 */ 64 public function init() { 65 if ( $this->redux_loaded ) { 66 return; 67 } 68 69 $this->redux_loaded = true; 70 add_action( 'admin_menu', array( $this, 'admin_menus' ) ); 71 72 if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification 73 if ( 'redux-' === substr( sanitize_text_field( wp_unslash( $_GET['page'] ) ), 0, 6 ) ) { // phpcs:ignore WordPress.Security.NonceVerification 74 $version = explode( '.', Redux_Core::$version ); 75 $this->display_version = $version[0] . '.' . $version[1]; 76 add_filter( 'admin_footer_text', array( $this, 'change_wp_footer' ) ); 77 add_action( 'admin_head', array( $this, 'admin_head' ) ); 78 } 79 } 80 } 81 82 /** 83 * Do Redirect. 84 */ 85 public function do_redirect() { 86 if ( ! defined( 'WP_CLI' ) ) { 87 wp_safe_redirect( esc_url( admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) ) ) ); 88 exit(); 89 } 90 } 91 92 /** 93 * Change Footer. 94 */ 95 public function change_wp_footer() { 96 echo esc_html__( 'If you like', 'redux-framework' ) . ' <strong>Redux</strong> ' . esc_html__( 'please leave us a', 'redux-framework' ) . ' <a href="https://wordpress.org/support/view/plugin-reviews/redux-framework?filter=5#postform" target="_blank" class="redux-rating-link" data-rated="Thanks :)">★★★★★</a> ' . esc_html__( 'rating. A huge thank you in advance!', 'redux-framework' ); 97 } 98 99 100 101 /** 102 * Register the Dashboard Pages which are later hidden but these pages 103 * are used to render the What's Redux pages. 104 * 105 * @access public 106 * @since 1.4 107 * @return void 108 */ 109 public function admin_menus() { 110 $page = 'add_options_page'; 111 112 // About Page. 113 $page( esc_html__( 'What is Redux Framework?', 'redux-framework' ), esc_html__( 'Redux', 'redux-framework' ), $this->minimum_capability, 'redux-framework', array( $this, 'about_screen' ) ); 114 115 // Templates Page. 116 $page( esc_html__( 'Templates', 'redux-framework' ), esc_html__( 'Templates', 'redux-framework' ), $this->minimum_capability, 'redux-templates', array( $this, 'templates' ) ); 117 118 remove_submenu_page( 'options-general.php', 'redux-templates' ); 119 120 // phpcs:ignore WordPress.NamingConventions.ValidHookName 121 do_action( 'redux/pro/welcome/admin/menu', $page, $this ); 122 } 123 124 /** 125 * Hide Individual Dashboard Pages 126 * 127 * @access public 128 * @since 1.4 129 * @return void 130 */ 131 public function admin_head() { 132 ?> 133 134 <script 135 id="redux-qtip-js" 136 src='<?php echo esc_url( Redux_Core::$url ); ?>assets/js/vendor/qtip/qtip.js'> 137 </script> 138 139 <script 140 id="redux-welcome-admin-js" 141 src='<?php echo esc_url( Redux_Core::$url ); ?>inc/welcome/js/redux-welcome-admin.js'> 142 </script> 143 144 <?php 145 if ( isset( $_GET['page'] ) && 'redux-support' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification 146 ?> 147 <script 148 id="jquery-easing" 149 src='<?php echo esc_url( Redux_Core::$url ); ?>inc/welcome/js/jquery.easing.min.js'> 150 </script> 151 <?php } ?> 152 153 <link 154 rel='stylesheet' id='redux-qtip-css' <?php // phpcs:ignore WordPress.WP.EnqueuedResources ?> 155 href='<?php echo esc_url( Redux_Core::$url ); ?>assets/css/vendor/qtip.css' 156 type='text/css' media='all'/> 157 158 <link 159 rel='stylesheet' id='elusive-icons' <?php // phpcs:ignore WordPress.WP.EnqueuedResources ?> 160 href='<?php echo esc_url( Redux_Core::$url ); ?>assets/css/vendor/elusive-icons.css' 161 type='text/css' media='all'/> 162 163 <link 164 rel='stylesheet' id='redux-welcome-css' <?php // phpcs:ignore WordPress.WP.EnqueuedResources ?> 165 href='<?php echo esc_url( Redux_Core::$url ); ?>inc/welcome/css/redux-welcome.css' 166 type='text/css' media='all'/> 167 168 <style> 169 .redux-badge:before { 170 <?php echo is_rtl() ? 'right' : 'left'; ?>: 0; 171 } 172 173 .about-wrap .redux-badge { 174 <?php echo is_rtl() ? 'left' : 'right'; ?>: 0; 175 } 176 177 .about-wrap .feature-rest div { 178 padding- <?php echo is_rtl() ? 'left' : 'right'; ?>: 100px; 179 } 180 181 .about-wrap .feature-rest div.last-feature { 182 padding- <?php echo is_rtl() ? 'right' : 'left'; ?>: 100px; 183 padding- <?php echo is_rtl() ? 'left' : 'right'; ?>: 0; 184 } 185 186 .about-wrap .feature-rest div.icon:before { 187 margin: <?php echo is_rtl() ? '0 -100px 0 0' : '0 0 0 -100px'; ?>; 188 } 189 </style> 190 <?php 191 } 192 193 /** 194 * Navigation tabs 195 * 196 * @access public 197 * @since 1.9 198 * @return void 199 */ 200 public function tabs() { 201 $selected = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : 'redux-framework'; // phpcs:ignore WordPress.Security.NonceVerification 202 $nonce = wp_create_nonce( 'redux-support-hash' ); 203 204 ?> 205 <input type="hidden" id="redux_support_nonce" value="<?php echo esc_attr( $nonce ); ?>"/> 206 <h2 class="nav-tab-wrapper"> 207 <a 208 class="nav-tab <?php echo( 'redux-framework' === $selected ? 'nav-tab-active' : '' ); ?>" 209 href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) ) ); ?>"> 210 <?php esc_attr_e( 'What is Redux?', 'redux-framework' ); ?> 211 </a> 212 <a 213 class="nav-tab <?php echo( 'redux-templates' === $selected ? 'nav-tab-active' : '' ); ?>" 214 href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-templates' ), 'options-general.php' ) ) ); ?>"> 215 <?php esc_attr_e( 'Templates', 'redux-framework' ); ?> 216 </a> 217 218 <?php // phpcs:ignore WordPress.NamingConventions.ValidHookName ?> 219 <?php do_action( 'redux/pro/welcome/admin/tab', $selected ); ?> 220 221 </h2> 222 <?php 223 } 224 225 /** 226 * Render About Screen 227 * 228 * @access public 229 * @since 1.4 230 * @return void 231 */ 232 public function about_screen() { 233 // Stupid hack for WordPress alerts and warnings. 234 echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; 235 236 require_once 'views/about.php'; 237 } 238 239 /** 240 * Render Templates Screen 241 * 242 * @access public 243 * @since 4.2 244 * @return void 245 */ 246 public function templates() { 247 // Stupid hack for WordPress alerts and warnings. 248 echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; 249 250 require_once 'views/templates.php'; 251 } 252 253 /** 254 * Action. 255 */ 256 public function actions() { 257 ?> 258 <p class="redux-actions"> 259 <a href="http://devs.redux.io/" class="docs button button-primary">Docs</a> 260 <a 261 href="https://wordpress.org/support/view/plugin-reviews/redux-framework?filter=5#postform" 262 class="review-us button button-primary" 263 target="_blank">Review Us</a> 264 <a 265 href="https://twitter.com/share" 266 class="twitter-share-button" 267 data-url="https://redux.io" 268 data-text="Supercharge your WordPress experience with Redux.io, the world's most powerful and widely used WordPress interface builder." 269 data-via="ReduxFramework" data-size="large" data-hashtags="Redux">Tweet</a> 270 <?php 271 $options = Redux_Helpers::get_plugin_options(); 272 $nonce = wp_create_nonce( 'redux_framework_demo' ); 273 274 $query_args = array( 275 'page' => 'redux-framework', 276 'redux-framework-plugin' => 'demo', 277 'nonce' => $nonce, 278 ); 279 280 if ( $options['demo'] ) { 281 ?> 282 <a 283 href="<?php echo esc_url( admin_url( add_query_arg( $query_args, 'options-general.php' ) ) ); ?>" 284 class=" button-text button-demo"><?php echo esc_html__( 'Disable Panel Demo', 'redux-framework' ); ?></a> 285 <?php 286 } else { 287 ?> 288 <a 289 href="<?php echo esc_url( admin_url( add_query_arg( $query_args, 'options-general.php' ) ) ); ?>" 290 class=" button-text button-demo active"><?php echo esc_html__( 'Enable Panel Demo', 'redux-framework' ); ?></a> 291 <?php 292 } 293 294 ?> 295 <script> 296 !function( d, s, id ) { 297 var js, fjs = d.getElementsByTagName( s )[0], 298 p = /^http:/.test( d.location ) ? 'http' : 'https'; 299 if ( !d.getElementById( id ) ) { 300 js = d.createElement( s ); 301 js.id = id; 302 js.src = p + '://platform.twitter.com/widgets.js'; 303 fjs.parentNode.insertBefore( js, fjs ); 304 } 305 }( document, 'script', 'twitter-wjs' ); 306 </script> 307 </p> 308 <?php 309 } 310 } 311 }