esc_html__( 'Activating ', 'accelerate' ), ) ); $translation_array = array( 'uri' => esc_url( admin_url( '/themes.php?page=demo-importer&browse=all&accelerate-hide-notice=welcome' ) ), 'btn_text' => esc_html__( 'Processing...', 'accelerate' ), 'nonce' => wp_create_nonce( 'accelerate_demo_import_nonce' ), ); wp_localize_script( 'accelerate-plugin-install-helper', 'accelerate_redirect_demo_page', $translation_array ); } /** * Handle the AJAX process while import or get started button clicked. */ public function accelerate_ajax_import_button_handler() { check_ajax_referer( 'accelerate_demo_import_nonce', 'security' ); $state = ''; if ( is_plugin_active( 'themegrill-demo-importer/themegrill-demo-importer.php' ) ) { $state = 'activated'; } elseif ( file_exists( WP_PLUGIN_DIR . '/themegrill-demo-importer/themegrill-demo-importer.php' ) ) { $state = 'installed'; } if ( 'activated' === $state ) { $response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&accelerate-hide-notice=welcome' ); } elseif ( 'installed' === $state ) { $response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&accelerate-hide-notice=welcome' ); if ( current_user_can( 'activate_plugin' ) ) { $result = activate_plugin( 'themegrill-demo-importer/themegrill-demo-importer.php' ); if ( is_wp_error( $result ) ) { $response['errorCode'] = $result->get_error_code(); $response['errorMessage'] = $result->get_error_message(); } } } else { wp_enqueue_script( 'plugin-install' ); $response['redirect'] = admin_url( '/themes.php?page=demo-importer&browse=all&accelerate-hide-notice=welcome' ); /** * Install Plugin. */ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $api = plugins_api( 'plugin_information', array( 'slug' => sanitize_key( wp_unslash( 'themegrill-demo-importer' ) ), 'fields' => array( 'sections' => false, ), ) ); $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install( $api->download_link ); if ( $result ) { $response['installed'] = 'succeed'; } else { $response['installed'] = 'failed'; } // Activate plugin. if ( current_user_can( 'activate_plugin' ) ) { $result = activate_plugin( 'themegrill-demo-importer/themegrill-demo-importer.php' ); if ( is_wp_error( $result ) ) { $response['errorCode'] = $result->get_error_code(); $response['errorMessage'] = $result->get_error_message(); } } } wp_send_json( $response ); exit(); } /** * Add admin menu. */ public function admin_menu() { $theme = wp_get_theme( get_template() ); $page = add_theme_page( esc_html__( 'About', 'accelerate' ) . ' ' . $theme->display( 'Name' ), esc_html__( 'About', 'accelerate' ) . ' ' . $theme->display( 'Name' ), 'activate_plugins', 'accelerate-sitelibrary', array( $this, 'sitelibrary_screen', ) ); add_action( 'admin_print_styles-' . $page, array( $this, 'enqueue_styles' ) ); } /** * Enqueue styles. */ public function enqueue_styles() { global $accelerate_version; wp_enqueue_style( 'accelerate-welcome', get_template_directory_uri() . '/css/admin/welcome.css', array(), $accelerate_version ); } /** * Add admin notice. */ public function admin_notice() { global $accelerate_version, $pagenow; wp_enqueue_style( 'accelerate-message', get_template_directory_uri() . '/css/admin/message.css', array(), $accelerate_version ); // Let's bail on theme activation. $notice_nag = get_option( 'accelerate_admin_notice_welcome' ); if ( ! $notice_nag ) { add_action( 'admin_notices', array( $this, 'welcome_notice' ) ); } } /** * Hide a notice if the GET variable is set. */ public static function hide_notices() { if ( isset( $_GET['accelerate-hide-notice'] ) && isset( $_GET['_accelerate_notice_nonce'] ) ) { if ( ! wp_verify_nonce( $_GET['_accelerate_notice_nonce'], 'accelerate_hide_notices_nonce' ) ) { wp_die( __( 'Action failed. Please refresh the page and retry.', 'accelerate' ) ); } if ( ! current_user_can( 'manage_options' ) ) { wp_die( __( 'Cheatin’ huh?', 'accelerate' ) ); } $hide_notice = sanitize_text_field( $_GET['accelerate-hide-notice'] ); update_option( 'accelerate_admin_notice_' . $hide_notice, 1 ); // Hide. if ( 'welcome' === $_GET['accelerate-hide-notice'] ) { update_option( 'accelerate_admin_notice_' . $hide_notice, 1 ); } else { // Show. delete_option( 'accelerate_admin_notice_' . $hide_notice ); } } } /** * Show welcome notice. */ public function welcome_notice() { ?>

', '' ); ?>

display( 'Name' ); ?>

display( 'Description' ); ?>

{$current_tab . '_screen'}(); } // Fallback to about screen. return $this->sitelibrary_display_screen(); } /** * Render site library. */ public function sitelibrary_display_screen() { ?>
intro(); ?>
about_screen(); } /** * Output the about screen. */ public function about_screen() { $theme = wp_get_theme( get_template() ); ?>
intro(); ?>

display( 'Name' ); ?>

display( 'Name' ); ?>

|
intro(); ?>

get_contents( $changelog_file ); $changelog_list = $this->parse_changelog( $changelog ); echo wp_kses_post( $changelog_list ); } ?>
'; foreach ( $changes as $index => $line ) { $changelog .= wp_kses_post( preg_replace( '~(=\s*Version\s*(\d+(?:\.\d+)+)\s*=|$)~Uis', '${1}', $line ) ); } $changelog .= ''; } return wp_kses_post( $changelog ); } /** * Output the supported plugins screen. */ public function supported_plugins_screen() { ?>
intro(); ?>

intro(); ?>