Atomic Edge analysis of CVE-2026-125784:nnRestroPress – Online Food Ordering System plugin for WordPress (versions <= 3.4.11) is vulnerable to Cross-Site Request Forgery (CSRF) due to missing or incorrect nonce validation on an unspecified function. The vulnerability allows unauthenticated attackers to perform unauthorized actions by tricking a site administrator into clicking a crafted link or submitting a forged request. The CVSS score is 4.3, indicating a medium severity issue, but the actual impact depends on the affected function.nnRoot Cause: The provided diff is truncated and does not show the vulnerable function or the nonce validation change. Atomic Edge research indicates the vulnerability resides in a function that processes state-changing requests without verifying a nonce. Without the full diff, the exact file path, function name, or line range cannot be determined. This lack of nonce validation allows requests to be forged from external sites.nnExploitation: An attacker would craft a malicious HTML page or link that, when visited by an authenticated administrator, sends a request to the vulnerable endpoint (e.g., /wp-admin/admin-ajax.php with a specific action parameter). The request performs an action such as modifying plugin settings, deleting data, or creating new administrative users. Because no nonce is required, the request is accepted.nnPatch Analysis: The patched version (3.4.12) adds or corrects nonce validation on the vulnerable function. The patch likely introduces a nonce check (e.g., using check_admin_referer() or wp_verify_nonce()) before processing the request. This ensures that the request originates from a legitimate source and cannot be forged.nnImpact: Successful exploitation could lead to unauthorized changes to plugin settings, data modification or deletion, privilege escalation (if the action allows user creation or role changes), or other administrative actions. The exact impact depends on the functionality of the vulnerable function, which is not disclosed in the provided diff.

