Add after-install setup screen
This commit is contained in:
parent
2580f79b6f
commit
30a24f3370
File diff suppressed because one or more lines are too long
@ -22,6 +22,30 @@ require_once __DIR__ . '/_setup-meta-fields.php';
|
||||
|
||||
require_once __DIR__ . '/users/_admin-profile.php';
|
||||
|
||||
// =============================================================================
|
||||
// FIRST INSTALL
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Redirects to setup menu page after installation
|
||||
*
|
||||
* @since 5.20.3
|
||||
*/
|
||||
|
||||
function fictioneer_first_install() {
|
||||
$theme_info = fictioneer_get_theme_info();
|
||||
|
||||
if ( is_admin() && isset( $_GET['activated'] ) && $GLOBALS['pagenow'] === 'themes.php' ) {
|
||||
$theme_info = fictioneer_get_theme_info();
|
||||
|
||||
if ( ! ( $theme_info['setup'] ?? 0 ) ) {
|
||||
wp_safe_redirect( admin_url( 'admin.php?page=fictioneer_setup' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'after_setup_theme', 'fictioneer_first_install' );
|
||||
|
||||
// =============================================================================
|
||||
// ENQUEUE ADMIN STYLESHEETS
|
||||
// =============================================================================
|
||||
|
@ -153,6 +153,7 @@ function fictioneer_get_theme_info() {
|
||||
'last_update_nag' => current_time( 'mysql', 1 ),
|
||||
'last_update_notes' => '',
|
||||
'last_version_download_url' => '',
|
||||
'setup' => 0,
|
||||
'version' => FICTIONEER_VERSION
|
||||
);
|
||||
|
||||
@ -167,6 +168,7 @@ function fictioneer_get_theme_info() {
|
||||
'last_update_nag' => '',
|
||||
'last_update_notes' => '',
|
||||
'last_version_download_url' => '',
|
||||
'setup' => 0,
|
||||
'version' => FICTIONEER_VERSION
|
||||
),
|
||||
$info
|
||||
|
@ -23,6 +23,8 @@ if ( wp_doing_ajax() ) {
|
||||
*/
|
||||
|
||||
function fictioneer_add_admin_menu() {
|
||||
$theme_info = fictioneer_get_theme_info();
|
||||
|
||||
add_menu_page(
|
||||
__( 'Fictioneer Settings', 'fictioneer' ),
|
||||
__( 'Fictioneer', 'fictioneer' ),
|
||||
@ -123,6 +125,17 @@ function fictioneer_add_admin_menu() {
|
||||
'fictioneer_settings_logs'
|
||||
);
|
||||
|
||||
if ( ! ( $theme_info['setup'] ?? 0 ) ) {
|
||||
$setup_hook = add_submenu_page(
|
||||
'fictioneer',
|
||||
__( 'Setup', 'fictioneer' ),
|
||||
__( 'Setup', 'fictioneer' ),
|
||||
'manage_options',
|
||||
'fictioneer_setup',
|
||||
'fictioneer_settings_setup'
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'admin_init', 'fictioneer_register_settings' );
|
||||
|
||||
// Add screen options
|
||||
@ -371,6 +384,16 @@ function fictioneer_settings_logs() {
|
||||
get_template_part( 'includes/functions/settings/_settings_page_logs' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for setup settings page
|
||||
*
|
||||
* @since 5.20.3
|
||||
*/
|
||||
|
||||
function fictioneer_settings_setup() {
|
||||
get_template_part( 'includes/functions/settings/_settings_page_setup' );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// SETTINGS CONTENT HELPERS
|
||||
// =============================================================================
|
||||
@ -554,3 +577,19 @@ function fictioneer_settings_page_assignment( $option, $label ) {
|
||||
|
||||
echo '<p class="fictioneer-sub-label">' . $label . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a label-wrapped setting toggle checkbox
|
||||
*
|
||||
* @since 5.21.0
|
||||
*
|
||||
* @param string $option The name of the setting option.
|
||||
*/
|
||||
|
||||
function fictioneer_settings_toggle( $option ) {
|
||||
// Start HTML ---> ?>
|
||||
<label class="checkbox-toggle" for="<?php echo $option; ?>">
|
||||
<input type="checkbox" id="<?php echo $option; ?>" name="<?php echo $option; ?>" value="1" autocomplete="off" <?php echo checked( 1, get_option( $option ), false ); ?>>
|
||||
</label>
|
||||
<?php // <--- End HTML
|
||||
}
|
||||
|
67
includes/functions/settings/_settings_page_setup.php
Normal file
67
includes/functions/settings/_settings_page_setup.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Partial: Setup Settings
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Fictioneer
|
||||
* @since 5.20.3
|
||||
*/
|
||||
|
||||
|
||||
// Setup
|
||||
|
||||
?>
|
||||
|
||||
<div class="fictioneer-settings">
|
||||
|
||||
<div class="fictioneer-settings__content">
|
||||
<form class="fictioneer-single-column fictioneer-single-column--setup">
|
||||
|
||||
<h1><?php _e( 'Fictioneer Setup', 'fictioneer' ); ?></h1>
|
||||
|
||||
<div><?php
|
||||
printf(
|
||||
'<p>Welcome and thank you for using Fictioneer!</p><p>Please make sure to read the installation guide thoroughly. If any issues arise, refer to the <a href="%1$s" target="_blank" rel="noopener">documentation</a> and <a href="%1$s" target="_blank" rel="noopener">FAQ</a> first. If you are new to WordPress, consider looking up some guides, as this theme is not the most beginner-friendly. For further questions or commissions, feel free to join the Discord.</p><p>The following steps will help you select some base options for an easier start, but you can skip this screen if you want. You can find all these options and much more in the Fictioneer menu and the Customizer under Appearance.</p>',
|
||||
'https://github.com/Tetrakern/fictioneer/blob/main/DOCUMENTATION.md',
|
||||
'https://github.com/Tetrakern/fictioneer/blob/main/FAQ.md'
|
||||
);
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card">
|
||||
<div class="fictioneer-card__wrapper">
|
||||
<div class="fictioneer-card__content">
|
||||
<div class="fictioneer-card__row">
|
||||
<p><strong><span class="dashicons dashicons-admin-generic"></span> <?php _e( 'Enable dark mode by default?', 'fictioneer' ); ?></strong></p>
|
||||
<p><?php _e( 'The theme is set to light mode by default, but you can switch to dark mode. Visitors can override the display mode with the sun/moon icon toggle on the frontend.', 'fictioneer' ); ?></p>
|
||||
</div>
|
||||
<div class="fictioneer-card__row">
|
||||
<?php fictioneer_settings_toggle( 'fictioneer_dark_mode_as_default' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2><?php _e( 'Tips', 'fictioneer' ); ?></h2>
|
||||
|
||||
<div class="fictioneer-card">
|
||||
<div class="fictioneer-card__wrapper">
|
||||
<div class="fictioneer-card__content">
|
||||
<div class="fictioneer-card__row">
|
||||
<p><span class="dashicons dashicons-lightbulb"></span> <strong><?php _e( 'Use child theme for customization.', 'fictioneer' ); ?></strong></p>
|
||||
<p><?php
|
||||
printf(
|
||||
__( 'Child themes allow you to overwrite any part of the parent theme without actually modifying it. Otherwise, any changes you make would be removed once you update the theme. While creating a child theme is not difficult, it does require a bit of technical skill. You can start with the prepared <a href="%s" target="_blank" rel="noopener">base child theme</a>.', 'fictioneer' ),
|
||||
'https://github.com/Tetrakern/fictioneer-child-theme'
|
||||
);
|
||||
?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
@ -395,6 +395,25 @@ body[class*="fictioneer_page_"] {
|
||||
@include bp(480px) {
|
||||
gap: 32px;
|
||||
}
|
||||
|
||||
&--setup {
|
||||
max-width: 768px;
|
||||
|
||||
h1 {
|
||||
font-size: 48px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.dashicons {
|
||||
font-size: 1.25em;
|
||||
height: 1em;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
@ -710,6 +729,44 @@ body[class*="fictioneer_page_"] {
|
||||
}
|
||||
}
|
||||
|
||||
.checkbox-toggle {
|
||||
display: inline-flex;
|
||||
border-radius: 3px;
|
||||
width: 54px;
|
||||
|
||||
input {
|
||||
appearance: none;
|
||||
display: block;
|
||||
background: var(--input-background-color) !important;
|
||||
padding: 2px !important;
|
||||
height: 29px;
|
||||
width: 100%;
|
||||
|
||||
&::before {
|
||||
content: none !important;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
background: rgb(0 0 0 / 20%);
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
height: 100%;
|
||||
width: 50%;
|
||||
box-shadow: 0 1px 4px 1px rgb(0 0 0 / 8%);
|
||||
}
|
||||
}
|
||||
|
||||
input:checked {
|
||||
background: var(--input-checkbox-background-color-checked) !important;
|
||||
|
||||
&::after {
|
||||
margin-left: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fcn-help {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user