Skip to content

Instantly share code, notes, and snippets.

View hivepress's full-sized avatar

HivePress hivepress

View GitHub Profile
@hivepress
hivepress / functions.php
Last active June 8, 2023 00:43
Add vendor profile link to the user account menu #hivepress #vendors
<?php
add_filter(
'hivepress/v1/menus/user_account',
function ( $menu ) {
if ( is_user_logged_in() ) {
$vendor_id = HivePress\Models\Vendor::query()->filter(
[
'user' => get_current_user_id(),
]
)->get_first_id();
@hivepress
hivepress / functions.php
Created July 23, 2022 23:36
Add vendor email link to the listing page #hivepress #listings
<?php
add_filter(
'hivepress/v1/templates/listing_view_page/blocks',
function( $blocks, $template ) {
$listing = $template->get_context( 'listing' );
if ( $listing ) {
$blocks = hivepress()->helper->merge_trees(
[ 'blocks' => $blocks ],
[
@hivepress
hivepress / functions.php
Created July 23, 2022 23:29
Make the profile description field required #hivepress #users
<?php
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
$form['fields']['description']['required'] = true;
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Last active July 26, 2023 17:21
Change the price display format for bookable listings #hivepress #listings #bookings
<?php
add_filter(
'hivepress/v1/models/listing/fields',
function( $fields, $model ) {
if ( isset( $fields['price'] ) ) {
$fields['price']['display_template'] = '%value% / day';
}
return $fields;
},
@hivepress
hivepress / functions.php
Created July 23, 2022 23:24
Restrict email domains for newly registered users #hivepress #users
<?php
add_filter(
'hivepress/v1/forms/user_register/errors',
function( $errors, $form ) {
if ( ! $errors ) {
$domain = hivepress()->helper->get_last_array_value( explode( '@', $form->get_value( 'email' ) ) );
if ( ! in_array(
$domain,
[
@hivepress
hivepress / style.css
Created July 23, 2022 23:17
Adjust the HivePress page width and padding #hivepress #themes
.hp-page {
max-width: 1234px;
padding: 32px;
}
@hivepress
hivepress / functions.php
Created July 23, 2022 23:16
Add custom CSS class to the HivePress page wrapper #hivepress #themes
<?php
add_filter(
'hivepress/v1/blocks/page',
function( $args ) {
return hivepress()->helper->merge_arrays(
$args,
[
'attributes' => [
'class' => [ 'my-custom-wrapper' ],
],
@hivepress
hivepress / functions.php
Created July 23, 2022 23:16
Add custom HTML wrapper to HivePress pages #hivepress #themes
<?php
add_filter(
'hivepress/v1/blocks/page',
function( $args ) {
return hivepress()->helper->merge_arrays(
$args,
[
'blocks' => [
'before' => [
'type' => 'content',
@hivepress
hivepress / header.php
Created July 23, 2022 23:15
Render HivePress menu in a third-party theme #hivepress #themes
<?php
if ( function_exists( 'hivepress' ) ) {
echo hivepress()->template->render_menu();
}
@hivepress
hivepress / functions.php
Created July 23, 2022 23:14
Declare HivePress support in a third-party theme #hivepress #themes
<?php
add_action(
'after_setup_theme',
function() {
add_theme_support( 'hivepress' );
}
);