Code Samples

Below you can find some useful code samples which use plugin’s WP filters and actions. Use them in functions.php file of your Child theme.

inventor_listing_detail_sections

If you want to change default order of listing sections at its detail page, you can use following code snippet. Notice that you can change sections of specific post type or modify input array directly if necessary.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
add_filter( 'inventor_listing_detail_sections', 'custom_detail_sections', 10, 2 );

function custom_detail_sections( $sections, $post_type ) {
    return array(
        'overview'      => esc_attr__( 'Details', 'inventor' ),
        'contact'       => esc_attr__( 'Contact', 'inventor' ),
        'location'      => esc_attr__( 'Location', 'inventor' ),
        'opening_hours' => esc_attr__( 'Opening Hours', 'inventor' ),
        'social'        => esc_attr__( 'Social connections', 'inventor' ),
        'description'   => esc_attr__( 'Description', 'inventor' ),
        'gallery'       => esc_attr__( 'Gallery', 'inventor' ),
        'video'         => esc_attr__( 'Video', 'inventor' ),
        'food_menu'     => esc_attr__( 'Meals And Drinks', 'inventor' ),
        'faq'           => esc_attr__( 'FAQ', 'inventor' ),
        'comments'      => null,
        'report'        => null
    );
}

inventor_metabox_social_networks

Using this filter you can modify predefined social networks either modifying input list or returning whole new array:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
add_filter( 'inventor_metabox_social_networks', 'custom_social_networks', 10, 2 );

function custom_social_networks( $social_networks, $post_type ) {
    return array(
        'facebook'          => 'Facebook',
        'twitter'           => 'Twitter',
        'instagram'         => 'Instagram',
        'youtube'           => 'YouTube',
        'linkedin'          => 'LinkedIn',
        'skype'             => 'Skype',
    );
}

inventor_submission_allowed_listing_post_types

Somebody may need to disable some of the listing post types for users at frontend submission, but want to keep them enabled for internal management in WP admin. It can be done:

1
2
3
4
5
add_filter( 'inventor_submission_allowed_listing_post_types', 'disable_on_frontend' );

function disable_on_frontend( $post_types ) {
    return array_diff( $post_types, ['hotel', 'car']);
}

inventor_submission_steps

By default, submission contains steps for every listing metabox. Each metabox has its unique key. Using this filter you can change order of submission steps or modify title and description of each metabox in the submission process. In the following example we changed the order and removed some steps:

1
2
3
4
5
6
7
8
9
add_filter( 'inventor_submission_steps', 'modify_submission_steps', 10, 2 );

function modify_submission_steps( $steps, $post_type ) {
    return array(
        'general' => $steps['general'],
        'contact' => $steps['contact'],
        'gallery' => $steps['gallery'],
    );
}

Keys of predefined metaboxes are: general, banner, gallery, video, location, price, contact, listing_category, opening_hours, social, faq, branding, color, date, time, date_interval, datetime_interval, time_interval, date_and_time_interval.

Note

Key of custom metaboxes is a metabox ID without listing_<post_type>_ prefix.

inventor_metabox_assigned

Listing type manager allows you to create custom post types, metaboxes and fields. But if you need to disable some metaboxes of predefined listing types, you can use code below:

1
2
3
4
5
6
7
8
9
add_filter( 'inventor_metabox_assigned', 'unassign_metabox', 10, 3 );

function unassign_metabox( $assigned, $metabox, $post_type ) {
    if( 'contact' == $metabox && $post_type == 'business' ) {
        return false;
    }

    return $assigned;
}

inventor_metabox_field_type

You can change field type of specific metabox field very easily. For example if you need to change location to multicheck instead of single select box, use this code snipet:

1
2
3
4
5
6
7
8
9
add_filter( 'inventor_metabox_field_type', 'multiple_locations', 10, 4 );

function multiple_locations( $field_type, $metabox_id, $field_id, $post_type ) {
    if( 'listing_locations' == $field_id ) {
        return 'taxonomy_multicheck_hierarchy';
    }

    return $field_type;
}

inventor_metabox_field_enabled

You can also disable any metabox field of specific listing type. For example if you need to disable street view in location metabox, use this code snippet:

1
2
3
4
5
6
7
8
9
add_filter( 'inventor_metabox_field_enabled', 'disable_street_view', 10, 4 );

function disable_street_view( $enabled, $metabox_id, $field_id, $post_type ) {
    if( 'listing_street_view' == $field_id ) {
        return false;
    }

    return $enabled;
}

inventor_metabox_field_name

If you need, you can change field name. For example code snippet below rename “Location” field to “Region”:

1
2
3
4
5
6
7
8
9
add_filter( 'inventor_metabox_field_name', 'rename_field', 10, 4 );

function rename_field( $name, $metabox_id, $field_id, $post_type ) {
    if( 'listing_locations' == $field_id ) {
        return __( 'Region', 'textdomain' );
    }

    return $name;
}