Skip to content

Instantly share code, notes, and snippets.

Avatar

HivePress hivepress

View GitHub Profile
@hivepress
hivepress / functions.php
Last active Aug 10, 2022
Add vendor profile link to the user account menu #hivepress #vendors
View functions.php
<?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 Jul 23, 2022
Add vendor email link to the listing page #hivepress #listings
View functions.php
<?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 Jul 23, 2022
Make the profile description field required #hivepress #users
View functions.php
<?php
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
$form['fields']['description']['required'] = true;
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Last active Jul 28, 2022
Change the price display format for bookable listings #hivepress #listings #bookings
View functions.php
<?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 Jul 23, 2022
Restrict email domains for newly registered users #hivepress #users
View functions.php
<?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 Jul 23, 2022
Adjust the HivePress page width and padding #hivepress #themes
View style.css
.hp-page {
max-width: 1234px;
padding: 32px;
}
@hivepress
hivepress / functions.php
Created Jul 23, 2022
Add custom CSS class to the HivePress page wrapper #hivepress #themes
View functions.php
<?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 Jul 23, 2022
Add custom HTML wrapper to HivePress pages #hivepress #themes
View functions.php
<?php
add_filter(
'hivepress/v1/blocks/page',
function( $args ) {
return hivepress()->helper->merge_arrays(
$args,
[
'blocks' => [
'before' => [
'type' => 'content',
@hivepress
hivepress / header.php
Created Jul 23, 2022
Render HivePress menu in a third-party theme #hivepress #themes
View header.php
<?php
if ( function_exists( 'hivepress' ) ) {
echo hivepress()->template->render_menu();
}
@hivepress
hivepress / functions.php
Created Jul 23, 2022
Declare HivePress support in a third-party theme #hivepress #themes
View functions.php
<?php
add_action(
'after_setup_theme',
function() {
add_theme_support( 'hivepress' );
}
);