Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Always run `composer lint` and `composer phpstan` before considering PHP work do
1. **`frontblocks.php`** — entry point; defines constants (`FRBL_VERSION`, `FRBL_PLUGIN`, `FRBL_PLUGIN_URL`, `FRBL_PLUGIN_PATH`), loads Composer autoloader, hooks `plugins_loaded` → singleton `FrontBlocks\Plugin_Main::get_instance()`.
2. **`includes/Plugin_Main.php`** — singleton; `load_modules()` instantiates all frontend and admin feature classes.
3. **`includes/Frontend/*.php`** — each feature is a self-contained class; constructor calls `init_hooks()` which registers the WordPress actions/filters it needs (block filtering for block-related features; other hooks — uploads, `wp_head`, `template_redirect`, etc. — for general site-tool features).
4. **`includes/Admin/Settings.php`** — settings page at `themes.php?page=frontblocks-settings`.
4. **`includes/Admin/Settings.php`** — the FrontBlocks menu (`admin.php?page=frontblocks-settings`) with a submenu for each settings tab. Build links with `Settings::get_settings_url( $tab )` and recognize its screens with `Settings::is_settings_screen( $screen_id )`, never with a hard-coded URL or screen ID.

### Module Pattern

Expand Down
2 changes: 1 addition & 1 deletion docs/COOKIE-NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ and other tracking integrations) has been removed from FrontBlocks. Sites that
had it enabled will show no cookie banner at all until FrontConsent is
installed — this is intentional, to push migration forward.

