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 May 9, 2022 07:01
Change the listing URL slug (requires refreshing permalinks) #hivepress #listings
<?php
add_filter(
'hivepress/v1/post_types',
function( $args ) {
$args['listing']['rewrite']['slug'] = 'custom-slug-here';
return $args;
},
100
);
@hivepress
hivepress / functions.php
Last active September 2, 2024 15:16
Require uploading at least one image for listings #hivepress #listings
<?php
add_filter(
'hivepress/v1/forms/listing_update/errors',
function( $errors, $form ) {
$listing = $form->get_model();
if ( $listing && ! $listing->get_image__id() ) {
$errors[] = 'Please upload at least one image.';
}
@hivepress
hivepress / functions.php
Last active February 27, 2024 09:46
Change the maximum number of images per listing #hivepress #listings
<?php
add_filter(
'hivepress/v1/models/listing',
function( $model ) {
$model['fields']['images']['max_files'] = 123;
return $model;
},
100
);
@hivepress
hivepress / functions.php
Created April 26, 2022 11:00
Make attachments optional for marketplace listings #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['attachments'] ) ) {
$attributes['attachments']['edit_field']['required'] = false;
}
return $attributes;
},
@hivepress
hivepress / functions.php
Created April 26, 2022 11:03
Change the price display format for marketplace listings #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['price'] ) ) {
$attributes['price']['display_format'] = '%value% / item';
}
return $attributes;
},
@hivepress
hivepress / style.css
Created April 26, 2022 15:47
Hide the Add Listing (List a Service, List a Property) button #hivepress #listings
.hp-menu--site-header .hp-menu__item--listing-submit{
display: none;
}
@hivepress
hivepress / functions.php
Created April 26, 2022 15:52
Make the purchase note or booking note required #hivepress #marketplace #bookings
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if(isset($form['fields']['purchase_note'])){
$form['fields']['purchase_note']['required'] = true;
}
return $form;
},
@hivepress
hivepress / functions.php
Last active May 24, 2022 20:29
Set the minimum price for marketplace listings #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['price'] ) ) {
$attributes['price']['edit_field']['min_value'] = 123;
}
return $attributes;
},
@hivepress
hivepress / style.css
Created April 26, 2022 15:56
Hide the Post a Request button #hivepress #requests
.hp-menu--site-header .hp-menu__item--request-submit{
display: none;
}
@hivepress
hivepress / functions.php
Created April 26, 2022 15:58
Change the minimum password length for users #hivepress #users
<?php
add_filter(
'hivepress/v1/models/user',
function( $model ) {
$model['fields']['password']['min_length'] = 123;
return $model;
},
1000
);