Skip to content

Instantly share code, notes, and snippets.

@albionselimaj
albionselimaj / functions.php
Created February 25, 2018 08:39
Enable Yoast SEO settings in single listing edit page
add_filter( 'mylisting/edit/hide_yoast_metabox', '__return_false' );
@albionselimaj
albionselimaj / functions.php
Last active July 26, 2018 01:03
Hide past events from Explore page
<?php
// Hide past events from Explore page.
add_filter( 'get_job_listings_query_args', function( $args ) {
$listing_types = ['event'];
if ( empty( $args['meta_query'] ) || empty( $args['meta_query']['listing_type_query'] ) ) {
return $args;
}
// Only apply to the listing types defined in $listing_types.
@albionselimaj
albionselimaj / functions.php
Created February 22, 2018 08:54
Add listing form: Choose a package after entering listing details
<?php
// Careful: Field visibility options will be ignored with this flow
add_filter( 'pre_option_job_manager_paid_listings_flow', function() {
return 'after';
}, 100 );
@albionselimaj
albionselimaj / functions.php
Created February 22, 2018 08:22
Hide "Add Listing" button for users with at least one active listing
<?php
add_action( 'wp_enqueue_scripts', function() {
if ( is_user_logged_in() && count_user_posts( get_current_user_id(), 'job_listing' ) >= 1 ) {
wp_add_inline_style( 'theme-styles-default', '.c27-main-header .header-button { display: none !important; }' );
}
}, 500 );
@albionselimaj
albionselimaj / functions.php
Created February 19, 2018 18:31
Display expired listings in search results
<?php
// Display Expired listings in search results
add_filter( 'get_job_listings_query_args', function( $args ) {
$args['post_status'] = [ 'publish', 'expired' ];
return $args;
}, 100 );
// Make Expired listings content public
add_action( 'init', function() {
@albionselimaj
albionselimaj / functions.php
Created February 17, 2018 19:17
Keep expired listings visible for SEO purposes
<?php
add_action( 'init', function() {
global $wp_post_statuses;
if ( is_array( $wp_post_statuses ) && ! empty( $wp_post_statuses['expired'] ) ) {
$wp_post_statuses['expired']->public = true;
}
}, 100 );
@albionselimaj
albionselimaj / scripts.js
Created February 17, 2018 18:09
Link to open sign-in modal
jQuery('a[href="#sign-in-modal"]').attr('data-toggle', 'modal').attr('data-target', '#sign-in-modal');
@albionselimaj
albionselimaj / functions.php
Created February 16, 2018 17:25
Google Maps Fix
// 1. Install and activate MyListing child theme
// 2. In WP Admin > Appearance > Editor, add the below code in functions.php file, at the end of the file.
add_action( 'wp_enqueue_scripts', function() {
wp_deregister_script( 'c27-google-maps' );
wp_enqueue_script( 'c27-google-maps', 'https://maps.googleapis.com/maps/api/js?key=' . c27()->get_setting('general_google_maps_api_key') . '&libraries=places&v=3', [], null, true );
}, 100 );
@albionselimaj
albionselimaj / functions.php
Created February 15, 2018 13:12
Change WooCommerce logout URL
<?php
add_action( 'template_redirect', function() {
global $wp;
if ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( get_permalink( $page_id ) );
exit;
}
} );
@albionselimaj
albionselimaj / functions.php
Created February 15, 2018 13:00
Add 'Product Type' column in User Dashboard > My Listings.
<?php
add_filter( 'job_manager_job_dashboard_columns', function( $columns ) {
$columns['product_type'] = 'Product Type';
return $columns;
} );
add_action( 'job_manager_job_dashboard_column_product_type', function( $listing ) {
if ( ! $listing->_package_id || ! ( $product = wc_get_product( $listing->_package_id ) ) ) {
return false;