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 .monorepo-source.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"productId": "funkycommerce-headless",
"repository": "coded-letter/superfunky-theme",
"source": "coded-letter/coded-letter-monorepo@2231c3290f97130c7f5a40820f205c0fb65f5687",
"source": "coded-letter/coded-letter-monorepo@91926789228a613709e0e3e6557551f58e9c4868",
"sourcePath": "workspace/backend/wordpress/themes/free/funkycommerce-headless",
"installSlug": "funkycommerce-headless",
"kind": "theme",
Expand Down
2 changes: 1 addition & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
exit;
}

define( 'FUNKYCOMMERCE_HEADLESS_VERSION', '1.2.31' );
define( 'FUNKYCOMMERCE_HEADLESS_VERSION', '1.2.32' );

/**
* Whether Superfunky Pro is active and licensed.
Expand Down
94 changes: 91 additions & 3 deletions inc/build-webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ function funkycommerce_register_static_generation_graphql() {
*/
function funkycommerce_trigger_storefront_build( $reason = 'scheduled' ) {
if ( ! funkycommerce_is_headless_mode() ) {
return;
return false;
}
$settings = funkycommerce_control_center_settings();
$webhook_url = $settings['build_webhook_url'] ?? '';

if ( empty( $webhook_url ) ) {
return;
return false;
}

$response = wp_safe_remote_post(
Expand Down Expand Up @@ -114,7 +114,7 @@ function funkycommerce_trigger_storefront_build( $reason = 'scheduled' ) {
),
admin_url( 'themes.php?page=funkycommerce-control-center' )
);
return;
return false;
}

$status = wp_remote_retrieve_response_code( $response );
Expand All @@ -130,10 +130,98 @@ function funkycommerce_trigger_storefront_build( $reason = 'scheduled' ) {
),
admin_url( 'themes.php?page=funkycommerce-control-center' )
);
return false;
}
return true;
}
add_action( FUNKYCOMMERCE_BUILD_EVENT, 'funkycommerce_trigger_storefront_build' );

/**
* Add a manual storefront rebuild action and optional Netlify status badge.
*
* @param WP_Admin_Bar $admin_bar Admin toolbar.
*/
function funkycommerce_build_admin_bar( $admin_bar ) {
if ( ! is_admin_bar_showing() || ! current_user_can( 'manage_options' ) ) {
return;
}
$settings = funkycommerce_control_center_settings();
$webhook_url = trim( (string) ( $settings['build_webhook_url'] ?? '' ) );
if ( '' === $webhook_url ) {
return;
}

$admin_bar->add_node(
array(
'id' => 'funkycommerce-storefront-build',
'title' => __( 'Rebuild storefront', 'funkycommerce-headless' ),
'href' => wp_nonce_url(
admin_url( 'admin-post.php?action=funkycommerce_manual_storefront_build' ),
'funkycommerce_manual_storefront_build'
),
'meta' => array(
'title' => __( 'Publish current WordPress content to the static storefront', 'funkycommerce-headless' ),
),
)
);

$site_id = trim( (string) ( $settings['build_badge_id'] ?? '' ) );
if ( '' === $site_id ) {
return;
}
$admin_bar->add_node(
array(
'id' => 'funkycommerce-storefront-build-status',
'parent' => 'funkycommerce-storefront-build',
'title' => '<img src="' . esc_url( 'https://api.netlify.com/api/v1/badges/' . rawurlencode( $site_id ) . '/deploy-status' ) . '" alt="' . esc_attr__( 'Netlify deploy status', 'funkycommerce-headless' ) . '" style="display:block;height:20px;margin:6px 8px 0 0;width:auto">',
'href' => 'https://app.netlify.com/sites/' . rawurlencode( $site_id ) . '/deploys',
'meta' => array(
'html' => true,
'target' => '_blank',
'rel' => 'noopener noreferrer',
'title' => __( 'Open Netlify deploys', 'funkycommerce-headless' ),
),
)
);
}
add_action( 'admin_bar_menu', 'funkycommerce_build_admin_bar', 90 );

/**
* Handle the explicit administrator rebuild request.
*/
function funkycommerce_handle_manual_storefront_build() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( esc_html__( 'You do not have permission to rebuild the storefront.', 'funkycommerce-headless' ), 403 );
}
check_admin_referer( 'funkycommerce_manual_storefront_build' );
$requested = funkycommerce_trigger_storefront_build( 'manual_admin_bar' );
wp_safe_redirect(
add_query_arg(
'funkycommerce_build_requested',
$requested ? '1' : '0',
wp_get_referer() ?: admin_url()
)
);
exit;
}
add_action( 'admin_post_funkycommerce_manual_storefront_build', 'funkycommerce_handle_manual_storefront_build' );

/**
* Confirm a manual build request in wp-admin.
*/
function funkycommerce_manual_storefront_build_notice() {
if ( ! current_user_can( 'manage_options' ) || ! isset( $_GET['funkycommerce_build_requested'] ) ) {
return;
}
$requested = '1' === sanitize_key( wp_unslash( $_GET['funkycommerce_build_requested'] ) );
$class = $requested ? 'notice-success' : 'notice-error';
$message = $requested
? __( 'Storefront rebuild requested. Netlify will publish the updated static content when the build completes.', 'funkycommerce-headless' )
: __( 'The storefront rebuild could not be requested. Check the build webhook configuration and notifications.', 'funkycommerce-headless' );
echo '<div class="notice ' . esc_attr( $class ) . ' is-dismissible"><p>' . esc_html( $message ) . '</p></div>';
}
add_action( 'admin_notices', 'funkycommerce_manual_storefront_build_notice' );

/**
* Preserve the content-change reason while keeping the debounce event argument-free.
*/
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "funkycommerce-headless-theme",
"private": true,
"version": "1.2.31",
"version": "1.2.32",
"description": "Tailwind/build tooling for the FunkyCommerce Headless WordPress theme's native frontend assets (block templates, template parts, loader, and Spotify slot).",
"scripts": {
"build:css": "tailwindcss -i ./assets/css/theme-source.css -o ./assets/dist/theme.css --minify",
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: headless, woocommerce, wpgraphql, full-site-editing
Requires at least: 6.7
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.2.31
Stable tag: 1.2.32
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -15,6 +15,11 @@ Control Center, the theme also ships a complete native WordPress rendering path
"Native frontend theme" below) with accessible header/footer/navigation templates and
core front/home/singular/archive/search/404 routes styled to match the storefront.

== 1.2.32 highlights ==

* Adds an administrator-toolbar action for manually publishing changed WordPress content to the static storefront.
* Displays the Netlify deployment status in the toolbar when a site ID is configured.

== 1.2.31 highlights ==

* Resolves canonical storefront blog posts before WordPress rewrite and old-slug redirect handling.
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A minimal, content-first block theme for polished WordPress preview
Requires at least: 6.7
Tested up to: 6.8
Requires PHP: 7.4
Version: 1.2.31
Version: 1.2.32
Update URI: https://github.com/coded-letter/superfunky-theme
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
Loading