Skip to content

Instantly share code, notes, and snippets.

View hivepress's full-sized avatar

HivePress hivepress

View GitHub Profile
@hivepress
hivepress / functions.php
Created July 17, 2024 23:59
Allow selecting multiple categories in the back-end listing form #hivepress #listings
<?php
add_filter(
'hivepress/v1/meta_boxes/listing_attributes',
function( $meta_box ) {
if ( isset( $meta_box['fields']['categories'] ) ) {
$meta_box['fields']['categories']['multiple'] = true;
unset( $meta_box['fields']['categories']['attributes']['data-multistep'] );
}
return $meta_box;
@hivepress
hivepress / functions.php
Last active July 16, 2024 11:29
Make the listing description field optional #hivepress #listings
<?php
add_filter(
'hivepress/v1/models/listing',
function( $form ) {
$form['fields']['description']['required'] = false;
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Created April 26, 2022 21:05
Change the attributes position (order) on the listing page #hivepress #listings
<?php
add_filter(
'hivepress/v1/templates/listing_view_page',
function( $template ) {
return hivepress()->helper->merge_trees(
$template,
[
'blocks' => [
'listing_attributes_secondary' => [
'_order' => 123,
@hivepress
hivepress / functions.php
Created April 26, 2022 17:18
Change the description field order in the listing edit form #hivepress #listings
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
$form['fields']['description']['_order'] = 123;
return $form;
},
1000
);
@hivepress
hivepress / functions.php
Created February 20, 2023 21:17
Make the location field required in the listing search form #hivepress #geolocation
<?php
add_filter(
'hivepress/v1/forms/listing_search',
function( $form ) {
if ( isset( $form['fields']['location'] ) ) {
$form['fields']['location']['required'] = true;
}
return $form;
},
@hivepress
hivepress / functions.php
Last active May 25, 2024 21:20
Add the Images field description in the listing form #hivepress #listings
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if(isset($form['fields']['images'])){
$form['fields']['images']['description'] = 'custom text here';
}
return $form;
},
@hivepress
hivepress / functions.php
Last active May 25, 2024 21:15
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
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 February 20, 2023 22:59
Add description to the price extras in the listing form #hivepress #marketplace
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['price_extras'] ) ) {
$form['fields']['price_extras']['description'] = 'custom text here';
}
return $form;
},
@hivepress
hivepress / functions.php
Created February 20, 2023 22:54
Add placeholder text to the listing description field #hivepress #listings
<?php
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
$form['fields']['description']['placeholder'] = 'custom text here';
return $form;
},
1000
);