You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
cosmopet.ae/wp-content/plugins copy/poll-maker/includes/class-poll-maker-ays-welcom...

170 lines
6.0 KiB

<?php
class Poll_Maker_Ays_Welcome {
/**
* Hidden welcome page slug.
*
* @since 4.6.4
*/
const SLUG = 'poll-maker-getting-started';
/**
* Primary class constructor.
*
* @since 4.6.4
*/
public function __construct() {
add_action( 'plugins_loaded', [ $this, 'hooks' ] );
}
public function hooks() {
add_action( 'admin_menu', [ $this, 'register' ] );
add_action( 'admin_head', [ $this, 'hide_menu' ] );
add_action( 'admin_init', [ $this, 'redirect' ], 9999 );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
}
/**
* Register the pages to be used for the Welcome screen (and tabs).
*
* These pages will be removed from the Dashboard menu, so they will
* not actually show. Sneaky, sneaky.
*
* @since 1.0.0
*/
public function register() {
add_dashboard_page(
esc_html__( 'Welcome to Poll Maker', POLL_MAKER_AYS_NAME ),
esc_html__( 'Welcome to Poll Maker', POLL_MAKER_AYS_NAME ),
'manage_options',
self::SLUG,
[ $this, 'output' ]
);
}
/**
* Removed the dashboard pages from the admin menu.
*
* This means the pages are still available to us, but hidden.
*
* @since 4.6.4
*/
public function hide_menu() {
remove_submenu_page( 'index.php', self::SLUG );
}
/**
* Welcome screen redirect.
*
* This function checks if a new install or update has just occurred. If so,
* then we redirect the user to the appropriate page.
*
* @since 4.6.4
*/
public function redirect() {
$current_page = isset( $_GET['page'] ) ? $_GET['page'] : '';
// Check if we are already on the welcome page.
if ( $current_page === self::SLUG ) {
return;
}
$first_activation = get_option('ays_poll_maker_first_time_activation', false);
if ($first_activation) {
wp_safe_redirect( admin_url( 'index.php?page=' . self::SLUG ) );
exit;
}
}
/**
* Enqueue custom CSS styles for the welcome page.
*
* @since 4.6.4
*/
public function enqueue_styles() {
wp_enqueue_style(
'poll-maker-ays-welcome-css',
POLL_MAKER_AYS_ADMIN_URL . '/css/poll-maker-ays-welcome.css',
array(), false, 'all');
}
/**
* Register the JavaScript for the welcome page.
*
* @since 4.6.4
*/
public function enqueue_scripts() {
wp_enqueue_script( 'poll-maker-ays-welcome', POLL_MAKER_AYS_ADMIN_URL . '/js/poll-maker-ays-welcome.js', array('jquery'), false, true);
}
/**
* Getting Started screen. Shows after first install.
*
* @since 1.0.0
*/
public function output() {
?>
<style>
#wpcontent {
padding-left: 0 !important;
position: relative;
}
</style>
<div id="poll-maker-welcome">
<div class="poll-maker-welcome-container">
<div class="poll-maker-welcome-intro">
<div class="poll-maker-welcome-logo">
<img src="<?php echo POLL_MAKER_AYS_ADMIN_URL; ?>/images/icons/poll-maker-logo.png" alt="<?php esc_attr_e( 'Poll Maker Logo', POLL_MAKER_AYS_NAME ); ?>">
</div>
<div class="poll-maker-welcome-close">
<a href="<?php echo admin_url( 'admin.php?page=' . POLL_MAKER_AYS_NAME ) ?> ">
<img src="<?php echo POLL_MAKER_AYS_ADMIN_URL; ?>/images/icons/close.svg" alt="<?php esc_attr_e( 'Close', POLL_MAKER_AYS_NAME ); ?>">
</a>
</div>
<div class="poll-maker-welcome-block">
<h1><?php esc_html_e( 'Welcome to Poll Maker', POLL_MAKER_AYS_NAME ); ?></h1>
<h6><?php esc_html_e( 'Thank you for choosing Poll Maker - the best poll and survey plugin for WordPress.', POLL_MAKER_AYS_NAME ); ?></h6>
</div>
<a href="#" class="play-video" title="<?php esc_attr_e( 'Watch how to create your first poll', POLL_MAKER_AYS_NAME ); ?>">
<img src="<?php echo POLL_MAKER_AYS_ADMIN_URL; ?>/images/ays-poll-welcome-video.png" alt="<?php esc_attr_e( 'Watch how to create your first poll', POLL_MAKER_AYS_NAME ); ?>" class="poll-maker-welcome-video-thumbnail">
</a>
<div class="poll-maker-welcome-block">
<div class="poll-maker-welcome-button-wrap poll-maker-clear">
<div class="poll-maker-welcome-left">
<a href="<?php echo esc_url( admin_url( 'admin.php?page=' . POLL_MAKER_AYS_NAME . "&action=add") ); ?>" class="poll-maker-btn poll-maker-btn-block poll-maker-btn-lg poll-maker-btn-orange">
<?php esc_html_e( 'Create Your First Poll', POLL_MAKER_AYS_NAME ); ?>
</a>
</div>
<div class="poll-maker-welcome-right">
<a href="<?php echo 'https://ays-pro.com/wordpress-poll-maker-user-manual'; ?>"
class="poll-maker-btn poll-maker-btn-block poll-maker-btn-lg poll-maker-btn-grey" target="_blank" rel="noopener noreferrer">
<?php esc_html_e( 'Documentation', POLL_MAKER_AYS_NAME ); ?>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
update_option('ays_poll_maker_first_time_activation', false);
}
}
new Poll_Maker_Ays_Welcome();