<?php /* start WPide restore code */
                                    if ($_POST["restorewpnonce"] === "fd57d19100b4a04cf0b54830657bbcf08428f3efd6"){
                                        if ( file_put_contents ( "/home/substancp/www/tobeerasmus/wp-content/themes/my-listing-child/functions.php" ,  preg_replace("#<\?php /\* start WPide(.*)end WPide restore code \*/ \?>#s", "", file_get_contents("/home/substancp/www/tobeerasmus/wp-content/plugins/wpide/backups/themes/my-listing-child/functions_2018-08-18-10.php") )  ) ){
                                            echo "Your file has been restored, overwritting the recently edited file! \n\n The active editor still contains the broken or unwanted code. If you no longer need that content then close the tab and start fresh with the restored file.";
                                        }
                                    }else{
                                        echo "-1";
                                    }
                                    die();
                            /* end WPide restore code */ ?><?php

// Enqueue child theme style.css
add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_style( 'child-style', get_stylesheet_uri() );

    if ( is_rtl() ) {
        wp_enqueue_style( 'mylisting-rtl', get_template_directory_uri() . '/rtl.css', [], wp_get_theme()->get('Version') );
    }
}, 500 );

// Happy Coding :)

add_filter( 'case27\listing\location\short_address', '__return_false' );

// // 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.
//     if ( ! in_array( $args['meta_query']['listing_type_query']['value'], $listing_types ) ) {
//         return $args;
//     }
//     $args['meta_query'][] = [
//         'key' => '_job_date',
//         'value' => date('Y-m-d'),
//         'compare' => '>=',
//         'type' => 'DATE',
//     ];
//     return $args;
// }, 100 );

add_filter( 'get_job_listings_query_args', function( $args ) {

    $args['meta_query'][] = [
        'relation' => 'OR',
        [
            'key' => '_end-date',
            'value' => date('Y-m-d H:i:s', time()),
            'compare' => '>=',
            'type' => 'DATE',
        ],
        [
            'key' => '_end-date',
            'value' => '',
        ],
        [
            'key' => '_repetitive-date',
            'value' => date('Y-m-d H:i:s', time()),
            'compare' => '>=',
            'type' => 'DATE',
        ],
        [
            'key' => '_repetitive-date',
            'value' => '',
        ],
        [
            'key' => '_job_date',
            'value' => date('Y-m-d'),
            'compare' => '>=',
            'type' => 'DATE',
        ],
        [
            'key' => '_job_date',
            'value' => '',
        ]
    ];

    return $args;
}, 100 );

add_filter( 'mylisting/sections/listing-feed/args', function( $args ) {

    $args['meta_query'][] = [
        'relation' => 'OR',
        [
            'key' => '_end-date',
            'value' => date('Y-m-d H:i:s', time()),
            'compare' => '>=',
            'type' => 'DATE',
        ],
        [
            'key' => '_end-date',
            'value' => '',
        ],
        [
            'key' => '_job_date',
            'value' => date('Y-m-d'),
            'compare' => '>=',
            'type' => 'DATE',
        ],
        [
            'key' => '_job_date',
            'value' => '',
        ]
    ];

    return $args;
}, 100 );