| 1 |
<?php |
| 2 |
// Exit if accessed directly |
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
/** |
| 7 |
* Welcome page class. |
| 8 |
* |
| 9 |
* This page is shown when the plugin is activated. |
| 10 |
* |
| 11 |
*/ |
| 12 |
class PieRegister_Welcome extends PieReg_Base { |
| 13 |
|
| 14 |
/** |
| 15 |
* Hidden welcome page slug. |
| 16 |
* |
| 17 |
*/ |
| 18 |
const SLUG = 'pieregister-getting-started'; |
| 19 |
|
| 20 |
/** |
| 21 |
* Primary class constructor. |
| 22 |
* |
| 23 |
*/ |
| 24 |
public function __construct() { |
| 25 |
|
| 26 |
add_action( 'plugins_loaded', array( $this, 'hooks' ) ); |
| 27 |
|
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* Register all WP hooks. |
| 32 |
* |
| 33 |
*/ |
| 34 |
public function hooks() { |
| 35 |
|
| 36 |
// If user is in admin ajax or doing cron, return. |
| 37 |
if ( wp_doing_ajax() || wp_doing_cron() ) { |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
// If user cannot manage_options, return. |
| 42 |
if ( !current_user_can('piereg_manage_cap') ) { |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
add_action( 'admin_menu', array( $this, 'register' ) ); |
| 47 |
add_action( 'admin_head', array( $this, 'hide_menu' ) ); |
| 48 |
add_action( 'admin_init', array( $this, 'redirect' ), 9999 ); |
| 49 |
add_action( 'admin_init', array( $this, 'piereg_welcome' ) ); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Register the pages to be used for the Welcome screen (and tabs). |
| 54 |
* |
| 55 |
* These pages will be removed from the Dashboard menu, so they will |
| 56 |
* not actually show. Sneaky, sneaky. |
| 57 |
* |
| 58 |
*/ |
| 59 |
public function register() { |
| 60 |
|
| 61 |
// Getting started - shows after installation. |
| 62 |
add_dashboard_page( |
| 63 |
esc_html__( 'Welcome to PieRegister', 'pie-register' ), |
| 64 |
esc_html__( 'Welcome to PieRegister', 'pie-register' ), |
| 65 |
apply_filters( 'pieregister_welcome_cap', 'piereg_manage_cap' ), |
| 66 |
self::SLUG, |
| 67 |
array( $this, 'output' ) |
| 68 |
); |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* Removed the dashboard pages from the admin menu. |
| 73 |
* |
| 74 |
* This means the pages are still available to us, but hidden. |
| 75 |
* |
| 76 |
*/ |
| 77 |
public function hide_menu() { |
| 78 |
remove_submenu_page( 'index.php', self::SLUG ); |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Welcome screen redirect. |
| 83 |
* |
| 84 |
* This function checks if a new install or update has just occurred. If so, |
| 85 |
* then we redirect the user to the appropriate page. |
| 86 |
* |
| 87 |
*/ |
| 88 |
public function redirect() { |
| 89 |
|
| 90 |
// Check if we should consider redirection. |
| 91 |
if ( ! get_transient( 'pieregister_activation_redirect' ) ) { |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
// If we are redirecting, clear the transient so it only happens once. |
| 96 |
delete_transient( 'pieregister_activation_redirect' ); |
| 97 |
|
| 98 |
// Check option to disable welcome redirect. |
| 99 |
if ( get_option( 'pieregister_activation_redirect', false ) ) { |
| 100 |
return; |
| 101 |
} |
| 102 |
|
| 103 |
wp_safe_redirect( admin_url( 'index.php?page=' . self::SLUG ) ); |
| 104 |
exit; |
| 105 |
} |
| 106 |
|
| 107 |
/** |
| 108 |
* Enqueue CSS for activation page. |
| 109 |
* |
| 110 |
*/ |
| 111 |
function piereg_welcome() |
| 112 |
{ |
| 113 |
wp_enqueue_style('pie_welcome_css'); |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Getting Started screen. Shows after first install. |
| 118 |
* |
| 119 |
*/ |
| 120 |
public function output() { |
| 121 |
?> |
| 122 |
|
| 123 |
<div id="pieregister-welcome"> |
| 124 |
<div class="container"> |
| 125 |
<div class="intro"> |
| 126 |
<div class="pie-register-logo"> |
| 127 |
<img src="<?php echo esc_url( plugins_url("assets/images/pie-register-logo.png",dirname(__FILE__)) ); ?>" alt="<?php esc_attr_e( 'Pie Register Logo', 'pie-register' ); ?>"> |
| 128 |
</div> |
| 129 |
<div class="block"> |
| 130 |
<h6 class="welcome-msg"><?php esc_html_e( 'How to create and use your first registration form', 'pie-register' ); ?></h6> |
| 131 |
</div> |
| 132 |
<div class="block"> |
| 133 |
<div class="welcome-pr-video"> |
| 134 |
<iframe width="833" height="441" src="https://www.youtube.com/embed/Gz-AOxZxHGQ?rel=0" title="How to create your first registration form" frameborder="0" rel="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
<div class="block block-white get-started-btns"> |
| 138 |
<div class="button-wrap pieregister-clear"> |
| 139 |
<div class="left"> |
| 140 |
<a href="<?php echo esc_url( admin_url( 'admin.php?page=pie-register' ) ); ?>" class="pieregister-btn pieregister-btn-block pieregister-btn-lg pieregister-btn-red"> |
| 141 |
<?php esc_html_e( 'Get Started', 'pie-register' ); ?> |
| 142 |
</a> |
| 143 |
</div> |
| 144 |
<div class="left"> |
| 145 |
<a href="https://pieregister.com/documentation/" |
| 146 |
class="pieregister-btn pieregister-btn-block pieregister-btn-lg pieregister-btn-white" target="_blank" rel="noopener noreferrer"> |
| 147 |
<?php esc_html_e( 'Read the Full Guide', 'pie-register' ); ?> |
| 148 |
</a> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
</div> |
| 152 |
</div><!-- /.intro --> |
| 153 |
|
| 154 |
<div class="features"> |
| 155 |
<div class="block-features"> |
| 156 |
<h1><?php esc_html_e( 'Frequently Used Features', 'pie-register' ); ?></h1> |
| 157 |
<div class="feature-list"> |
| 158 |
<a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=pie-notifications')) ?>" target="_blank"> |
| 159 |
<div class="feature-block first"> |
| 160 |
<div class="feature-block-icon"> |
| 161 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/email-notifications.png",dirname(__FILE__)) ); ?>"> |
| 162 |
</div> |
| 163 |
<div class="feature-block-content"> |
| 164 |
<h5><?php esc_html_e( 'Set Email Notifications', 'pie-register' ); ?></h5> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
</a> |
| 168 |
|
| 169 |
<a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=pie-invitation-codes')) ?>" target="_blank"> |
| 170 |
<div class="feature-block last"> |
| 171 |
<div class="feature-block-icon"> |
| 172 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/invitation-codes.png",dirname(__FILE__)) ); ?>"> |
| 173 |
</div> |
| 174 |
<div class="feature-block-content"> |
| 175 |
<h5><?php esc_html_e( 'Generate Invitation Codes', 'pie-register' ); ?></h5> |
| 176 |
</div> |
| 177 |
</div> |
| 178 |
</a> |
| 179 |
|
| 180 |
<a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=pie-gateway-settings')) ?>" target="_blank"> |
| 181 |
<div class="feature-block first"> |
| 182 |
<div class="feature-block-icon"> |
| 183 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/payment-methods.png",dirname(__FILE__)) ); ?>"> |
| 184 |
</div> |
| 185 |
<div class="feature-block-content"> |
| 186 |
<h5><?php esc_html_e( 'Setup Payment Methods', 'pie-register' ); ?></h5> |
| 187 |
</div> |
| 188 |
</div> |
| 189 |
</a> |
| 190 |
|
| 191 |
<a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=pie-user-roles-custom')) ?>" target="_blank"> |
| 192 |
<div class="feature-block last"> |
| 193 |
<div class="feature-block-icon"> |
| 194 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/user-roles.png",dirname(__FILE__)) ); ?>"> |
| 195 |
</div> |
| 196 |
<div class="feature-block-content"> |
| 197 |
<h5><?php esc_html_e( 'Create User Roles', 'pie-register' ); ?></h5> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
</a> |
| 201 |
|
| 202 |
<a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=pie-black-listed-users')) ?>" target="_blank"> |
| 203 |
<div class="feature-block first"> |
| 204 |
<div class="feature-block-icon"> |
| 205 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/control-users.png",dirname(__FILE__)) ); ?>"> |
| 206 |
</div> |
| 207 |
<div class="feature-block-content"> |
| 208 |
<h5><?php esc_html_e( 'Control Users', 'pie-register' ); ?></h5> |
| 209 |
</div> |
| 210 |
</div> |
| 211 |
</a> |
| 212 |
|
| 213 |
<a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=pie-settings&tab=security')) ?>" target="_blank"> |
| 214 |
<div class="feature-block last"> |
| 215 |
<div class="feature-block-icon"> |
| 216 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/update-security.png",dirname(__FILE__)) ); ?>"> |
| 217 |
</div> |
| 218 |
<div class="feature-block-content"> |
| 219 |
<h5><?php esc_html_e( 'Update Security', 'pie-register' ); ?></h5> |
| 220 |
</div> |
| 221 |
</div> |
| 222 |
</a> |
| 223 |
</div> |
| 224 |
</div> |
| 225 |
</div><!-- /.features --> |
| 226 |
|
| 227 |
<div class="resourceful-links"> |
| 228 |
<div class="block block-white"> |
| 229 |
<h1><?php esc_html_e( 'Resourceful Links', 'pie-register' ); ?></h1> |
| 230 |
<div class="resourceful-links-list"> |
| 231 |
<div class="resourceful-link"> |
| 232 |
<a href="https://pieregister.com/docs-category/getting-started/?utm_source=plugindashboard&utm_medium=abouttab&utm_campaign=documentlink" target="_blank"> |
| 233 |
<div class="resourceful-link-image"> |
| 234 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/getting-started.png",dirname(__FILE__)) ); ?>"> |
| 235 |
</div> |
| 236 |
<h6><?php esc_html_e( 'Getting Started', 'pie-register' ); ?></h6> |
| 237 |
</a> |
| 238 |
</div> |
| 239 |
|
| 240 |
<div class="resourceful-link"> |
| 241 |
<a href="https://pieregister.com/docs-category/addons/?utm_source=plugindashboard&utm_medium=abouttab&utm_campaign=documentlink" target="_blank"> |
| 242 |
<div class="resourceful-link-image"> |
| 243 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/addons.png",dirname(__FILE__)) ); ?>"> |
| 244 |
</div> |
| 245 |
<h6><?php esc_html_e( 'Add-ons', 'pie-register' ); ?></h6> |
| 246 |
</a> |
| 247 |
</div> |
| 248 |
|
| 249 |
<div class="resourceful-link"> |
| 250 |
<a href="https://pieregister.com/docs-category/features/?utm_source=plugindashboard&utm_medium=abouttab&utm_campaign=documentlink" target="_blank"> |
| 251 |
<div class="resourceful-link-image"> |
| 252 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/features.png",dirname(__FILE__)) ); ?>"> |
| 253 |
</div> |
| 254 |
<h6><?php esc_html_e( 'Features', 'pie-register' ); ?></h6> |
| 255 |
</a> |
| 256 |
</div> |
| 257 |
|
| 258 |
<div class="resourceful-link"> |
| 259 |
<a href="https://pieregister.com/docs-category/shortcuts/?utm_source=plugindashboard&utm_medium=abouttab&utm_campaign=documentlink" target="_blank"> |
| 260 |
<div class="resourceful-link-image"> |
| 261 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/shortcuts.png",dirname(__FILE__)) ); ?>"> |
| 262 |
</div> |
| 263 |
<h6><?php esc_html_e( 'Shortcuts', 'pie-register' ); ?></h6> |
| 264 |
</a> |
| 265 |
</div> |
| 266 |
|
| 267 |
<div class="resourceful-link"> |
| 268 |
<a href="https://pieregister.com/docs-category/how-to-articles/?utm_source=plugindashboard&utm_medium=abouttab&utm_campaign=documentlink" target="_blank"> |
| 269 |
<div class="resourceful-link-image"> |
| 270 |
<img src="<?php echo esc_url( plugins_url("assets/images/welcome/how-to-articles.png",dirname(__FILE__)) ); ?>"> |
| 271 |
</div> |
| 272 |
<h6><?php esc_html_e( 'How-to', 'pie-register' ); ?></h6> |
| 273 |
</a> |
| 274 |
</div> |
| 275 |
</div> |
| 276 |
</div> |
| 277 |
</div><!-- /.resourceful links --> |
| 278 |
</div><!-- /.container --> |
| 279 |
</div><!-- /#pieregister-welcome --> |
| 280 |
<?php |
| 281 |
} |
| 282 |
} |
| 283 |
|
| 284 |
new PieRegister_Welcome(); |
| 285 |
|