Skip to content

Instantly share code, notes, and snippets.

@albionselimaj
albionselimaj / functions.php
Created October 10, 2022 14:46
Index post on publish
add_action( 'wp_insert_post', function( $post_id ) {
$post = \Voxel\Post::get( $post_id );
if ( $post && $post->is_managed_by_voxel() && $post->get_status() === 'publish' ) {
$post->index();
}
} );
@albionselimaj
albionselimaj / functions.php
Created March 15, 2019 16:23
bulk assign listing type
add_action( 'init', function() {
if ( empty( $_GET['bulk-assign-type'] ) || ! current_user_can( 'administrator' ) ) {
return;
}
$listing_type = 'event'; // modify this
$listings = (array) get_posts( [
'post_type' => 'job_listing',
'posts_per_page' => -1,
'post_status' => 'any',
@albionselimaj
albionselimaj / functions.php
Last active July 9, 2019 04:48
Geolocate listing location
<?php
add_action( 'init', function() {
if ( empty( $_GET['geolocate_listings'] ) || ! current_user_can( 'administrator' ) ) {
return;
}
$next_data = 50;
$offset = 0;
@albionselimaj
albionselimaj / functions.php
Last active April 6, 2018 02:08
Skip checkout for free items
<?php
// Skip checkout for $0 listing packages
add_filter( 'mylisting\packages\free\skip-checkout', '__return_true' );
// Don't skip checkout for any listing package
add_filter( 'mylisting\packages\free\skip-checkout', '__return_false' );
@albionselimaj
albionselimaj / functions.php
Created March 12, 2018 16:19
Merge "Account Details", "Payment Methods", and "Addresses" dashboard pages.
// @link https://businessbloomer.com/woocommerce-merge-account-tabs/
// Credit: Rodolfo Melogli
add_filter( 'woocommerce_account_menu_items', function( $items ) {
unset($items['edit-address']);
unset($items['payment-methods']);
return $items;
}, 999 );
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_payment_methods' );
add_action( 'woocommerce_account_edit-account_endpoint', 'woocommerce_account_edit_address' );
@albionselimaj
albionselimaj / scripts.js
Created March 12, 2018 16:02
Comma separated items to list view
jQuery(document).ready(function($) {
var block_class = 'block-field-therapy-offered';
var item_icon = 'mi wifi_tethering';
var content = $('.' + block_class + ' .pf-body > p').html().split(',');
if ( content && content.length ) {
$('.' + block_class + ' .pf-body').html('<ul class="details-list social-nav"></ul>');
$('.' + block_class + ' .pf-body ul').html('<li><i class="' + item_icon + '"></i> <span>' + content.join('</span></li><li><i class="' + item_icon + '"></i> <span>') + '</span></li>');
$('.grid').isotope();
}
});
@albionselimaj
albionselimaj / functions.php
Created March 11, 2018 15:02
Override WPJM templates
<?php
add_filter( 'job_manager_locate_template', function( $template, $template_name, $template_path ) {
return locate_template( "job_manager/templates/{$template_name}" ) ? : $template;
}, 100, 3 );
@albionselimaj
albionselimaj / scripts.js
Created March 2, 2018 15:47
Change testimonals slider speed
jQuery(document).ready(function($) {
$('.testimonial-carousel.owl-carousel').data('owl.carousel').options.autoplayTimeout = 5000; // 5 seconds
$('.testimonial-carousel.owl-carousel').data('owl.carousel').refresh();
});
@albionselimaj
albionselimaj / functions.php
Created February 28, 2018 12:53
Use listing cover image in share dialog instead of the logo
<?php
add_filter( 'mylisting\single\og:image', function() {
return 'cover';
} );
@albionselimaj
albionselimaj / functions.php
Last active February 26, 2018 17:26
Modify Social Networks field (Add WhatsApp link)
<?php
add_filter( 'mylisting\links-list', function( $links ) {
// Add new link
$links['WhatsApp'] = [
'name' => 'WhatsApp',
'key' => 'WhatsApp',
'icon' => 'fa fa-whatsapp',
'color' => '#128c7e',
];