CVE-2026-125784: RestroPress – Online Food Ordering System <= 3.4.11 Cross-Site Request Forgery PoC, Patch Analysis & Rule
CVE-2026-125784
restropress
3.4.11
3.5.0
Analysis Overview
Differential between vulnerable and patched code
Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/restropress/blocks/cart-panel/render.php
+++ b/restropress/blocks/cart-panel/render.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * Cart Panel block (rpress/cart-panel).
+ *
+ * Mini cart from the shared store: lines with quantity steppers (existing
+ * rpress_cart_item_quantity AJAX), totals from RPRESS_Cart, the store's
+ * open state from the slot engine, and a checkout button that runs the
+ * existing pre-checkout validation (rpress_proceed_checkout). A polite live
+ * region announces every change.
+ *
+ * @package RPRESS
+ * @since 3.5
+ *
+ * @var array $attributes Block attributes.
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+if ( ! rpress_block_storefront_supported() ) {
+ echo rpress_block_storefront_fallback( 'cart-panel', $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+rpress_block_storefront_seed_state();
+
+$rpress_sf_title = ! empty( $attributes['title'] ) ? $attributes['title'] : apply_filters( 'rpress_cart_title', __( 'Your Order', 'restropress' ) );
+$rpress_sf_sticky = ! isset( $attributes['sticky'] ) || ! empty( $attributes['sticky'] );
+$rpress_sf_title_id = wp_unique_id( 'rpress-sf-cart-title-' );
+$rpress_sf_checkout = rpress_get_option( 'checkout_button_text', __( 'Checkout', 'restropress' ) );
+
+$rpress_sf_wrapper = rpress_block_storefront_wrapper(
+ 'rpress-sf-cart' . ( $rpress_sf_sticky ? ' is-sticky' : '' ),
+ array(
+ 'data-wp-interactive' => RPRESS_STOREFRONT_NAMESPACE,
+ 'data-wp-class--is-busy' => 'state.busy',
+ 'aria-labelledby' => $rpress_sf_title_id,
+ )
+);
+?>
+<aside <?php echo $rpress_sf_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
+ <div class="rpress-sf-cart-head">
+ <h2 class="rpress-sf-cart-title" id="<?php echo esc_attr( $rpress_sf_title_id ); ?>"><?php echo esc_html( $rpress_sf_title ); ?></h2>
+ <span class="rpress-sf-cart-count" data-wp-text="state.cart.countLabel"></span>
+ </div>
+
+ <p class="rpress-sf-cart-closed" hidden data-wp-bind--hidden="state.store.open" data-wp-text="state.store.message"></p>
+
+ <p class="rpress-sf-cart-empty" data-wp-bind--hidden="state.cart.hasItems">
+ <?php echo esc_html( apply_filters( 'rpress_block_storefront_empty_cart_text', __( 'Your cart is empty. Add items from the menu to get started.', 'restropress' ) ) ); ?>
+ </p>
+
+ <ul class="rpress-sf-cart-lines" data-wp-bind--hidden="!state.cart.hasItems">
+ <template data-wp-each--line="state.cart.items" data-wp-each-key="context.line.key">
+ <li class="rpress-sf-cart-line">
+ <div class="rpress-sf-cart-line-info">
+ <span class="rpress-sf-cart-line-name" data-wp-text="context.line.name"></span>
+ <span class="rpress-sf-cart-line-options" data-wp-bind--hidden="!context.line.hasOptions" data-wp-text="context.line.options"></span>
+ </div>
+ <div class="rpress-sf-cart-line-qty" role="group" data-wp-bind--aria-label="context.line.quantityLabel">
+ <button type="button" class="rpress-sf-qty-btn" data-wp-on--click="actions.decrement" data-wp-bind--aria-label="context.line.decreaseLabel" data-wp-bind--disabled="state.busy">
+ <span aria-hidden="true">−</span>
+ </button>
+ <span class="rpress-sf-qty-value" data-wp-text="context.line.quantity"></span>
+ <button type="button" class="rpress-sf-qty-btn" data-wp-on--click="actions.increment" data-wp-bind--aria-label="context.line.increaseLabel" data-wp-bind--disabled="state.busy">
+ <span aria-hidden="true">+</span>
+ </button>
+ </div>
+ <span class="rpress-sf-cart-line-total" data-wp-text="context.line.lineTotal"></span>
+ </li>
+ </template>
+ </ul>
+
+ <dl class="rpress-sf-cart-totals" data-wp-bind--hidden="!state.cart.hasItems">
+ <div class="rpress-sf-cart-row">
+ <dt><?php esc_html_e( 'Subtotal', 'restropress' ); ?></dt>
+ <dd data-wp-text="state.cart.subtotal"></dd>
+ </div>
+ <template data-wp-each--fee="state.cart.fees" data-wp-each-key="context.fee.key">
+ <div class="rpress-sf-cart-row">
+ <dt data-wp-text="context.fee.label"></dt>
+ <dd data-wp-text="context.fee.amount"></dd>
+ </div>
+ </template>
+ <div class="rpress-sf-cart-row" data-wp-bind--hidden="!state.cart.showTax">
+ <dt data-wp-text="state.cart.taxLabel"></dt>
+ <dd data-wp-text="state.cart.tax"></dd>
+ </div>
+ <div class="rpress-sf-cart-row is-total">
+ <dt><?php esc_html_e( 'Total', 'restropress' ); ?></dt>
+ <dd data-wp-text="state.cart.total"></dd>
+ </div>
+ </dl>
+
+ <p class="rpress-sf-cart-error" role="alert" data-wp-bind--hidden="!state.error" data-wp-text="state.error"></p>
+
+ <a class="rpress-sf-checkout" data-wp-bind--href="state.checkoutUrl" href="<?php echo esc_url( rpress_get_checkout_uri() ); ?>" data-wp-on--click="actions.checkout" data-wp-bind--hidden="!state.cart.hasItems" data-wp-bind--aria-disabled="state.checkoutDisabled">
+ <span class="rpress-sf-checkout-label"><?php echo esc_html( $rpress_sf_checkout ); ?></span>
+ <span class="rpress-sf-checkout-total" data-wp-text="state.cart.total"></span>
+ </a>
+
+ <div class="screen-reader-text rpress-sf-live" aria-live="polite" aria-atomic="true" data-wp-text="state.announcement"></div>
+</aside>
--- a/restropress/blocks/category-nav/render.php
+++ b/restropress/blocks/category-nav/render.php
@@ -0,0 +1,68 @@
+<?php
+/**
+ * Menu Categories block (rpress/category-nav).
+ *
+ * Jump links to the item grid's category sections. A scrollspy marks the
+ * section in view with aria-current; in filter mode a click shows only that
+ * category instead of scrolling.
+ *
+ * @package RPRESS
+ * @since 3.5
+ *
+ * @var array $attributes Block attributes.
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+if ( ! rpress_block_storefront_supported() ) {
+ echo rpress_block_storefront_fallback( 'category-nav', $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+rpress_block_storefront_seed_state();
+
+$rpress_sf_terms = rpress_block_storefront_categories(
+ isset( $attributes['categories'] ) ? $attributes['categories'] : '',
+ isset( $attributes['categoryExclude'] ) ? $attributes['categoryExclude'] : ''
+);
+if ( empty( $rpress_sf_terms ) ) {
+ return;
+}
+
+$rpress_sf_filter = ! empty( $attributes['filter'] );
+$rpress_sf_sticky = ! isset( $attributes['sticky'] ) || ! empty( $attributes['sticky'] );
+$rpress_sf_orientation = isset( $attributes['orientation'] ) && 'vertical' === $attributes['orientation'] ? 'vertical' : 'horizontal';
+
+$rpress_sf_classes = 'rpress-sf-catnav is-' . $rpress_sf_orientation;
+if ( $rpress_sf_sticky ) {
+ $rpress_sf_classes .= ' is-sticky';
+}
+if ( $rpress_sf_filter ) {
+ $rpress_sf_classes .= ' is-filter';
+}
+
+$rpress_sf_wrapper = rpress_block_storefront_wrapper(
+ $rpress_sf_classes,
+ array(
+ 'data-wp-interactive' => RPRESS_STOREFRONT_NAMESPACE,
+ 'data-wp-context' => wp_json_encode( array( 'filter' => $rpress_sf_filter ) ),
+ 'data-wp-init' => 'callbacks.initScrollspy',
+ 'data-wp-watch' => 'callbacks.revealActiveCategory',
+ )
+);
+?>
+<nav <?php echo $rpress_sf_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> aria-label="<?php esc_attr_e( 'Menu categories', 'restropress' ); ?>">
+ <ul class="rpress-sf-catnav-list">
+ <?php if ( $rpress_sf_filter ) : ?>
+ <li class="rpress-sf-catnav-item">
+ <a class="rpress-sf-catnav-link" href="#" data-wp-context='{"cat":""}' data-wp-on--click="actions.selectCategory" data-wp-bind--aria-current="state.categoryCurrent" data-wp-class--is-active="state.isCategoryActive"><?php esc_html_e( 'All', 'restropress' ); ?></a>
+ </li>
+ <?php endif; ?>
+ <?php foreach ( $rpress_sf_terms as $rpress_sf_term ) : ?>
+ <?php $rpress_sf_slug = sanitize_title( $rpress_sf_term->slug ); ?>
+ <li class="rpress-sf-catnav-item">
+ <a class="rpress-sf-catnav-link" href="#rpress-sf-cat-<?php echo esc_attr( $rpress_sf_slug ); ?>" data-wp-context="<?php echo esc_attr( wp_json_encode( array( 'cat' => $rpress_sf_slug ) ) ); ?>" data-wp-on--click="actions.selectCategory" data-wp-bind--aria-current="state.categoryCurrent" data-wp-class--is-active="state.isCategoryActive"><?php echo esc_html( $rpress_sf_term->name ); ?></a>
+ </li>
+ <?php endforeach; ?>
+ </ul>
+</nav>
--- a/restropress/blocks/item-grid/render.php
+++ b/restropress/blocks/item-grid/render.php
@@ -0,0 +1,139 @@
+<?php
+/**
+ * Menu Items block (rpress/item-grid).
+ *
+ * Items grouped by category. Each card's Add button is the existing
+ * purchase link, so it opens the classic item popup. Search and category
+ * filtering hide cards through the shared "restropress" store.
+ *
+ * @package RPRESS
+ * @since 3.5
+ *
+ * @var array $attributes Block attributes.
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+if ( ! rpress_block_storefront_supported() ) {
+ echo rpress_block_storefront_fallback( 'item-grid', $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+rpress_block_storefront_seed_state();
+
+$rpress_sf_layout = isset( $attributes['layout'] ) && 'list' === $attributes['layout'] ? 'list' : 'grid';
+$rpress_sf_columns = isset( $attributes['columns'] ) ? max( 1, min( 4, (int) $attributes['columns'] ) ) : 2;
+$rpress_sf_image = ! isset( $attributes['showImage'] ) || ! empty( $attributes['showImage'] );
+$rpress_sf_desc = ! isset( $attributes['showDescription'] ) || ! empty( $attributes['showDescription'] );
+$rpress_sf_price = ! isset( $attributes['showPrice'] ) || ! empty( $attributes['showPrice'] );
+$rpress_sf_terms = rpress_block_storefront_categories(
+ isset( $attributes['categories'] ) ? $attributes['categories'] : '',
+ isset( $attributes['categoryExclude'] ) ? $attributes['categoryExclude'] : ''
+);
+$rpress_sf_sections = array();
+$rpress_sf_old_ui = ! empty( rpress_get_option( 'old_ui_ux' ) );
+$rpress_sf_all = array();
+
+global $post;
+$rpress_sf_prev_post = $post;
+
+foreach ( $rpress_sf_terms as $rpress_sf_term ) {
+ $rpress_sf_items = rpress_block_storefront_category_items(
+ $rpress_sf_term,
+ isset( $attributes['orderby'] ) ? $attributes['orderby'] : 'title',
+ isset( $attributes['order'] ) ? $attributes['order'] : 'ASC'
+ );
+ if ( empty( $rpress_sf_items ) ) {
+ continue;
+ }
+ $rpress_sf_cards = '';
+ $rpress_sf_titles = array();
+ foreach ( $rpress_sf_items as $rpress_sf_item ) {
+ // The purchase link reads the global post for the button behavior.
+ $post = $rpress_sf_item; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+ setup_postdata( $post );
+
+ $rpress_sf_id = (int) $rpress_sf_item->ID;
+ $rpress_sf_title = get_the_title( $rpress_sf_item );
+ $rpress_sf_norm = rpress_block_storefront_normalize( $rpress_sf_title );
+ $rpress_sf_titles[] = $rpress_sf_norm;
+ $rpress_sf_all[] = $rpress_sf_norm;
+ $rpress_sf_available = rpress_fooditem_available( $rpress_sf_id );
+ $rpress_sf_classes = 'rpress-sf-card' . ( $rpress_sf_available ? '' : ' is-unavailable' );
+
+ $rpress_sf_card = '<article class="' . esc_attr( $rpress_sf_classes ) . '" id="rpress-sf-item-' . esc_attr( $rpress_sf_id ) . '"';
+ $rpress_sf_card .= ' data-wp-context="' . esc_attr( wp_json_encode( array( 'title' => $rpress_sf_norm ) ) ) . '"';
+ $rpress_sf_card .= ' data-wp-bind--hidden="state.isItemHidden" aria-labelledby="rpress-sf-item-title-' . esc_attr( $rpress_sf_id ) . '">';
+ $rpress_sf_card .= '<div class="rpress-sf-card-body">';
+ $rpress_sf_card .= '<h3 class="rpress-sf-card-title" id="rpress-sf-item-title-' . esc_attr( $rpress_sf_id ) . '">' . esc_html( $rpress_sf_title ) . '</h3>';
+ if ( $rpress_sf_desc ) {
+ $rpress_sf_excerpt = has_excerpt( $rpress_sf_item ) ? get_post_field( 'post_excerpt', $rpress_sf_id ) : '';
+ if ( '' !== trim( (string) $rpress_sf_excerpt ) ) {
+ $rpress_sf_card .= '<p class="rpress-sf-card-desc">' . esc_html( wp_trim_words( wp_strip_all_tags( $rpress_sf_excerpt ), 24 ) ) . '</p>';
+ }
+ }
+ $rpress_sf_card .= '<div class="rpress-sf-card-footer">';
+ if ( $rpress_sf_price ) {
+ $rpress_sf_card .= '<span class="rpress-sf-card-price">' . esc_html( rpress_block_storefront_price_text( $rpress_sf_id ) ) . '</span>';
+ }
+ // .rpress-menu-v2 gives the Add button the 3.4 skin, the merchant's
+ // add-button settings and the active template pack's styling.
+ $rpress_sf_card .= '<div class="rpress-sf-card-action' . ( $rpress_sf_old_ui ? '' : ' rpress-menu-v2' ) . '">' . rpress_block_storefront_add_button( $rpress_sf_id ) . '</div>';
+ $rpress_sf_card .= '</div></div>';
+ if ( $rpress_sf_image && has_post_thumbnail( $rpress_sf_id ) ) {
+ $rpress_sf_card .= '<div class="rpress-sf-card-media">' . get_the_post_thumbnail(
+ $rpress_sf_id,
+ 'medium',
+ array(
+ 'class' => 'rpress-sf-card-img',
+ 'alt' => '',
+ 'loading' => 'lazy',
+ 'decoding' => 'async',
+ )
+ ) . '</div>';
+ }
+ $rpress_sf_card .= '</article>';
+ $rpress_sf_cards .= $rpress_sf_card;
+ }
+
+ $rpress_sf_slug = sanitize_title( $rpress_sf_term->slug );
+ $rpress_sf_sections[] = '<section class="rpress-sf-section" id="rpress-sf-cat-' . esc_attr( $rpress_sf_slug ) . '"'
+ . ' data-rpress-sf-section="' . esc_attr( $rpress_sf_slug ) . '"'
+ . ' data-wp-context="' . esc_attr( wp_json_encode( array( 'cat' => $rpress_sf_slug, 'titles' => $rpress_sf_titles ) ) ) . '"'
+ . ' data-wp-bind--hidden="state.isSectionHidden"'
+ . ' aria-labelledby="rpress-sf-cat-title-' . esc_attr( $rpress_sf_slug ) . '">'
+ . '<h2 class="rpress-sf-section-title" id="rpress-sf-cat-title-' . esc_attr( $rpress_sf_slug ) . '" tabindex="-1">' . esc_html( $rpress_sf_term->name ) . '</h2>'
+ . '<div class="rpress-sf-items">' . $rpress_sf_cards . '</div>'
+ . '</section>';
+}
+
+$post = $rpress_sf_prev_post; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+if ( $post instanceof WP_Post ) {
+ setup_postdata( $post );
+} else {
+ wp_reset_postdata();
+}
+
+$rpress_sf_wrapper = rpress_block_storefront_wrapper(
+ 'rpress-sf-item-grid is-layout-' . $rpress_sf_layout,
+ array(
+ 'data-wp-interactive' => RPRESS_STOREFRONT_NAMESPACE,
+ 'data-wp-context' => wp_json_encode( array( 'titles' => $rpress_sf_all ) ),
+ 'data-wp-init' => 'callbacks.initGrid',
+ 'style' => '--rpress-sf-columns:' . $rpress_sf_columns . ';',
+ )
+);
+?>
+<div <?php echo $rpress_sf_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
+ <?php if ( empty( $rpress_sf_sections ) ) : ?>
+ <p class="rpress-sf-empty">
+ <?php
+ /* translators: %s: post type plural label */
+ printf( esc_html__( 'No %s found', 'restropress' ), esc_html( rp_get_label_plural() ) );
+ ?>
+ </p>
+ <?php else : ?>
+ <?php echo implode( '', $rpress_sf_sections ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped while built above. ?>
+ <p class="rpress-sf-no-results" role="status" hidden data-wp-bind--hidden="!state.hasNoResults" data-wp-text="state.noResultsText"></p>
+ <?php endif; ?>
+</div>
--- a/restropress/blocks/menu-search/render.php
+++ b/restropress/blocks/menu-search/render.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Menu Search block (rpress/menu-search).
+ *
+ * Filters the item grid live through the shared store: cards whose name
+ * does not match hide, empty categories hide with them.
+ *
+ * @package RPRESS
+ * @since 3.5
+ *
+ * @var array $attributes Block attributes.
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+if ( ! rpress_block_storefront_supported() ) {
+ echo rpress_block_storefront_fallback( 'menu-search', $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+rpress_block_storefront_seed_state();
+
+$rpress_sf_placeholder = ! empty( $attributes['placeholder'] ) ? $attributes['placeholder'] : __( 'Search menu items...', 'restropress' );
+$rpress_sf_input_id = wp_unique_id( 'rpress-sf-search-' );
+
+$rpress_sf_wrapper = rpress_block_storefront_wrapper(
+ 'rpress-sf-search',
+ array( 'data-wp-interactive' => RPRESS_STOREFRONT_NAMESPACE )
+);
+?>
+<div <?php echo $rpress_sf_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
+ <form role="search" class="rpress-sf-search-form" data-wp-on--submit="actions.preventSubmit">
+ <label class="screen-reader-text" for="<?php echo esc_attr( $rpress_sf_input_id ); ?>"><?php esc_html_e( 'Search menu items', 'restropress' ); ?></label>
+ <input
+ type="search"
+ id="<?php echo esc_attr( $rpress_sf_input_id ); ?>"
+ class="rpress-sf-search-input"
+ placeholder="<?php echo esc_attr( $rpress_sf_placeholder ); ?>"
+ autocomplete="off"
+ spellcheck="false"
+ data-wp-bind--value="state.query"
+ data-wp-on--input="actions.setQuery"
+ data-wp-on--keydown="actions.searchKeydown"
+ />
+ <button type="button" class="rpress-sf-search-clear" hidden data-wp-bind--hidden="!state.query" data-wp-on--click="actions.clearQuery" aria-label="<?php esc_attr_e( 'Clear search', 'restropress' ); ?>">
+ <span aria-hidden="true">×</span>
+ </button>
+ </form>
+</div>
--- a/restropress/blocks/service-bar/render.php
+++ b/restropress/blocks/service-bar/render.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Service Bar block (rpress/service-bar).
+ *
+ * Renders the classic menu's own service toolbar parts ({template}/delivery-option
+ * and {template}/time-option), so the delivery/pickup tabs, the date and time
+ * popup, the slot check AJAX and the service cookies are the existing ones.
+ * The block only adds a wrapper; the closed notice comes from time-option.
+ *
+ * @package RPRESS
+ * @since 3.5
+ *
+ * @var array $attributes Block attributes.
+ */
+
+defined( 'ABSPATH' ) || exit;
+
+if ( ! rpress_block_storefront_supported() ) {
+ echo rpress_block_storefront_fallback( 'service-bar', $attributes ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ return;
+}
+
+rpress_block_storefront_seed_state();
+
+$rpress_sf_template = rpress_get_option( 'template', 'list' );
+$rpress_sf_template = in_array( $rpress_sf_template, array( 'list', 'grid' ), true ) ? $rpress_sf_template : 'list';
+$rpress_sf_old_ui = ! empty( rpress_get_option( 'old_ui_ux' ) );
+
+ob_start();
+if ( ! $rpress_sf_old_ui ) {
+ echo '<div class="rpress-option-col">';
+ rpress_get_template_part( $rpress_sf_template . '/delivery-option' );
+ echo '</div>';
+}
+echo '<div class="rpress-option-col rpress-edit-address-wrap"><span class="left-brdr"></span>';
+rpress_get_template_part( $rpress_sf_template . '/time-option' );
+echo '</div>';
+$rpress_sf_inner = trim( (string) ob_get_clean() );
+
+// Not an Interactivity region: rp-frontend.js rewrites this markup (service
+// switch, date and time updates), so the runtime must not own it.
+$rpress_sf_wrapper = rpress_block_storefront_wrapper( 'rpress-sf-service-bar' );
+?>
+<div <?php echo $rpress_sf_wrapper; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
+ <div class="<?php echo esc_attr( $rpress_sf_old_ui ? 'rpress-sf-service-inner' : 'rpress-sf-service-inner rpress-menu-v2' ); ?>">
+ <div class="rpress-options-row" role="group" aria-label="<?php esc_attr_e( 'Order type, date and time', 'restropress' ); ?>">
+ <?php echo $rpress_sf_inner; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core template parts escape their own output. ?>
+ </div>
+ </div>
+</div>
--- a/restropress/includes/admin/admin-pages.php
+++ b/restropress/includes/admin/admin-pages.php
@@ -1,401 +1,406 @@
-<?php
-/**
- * Admin Pages
- *
- * @package RPRESS
- * @subpackage Admin/Pages
- * @copyright Copyright (c) 2018, Magnigenie
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
- * @since 1.0.0
- */
-// Exit if accessed directly
-defined('ABSPATH') || exit;
-if (class_exists('RP_Admin_Menus', false)) {
- return new RP_Admin_Menus();
-}
-/**
- * RP_Admin_Menus Class.
- */
-class RP_Admin_Menus
-{
- /**
- * Hook in tabs.
- */
- public function __construct()
- {
- // Add menus.
- add_action('admin_menu', array($this, 'admin_menu'));
- add_action('admin_menu', array($this, 'menu_order_count'));
-
- // Style the Orders pending-count bubble as a RestroPress-orange badge.
- add_action('admin_head', array($this, 'print_menu_badge_css'));
-
- // The badge count is cached per date-range; invalidate it whenever an
- // order is created or changes status so the number stays accurate.
- add_action('rpress_insert_payment', array($this, 'bump_menu_pending_version'));
- add_action('rpress_update_order_status', array($this, 'bump_menu_pending_version'));
- add_action('rpress_update_payment_status', array($this, 'bump_menu_pending_version'));
- add_action('save_post_rpress_payment', array($this, 'on_save_rpress_payment'), 10, 2);
- add_action('wp_trash_post', array($this, 'on_trash_rpress_payment'));
- add_action('untrash_post', array($this, 'on_trash_rpress_payment'));
- add_action('delete_post', array($this, 'on_trash_rpress_payment'));
- add_action('updated_post_meta', array($this, 'on_post_meta_updated'), 10, 4);
- add_action('added_post_meta', array($this, 'on_post_meta_updated'), 10, 4);
-
- //Custom menu ordering
- add_filter('custom_menu_order', '__return_true');
- add_filter('menu_order', array($this, 'menu_order'));
- }
- /**
- * Add menu items.
- */
- public function admin_menu()
- {
- global $menu;
- $menu[] = array('', 'read', 'separator-restropress', '', 'wp-menu-separator restropress');
- $rpress_payment = get_post_type_object('rpress_payment');
- $customer_view_role = apply_filters('rpress_view_customers_role', 'view_shop_reports');
- add_menu_page(esc_html__('RestroPress', 'restropress'), esc_html__('RestroPress', 'restropress'), 'manage_shop_settings', 'restropress', null, null, '55.5');
- //Added version 3.1
- add_submenu_page('restropress', esc_html__('Dashboard', 'restropress'), esc_html__('Dashboard', 'restropress'), $customer_view_role, 'rpress-dashboard', array($this, 'rpress_dashboard_page'), null, null);
- add_submenu_page('', __( 'Home', 'restropress' ), __( 'Home', 'restropress' ), 'manage_shop_settings', 'rpress-setup', 'rpress_admin_home_page', null , null );
- add_submenu_page('restropress', $rpress_payment->labels->name, $rpress_payment->labels->menu_name, 'edit_shop_payments', 'rpress-payment-history', 'rpress_payment_history_page', null, null);
- add_submenu_page('restropress', esc_html__('Customers', 'restropress'), esc_html__('Customers', 'restropress'), $customer_view_role, 'rpress-customers', 'rpress_customers_page', null, null);
- add_submenu_page('restropress', esc_html__('Discount Codes', 'restropress'), esc_html__('Discount Codes', 'restropress'), 'manage_shop_discounts', 'rpress-discounts', 'rpress_discounts_page');
- add_submenu_page('restropress', esc_html__('Earnings and Sales Reports', 'restropress'), esc_html__('Reports', 'restropress'), 'view_shop_reports', 'rpress-reports', 'rpress_reports_page');
- add_submenu_page('restropress', esc_html__('RestroPress Settings', 'restropress'), esc_html__('Settings', 'restropress'), 'manage_shop_settings', 'rpress-settings', 'rpress_options_page');
- add_submenu_page('restropress', esc_html__('RestroPress Info and Tools', 'restropress'), esc_html__('Tools', 'restropress'), 'manage_shop_settings', 'rpress-tools', 'rpress_tools_page');
- add_submenu_page('restropress', esc_html__('RestroPress Extensions', 'restropress'), '<span style="color:#f39c12;">' . esc_html__('Extensions', 'restropress') . '</span>', 'manage_shop_settings', 'rpress-extensions', 'rpress_extensions_page');
- // Remove the additional restropress menu
- remove_submenu_page('restropress', 'restropress');
-
- // Menu import/export live under Menu Items (the CPT menu), reachable at
- // edit.php?post_type=fooditem&page=rpress-menu-(import|export). Following
- // the WooCommerce pattern, the pages are registered but hidden from the
- // sidebar - they surface as buttons in the Menu Items list header
- // (see rpress_fooditem_list_table_buttons) so the submenu stays clean.
- $hidden_pages = array();
- $hidden_pages[ __( 'Import Menu', 'restropress' ) ] = add_submenu_page('edit.php?post_type=fooditem', esc_html__('Import Menu', 'restropress'), esc_html__('Import', 'restropress'), 'edit_products', 'rpress-menu-import', array('RPress_Onboarding', 'render_menu_importer'));
- if ( function_exists( 'rpress_menu_export_page' ) ) {
- $hidden_pages[ __( 'Export Menu', 'restropress' ) ] = add_submenu_page('edit.php?post_type=fooditem', esc_html__('Export Menu', 'restropress'), esc_html__('Export', 'restropress'), 'export_shop_reports', 'rpress-menu-export', 'rpress_menu_export_page');
- }
- remove_submenu_page('edit.php?post_type=fooditem', 'rpress-menu-import');
- remove_submenu_page('edit.php?post_type=fooditem', 'rpress-menu-export');
- // Removing the submenu entry also drops the page title, which leaves the
- // admin <title> null (PHP 8.1+ deprecation). Set it before the header.
- foreach ( $hidden_pages as $page_title => $hook ) {
- if ( $hook ) {
- add_action( 'load-' . $hook, function () use ( $page_title ) {
- $GLOBALS['title'] = $page_title;
- } );
- }
- }
- }
- public function rpress_dashboard_page()
- {
- // Define the path to the file
- // Get the plugin directory path
- $plugin_dir = plugin_dir_path(__FILE__);
- // Define the relative path to the file within the plugin
- $file_relative_path = '/dashboard/rp-dashboard.php';
-
- // Build the full path to the file
- $file_path = $plugin_dir . $file_relative_path;
-
- // Check if the file exists before including it
- if (file_exists($file_path)) {
- // Include the file
- include_once($file_path);
- } else {
- // Display an error message if the file doesn't exist
- echo esc_html("Error: File not found - $file_relative_path");
- }
- }
- /**
- * Adds the order pending count to the menu.
- */
- public function menu_order_count()
- {
- global $submenu;
- if (isset($submenu['restropress'])) {
- // Remove 'RestroPress' sub menu item.
- unset($submenu['restropress'][0]);
- // Add count if user has access.
- if (apply_filters('rpress_include_pending_order_count_in_menu', true) && current_user_can('edit_shop_payments')) {
- $pending_count = $this->get_menu_pending_count();
- $order_count = apply_filters('rpress_menu_order_count', $pending_count);
- if ($order_count) {
- foreach ($submenu['restropress'] as $key => $menu_item) {
- if (0 === strpos($menu_item[0], _x('Orders', 'Admin menu name', 'restropress'))) {
- $submenu['restropress'][$key][0] .= ' <span class="rpress-order-badge">' . number_format_i18n($order_count) . '</span>';
- break;
- }
- }
- }
- }
- }
- }
-
- /**
- * All-time pending-order count for the Orders menu badge.
- *
- * Cached briefly; the cache key carries a version that is bumped whenever
- * an order is created or changes status.
- *
- * @since 3.3
- * @return int
- */
- public function get_menu_pending_count()
- {
- $version = (int) get_option('rpress_menu_pending_version', 1);
- $cache_key = 'rpress_menu_pending_' . $version;
-
- $cached = get_transient($cache_key);
- if (false !== $cached) {
- return (int) $cached;
- }
-
- // Validate and clean up any orphaned or deleted order statuses.
- if ( function_exists( 'rpress_validate_and_cleanup_order_statuses' ) ) {
- rpress_validate_and_cleanup_order_statuses();
- }
-
- // Ensure RPRESS_Payment_History_Table class is loaded if available.
- $plugin_dir = defined( 'RP_PLUGIN_DIR' ) ? RP_PLUGIN_DIR : ( defined( 'RPRESS_PLUGIN_DIR' ) ? RPRESS_PLUGIN_DIR : ( defined( 'RP_PLUGIN_FILE' ) ? plugin_dir_path( RP_PLUGIN_FILE ) : '' ) );
- if ( ! class_exists( 'WP_List_Table' ) && file_exists( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ) ) {
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
- }
- if ( ! class_exists( 'RPRESS_Payment_History_Table' ) && ! empty( $plugin_dir ) && file_exists( $plugin_dir . 'includes/admin/payments/class-payments-table.php' ) ) {
- require_once $plugin_dir . 'includes/admin/payments/class-payments-table.php';
- }
-
- // Calculate pending order count synchronized with Orders list table needs-attention operational window.
- if ( class_exists( 'RPRESS_Payment_History_Table' ) && method_exists( 'RPRESS_Payment_History_Table', 'get_needs_attention_ids' ) ) {
- $needs_attention_ids = RPRESS_Payment_History_Table::get_needs_attention_ids( null, null, false );
- $count = count( $needs_attention_ids );
- } else {
- global $wpdb;
- $count = (int) $wpdb->get_var($wpdb->prepare(
- "SELECT COUNT(DISTINCT pm.post_id)
- FROM {$wpdb->postmeta} pm
- INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id
- WHERE pm.meta_key = %s
- AND pm.meta_value = %s
- AND p.post_type = %s
- AND p.post_status NOT IN (%s, %s, %s, %s, %s, %s)",
- '_order_status',
- 'pending',
- 'rpress_payment',
- 'trash',
- 'cancelled',
- 'refunded',
- 'failed',
- 'abandoned',
- 'completed'
- ));
- }
-
- set_transient($cache_key, $count, 2 * MINUTE_IN_SECONDS);
- return $count;
- }
-
- /**
- * Invalidate the cached badge counts after an order changes.
- *
- * Counts are keyed by a version number, so bumping it lets every cached
- * range fall through to a fresh query without tracking individual keys.
- *
- * @since 3.3
- * @return void
- */
- public function bump_menu_pending_version()
- {
- $version = (int) get_option('rpress_menu_pending_version', 1);
- update_option('rpress_menu_pending_version', $version + 1, false);
- if (function_exists('wp_cache_flush_group')) {
- wp_cache_flush_group('rpress');
- }
- }
-
- /**
- * Synchronize post_status and bump cache version when an order is saved.
- *
- * @since 3.3.1
- * @param int $post_id
- * @param WP_Post $post
- * @return void
- */
- public function on_save_rpress_payment($post_id, $post = null)
- {
- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
- return;
- }
-
- if (!$post || $post->post_type !== 'rpress_payment') {
- return;
- }
-
- // Keep post_status in sync with _order_status if order is completed/finished
- $order_status = get_post_meta($post_id, '_order_status', true);
- $completed_statuses = array('completed', 'cancelled', 'refunded', 'failed', 'abandoned');
- if (in_array($order_status, $completed_statuses, true) && $post->post_status === 'pending') {
- wp_update_post(array(
- 'ID' => $post_id,
- 'post_status' => 'publish',
- ));
- }
-
- $this->bump_menu_pending_version();
- }
-
- /**
- * Invalidate cache when post meta for _order_status changes.
- *
- * @since 3.3.1
- */
- public function on_post_meta_updated($meta_id, $object_id, $meta_key, $_meta_value)
- {
- if ($meta_key === '_order_status' && get_post_type($object_id) === 'rpress_payment') {
- $this->bump_menu_pending_version();
- }
- }
-
- /**
- * Invalidate cache when an order post is trashed, untrashed, or deleted.
- *
- * @since 3.3.1
- */
- public function on_trash_rpress_payment($post_id)
- {
- if (get_post_type($post_id) === 'rpress_payment') {
- // Keep _order_status: a trashed order must come back with its status
- // when restored. Status meta is removed only on permanent delete.
- $this->bump_menu_pending_version();
- }
- }
-
- /**
- * Output the Orders menu badge styling (RestroPress-orange rounded pill).
- *
- * @since 3.3
- * @return void
- */
- public function print_menu_badge_css()
- {
- ?>
-<style id="rpress-order-badge-css">
-#adminmenu .rpress-order-badge {
- display: inline-block;
- min-width: 18px;
- height: 18px;
- margin: 1px 0 0 6px;
- padding: 0 6px;
- border-radius: 9px;
- background: #ff4f18;
- color: #fff;
- font-size: 11px;
- line-height: 18px;
- font-weight: 600;
- text-align: center;
- vertical-align: middle;
- box-sizing: border-box;
-}
-#adminmenu li.current .rpress-order-badge,
-#adminmenu a:hover .rpress-order-badge,
-#adminmenu li.menu-top:hover .rpress-order-badge {
- background: #ff4f18;
- color: #fff;
-}
-</style>
- <?php
- }
-
- public function rpress_add_setup_wizard_menu()
- {
- add_submenu_page(
- null, // ← no menu entry, hidden
- __('RestroPress Setup', 'restropress'),
- '', // No label in menu
- 'manage_options',
- 'rpress-setup',
- [$this, 'rpress_admin_home_page'],
- );
- }
-
- public function rpress_setup_wizard_page_callback()
- {
- $enable_service = get_option('enable_service', 'delivery_and_pickup');
- $default_service = get_option('default_service', 'delivery');
- ?>
- <div class="wrap">
- <h1>RestroPress Setup Wizard</h1>
- <form method="post" id="rpress-setup-form">
- <?php wp_nonce_field('my_plugin_save_setup', 'my_plugin_setup_nonce'); ?>
-
- <!-- Step 1 -->
- <div class="rpress-setup-step" data-step="1" style="display:block;">
- <h2>Step 1: Choose Services</h2>
- <p>
- <label><input type="radio" name="enable_service" value="delivery_and_pickup" <?php checked($enable_service, 'delivery_and_pickup'); ?>> Both Delivery and Pickup</label><br>
- <label><input type="radio" name="enable_service" value="delivery" <?php checked($enable_service, 'delivery'); ?>> Delivery Only</label><br>
- <label><input type="radio" name="enable_service" value="pickup" <?php checked($enable_service, 'pickup'); ?>> Pickup Only</label>
- </p>
- <button type="button" class="button button-primary next-step">Next</button>
- </div>
-
- <!-- Step 2 -->
- <div class="rpress-setup-step" data-step="2" style="display:none;">
- <h2>Step 2: Default Settings</h2>
- <p>
- <label><input type="radio" name="default_service" value="delivery" <?php checked($default_service, 'delivery'); ?>> Delivery</label><br>
- <label><input type="radio" name="default_service" value="pickup" <?php checked($default_service, 'pickup'); ?>> Pickup</label>
- </p>
- <button type="button" class="button back-step">Back</button>
- <button type="button" class="button button-primary next-step">Next</button>
- </div>
-
- <!-- Step 3 -->
- <div class="rpress-setup-step" data-step="3" style="display:none;">
- <h2>Step 3: Finish</h2>
- <p>You're all set! Click below to save and complete setup.</p>
- <button type="button" class="button back-step">Back</button>
- <?php submit_button('Save & Finish Setup'); ?>
- </div>
- </form>
- </div>
- <?php
- }
-
- /**
- * Reorder the RestroPress menu items in admin.
- *
- * @param int $menu_order Menu order.
- * @return array
- */
- public function menu_order($menu_order)
- {
- // Initialize our custom order array.
- $rpress_menu_order = array();
- // Get the index of our custom separator.
- $rpress_separator = array_search('separator-restropress', $menu_order, true);
- // Get index of fooditem menu.
- $rpress_fooditems = array_search('edit.php?post_type=fooditem', $menu_order, true);
- //Remove the custom separator and fooditems menu so that we can re-order them
- unset($menu_order[$rpress_separator]);
- unset($menu_order[$rpress_fooditems]);
- // Loop through menu order and do some rearranging.
- foreach ($menu_order as $index => $item) {
- if ('restropress' === $item) {
- $rpress_menu_order[] = 'separator-restropress';
- $rpress_menu_order[] = $item;
- $rpress_menu_order[] = 'edit.php?post_type=fooditem';
- } elseif (!in_array($item, array('separator-restropress'), true)) {
- $rpress_menu_order[] = $item;
- }
- }
- // Return order.
- return $rpress_menu_order;
- }
-}
-return new RP_Admin_Menus();
-
+<?php
+/**
+ * Admin Pages
+ *
+ * @package RPRESS
+ * @subpackage Admin/Pages
+ * @copyright Copyright (c) 2018, Magnigenie
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
+ * @since 1.0.0
+ */
+// Exit if accessed directly
+defined('ABSPATH') || exit;
+if (class_exists('RP_Admin_Menus', false)) {
+ return new RP_Admin_Menus();
+}
+/**
+ * RP_Admin_Menus Class.
+ */
+class RP_Admin_Menus
+{
+ /**
+ * Hook in tabs.
+ */
+ public function __construct()
+ {
+ // Add menus.
+ add_action('admin_menu', array($this, 'admin_menu'));
+ add_action('admin_menu', array($this, 'menu_order_count'));
+
+ // Style the Orders pending-count bubble as a RestroPress-orange badge.
+ add_action('admin_head', array($this, 'print_menu_badge_css'));
+
+ // The badge count is cached per date-range; invalidate it whenever an
+ // order is created or changes status so the number stays accurate.
+ add_action('rpress_insert_payment', array($this, 'bump_menu_pending_version'));
+ add_action('rpress_update_order_status', array($this, 'bump_menu_pending_version'));
+ add_action('rpress_update_payment_status', array($this, 'bump_menu_pending_version'));
+ add_action('save_post_rpress_payment', array($this, 'on_save_rpress_payment'), 10, 2);
+ add_action('wp_trash_post', array($this, 'on_trash_rpress_payment'));
+ add_action('untrash_post', array($this, 'on_trash_rpress_payment'));
+ add_action('delete_post', array($this, 'on_trash_rpress_payment'));
+ add_action('updated_post_meta', array($this, 'on_post_meta_updated'), 10, 4);
+ add_action('added_post_meta', array($this, 'on_post_meta_updated'), 10, 4);
+
+ //Custom menu ordering
+ add_filter('custom_menu_order', '__return_true');
+ add_filter('menu_order', array($this, 'menu_order'));
+ }
+ /**
+ * Add menu items.
+ */
+ public function admin_menu()
+ {
+ global $menu;
+ $menu[] = array('', 'read', 'separator-restropress', '', 'wp-menu-separator restropress');
+ $rpress_payment = get_post_type_object('rpress_payment');
+ $customer_view_role = apply_filters('rpress_view_customers_role', 'view_shop_reports');
+ add_menu_page(esc_html__('RestroPress', 'restropress'), esc_html__('RestroPress', 'restropress'), 'manage_shop_settings', 'restropress', null, null, '55.5');
+ //Added version 3.1
+ add_submenu_page('restropress', esc_html__('Dashboard', 'restropress'), esc_html__('Dashboard', 'restropress'), $customer_view_role, 'rpress-dashboard', array($this, 'rpress_dashboard_page'), null, null);
+ add_submenu_page('', __( 'Home', 'restropress' ), __( 'Home', 'restropress' ), 'manage_shop_settings', 'rpress-setup', 'rpress_admin_home_page', null , null );
+ add_submenu_page('restropress', $rpress_payment->labels->name, $rpress_payment->labels->menu_name, 'edit_shop_payments', 'rpress-payment-history', 'rpress_payment_history_page', null, null);
+ add_submenu_page('restropress', esc_html__('Customers', 'restropress'), esc_html__('Customers', 'restropress'), $customer_view_role, 'rpress-customers', 'rpress_customers_page', null, null);
+ add_submenu_page('restropress', esc_html__('Discount Codes', 'restropress'), esc_html__('Discount Codes', 'restropress'), 'manage_shop_discounts', 'rpress-discounts', 'rpress_discounts_page');
+ add_submenu_page('restropress', esc_html__('Earnings and Sales Reports', 'restropress'), esc_html__('Reports', 'restropress'), 'view_shop_reports', 'rpress-reports', 'rpress_reports_page');
+ add_submenu_page('restropress', esc_html__('RestroPress Settings', 'restropress'), esc_html__('Settings', 'restropress'), 'manage_shop_settings', 'rpress-settings', 'rpress_options_page');
+ add_submenu_page('restropress', esc_html__('RestroPress Info and Tools', 'restropress'), esc_html__('Tools', 'restropress'), 'manage_shop_settings', 'rpress-tools', 'rpress_tools_page');
+ add_submenu_page('restropress', esc_html__('RestroPress Extensions', 'restropress'), '<span style="color:#f39c12;">' . esc_html__('Extensions', 'restropress') . '</span>', 'manage_shop_settings', 'rpress-extensions', 'rpress_extensions_page');
+ // Remove the additional restropress menu
+ remove_submenu_page('restropress', 'restropress');
+
+ // Menu import/export live under Menu Items (the CPT menu), reachable at
+ // edit.php?post_type=fooditem&page=rpress-menu-(import|export). Following
+ // the WooCommerce pattern, the pages are registered but hidden from the
+ // sidebar - they surface as buttons in the Menu Items list header
+ // (see rpress_fooditem_list_table_buttons) so the submenu stays clean.
+ $hidden_pages = array();
+ $hidden_pages[ __( 'Import Menu', 'restropress' ) ] = add_submenu_page('edit.php?post_type=fooditem', esc_html__('Import Menu', 'restropress'), esc_html__('Import', 'restropress'), 'edit_products', 'rpress-menu-import', array('RPress_Onboarding', 'render_menu_importer'));
+ if ( function_exists( 'rpress_menu_export_page' ) ) {
+ $hidden_pages[ __( 'Export Menu', 'restropress' ) ] = add_submenu_page('edit.php?post_type=fooditem', esc_html__('Export Menu', 'restropress'), esc_html__('Export', 'restropress'), 'export_shop_reports', 'rpress-menu-export', 'rpress_menu_export_page');
+ }
+ remove_submenu_page('edit.php?post_type=fooditem', 'rpress-menu-import');
+ remove_submenu_page('edit.php?post_type=fooditem', 'rpress-menu-export');
+ // Removing the submenu entry also drops the page title, which leaves the
+ // admin <title> null (PHP 8.1+ deprecation). Set it before the header.
+ foreach ( $hidden_pages as $page_title => $hook ) {
+ if ( $hook ) {
+ add_action( 'load-' . $hook, function () use ( $page_title ) {
+ $GLOBALS['title'] = $page_title;
+ } );
+ }
+ }
+ }
+ public function rpress_dashboard_page()
+ {
+ // Define the path to the file
+ // Get the plugin directory path
+ $plugin_dir = plugin_dir_path(__FILE__);
+ // Define the relative path to the file within the plugin
+ $file_relative_path = '/dashboard/rp-dashboard.php';
+
+ // Build the full path to the file
+ $file_path = $plugin_dir . $file_relative_path;
+
+ // Check if the file exists before including it
+ if (file_exists($file_path)) {
+ // Include the file
+ include_once($file_path);
+ } else {
+ // Display an error message if the file doesn't exist
+ echo esc_html("Error: File not found - $file_relative_path");
+ }
+ }
+ /**
+ * Adds the order pending count to the menu.
+ */
+ public function menu_order_count()
+ {
+ global $submenu;
+ if (isset($submenu['restropress'])) {
+ // Remove the 'RestroPress' sub menu item. Match the slug, not position 0:
+ // post types shown under this menu (Reservations) can be registered first.
+ foreach ($submenu['restropress'] as $key => $menu_item) {
+ if (isset($menu_item[2]) && 'restropress' === $menu_item[2]) {
+ unset($submenu['restropress'][$key]);
+ }
+ }
+ // Add count if user has access.
+ if (apply_filters('rpress_include_pending_order_count_in_menu', true) && current_user_can('edit_shop_payments')) {
+ $pending_count = $this->get_menu_pending_count();
+ $order_count = apply_filters('rpress_menu_order_count', $pending_count);
+ if ($order_count) {
+ foreach ($submenu['restropress'] as $key => $menu_item) {
+ if (0 === strpos($menu_item[0], _x('Orders', 'Admin menu name', 'restropress'))) {
+ $submenu['restropress'][$key][0] .= ' <span class="rpress-order-badge">' . number_format_i18n($order_count) . '</span>';
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * All-time pending-order count for the Orders menu badge.
+ *
+ * Cached briefly; the cache key carries a version that is bumped whenever
+ * an order is created or changes status.
+ *
+ * @since 3.3
+ * @return int
+ */
+ public function get_menu_pending_count()
+ {
+ $version = (int) get_option('rpress_menu_pending_version', 1);
+ $cache_key = 'rpress_menu_pending_' . $version;
+
+ $cached = get_transient($cache_key);
+ if (false !== $cached) {
+ return (int) $cached;
+ }
+
+ // Validate and clean up any orphaned or deleted order statuses.
+ if ( function_exists( 'rpress_validate_and_cleanup_order_statuses' ) ) {
+ rpress_validate_and_cleanup_order_statuses();
+ }
+
+ // Ensure RPRESS_Payment_History_Table class is loaded if available.
+ $plugin_dir = defined( 'RP_PLUGIN_DIR' ) ? RP_PLUGIN_DIR : ( defined( 'RPRESS_PLUGIN_DIR' ) ? RPRESS_PLUGIN_DIR : ( defined( 'RP_PLUGIN_FILE' ) ? plugin_dir_path( RP_PLUGIN_FILE ) : '' ) );
+ if ( ! class_exists( 'WP_List_Table' ) && file_exists( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ) ) {
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
+ }
+ if ( ! class_exists( 'RPRESS_Payment_History_Table' ) && ! empty( $plugin_dir ) && file_exists( $plugin_dir . 'includes/admin/payments/class-payments-table.php' ) ) {
+ require_once $plugin_dir . 'includes/admin/payments/class-payments-table.php';
+ }
+
+ // Calculate pending order count synchronized with Orders list table needs-attention operational window.
+ if ( class_exists( 'RPRESS_Payment_History_Table' ) && method_exists( 'RPRESS_Payment_History_Table', 'get_needs_attention_ids' ) ) {
+ $needs_attention_ids = RPRESS_Payment_History_Table::get_needs_attention_ids( null, null, false );
+ $count = count( $needs_attention_ids );
+ } else {
+ global $wpdb;
+ $count = (int) $wpdb->get_var($wpdb->prepare(
+ "SELECT COUNT(DISTINCT pm.post_id)
+ FROM {$wpdb->postmeta} pm
+ INNER JOIN {$wpdb->posts} p ON p.ID = pm.post_id
+ WHERE pm.meta_key = %s
+ AND pm.meta_value = %s
+ AND p.post_type = %s
+ AND p.post_status NOT IN (%s, %s, %s, %s, %s, %s)",
+ '_order_status',
+ 'pending',
+ 'rpress_payment',
+ 'trash',
+ 'cancelled',
+ 'refunded',
+ 'failed',
+ 'abandoned',
+ 'completed'
+ ));
+ }
+
+ set_transient($cache_key, $count, 2 * MINUTE_IN_SECONDS);
+ return $count;
+ }
+
+ /**
+ * Invalidate the cached badge counts after an order changes.
+ *
+ * Counts are keyed by a version number, so bumping it lets every cached
+ * range fall through to a fresh query without tracking individual keys.
+ *
+ * @since 3.3
+ * @return void
+ */
+ public function bump_menu_pending_version()
+ {
+ $version = (int) get_option('rpress_menu_pending_version', 1);
+ update_option('rpress_menu_pending_version', $version + 1, false);
+ if (function_exists('wp_cache_flush_group')) {
+ wp_cache_flush_group('rpress');
+ }
+ }
+
+ /**
+ * Synchronize post_status and bump cache version when an order is saved.
+ *
+ * @since 3.3.1
+ * @param int $post_id
+ * @param WP_Post $post
+ * @return void
+ */
+ public function on_save_rpress_payment($post_id, $post = null)
+ {
+ if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
+ return;
+ }
+
+ if (!$post || $post->post_type !== 'rpress_payment') {
+ return;
+ }
+
+ // Keep post_status in sync with _order_status if order is completed/finished
+ $order_status = get_post_meta($post_id, '_order_status', true);
+ $completed_statuses = array('completed', 'cancelled', 'refunded', 'failed', 'abandoned');
+ if (in_array($order_status, $completed_statuses, true) && $post->post_status === 'pending') {
+ wp_update_post(array(
+ 'ID' => $post_id,
+ 'post_status' => 'publish',
+ ));
+ }
+
+ $this->bump_menu_pending_version();
+ }
+
+ /**
+ * Invalidate cache when post meta for _order_status changes.
+ *
+ * @since 3.3.1
+ */
+ public function on_post_meta_updated($meta_id, $object_id, $meta_key, $_meta_value)
+ {
+ if ($meta_key === '_order_status' && get_post_type($object_id) === 'rpress_payment') {
+ $this->bump_menu_pending_version();
+ }
+ }
+
+ /**
+ * Invalidate cache when an order post is trashed, untrashed, or deleted.
+ *
+ * @since 3.3.1
+ */
+ public function on_trash_rpress_payment($post_id)
+ {
+ if (get_post_type($post_id) === 'rpress_payment') {
+ // Keep _order_status: a trashed order must come back with its status
+ // when restored. Status meta is removed only on permanent delete.
+ $this->bump_menu_pending_version();
+ }
+ }
+
+ /**
+ * Output the Orders menu badge styling (RestroPress-orange rounded pill).
+ *
+ * @since 3.3
+ * @return void
+ */
+ public function print_menu_badge_css()
+ {
+ ?>
+<style id="rpress-order-badge-css">
+#adminmenu .rpress-order-badge {
+ display: inline-block;
+ min-width: 18px;
+ height: 18px;
+ margin: 1px 0 0 6px;
+ padding: 0 6px;
+ border-radius: 9px;
+ background: #ff4f18;
+ color: #fff;
+ font-size: 11px;
+ line-height: 18px;
+ font-weight: 600;
+ text-align: center;
+ vertical-align: middle;
+ box-sizing: border-box;
+}
+#adminmenu li.current .rpress-order-badge,
+#adminmenu a:hover .rpress-order-badge,
+#adminmenu li.menu-top:hover .rpress-order-badge {
+ background: #ff4f18;
+ color: #fff;
+}
+</style>
+ <?php
+ }
+
+ public function rpress_add_setup_wizard_menu()
+ {
+ add_submenu_page(
+ null, // ← no menu entry, hidden
+ __('RestroPress Setup', 'restropress'),
+ '', // No label in menu
+ 'manage_options',
+ 'rpress-setup',
+ [$this, 'rpress_admin_home_page'],
+ );
+ }
+
+ public function rpress_setup_wizard_page_callback()
+ {
+ $enable_service = get_option('enable_service', 'delivery_and_pickup');
+ $default_service = get_option('default_service', 'delivery');
+ ?>
+ <div class="wrap">
+ <h1>RestroPress Setup Wizard</h1>
+ <form method="post" id="rpress-setup-form">
+ <?php wp_nonce_field('my_plugin_save_setup', 'my_plugin_setup_nonce'); ?>
+
+ <!-- Step 1 -->
+ <div class="rpress-setup-step" data-step="1" style="display:block;">
+ <h2>Step 1: Choose Services</h2>
+ <p>
+ <label><input type="radio" name="enable_service" value="delivery_and_pickup" <?php checked($enable_service, 'delivery_and_pickup'); ?>> Both Delivery and Pickup</label><br>
+ <label><input type="radio" name="enable_service" value="delivery" <?php checked($enable_service, 'delivery'); ?>> Delivery Only</label><br>
+ <label><input type="radio" name="enable_service" value="pickup" <?php checked($enable_service, 'pickup'); ?>> Pickup Only</label>
+ </p>
+ <button type="button" class="button button-primary next-step">Next</button>
+ </div>
+
+ <!-- Step 2 -->
+ <div class="rpress-setup-step" data-step="2" style="display:none;">
+ <h2>Step 2: Default Settings</h2>
+ <p>
+ <label><input type="radio" name="default_service" value="delivery" <?php checked($default_service, 'delivery'); ?>> Delivery</label><br>
+ <label><input type="radio" name="default_service" value="pickup" <?php checked($default_service, 'pickup'); ?>> Pickup</label>
+ </p>
+ <button type="button" class="button back-step">Back</button>
+ <button type="button" class="button button-primary next-step">Next</button>
+ </div>
+
+ <!-- Step 3 -->
+ <div class="rpress-setup-step" data-step="3" style="display:none;">
+ <h2>Step 3: Finish</h2>
+ <p>You're all set! Click below to save and complete setup.</p>
+ <button type="button" class="button back-step">Back</button>
+ <?php submit_button('Save & Finish Setup'); ?>
+ </div>
+ </form>
+ </div>
+ <?php
+ }
+
+ /**
+ * Reorder the RestroPress menu items in admin.
+ *
+ * @param int $menu_order Menu order.
+ * @return array
+ */
+ public function menu_order($menu_order)
+ {
+ // Initialize our custom order array.
+ $rpress_menu_order = array();
+ // Get the index of our custom separator.
+ $rpress_separator = array_search('separator-restropress', $menu_order, true);
+ // Get index of fooditem menu.
+ $rpress_fooditems = array_search('edit.php?post_type=fooditem', $menu_order, true);
+ //Remove the custom separator and fooditems menu so that we can re-order them
+ unset($menu_order[$rpress_separator]);
+ unset($menu_order[$rpress_fooditems]);
+ // Loop through menu order and do some rearranging.
+ foreach ($menu_order as $index => $item) {
+ if ('restropress' === $item) {
+ $rpress_menu_order[] = 'separator-restropress';
+ $rpress_menu_order[] = $item;
+ $rpress_menu_order[] = 'edit.php?post_type=fooditem';
+ } elseif (!in_array($item, array('separator-restropress'), true)) {
+ $rpress_menu_order[] = $item;
+ }
+ }
+ // Return order.
+ return $rpress_menu_order;
+ }
+}
+return new RP_Admin_Menus();
+
--- a/restropress/includes/admin/class-rp-addon-sorting.php
+++ b/restropress/includes/admin/class-rp-addon-sorting.php
@@ -1,285 +1,288 @@
-<?php
-// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
-// Exit if accessed directly
-if (!defined('ABSPATH'))
- exit;
-
-/**
- * Addon Category Sorting
- */
-class RP_Addon_Sorting
-{
-
- /**
- * Initializes the object instance
- */
- public function __construct()
- {
- add_action('init', array($this, 'front_end_order_terms'), 20);
- add_action('admin_head', array($this, 'admin_sort_categories'));
- add_action('wp_ajax_rp_update_addon_category_order', array($this, 'update_category_order'));
- add_action('wp_ajax_rp_get_addon_category_order', array($this, 'rp_get_category_order'));
- add_filter("get_terms", [$this, "rp_sort_addon_on_edit_texonomy_page"], 10, 3);
- }
-
- /**
- * Functionalities and Includes to enable Category Sorting
- *
- * @since 1.0
- * @return void
- */
- public function admin_sort_categories()
- {
- $screen = function_exists('get_current_screen') ? get_current_screen() : '';
-
- if (empty($screen)) {
- return;
- }
-
- if (!taxonomy_exists('addon_category')) {
- return;
- }
-
- $should_load = false;
-
- // Addon taxonomy list + edit term screens.
- if (in_array($screen->base, array('edit-tags', 'term'), true)) {
- $should_load = isset($screen->taxonomy) && 'addon_category' === $screen->taxonomy;
- }
-
- // Food item edit screens where addon groups are sortable.
- if ('post' === $screen->base) {
- $should_load = isset($screen->post_type) && 'fooditem' === $screen->post_type;
- }
-
- if (!$should_load) {
- return;
- }
-
- $this->enqueue_assets();
- $this->set_default_term_order('addon_category');
- add_filter('terms_clauses', array($this, 'set_tax_order'), 10, 3);
- }
-
-
-
- /**
- * Enqueueing assets for drag and drop sorting
- *
- * @since 1.0.0
- * @return void
- */
- public function enqueue_assets()
- {
- wp_enqueue_style('rp-addon-sorting', RP_PLUGIN_URL . "assets/css/admin-rp-addon-sorting.css", array(), '', 'all');
- wp_enqueue_script('rp-addon-sorting', RP_PLUGIN_URL . "assets/js/admin/admin-rp-addon-sorting.js", array('jquery-ui-core', 'jquery-ui-sortable'), time(), true);
- $food_item_id = isset($_GET['post']) ? absint(wp_unslash($_GET['post'])) : 0;
-
- wp_localize_script(
- 'rp-addon-sorting',
- 'rp_addon_sorting_data',
- array(
- 'preloader_url' => esc_url(admin_url('images/wpspin_light.gif')),
- 'term_order_nonce' => wp_create_nonce('term_order_nonce'),
- 'paged' => isset($_GET['paged']) ? absint(wp_unslash($_GET['paged'])) : 0,
- 'per_page_id' => "edit_addon_category_per_page",
- 'fooditem_id' => $food_item_id,
- 'is_variable_fooditem' => rpress_has_variable_prices($food_item_id),
- 'screen_taxonomy' => isset($_GET['taxonomy']) ? sanitize_key(wp_unslash($_GET['taxonomy'])) : '',
- )
- );
- }
-
- /**
- * Setting a default term order if the drag and drop
- * is not done yet
- *
- * @since 1.0.0
- * @return void
- */
- public function set_default_term_order($tax_slug)
- {
- $terms = get_terms(array(
- 'taxonomy' => $tax_slug,
- 'hide_empty' => false,
- ));
-
- if (is_wp_error($terms)) {
- return;
- }
-
- $order = $this->get_max_taxonomy_order($tax_slug);
- foreach ($terms as $term) {
- if (!get_term_meta($term->term_id, 'addon_position', true)) {
- update_term_meta($term->term_id, 'addon_position', $order);
- $order++;
- }
- }
- }
-
- /**
- * Get category order via AJAX
- *
- * @return void
- */
- function rp_get_category_order()
- {
- if (!check_ajax_referer('term_order_nonce', 'term_order_nonce', false)) {
- wp_send_json_error();
- }
- $fooditem_id = filter_var(wp_unslash($_POST['fooditem_id']), FILTER_SANITIZE_NUMBER_INT);
- $addon_cat_terms = get_terms(array(
- 'taxonomy' => 'addon_category',
- 'orderby' => 'name',
- 'order' => 'ASC',
- 'hide_empty' => false,
- ));
-
- if (is_wp_error($addon_cat_terms)) {
- wp_send_json_error();
- }
-
- $return_array = [];
- foreach ($addon_cat_terms as $term_key => $addon_cat_term) {
- $return_array[$addon_cat_term->term_id] = (int) get_term_meta($addon_cat_term->term_id, 'addon_position', true);
- }
-
- wp_send_json_success($return_array);
- wp_die();
- }
-
- /**
- * Get the maximum tax_position for categories
- *
- * @since 1.0.0
- */
- private function get_max_taxonomy_order($tax_slug)
- {
- global $wpdb;
- $max_term_order = $wpdb->get_col(
- $wpdb->prepare(
- "SELECT MAX( CAST( tm.meta_value AS UNSIGNED ) )
- FROM $wpdb->terms t
- JOIN $wpdb->term_taxonomy tt ON t.term_id = tt.term_id AND tt.taxonomy = '%s'
- JOIN $wpdb->termmeta tm ON tm.term_id = t.term_id WHERE tm.meta_key = 'tax_position'",
- $tax_slug
- )
- );
- $max_term_order = is_array($max_term_order) ? current($max_term_order) : 0;
- return (int) $max_term_order === 0 || empty($max_term_order) ? 1 : (int) $max_term_order + 1;
- }
-
- /**
- * Create custom help tab
- *
- * @since 1.0.0
- * @return void
- */
- public function custom_help_tab()
- {
- $screen = get_current_screen();
- $screen->add_help_tab(
- array(
- 'id' => 'rp_addon_sorting_help_tab',
- 'title' => __('Add-on Group Ordering', 'restropress'),
- 'content' => '<p>' . __('To reposition an add-on group in the list, simply drag & drop it into the desired position. Each time you reposition a group, the data will update in the database and on the front end of your site.', 'restropress') . '</p>',
- )
- );
- }
-
- /**
- * Re-Order the taxonomies based on the tax_position value
- *
- * @param array $pieces Array of SQL query clauses
- * @param array $taxonomies Array of taxonomy names
- * @param array $args Array of term query args
- */
- public function set_tax_order($pieces, $taxonomies, $args)
- {
- foreach ($taxonomies as $taxonomy) {
- if ($taxonomy === 'addon_category') {
- global $wpdb;
- $join_statement = " LEFT JOIN $wpdb->termmeta AS term_meta ON t.term_id = term_meta.term_id AND term_meta.meta_key = 'tax_position'";
- if (!$this->does_substring_exist($pieces['join'], $join_statement)) {
- $pieces['join'] .= $join_statement;
- }
- $pieces['orderby'] = 'ORDER BY CAST( term_meta.meta_value AS UNSIGNED )';
- }
- }
- return $pieces;
- }
-
- /**
- * Check if a substring exists inside a string
- *
- * @param string $string The main string (haystack) we're searching in
- * @param string $substring The substring we're searching for
- *
- * @return bool True if substring exists, else false
- */
- protected function does_substring_exist($string, $substring)
- {
- return strstr($string, $substring) !== false;
- }
-
- /**
- * Ajax callback function to update new sorting order
- *
- *
Proof of Concept (PHP)
NOTICE :
This proof-of-concept is provided for educational and authorized security research purposes only.
You may not use this code against any system, application, or network without explicit prior authorization from the system owner.
Unauthorized access, testing, or interference with systems may violate applicable laws and regulations in your jurisdiction.
This code is intended solely to illustrate the nature of a publicly disclosed vulnerability in a controlled environment and may be incomplete, unsafe, or unsuitable for real-world use.
By accessing or using this information, you acknowledge that you are solely responsible for your actions and compliance with applicable laws.
<?php
// ==========================================================================
// Atomic Edge CVE Research | https://atomicedge.io
// Copyright (c) Atomic Edge. All rights reserved.
//
// LEGAL DISCLAIMER:
// This proof-of-concept is provided for authorized security testing and
// educational purposes only. Use of this code against systems without
// explicit written permission from the system owner is prohibited and may
// violate applicable laws including the Computer Fraud and Abuse Act (USA),
// Criminal Code s.342.1 (Canada), and the EU NIS2 Directive / national
// computer misuse statutes. This code is provided "AS IS" without warranty
// of any kind. Atomic Edge and its authors accept no liability for misuse,
// damages, or legal consequences arising from the use of this code. You are
// solely responsible for ensuring compliance with all applicable laws in
// your jurisdiction before use.
// ==========================================================================
// Atomic Edge CVE Research - Proof of Conceptn// CVE-2026-125784 - RestroPress – Online Food Ordering System <= 3.4.11 - Cross-Site Request Forgeryn// This PoC demonstrates a CSRF attack against an unspecified endpoint.n// The actual endpoint and parameters are unknown due to the truncated diff.n// Replace the $target_url and $payload with the correct values.nn$target_url = 'http://example.com/wp-admin/admin-ajax.php';n$payload = [n 'action' => 'vulnerable_action', // Replace with actual actionn 'param1' => 'value1', // Replace with actual parametersn // Add other required parametersn];nn// Initialize cURLn$ch = curl_init();nn// Set the URLncurl_setopt($ch, CURLOPT_URL, $target_url);nn// Set POST methodncurl_setopt($ch, CURLOPT_POST, true);nn// Set POST fieldsncurl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));nn// Return the response instead of outputtingncurl_setopt($ch, CURLOPT_RETURNTRANSFER, true);nn// Execute the requestn$response = curl_exec($ch);nn// Check for errorsnif (curl_errno($ch)) {n echo 'Error: ' . curl_error($ch);n} else {n echo 'Request sent. Response: ' . $response;n}nn// Close cURLncurl_close($ch);nn// Note: This PoC does not include nonce because the vulnerability is missing nonce validation.n// In a real attack, the administrator would need to be authenticated (e.g., via cookies).n// The attacker would host a page that automatically submits this form.
Frequently Asked Questions
How Atomic Edge Works
Simple Setup. Powerful Security.
Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.
Trusted by Developers & Organizations






