Skip to content

Commit 9fec6c5

Browse files
committed
Update
1 parent 8c8cce1 commit 9fec6c5

9 files changed

Lines changed: 49 additions & 30 deletions

File tree

includes/admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public function register() : void {
1313

1414
public function register_menu() : void {
1515
add_options_page(
16-
__( 'Nightly', TEXT_DOMAIN ),
17-
__( 'Nightly', TEXT_DOMAIN ),
16+
__( 'Nightly', 'nightly' ),
17+
__( 'Nightly', 'nightly' ),
1818
'manage_options',
1919
PLUGIN_SLUG,
2020
array( $this, 'render_page' )

includes/constants.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,28 @@
22

33
namespace Nightly;
44

5-
if ( ! defined( 'ABSPATH' ) ) {
5+
if (! defined('ABSPATH')) {
66
exit;
77
}
88

9-
const VERSION = '1.0.2';
9+
const VERSION = '1.0.3';
1010
const PLUGIN_SLUG = 'nightly';
11-
const TEXT_DOMAIN = 'nightly';
1211
const OPTION_KEY = 'nightly_options';
1312
const OPTION_REVIEW_DISMISSED = 'nightly_review_dismissed';
1413
const OPTION_REVIEW_VISIBLE = 'nightly_review_visible';
1514
const REST_NAMESPACE = 'nightly/v1';
1615

17-
function plugin_file() : string {
18-
return dirname( __DIR__ ) . '/nightly.php';
16+
function plugin_file(): string
17+
{
18+
return dirname(__DIR__) . '/nightly.php';
1919
}
2020

21-
function plugin_dir() : string {
22-
return dirname( __DIR__ ) . '/';
21+
function plugin_dir(): string
22+
{
23+
return dirname(__DIR__) . '/';
2324
}
2425

25-
function plugin_url() : string {
26-
return plugin_dir_url( plugin_file() );
26+
function plugin_url(): string
27+
{
28+
return plugin_dir_url(plugin_file());
2729
}

includes/frontend.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ public function register() : void {
1717
return;
1818
}
1919

20+
// Use template_redirect to check per-page disable (query is ready at this point)
21+
add_action( 'template_redirect', array( $this, 'init_frontend' ) );
22+
}
23+
24+
/**
25+
* Initialize frontend hooks after the query is ready.
26+
* Allows per-page dark mode disable to work correctly.
27+
*/
28+
public function init_frontend() : void {
2029
// Check if dark mode is disabled for current post/page
2130
if ( $this->is_dark_mode_disabled() ) {
2231
return;
@@ -218,7 +227,7 @@ public function render_toggle_button() : void {
218227
$style = $this->settings['toggle_style'] ?? 'classic';
219228
$size = $this->settings['toggle_size'] ?? 'm';
220229
?>
221-
<button id="nightly-toggle" class="nightly-toggle nightly-toggle-<?php echo esc_attr( $position ); ?> nightly-style-<?php echo esc_attr( $style ); ?> nightly-size-<?php echo esc_attr( $size ); ?>" aria-label="<?php esc_attr_e( 'Toggle dark mode', TEXT_DOMAIN ); ?>" type="button">
230+
<button id="nightly-toggle" class="nightly-toggle nightly-toggle-<?php echo esc_attr( $position ); ?> nightly-style-<?php echo esc_attr( $style ); ?> nightly-size-<?php echo esc_attr( $size ); ?>" aria-label="<?php esc_attr_e( 'Toggle dark mode', 'nightly' ); ?>" type="button">
222231
<?php if ( $style === 'classic' ) : ?>
223232
<svg class="nightly-icon-light" viewBox="0 0 20 20" fill="currentColor">
224233
<path fill-rule="evenodd" d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z" clip-rule="evenodd"></path>

includes/meta-boxes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function register_meta_box() : void {
1818

1919
add_meta_box(
2020
'nightly_dark_mode_control',
21-
__( 'Dark Mode Settings', TEXT_DOMAIN ),
21+
__( 'Dark Mode Settings', 'nightly' ),
2222
array( $this, 'render_meta_box' ),
2323
$post_types,
2424
'side',
@@ -64,11 +64,11 @@ public function render_meta_box( $post ) : void {
6464
style="margin-top: 2px;"
6565
/>
6666
<span>
67-
<?php esc_html_e( 'Disable dark mode for this content', TEXT_DOMAIN ); ?>
67+
<?php esc_html_e( 'Disable dark mode for this content', 'nightly' ); ?>
6868
</span>
6969
</label>
7070
<p class="description" style="margin: 8px 0 0 26px;">
71-
<?php esc_html_e( 'When enabled, dark mode will not be applied to this post/page.', TEXT_DOMAIN ); ?>
71+
<?php esc_html_e( 'When enabled, dark mode will not be applied to this post/page.', 'nightly' ); ?>
7272
</p>
7373
</div>
7474
<?php

includes/notices.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ public function review_notice() : void {
4646
);
4747

4848
echo '<div class="notice notice-info is-dismissible">';
49-
echo '<p>' . esc_html__( 'Enjoying Nightly? Please consider leaving a review.', TEXT_DOMAIN ) . '</p>';
49+
echo '<p>' . esc_html__( 'Enjoying Nightly? Please consider leaving a review.', 'nightly' ) . '</p>';
5050
echo '<p>';
51-
echo '<a class="button button-primary" href="' . esc_url( $review_url ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Leave a review', TEXT_DOMAIN ) . '</a> ';
52-
echo '<a class="button" href="' . esc_url( $dismiss_url ) . '">' . esc_html__( 'Dismiss', TEXT_DOMAIN ) . '</a>';
51+
echo '<a class="button button-primary" href="' . esc_url( $review_url ) . '" target="_blank" rel="noopener noreferrer">' . esc_html__( 'Leave a review', 'nightly' ) . '</a> ';
52+
echo '<a class="button" href="' . esc_url( $dismiss_url ) . '">' . esc_html__( 'Dismiss', 'nightly' ) . '</a>';
5353
echo '</p>';
5454
echo '</div>';
5555
}
5656

5757
public function dismiss_review() : void {
5858
if ( ! Permissions::can_manage() ) {
59-
wp_die( esc_html__( 'You do not have permission to do that.', TEXT_DOMAIN ) );
59+
wp_die( esc_html__( 'You do not have permission to do that.', 'nightly' ) );
6060
}
6161

6262
check_admin_referer( 'nightly_dismiss_review' );

includes/sanitize.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function options( array $values ) {
6767
} else {
6868
return new WP_Error(
6969
'nightly_invalid_selectors',
70-
__( 'Invalid CSS selectors provided.', TEXT_DOMAIN ),
70+
__( 'Invalid CSS selectors provided.', 'nightly' ),
7171
array( 'status' => 400 )
7272
);
7373
}
@@ -163,7 +163,7 @@ public static function options( array $values ) {
163163
if ( strlen( $sanitized['example_text'] ) > 200 ) {
164164
return new WP_Error(
165165
'nightly_invalid_text',
166-
__( 'Example text is too long.', TEXT_DOMAIN ),
166+
__( 'Example text is too long.', 'nightly' ),
167167
array( 'status' => 400 )
168168
);
169169
}

nightly.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<?php
22

33
/**
4-
* Plugin Name: Dark Mode for WordPress - Nightly
4+
* Plugin Name: Nightly Dark Mode
55
* Plugin URI: https://plugpress.io/nightly
6-
* Description: The most powerful dark mode plugin for WordPress. Eye-friendly night mode with smart scheduling, 6 color themes, smooth transitions, and advanced customization. Perfect for reducing eye strain and enhancing user experience.
7-
* Version: 1.0.2
6+
* Description: An elegant dark mode plugin with smart scheduling, 6 color themes, smooth transitions, and advanced customization. Reduces eye strain and enhances user experience.
7+
* Version: 1.0.3
88
* Author: Fahim Reza
99
* Author URI: https://plugpress.io
1010
* License: GPL v2 or later
1111
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
1212
* Text Domain: nightly
13-
* Domain Path: /languages
1413
* Requires at least: 6.0
1514
* Requires PHP: 7.4
1615
*

readme.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Tags: dark mode, night mode, dark theme, eye care
44
Requires at least: 6.0
55
Tested up to: 6.9
66
Requires PHP: 7.4
7-
Stable tag: 1.0.2
7+
Stable tag: 1.0.3
88
License: GPLv2 or later
99
License URI: https://www.gnu.org/licenses/gpl-2.0.html
1010

11-
Dark Mode Toggle for WordPress with smart scheduling, multiple themes, and customization options.
11+
Dark Mode Toggle with smart scheduling, multiple themes, and customization options.
1212

1313
== Description ==
1414

15-
Nightly is a Dark Mode Toggle that adds a professional dark mode to your WordPress site with one click. Give your visitors a comfortable viewing experience with automatic dark mode that reduces eye strain and saves battery life.
15+
Nightly is a Dark Mode Toggle that adds a dark mode to your site with one click. Give your visitors a comfortable viewing experience with automatic dark mode that reduces eye strain and saves battery life.
1616

1717
= Why Dark Mode? =
1818

@@ -56,6 +56,15 @@ Lightweight and fast with no impact on page speed.
5656
4. Navigate to **Settings → Nightly** to configure
5757
5. Enable dark mode and customize your preferences
5858

59+
= Build from Source =
60+
61+
To build the plugin from source, clone the repository and install dependencies:
62+
63+
`git clone https://github.com/plugpress-io/nightly.git`
64+
`cd nightly`
65+
`npm install`
66+
`npm run build`
67+
5968
== Frequently Asked Questions ==
6069

6170
= Does it work with my WordPress theme? =
@@ -100,7 +109,7 @@ Use the "Dark Mode Settings" meta box in the post/page editor to disable dark mo
100109

101110
== Screenshots ==
102111

103-
1. Admin ettings
112+
1. Admin Settings
104113
2. Toggle button customization
105114
3. Six beautiful color theme options
106115

src/admin/router.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Router = () => {
2323
<h1 className="text-lg font-semibold text-gray-900">Nightly</h1>
2424
</div>
2525
<div className="flex items-center gap-3">
26-
<span className="text-xs text-gray-500 font-medium">v1.0.2</span>
26+
<span className="text-xs text-gray-500 font-medium">v1.0.3</span>
2727
<a
2828
href="https://plugpress.io/docs"
2929
target="_blank"

0 commit comments

Comments
 (0)