**Appearance → FrontBlocks → Cookie Notice** is now a static promo panel: it
**FrontBlocks → Cookie Notice** is now a static promo panel: it
explains the move and links to install FrontConsent. If FrontConsent isn't
installed yet, that link only installs it — WordPress still requires a
separate activation step (a confirmation screen with an "Activate Plugin"
Expand Down
2 changes: 1 addition & 1 deletion docs/GOOGLE-SIGNIN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ password. It uses [Google Identity Services](https://developers.google.com/ident
on the browser side and verifies the resulting ID token server-side —
no third-party PHP library or Google API client is required.

Enable it from **Appearance → FrontBlocks → Google Sign-In**. The button
Enable it from **FrontBlocks → Social Login**. The button
stays hidden everywhere until a Client ID and Client Secret are set there.

## Settings
Expand Down
2 changes: 1 addition & 1 deletion docs/IMAGE-MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ intermediate image sizes WordPress generates on upload, and automatically
serves modern image formats (WebP/AVIF) on the frontend when the server
supports them.

Enable it from **Appearance → FrontBlocks → Image Management**.
Enable it from **FrontBlocks → Image Management**.

## Settings

Expand Down
2 changes: 1 addition & 1 deletion docs/REDUNDANT-PLUGINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ add_filter( 'frontblocks_redundant_plugins', function ( $entries ) {
'shortpixel-image-optimiser/wp-shortpixel.php' => 'ShortPixel Image Optimizer',
),
// Optional: link shown on the notice for more information.
'doc_url' => admin_url( 'themes.php?page=frontblocks-settings' ),
'doc_url' => \FrontBlocks\Admin\Settings::get_settings_url(),
);

return $entries;
Expand Down
17 changes: 16 additions & 1 deletion docs/SETTINGS-TAB-EXTENSIONS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Extending FrontBlocks Settings Tabs

FrontBlocks exposes two hooks for companion plugins that need a dedicated tab on the **Appearance → FrontBlocks** settings screen.
FrontBlocks exposes two hooks for companion plugins that need a dedicated tab on the **FrontBlocks** settings screen. Every tab also gets an entry in the FrontBlocks menu of the admin sidebar.

## Add a tab and its panel

Expand Down Expand Up @@ -31,4 +31,19 @@ function my_plugin_render_settings_tab() {
}
```

## The FrontBlocks menu

FrontBlocks has a menu of its own in the admin sidebar, right below Appearance, with a submenu entry for each tab. Each entry is a page of its own, so a tab has a URL that can be linked, bookmarked and opened from the sidebar:

| Tab id | Page slug | URL |
| --- | --- | --- |
| `blocks` (the first tab) | `frontblocks-settings` | `admin.php?page=frontblocks-settings` |
| any other, for example `my-plugin` | `frontblocks-settings-my-plugin` | `admin.php?page=frontblocks-settings-my-plugin` |

- Your tab appears in the submenu automatically. Add `'menu' => false` to the tab definition to keep it out of the submenu. It is still a tab of the screen.
- Link to a tab with `\FrontBlocks\Admin\Settings::get_settings_url( 'my-plugin' )`, not with a hard-coded URL.
- Recognize the settings screens with `\FrontBlocks\Admin\Settings::is_settings_screen( $hook_or_screen_id )`. The screen ID of a tab is not the same on every tab, and it was different when the screen lived under Appearance. Do not compare it with a fixed string such as `appearance_page_frontblocks-settings`.
- Check that the method exists before you call it if your plugin must work with older versions of FrontBlocks, which had the page under Appearance (`themes.php?page=frontblocks-settings`).
- The old Appearance URL still works. It redirects to the new menu and keeps its query arguments and its `#tab`.

The panel action runs after FrontBlocks closes its settings form. If your tab submits data, provide its own form, nonce, capability checks, and sanitization.
2 changes: 1 addition & 1 deletion docs/TESTING-INSTRUCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Apariencia → Frontblocks

O directamente:
```
http://tu-sitio.local/wp-admin/themes.php?page=frontblocks-settings
http://tu-sitio.local/wp-admin/admin.php?page=frontblocks-settings
```

---
Expand Down
2 changes: 1 addition & 1 deletion frontblocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function frbl_plugin_activation_redirect() {
// Redirect to settings page.
if ( get_option( 'frbl_activation_redirect', false ) ) {
delete_option( 'frbl_activation_redirect' );
wp_safe_redirect( admin_url( 'themes.php?page=frontblocks-settings' ) );
wp_safe_redirect( class_exists( '\FrontBlocks\Admin\Settings' ) ? \FrontBlocks\Admin\Settings::get_settings_url() : admin_url( 'admin.php?page=frontblocks-settings' ) );
exit;
}
}
Expand Down
4 changes: 2 additions & 2 deletions includes/Admin/CookieNoticeDeprecationNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ public function render_notice() {
return;
}

$allowed_screens = array( 'appearance_page_frontblocks-settings', 'dashboard', 'plugins' );
if ( ! in_array( $screen->id, $allowed_screens, true ) ) {
$allowed_screens = array( 'dashboard', 'plugins' );
if ( ! in_array( $screen->id, $allowed_screens, true ) && ! Settings::is_settings_screen( $screen->id ) ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Admin/ImageManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public function sanitize_settings( $value, $option ) {
* @return void
*/
public function enqueue_assets( $hook ) {
if ( 'appearance_page_' . $this->page_slug !== $hook ) {
if ( ! Settings::is_settings_screen( $hook ) ) {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions includes/Admin/RedundantPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private static function get_default_entries() {
'safe-svg/safe-svg.php' => 'Safe SVG',
'svg-support/svg-support.php' => 'SVG Support',
),
'doc_url' => admin_url( 'themes.php?page=frontblocks-settings' ),
'doc_url' => Settings::get_settings_url(),
),
'login-google' => array(
'feature' => __( 'Google Login', 'frontblocks' ),
Expand All @@ -110,7 +110,7 @@ private static function get_default_entries() {
'login-with-google/login-with-google.php' => 'Login with Google',
'login-with/login-with.php' => 'Login with',
),
'doc_url' => admin_url( 'themes.php?page=frontblocks-settings' ),
'doc_url' => Settings::get_settings_url( 'google-signin' ),
),
'staging-mode' => array(
'feature' => __( 'Staging Mode', 'frontblocks' ),
Expand All @@ -119,7 +119,7 @@ private static function get_default_entries() {
'plugins' => array(
'360-orbit-staging-guard/360-orbit-staging-guard.php' => '360 Orbit Staging Guard',
),
'doc_url' => admin_url( 'themes.php?page=frontblocks-settings' ),
'doc_url' => Settings::get_settings_url( 'maintenance' ),
),
);
}
Expand All @@ -140,8 +140,8 @@ public function render_notices() {
return;
}

$allowed_screens = array( 'appearance_page_frontblocks-settings', 'dashboard', 'plugins' );
if ( ! in_array( $screen->id, $allowed_screens, true ) && false === strpos( $screen->id, 'frontblocks' ) ) {
$allowed_screens = array( 'dashboard', 'plugins' );
if ( ! in_array( $screen->id, $allowed_screens, true ) && ! Settings::is_settings_screen( $screen->id ) && false === strpos( $screen->id, 'frontblocks' ) ) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions includes/Admin/ReviewNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function review_notice() {
}

if ( ! $debug ) {
$allowed_screens = array( 'appearance_page_frontblocks-settings', 'dashboard' );
if ( ! in_array( $screen->id, $allowed_screens, true ) && false === strpos( $screen->id, 'frontblocks' ) ) {
$allowed_screens = array( 'dashboard' );
if ( ! in_array( $screen->id, $allowed_screens, true ) && ! Settings::is_settings_screen( $screen->id ) && false === strpos( $screen->id, 'frontblocks' ) ) {
return;
}
}
Expand Down
Loading
Loading