class-redux-welcome.php
235 lines
| 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 string $minimum_capability = 'manage_options'; |
| 27 | |
| 28 | /** |
| 29 | * Display version. |
| 30 | * |
| 31 | * @var string |
| 32 | */ |
| 33 | public string $display_version = ''; |
| 34 | |
| 35 | /** |
| 36 | * Is loaded. |
| 37 | * |
| 38 | * @var bool |
| 39 | */ |
| 40 | public bool $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 | } |
| 51 | |
| 52 | /** |
| 53 | * Class init. |
| 54 | */ |
| 55 | public function init() { |
| 56 | if ( $this->redux_loaded ) { |
| 57 | return; |
| 58 | } |
| 59 | |
| 60 | $this->redux_loaded = true; |
| 61 | add_action( 'admin_menu', array( $this, 'admin_menus' ) ); |
| 62 | |
| 63 | if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 64 | if ( 'redux-' === substr( sanitize_text_field( wp_unslash( $_GET['page'] ) ), 0, 6 ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 65 | $version = explode( '.', Redux_Core::$version ); |
| 66 | $this->display_version = $version[0] . '.' . $version[1]; |
| 67 | add_filter( 'admin_footer_text', array( $this, 'change_wp_footer' ) ); |
| 68 | add_action( 'admin_head', array( $this, 'admin_head' ) ); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Do Redirect. |
| 75 | */ |
| 76 | public function do_redirect() { |
| 77 | if ( ! defined( 'WP_CLI' ) ) { |
| 78 | wp_safe_redirect( esc_url( admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) ) ) ); |
| 79 | exit(); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Change Footer. |
| 85 | */ |
| 86 | public function change_wp_footer() { |
| 87 | 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' ); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | |
| 92 | /** |
| 93 | * Register the Dashboard Pages which are later hidden but these pages |
| 94 | * are used to render the What's Redux pages. |
| 95 | * |
| 96 | * @access public |
| 97 | * @since 1.4 |
| 98 | * @return void |
| 99 | */ |
| 100 | public function admin_menus() { |
| 101 | $page = 'add_options_page'; |
| 102 | |
| 103 | // About Page. |
| 104 | $page( esc_html__( 'What is Redux Framework?', 'redux-framework' ), esc_html__( 'Redux', 'redux-framework' ), $this->minimum_capability, 'redux-framework', array( $this, 'about_screen' ) ); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Hide Individual Dashboard Pages |
| 109 | * |
| 110 | * @access public |
| 111 | * @since 1.4 |
| 112 | * @return void |
| 113 | */ |
| 114 | public function admin_head() { |
| 115 | ?> |
| 116 | <link |
| 117 | rel='stylesheet' id='elusive-icons' <?php // phpcs:ignore WordPress.WP.EnqueuedResources ?> |
| 118 | href='<?php echo esc_url( Redux_Core::$url ); ?>assets/css/vendor/elusive-icons.css' |
| 119 | type='text/css' media='all'/> |
| 120 | |
| 121 | <link |
| 122 | rel='stylesheet' id='redux-welcome' <?php // phpcs:ignore WordPress.WP.EnqueuedResources ?> |
| 123 | href='<?php echo esc_url( Redux_Core::$url ); ?>inc/welcome/css/redux-welcome.min.css' |
| 124 | type='text/css' media='all'/> |
| 125 | |
| 126 | <style> |
| 127 | .redux-badge:before { |
| 128 | <?php echo is_rtl() ? 'right' : 'left'; ?>: 0; |
| 129 | } |
| 130 | |
| 131 | .about-wrap .redux-badge { |
| 132 | <?php echo is_rtl() ? 'left' : 'right'; ?>: 0; |
| 133 | } |
| 134 | </style> |
| 135 | <?php |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Navigation tabs |
| 140 | * |
| 141 | * @access public |
| 142 | * @since 1.9 |
| 143 | * @return void |
| 144 | */ |
| 145 | public function tabs() { |
| 146 | $selected = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : 'redux-framework'; // phpcs:ignore WordPress.Security.NonceVerification |
| 147 | |
| 148 | ?> |
| 149 | <h2 class="nav-tab-wrapper"> |
| 150 | <a |
| 151 | class="nav-tab <?php echo( 'redux-framework' === $selected ? 'nav-tab-active' : '' ); ?>" |
| 152 | href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'redux-framework' ), 'options-general.php' ) ) ); ?>"> |
| 153 | <?php esc_attr_e( 'What is Redux?', 'redux-framework' ); ?> |
| 154 | </a> |
| 155 | </h2> |
| 156 | <?php |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Render About Screen |
| 161 | * |
| 162 | * @access public |
| 163 | * @since 1.4 |
| 164 | * @return void |
| 165 | */ |
| 166 | public function about_screen() { |
| 167 | // Stupid hack for WordPress alerts and warnings. |
| 168 | echo '<div class="wrap" style="height:0;overflow:hidden;"><h2></h2></div>'; |
| 169 | |
| 170 | require_once 'views/about.php'; |
| 171 | } |
| 172 | |
| 173 | /** |
| 174 | * Action. |
| 175 | */ |
| 176 | public function actions() { |
| 177 | ?> |
| 178 | <p class="redux-actions"> |
| 179 | <a href="https://devs.redux.io/" class="docs button button-primary">Docs</a> |
| 180 | <a |
| 181 | href="https://wordpress.org/support/view/plugin-reviews/redux-framework?filter=5#postform" |
| 182 | class="review-us button button-primary" |
| 183 | target="_blank">Review Us</a> |
| 184 | <a |
| 185 | href="https://twitter.com/share" |
| 186 | class="twitter-share-button" |
| 187 | data-url="https://redux.io" |
| 188 | data-text="Supercharge your WordPress experience with Redux.io, the world's most powerful and widely used WordPress interface builder." |
| 189 | data-via="ReduxFramework" data-size="large" data-hashtags="Redux">Tweet</a> |
| 190 | <?php |
| 191 | |
| 192 | $options = Redux_Helpers::get_plugin_options(); |
| 193 | $nonce = wp_create_nonce( 'redux_framework_demo' ); |
| 194 | |
| 195 | $query_args = array( |
| 196 | 'page' => 'redux-framework', |
| 197 | 'redux-framework-plugin' => 'demo', |
| 198 | 'nonce' => $nonce, |
| 199 | ); |
| 200 | |
| 201 | if ( $options['demo'] ) { |
| 202 | ?> |
| 203 | <a |
| 204 | href="<?php echo esc_url( admin_url( add_query_arg( $query_args, 'options-general.php' ) ) ); ?>" |
| 205 | class=" button-text button-demo"><?php echo esc_html__( 'Disable Panel Demo', 'redux-framework' ); ?></a> |
| 206 | <?php |
| 207 | } else { |
| 208 | ?> |
| 209 | <a |
| 210 | href="<?php echo esc_url( admin_url( add_query_arg( $query_args, 'options-general.php' ) ) ); ?>" |
| 211 | class=" button-text button-demo active"><?php echo esc_html__( 'Enable Panel Demo', 'redux-framework' ); ?></a> |
| 212 | <?php |
| 213 | } |
| 214 | |
| 215 | ?> |
| 216 | <script> |
| 217 | !function( d, s, id ) { |
| 218 | let js; |
| 219 | const fjs = d.getElementsByTagName( s )[0], |
| 220 | |
| 221 | p = /^http:/.test( d.location ) ? 'http' : 'https'; |
| 222 | if ( !d.getElementById( id ) ) { |
| 223 | js = d.createElement( s ); |
| 224 | js.id = id; |
| 225 | js.src = p + '://platform.twitter.com/widgets.js'; |
| 226 | fjs.parentNode.insertBefore( js, fjs ); |
| 227 | } |
| 228 | }( document, 'script', 'twitter-wjs' ); |
| 229 | </script> |
| 230 | </p> |
| 231 | <?php |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 |