wpsl.php 4.19 KB
<?php
/**
 * Understrap emails
 *
 * @package Understrap
 */

// Exit if accessed directly.



add_filter( 'wpsl_frontend_meta_fields', 'custom_frontend_meta_fields' );

function custom_frontend_meta_fields( $store_fields ) {
    $store_fields['wpsl_first_name'] = array( 
        'name' => 'first_name',
        'type' => 'text'
    );
    $store_fields['wpsl_last_name'] = array( 
      'name' => 'last_name',
      'type' => 'text'
    );
    $store_fields['wpsl_email'] = array( 
        'name' => 'email',
        'type' => 'text'
    );
    $store_fields['wpsl_phone'] = array( 
        'name' => 'phone',
        'type' => 'text'
      );
    $store_fields['wpsl_ext'] = array( 
      'name' => 'ext',
      'type' => 'int'
    );
    $store_fields['wpsl_fp_id'] = array( 
        'name' => 'fp_id',
        'type' => 'text'
    );
    $store_fields['wpsl_designation'] = array( 
        'name' => 'designation',
        'type' => 'text'
    );
    $store_fields['wpsl_unit'] = array( 
      'name' => 'unit',
      'type' => 'text'
    );

    
    
    return $store_fields;
}

add_filter( 'wpsl_meta_box_fields', 'custom_meta_box_fields2' );

function custom_meta_box_fields2( $meta_fields ) {
    
    $meta_fields[__( 'Additional Information', 'wpsl' )] = array(
        'phone' => array(
            'label' => __( 'Tel', 'wpsl' )
        ),
        'ext' => array(
          'label' => __( 'Ext', 'wpsl' )
        ),
        'unit' => array(
            'label' => __( 'Unit', 'wpsl' )
        ),
        'email' => array(
            'label' => __( 'Email', 'wpsl' )
        ),
        'url' => array(
            'label' => __( 'Url', 'wpsl' )
        ),
        'first_name' => array(
            'label' => __( 'First Name', 'wpsl' )
        ),
        'last_name' => array(
          'label' => __( 'Last Name', 'wpsl' )
        ),
        'designation' => array(
            'label' => __( 'Designation', 'wpsl' )
        ),
        'fp_id' => array(
            'label' => __( 'FP ID', 'wpsl' )
        )
        
    );

    return $meta_fields;
}


add_filter('wpsl_templates', 'custom_templates');

function custom_templates($templates)
{

    $templates[] = array(
        'id' => 'store',
        'name' => 'Custom store template',
        'path' => get_stylesheet_directory() . '/' . 'wpsl-templates/store-listings-map-left.php',
    );


    return $templates;
}

add_filter('wpsl_listing_template', 'custom_listing_template');

function custom_listing_template()
{

    global $wpsl, $wpsl_settings;

    include( get_stylesheet_directory() . '/' . 'wpsl-templates/store-listings.php');    
   
    return $listing_template;
}

add_filter('wpsl_store_header_template', 'custom_store_header_template');

function custom_store_header_template()
{

    $header_template = '<% if ( wpslSettings.storeUrl == 1 && url ) { %>' . "\r\n";
    $header_template .= '<a href="<%= url %>" target="_blank" class="placelink"><%= store %></a>' . "\r\n";

    $header_template .= '<% } else { %>' . "\r\n";
    $header_template .= '<%= store %>' . "\r\n";
    $header_template .= '<% } %>';

    return $header_template;
}

add_filter( 'wpsl_info_window_template', 'custom_info_window_template' );

function custom_info_window_template() {


    include( get_stylesheet_directory() . '/' . 'wpsl-templates/store-custom_more_info.php');    

     
     return $info_window_template;

}


function delete_autoload_map_transient()
{
    global $wpdb;

    $option_names = $wpdb->get_results("SELECT option_name AS transient_name FROM " . $wpdb->options . " WHERE option_name LIKE ('\_transient\_wpsl\_autoload\_%')");

    if ($option_names) {
        foreach ($option_names as $option_name) {
            $transient_name = str_replace("_transient_", "", $option_name->transient_name);
            delete_transient($transient_name);
        }
    }
}


add_shortcode( 'count_stores', 'count_stores' );
function count_stores( ) {
    $count_pages = wp_count_posts( 'wpsl_stores' );
    return  ' <h2 class="find-number" id="find-number">'.$count_pages->publish.'</h2>' ;
}

	
add_action("wp_ajax_nopriv_send_planner_notice", "send_planner_notice");
add_action("wp_ajax_send_planner_notice", "send_planner_notice");




add_filter( 'wpsl_include_post_content', '__return_true' );