Function
Other 3.5.1 additions
On this page
- rp_addon_licence_problem()
- rpress_get_cart_item_count()
- rpress_stash_removed_cart_line()
- rpress_get_storefront_layout()
- rpress_account_hub_register_reorder_notice()
- rpress_reservation_redirect_legacy_account_link()
- rpress_reservation_account_has_bookings()
- rpress_reservation_account_section()
- rpress_reservation_register_table_booking_notice()
- rpress_setup_wizard_register_notice()
- rpress_get_service_date_options()
- rpress_service_time_label()
- rpress_get_service_time_options()
- rpress_get_next_order_status()
- rpress_payment_claim_key()
- rpress_read_payment_claim_row()
- rpress_get_payment_claim()
- rpress_claim_payment()
- rpress_release_payment_claim()
- rpress_is_payment_resumable()
- rpress_get_current_location_id()
- rpress_service_asap_allowed()
- rpress_legacy_shortcode_names()
- rpress_register_legacy_shortcodes()
- rpress_owns_legacy_shortcode()
- rpress_content_has_shortcode()
- rpress_replace_shortcode_name()
- rpress_migrate_legacy_shortcodes()
- rpress_legacy_shortcode_own_pages()
Other functions added to RestroPress core in 3.5.1.
30 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.
rp_addon_licence_problem()#
Checks whether any active RestroPress add-on has a missing or invalid license.
Compares classes listed in the add-ons feed with each add-on's <text_domain>_license_status option, returning true when one is empty or invalid. Used as the condition for the license notice in the admin notification center; it prints nothing.
rp_addon_licence_problem()
Returns bool
Note: Fetches the remote add-ons feed when it is not cached.
Internal. Defined in includes/admin/admin-actions.php, line 44.
rpress_get_cart_item_count()#
Returns the total number of items in the cart, adding up line quantities.
A line with no quantity counts as one. The total is filtered by rpress_cart_item_count. Use it for item counts such as cart badges; rpress_get_cart_quantity() is kept for existing code.
rpress_get_cart_item_count()
Returns int
Example
$count = rpress_get_cart_item_count();
printf( esc_html( _n( '%d item', '%d items', $count, 'restropress' ) ), (int) $count );
Defined in includes/cart/functions.php, line 52.
rpress_stash_removed_cart_line()#
Saves a cart line in the session before it is removed, so it can be restored.
Hooked to rpress_pre_remove_from_cart. Stores the line and the current time in the rpress_removed_cart_line session key for the undo AJAX handler, which accepts it for up to 10 minutes. Only the last removed line is kept.
rpress_stash_removed_cart_line( $cart_key )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$cart_key | int | Required | Cart key being removed. |
Internal. Defined in includes/cart/functions.php, line 91.
rpress_get_storefront_layout()#
Returns the storefront layout settings in effect.
Starts with the core defaults, applies the layout of each pack in the active pack's extends chain, then the sanitized storefront_layout option. The result is filtered by rpress_storefront_layout. It does not check whether the current page shows the menu; use rpress_storefront_layout_current() for that.
rpress_get_storefront_layout()
Returns array: Keys include masthead, nav_style, nav_media, columns, card_style, show_image, cart_style, item_style, rails and sections.
Example
$layout = rpress_get_storefront_layout();
$columns = isset( $layout['columns'] ) ? (int) $layout['columns'] : 1;
Defined in includes/class-rpress-template-packs.php, line 549.
rpress_account_hub_register_reorder_notice()#
Registers the reorder suggestion in the admin notification center.
Hooked to rpress_register_admin_notices. The notice is shown according to rpress_account_hub_show_reorder_notice().
rpress_account_hub_register_reorder_notice()
Internal. Defined in includes/features/account-hub/admin.php, line 50.
rpress_reservation_redirect_legacy_account_link()#
Redirects old reservation account links to the Reservations section URL.
Runs on template_redirect. Acts only on a customer dashboard page requested with rpress_account=reservations, and ends the request after redirecting.
rpress_reservation_redirect_legacy_account_link()
Internal. Defined in includes/features/reservations/account.php, line 65.
rpress_reservation_account_has_bookings()#
Checks whether the current user has any reservations.
Looks for published reservations matched by user ID or account email. The result is cached for the request; logged-out visitors get false.
rpress_reservation_account_has_bookings()
Returns bool
Example
if ( rpress_reservation_account_has_bookings() ) {
$url = rpress_account_url( 'reservations' );
}
Defined in includes/features/reservations/account.php, line 100.
rpress_reservation_account_section()#
Adds the Reservations section to the customer account sections.
Callback for the rpress_account_sections filter. The section is visible only to customers who have reservations.
rpress_reservation_account_section( $sections )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$sections | array | Required | Account sections. |
Returns array: Account sections including reservations.
Internal. Defined in includes/features/reservations/account.php, line 116.
rpress_reservation_register_table_booking_notice()#
Registers the Table Booking extension suggestion in the admin notification center.
Hooked to rpress_register_admin_notices. It shows only when reservations exist, Table Booking is not detected and the user has not dismissed it.
rpress_reservation_register_table_booking_notice()
Internal. Defined in includes/features/reservations/admin.php, line 303.
rpress_setup_wizard_register_notice()#
Registers the setup wizard suggestion in the admin notification center.
Hooked to rpress_register_admin_notices. It shows only while the wizard is not complete, the rpress_show_setup_wizard option is empty and the user has not dismissed it.
rpress_setup_wizard_register_notice()
Internal. Defined in includes/features/setup-wizard/loader.php, line 143.
rpress_get_service_date_options()#
Returns the date choices for the order popup's date dropdown.
When the service hours engine is enabled and pre-ordering is on for the service, lists the engine's available dates; the current date is always included if not empty. Filtered by rpress_service_date_options.
rpress_get_service_date_options( $service_type, $current_date )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$service_type | string | Required | Service type key, such as delivery or pickup. |
$current_date | string | Required | Date the popup opened on, in Y-m-d format. |
Returns array: Y-m-d date => formatted date label.
Example
$today = rpress_get_wp_now()->format( 'Y-m-d' );
$dates = rpress_get_service_date_options( 'delivery', $today );
Defined in includes/features/slot-engine/functions.php, line 215.
rpress_service_time_label()#
Returns the customer-facing label for an order time.
Passes the time through the rpress_service_time_label filter. Only the displayed label should change; the value saved with the order stays the plain time.
rpress_service_time_label( $time, $service_type = '', $service_date = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$time | string | Required | Time slot in the store's time format. |
$service_type | string | '' | Service type key, such as delivery or pickup. |
$service_date | string | '' | Service date in Y-m-d format, or empty when unknown. |
Returns string
Example
echo esc_html( rpress_service_time_label( '06:00 PM', 'delivery' ) );
Defined in includes/features/slot-engine/functions.php, line 244.
rpress_get_service_time_options()#
Returns the time choices for a service on a given date.
For today, when ASAP is enabled and slots exist, an ASAP option comes first; with the "ASAP only" setting it is the only option. Labels for timed slots use rpress_service_time_label(), and the list is filtered by rpress_service_time_options.
rpress_get_service_time_options( $service_type, $service_date )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$service_type | string | Required | Service type key, such as delivery or pickup. |
$service_date | string | Required | Service date in Y-m-d format. |
Returns array[]: List of arrays with value and label strings.
Example
$today = rpress_get_wp_now()->format( 'Y-m-d' );
foreach ( rpress_get_service_time_options( 'pickup', $today ) as $option ) {
printf( '<option value="%s">%s</option>', esc_attr( $option['value'] ), esc_html( $option['label'] ) );
}
Defined in includes/features/slot-engine/functions.php, line 259.
rpress_get_next_order_status()#
Returns the next fulfilment status for an order.
Follows the tracker steps: the delivery flow for delivery, and the pickup flow for any other service type. out_for_delivery is treated as transit, and it never returns cancelled. A computed result is filtered by rpress_next_order_status; the early returns for final or unknown statuses are not filtered. It does not change the order.
rpress_get_next_order_status( $status, $service_type = 'delivery' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$status | string | Required | Current order status key. |
$service_type | string | 'delivery' | Service type key, such as delivery or pickup. |
Returns string: Next status key, or an empty string when there is none.
Example
$next = rpress_get_next_order_status( 'ready', 'delivery' );
Defined in includes/payments/functions.php, line 1083.
rpress_payment_claim_key()#
Returns the option name that stores the claim for a payment.
rpress_payment_claim_key( $payment_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order (payment) ID. |
Returns string
Internal. Defined in includes/payments/resume-claim.php, line 53.
rpress_read_payment_claim_row()#
Reads a payment's claim row directly from the database.
Bypasses the options cache and returns the row even if the claim has expired. Use rpress_get_payment_claim() to check for a live claim.
rpress_read_payment_claim_row( $payment_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order (payment) ID. |
Returns array|false: owner, expires (Unix time) and raw (stored value), or false when there is no row.
Internal. Defined in includes/payments/resume-claim.php, line 64.
rpress_get_payment_claim()#
Returns the live claim on a payment.
rpress_get_payment_claim( $payment_id )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order (payment) ID. |
Returns array|false: owner (string) and expires (int Unix time), or false when unclaimed or expired.
Example
$claim = rpress_get_payment_claim( $payment_id );
if ( $claim ) {
// Another process may be working on this payment.
}
Defined in includes/payments/resume-claim.php, line 85.
rpress_claim_payment()#
Claims an expiring lock on a payment for one owner.
A gateway can call this before contacting its processor so that checkout does not resume and rewrite the same pending payment. It succeeds when there is no live claim or the same owner already holds it, in which case the expiry is renewed; expired claims are replaced. The claim is stored as a row in the options table.
rpress_claim_payment( $payment_id, $owner, $ttl = 300 )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order (payment) ID. |
$owner | string | Required | Owner identifier, such as the gateway ID. Any | characters are removed. |
$ttl | int | 300 | Lifetime in seconds, minimum 1. |
Returns bool: True if the owner holds the claim; false if another owner holds it or the arguments are empty.
Example
if ( rpress_claim_payment( $payment_id, 'my_gateway', 15 * MINUTE_IN_SECONDS ) ) {
// Contact the payment processor, then release when the payment is settled.
rpress_release_payment_claim( $payment_id, 'my_gateway' );
}
Note: The lock is re-entrant by owner string: two requests that use the same owner both get true. Use a per-request owner if they must exclude each other.
Defined in includes/payments/resume-claim.php, line 109.
rpress_release_payment_claim()#
Releases a payment claim held by the given owner.
Leaves claims held by other owners unchanged.
rpress_release_payment_claim( $payment_id, $owner )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment_id | int | Required | Order (payment) ID. |
$owner | string | Required | Owner passed to rpress_claim_payment(). |
Returns bool: True when this owner's claim row was removed.
Example
rpress_release_payment_claim( $payment_id, 'my_gateway' );
Defined in includes/payments/resume-claim.php, line 150.
rpress_is_payment_resumable()#
Checks whether checkout may resume and rewrite a pending payment.
Requires a payment whose is_recoverable() method returns true and which has no live claim other than the caller's own. If those checks pass, the rpress_can_resume_payment filter has the final say.
rpress_is_payment_resumable( $payment, $purchase_data = array(), $context = 'insert', $own_claim = '' )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$payment | RPRESS_Payment | Required | Payment object. Any other value returns false. |
$purchase_data | array | array() | Purchase data of the current checkout, passed to the filter. |
$context | string | 'insert' | purchase or insert, passed to the filter. |
$own_claim | string | '' | Claim owner held by the caller. |
Returns bool
Example
$payment = new RPRESS_Payment( $payment_id );
$can = rpress_is_payment_resumable( $payment );
Defined in includes/payments/resume-claim.php, line 175.
rpress_get_current_location_id()#
Returns the ID of the branch the customer is ordering from.
Reads the branch cookie, then default_location in the RestroPress settings, then in the rp_multi_location option. Filtered by rpress_current_location_id.
rpress_get_current_location_id()
Returns int: Multi-Location term ID, or 0.
Example
$location_id = rpress_get_current_location_id();
Note: The value can come from a cookie and is not validated against existing branches; do not use it for access control.
Defined in includes/rp-core-functions.php, line 321.
rpress_service_asap_allowed()#
Checks whether ASAP can be used as the service time for a date.
True only when the enable_asap_option setting is on and the date is empty or today in the site timezone.
rpress_service_asap_allowed( $service_date )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$service_date | string | Required | Service date in Y-m-d format. Empty counts as today. |
Returns bool
Example
$allowed = rpress_service_asap_allowed( rpress_get_wp_now()->format( 'Y-m-d' ) );
Defined in includes/rp-core-functions.php, line 1437.
rpress_legacy_shortcode_names()#
Returns the map of old RestroPress shortcode names to their new names.
Covers order_history, customer_dashboard, custom_forgot_password and foodsearch.
rpress_legacy_shortcode_names()
Returns array: Old name => new rpress_ name.
Defined in includes/shortcode-prefix.php, line 22.
rpress_register_legacy_shortcodes()#
Registers old shortcode names as aliases of the new ones.
Runs on init. A name is skipped when it is already registered or its new shortcode does not exist.
rpress_register_legacy_shortcodes()
Internal. Defined in includes/shortcode-prefix.php, line 36.
rpress_owns_legacy_shortcode()#
Checks whether an old shortcode name is currently registered as a RestroPress alias.
True only when the old and new names point to the same callback.
rpress_owns_legacy_shortcode( $old )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$old | string | Required | Old shortcode name. |
Returns bool
Example
if ( rpress_owns_legacy_shortcode( 'order_history' ) ) {
// [order_history] renders the RestroPress order history.
}
Defined in includes/shortcode-prefix.php, line 54.
rpress_content_has_shortcode()#
Checks whether content uses a RestroPress shortcode by its new or old name.
The old name counts only while it is registered as a RestroPress alias.
rpress_content_has_shortcode( $content, $new )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$content | string | Required | Post content. |
$new | string | Required | New shortcode name, without brackets. |
Returns bool
Example
$post = get_post();
if ( $post && rpress_content_has_shortcode( $post->post_content, 'rpress_customer_dashboard' ) ) {
// This is a customer dashboard page.
}
Defined in includes/shortcode-prefix.php, line 71.
rpress_replace_shortcode_name()#
Renames a shortcode's opening and closing tags in a string.
Only whole tag names are replaced, so longer names that start with the old one are left alone. It does not save anything.
rpress_replace_shortcode_name( $content, $old, $new )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$content | string | Required | Content to rewrite. |
$old | string | Required | Old shortcode name. |
$new | string | Required | New shortcode name. |
Returns string: Rewritten content.
Example
$updated = rpress_replace_shortcode_name( '[order_history]', 'order_history', 'rpress_order_history' );
Defined in includes/shortcode-prefix.php, line 94.
rpress_migrate_legacy_shortcodes()#
Rewrites old shortcode names in saved content, once per site.
Runs on init until the rpress_shortcode_prefix_migrated option is set. If the old name is RestroPress's or unregistered, all non-revision posts using it are updated; otherwise only pages RestroPress identifies as its own. Content is written directly to the database, without revisions or save_post.
rpress_migrate_legacy_shortcodes()
Internal. Defined in includes/shortcode-prefix.php, line 105.
rpress_legacy_shortcode_own_pages()#
Returns the page IDs RestroPress treats as its own for an old shortcode name.
Used by the migration when another plugin owns the name. Only order_history (the order_history_page option) and custom_forgot_password (the forgot-password page) have entries.
rpress_legacy_shortcode_own_pages( $old )
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$old | string | Required | Old shortcode name. |
Returns int[]: Page IDs; may be empty or contain 0.
Internal. Defined in includes/shortcode-prefix.php, line 150.
