Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search Search Results for '.val'

Viewing 10 results - 41 through 50 (of 70 total)
  • Author
    Search Results

  • Shaun Lippitt
    Participant

    Hi Trevor,

    Apologies for starting another thread about this!

    After going off to find how to reset the search through javascript, i saw that someone else has already asked about this before and used the code below to reset the search.

    I’ve added this to my page and it seems to be working like i wanted it to. However, the county dropdown isn’t working independently now.

    Can you help me?

    (function ( $ ) {
    	"use strict";
    	
    	jQuery(document).on("sf:ajaxstart", ".searchandfilter", function(){
    		
    	  var tax1 = jQuery('.sf-field-taxonomy-regions select').val();
    	  
    	  if(location.search.search('_sft_regions='+tax1) == -1) {
    		jQuery('.sf-field-taxonomy-counties select').val("");
    	  }
    	
    });
    }(jQuery));
    #95245

    robert stojanovic
    Participant

    <?php
    /**
    * Setup ClassiPost Child Theme textdomain.
    *
    * Declare textdomain for this child theme.
    * Translations can be filed in the /languages/ directory.
    */
    function classipost_theme_setup() {
    load_child_theme_textdomain( ‘classipost’, get_stylesheet_directory() . ‘/languages’ );

    /**
    * Add image sizes
    */
    add_theme_support( ‘post-thumbnails’ );
    add_image_size( ‘ad-thumb’, 75, 75, true );
    add_image_size( ‘ad-medium’, 450, 300, true );
    add_image_size( ‘ad-featured’, 500, 500, true );
    add_image_size( ‘ad-large’, 725, 490, true );
    }
    add_action( ‘after_setup_theme’, ‘classipost_theme_setup’ );

    /*
    * Load the Options Panel
    */

    define( ‘OPTIONS_FRAMEWORK_DIRECTORY’, get_stylesheet_directory_uri() . ‘/inc/’ );
    require_once dirname( __FILE__ ) . ‘/inc/options-framework.php’;

    // Loads options.php from child or parent theme
    $optionsfile = locate_template( ‘options.php’ );
    load_template( $optionsfile );

    add_action( ‘optionsframework_after’, ‘optionscheck_display_sidebar’ );
    function optionscheck_display_sidebar() { ?>
    <div id=”optionsframework-sidebar”>
    <div class=”metabox-holder”>
    <div class=”postbox”>
    <h3>ClassiPost Child Theme</h3>
    <div class=”inside”>
    <p>If you’ve reached this far, you probably bought this child theme and you’re looking to set it up for your own needs.</p>
    <p>Don’t forget to follow the installation steps and also to save these options for the first time.</p>
    <p>Feel free to look around and change these settings as you want.</p>
    <p>If you need general help regarding this child theme, or you think you found bugs, you can ask for support on the dedicated forum.</p>
    <p>NOTE: <i>I do not provide support for <u>custom development</u> of the Child Theme. I will generally answer such questions with guidance and even small code samples but do not expect me to do all your work.</i></p>
    </div>
    </div>
    </div>
    </div>
    <?php }

    /*
    * This function loads an additional CSS file for the options panel
    * which allows us to style the sidebar
    */

    if ( is_admin() ) {
    $of_page= ‘classipress_page_classipost-options’;
    add_action( “admin_print_styles-$of_page”, ‘optionsframework_custom_css’, 100);
    }

    function optionsframework_custom_css () {
    wp_enqueue_style(
    ‘optionsframework-custom-css’,
    get_stylesheet_directory_uri() .’/inc/css/options-custom.css’
    );
    }

    /*
    * This one shows/hides the location option when a radio box is clicked.
    */
    add_action( ‘optionsframework_custom_scripts’, ‘optionsframework_custom_scripts’ );
    function optionsframework_custom_scripts() {
    if (is_admin()) {
    ?>
    <script type=”text/javascript”>
    jQuery(document).ready(function($) {

    $(‘#section-classipost_custom_meta’).hide();
    $(‘input[name=classipost-child-theme\\[classipost_location\\]]’).change(function () { //use change event
    if (this.value == ‘custom_location_field’) { //check value if it is custom_location_field
    $(‘#section-classipost_custom_meta’).stop(true,true).show(500); //than show
    } else {
    $(‘#section-classipost_custom_meta’).stop(true,true).hide(500); //else hide
    }
    });
    });
    </script>
    <?php
    }
    }

    add_action(‘admin_init’,’optionscheck_change_santiziation’, 100);

    function optionscheck_change_santiziation() {
    remove_filter( ‘of_sanitize_textarea’, ‘of_sanitize_textarea’ );
    add_filter( ‘of_sanitize_textarea’, ‘of_sanitize_textarea_custom’ );
    }

    function of_sanitize_textarea_custom($input) {
    return $input;
    }

    function of_get_default( $option ) {
    $defaults = optionsframework_options();
    if ( isset( $defaults[$option][‘std’] ) ) {
    return $defaults[$option][‘std’];
    }
    return false; // default if no std is set
    }

    /* Convert hexdec color string to rgb(a) string */
    function hex2rgba($color, $opacity = false) {

    $default = ‘rgb(255,204,51)’;

    //Return default if no color provided
    if(empty($color))
    return $default;

    //Sanitize $color if “#” is provided
    if ($color[0] == ‘#’ ) {
    $color = substr( $color, 1 );
    }

    //Check if color has 6 or 3 characters and get values
    if (strlen($color) == 6) {
    $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
    } elseif ( strlen( $color ) == 3 ) {
    $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
    } else {
    return $default;
    }

    //Convert hexadec to rgb
    $rgb = array_map(‘hexdec’, $hex);

    //Check if opacity is set(rgba or rgb)
    if($opacity){
    if(abs($opacity) > 1)
    $opacity = 1.0;
    $output = ‘rgba(‘.implode(“,”,$rgb).’,’.$opacity.’)’;
    } else {
    $output = ‘rgb(‘.implode(“,”,$rgb).’)’;
    }

    //Return rgb(a) color string
    return $output;
    }

    /*
    * Theme options custom CSS
    */
    function classipost_inline_css(){
    $classipost_layout = of_get_option(‘col-layout’, of_get_default(‘col-layout’));
    $body_background = of_get_option(‘background_picker’, of_get_default(‘background_picker’ ));
    $header_image = of_get_option(‘header_image’, of_get_default(‘header_image’ ));
    $header_background = of_get_option(‘header_image’, of_get_default(‘header_image’ ));
    $header_menu_text_color = of_get_option(‘header_menu_text_color’, of_get_default(‘header_menu_text_color’ ));
    $header_text_color = of_get_option(‘header_text_color’, of_get_default(‘header_text_color’ ));
    $header_height = of_get_option(‘header_height’, of_get_default(‘header_height’ ));
    $color_searchbar = of_get_option(‘color_searchbar’, of_get_default(‘color_searchbar’ ));
    $color_link = of_get_option(‘color_link’, of_get_default(‘color_link’ ));
    $color_button = of_get_option(‘color_button’, of_get_default(‘color_button’ ));
    $color_topbar = of_get_option(‘color_topbar’, of_get_default(‘color_topbar’ ));
    $color_footer_menu = of_get_option(‘color_footer_menu’, of_get_default(‘color_footer_menu’ ));
    $color_footer = of_get_option(‘color_footer’, of_get_default(‘color_footer’ ));
    $custom_css = of_get_option(‘custom_css’, of_get_default(‘custom_css’ ));
    ?>
    <style type=”text/css”>
    <?php echo $classipost_layout; ?>

    <?php if (!empty( of_get_option(‘background_picker’) != of_get_default(‘background_picker’ ))) { ?>
    /* Dynamic Body Background Color or Image */
    body {
    background: <?php echo $body_background[‘color’] . ‘ url(‘ . $body_background[‘image’] . ‘) ‘ . $body_background[‘repeat’] . ‘ ‘ . $body_background[‘position’] . ‘ ‘ . $body_background[‘attachment’];?>;
    }
    <?php } ?>
    <?php if ( of_get_option(‘custom_header’, of_get_default(‘custom_header’ )) == 1 ) { ?>
    /* Dynamic Header Background Color or Image */

    @media
    screen and (min-width:768px){
    .header-image {
    background: <?php echo ‘linear-gradient(‘. hex2rgba($header_background[‘color’],0.2) .’,’. hex2rgba($header_background[‘color’],0.2) .’)’,’, url(‘ . $header_background[‘image’] . ‘) ‘ . $header_background[‘repeat’] . ‘ ‘ . $header_background[‘position’] . ‘ ‘ . $header_background[‘attachment’];?>;
    background-size: cover;
    height: <?php echo $header_height; ?>;
    margin-bottom: 15px;
    }
    <?php if (!empty( of_get_option(‘color_searchbar’) == of_get_default(‘color_searchbar’ ))) { ?>
    .main-header.header-image {
    border-top: 5px solid <?php echo $color_searchbar; ?>;
    }
    <?php } ?>

    <?php if ( of_get_option(‘header_position’, of_get_default(‘header_position’ )) == 1 && of_get_option(‘color_searchbar’) == of_get_default(‘color_searchbar’ )) {?>
    .header-image .search-wrap {
    padding-top: 10px;
    }
    <?php } ?>

    .header-message h1.header-title, .header-message .header-text {
    color: <?php echo $header_text_color; ?>;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.7));
    }
    .header-message {
    margin: 10px 10px 50px 10px;
    }

    .header-message .btn-lg {
    font-size: 24px;
    font-weight: 700;
    }

    #primary-menu.header-menu-home .navbar-nav>li>a {
    color: <?php echo $header_menu_text_color; ?>;
    }
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘color_topbar’) != of_get_default(‘color_topbar’ ))) { ?>
    /* Dynamic Top Bar Color */
    .top-header {
    background: <?php echo $color_topbar; ?>;
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘color_searchbar’) != of_get_default(‘color_searchbar’ ))) { ?>
    /* Dynamic Search Bar Color */
    #affix-menu.affix-top {
    background: <?php echo hex2rgba($color_searchbar, 0.3); ?>;
    }
    #affix-menu.affix {
    background: <?php echo hex2rgba($color_searchbar, 0.5); ?>;
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘color_link’) != of_get_default(‘color_link’ ))) { ?>
    /* Dynamic Links Color */
    a{
    color: <?php echo $color_link; ?>;
    }
    a:hover, a:focus {
    color: <?php echo $color_link; ?>;
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘color_button’) != of_get_default(‘color_button’ ))) { ?>
    /* Dynamic Button Color */
    .orangebutton {
    background-color: <?php echo $color_button; ?>;
    border-color: <?php echo $color_button; ?>;
    }
    .orangebutton:hover {
    background-color: <?php echo $color_button; ?>;
    border-color: <?php echo $color_button; ?>;
    }
    .btn_orange,
    .reports_form input[type=”submit”] {
    background-color: <?php echo $color_button; ?>;
    }
    .btn_orange:hover,
    .order-gateway input[type=”submit”]:hover,
    .reports_form input[type=”submit”]:hover {
    background-color: <?php echo $color_button; ?>;
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘color_footer_menu’) != of_get_default(‘color_footer_menu’ ))) { ?>
    /* Dynamic Footer Menu Color */
    .footer-nav-menu {
    background: <?php echo $color_footer_menu; ?>;
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘color_footer’) != of_get_default(‘color_footer’ ))) { ?>
    /* Dynamic Footer Background Color */
    .footer {
    background: <?php echo $color_footer; ?>;
    }
    <?php } ?>
    <?php if (!empty( of_get_option(‘custom_css’) != of_get_default(‘custom_css’ ))) { ?>
    /* Dynamic Custom CSS */
    <?php echo $custom_css; ?>
    <?php } ?>

    </style>
    <?php
    }
    add_action(‘wp_head’,’classipost_inline_css’);

    // Load different color stylesheet
    function options_stylesheets_alt_style() {
    if ( of_get_option( ‘stylesheet’, of_get_default(‘stylesheet’ ) ) ) {
    wp_enqueue_style( ‘options_stylesheets_alt_style’, of_get_option(‘stylesheet’, of_get_default(‘stylesheet’ )), array(), null );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘options_stylesheets_alt_style’, 100 );

    /**
    * Load ClassiPost custom scripts
    */
    function classipost_enqueue_scripts() {
    global $cp_options;
    // reload gmaps with geolocation support
    wp_deregister_script( ‘google-maps’ );
    $gmap_params = array(
    ‘language’ => $cp_options->gmaps_lang,
    ‘region’ => $cp_options->gmaps_region,
    ‘libraries’ => ‘places’
    );

    if ( $cp_options->api_key ) {
    $gmap_params[‘key’] = $cp_options->api_key;
    }

    $google_maps_url = ( is_ssl() ? ‘https’ : ‘http’ ) . ‘://maps.googleapis.com/maps/api/js’;
    $google_maps_url = add_query_arg( $gmap_params, $google_maps_url );
    $protocol = is_ssl() ? ‘https’ : ‘http’;
    wp_enqueue_script(‘bootstrap-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap.min.js’, false, ‘3.3.6’);
    wp_enqueue_script(‘bootstrap-select-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap-select.min.js’, false, ‘1.10.0’);
    wp_enqueue_script(‘bootstrap-dropdown-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap-hover-dropdown.min.js’, false, ‘2.2.1’);
    wp_enqueue_script(‘tabcollapse-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap-tabcollapse.js’, false, ‘1.0.0’);
    if ( is_single() ) {
    wp_enqueue_script(‘lightgallery-js’, get_stylesheet_directory_uri() . ‘/js/lightgallery/js/lightgallery-all.min.js’, false, ‘1.4.4’);
    wp_enqueue_script(‘mousewheel-js’, get_stylesheet_directory_uri() . ‘/js/jquery.mousewheel.min.js’, false, ‘3.1.12’);
    }
    wp_enqueue_script(‘owl-carousel-js’, get_stylesheet_directory_uri() . ‘/js/owl.carousel2.min.js’, false, ‘2.1.1’);
    if (of_get_option(‘infinitescroll’, of_get_default(‘infinitescroll’ )) == ‘infinite’) {
    wp_enqueue_script(‘infinitescroll’, get_stylesheet_directory_uri() . ‘/js/jquery.infinitescroll.min.js’, array(‘jquery’), ‘1.1’);
    }

    if ( is_page_template( ‘tpl-ads-home.php’ ) && of_get_option(‘custom_header’, of_get_default(‘custom_header’ )) == 1 ) {
    wp_enqueue_script(‘typed’, get_stylesheet_directory_uri() . ‘/js/typed.min.js’, array(‘jquery’), ‘1.1.4’);
    }
    wp_enqueue_script( ‘google-maps’, $google_maps_url, array( ‘jquery’ ), ‘3.0’ );
    if (of_get_option(‘classipost_location’, of_get_default(‘classipost_location’ )) == ‘city_geolocation’) {
    wp_enqueue_script(‘geotext-js’, get_stylesheet_directory_uri() . ‘/js/geotext.min.js’, false, ‘1.0.0’);
    }
    wp_enqueue_script(‘classipost-js’, get_stylesheet_directory_uri() . ‘/js/classipost.js’, false, ‘1.0.0’);

    // only load the general.js if available in child theme
    if ( file_exists( get_stylesheet_directory() . ‘/js/custom.js’ ) ) {
    wp_enqueue_script( ‘custom-js’, get_stylesheet_directory_uri() . ‘/js/custom.js’, array( ‘jquery’ ), ‘1.0’ );
    }
    }
    add_action( ‘wp_enqueue_scripts’, ‘classipost_enqueue_scripts’, 99 );

    /**
    * Enqueue both Parent and child theme stylesheets.
    * This makes sure that the child theme stylesheet is loaded after the parent sheet.
    */
    function classipost_enqueue_styles() {
    $protocol = is_ssl() ? ‘https’ : ‘http’;
    $parent_style = ‘at-main’;
    wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_style(‘bootstrap’, get_stylesheet_directory_uri() . ‘/js/assets/bootstrap.min.css’, false, ‘3.3.6’);
    wp_deregister_style( ‘font-awesome’);
    wp_register_style( ‘font-awesome’, get_stylesheet_directory_uri() . ‘/js/assets/font-awesome.min.css’, false, ‘4.6.3’ );
    wp_enqueue_style( ‘font-awesome’);
    wp_enqueue_style(‘bootstrap-select-css’, get_stylesheet_directory_uri() . ‘/js/assets/bootstrap-select.min.css’, false, ‘1.10.0’);
    wp_enqueue_style(‘owl-carousel’, get_stylesheet_directory_uri() . ‘/js/assets/owl.carousel.min.css’, false, ‘2.1.1’);
    wp_enqueue_style(‘owl-theme’, get_stylesheet_directory_uri() . ‘/js/assets/owl.theme.default.min.css’, false, ‘2.1.1’);
    if ( is_single() ) {
    wp_enqueue_style(‘lightgallery’, get_stylesheet_directory_uri() . ‘/js/lightgallery/css/lightgallery.min.css’, false, ‘1.4.4’);
    }
    wp_enqueue_style(‘classipost-main’, get_stylesheet_directory_uri() . ‘/style.css’, array( $parent_style ) );
    }
    add_action( ‘wp_enqueue_scripts’, ‘classipost_enqueue_styles’ );

    // Remove Classipress color stylesheets
    function classipost_dequeue_styles() {
    wp_dequeue_style( ‘at-color’);
    wp_dequeue_style( ‘open-sans’ );
    wp_dequeue_script( ‘tinynav’);
    wp_dequeue_script( ‘selectbox’);
    wp_dequeue_script( ‘jqueryeasing’);
    wp_dequeue_script( ‘jcarousellite’);
    wp_dequeue_script( ‘colorbox’ );
    }
    add_action( ‘wp_enqueue_scripts’, ‘classipost_dequeue_styles’, 99 );

    /**
    * Remove emoji
    */
    function disable_wp_emojicons() {

    // all actions related to emojis
    remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
    remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
    remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
    remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
    remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
    remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
    remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
    // filter to remove TinyMCE emojis
    add_filter( ‘tiny_mce_plugins’, ‘disable_emojicons_tinymce’ );
    // remove DNS prefetch
    add_filter( ’emoji_svg_url’, ‘__return_false’ );
    }
    add_action( ‘init’, ‘disable_wp_emojicons’ );

    function disable_emojicons_tinymce( $plugins ) {
    if ( is_array( $plugins ) ) {
    return array_diff( $plugins, array( ‘wpemoji’ ) );
    } else {
    return array();
    }
    }

    /**
    * Remove cp color customizer for now
    */
    function remove_color_customizer() {
    remove_action( ‘wp_head’, ‘_cp_customize_css’, 999 );
    remove_action( ‘customize_controls_enqueue_scripts’, ‘_cp_enqueue_customizer_color_previewer’ );
    remove_action( ‘customize_register’, ‘_cp_customize_color_scheme’ );
    //remove_action( ‘after_setup_theme’, ‘cp_custom_header_setup’ );
    remove_action( ‘customize_register’, ‘_cp_customize_site’ );
    remove_action( ‘customize_register’, ‘_cp_customize_footer’ );
    }
    add_action (‘init’, ‘remove_color_customizer’);

    /**
    * Register top menu navigation positioon
    */
    function classipost_register_top_menu() {
    register_nav_menu( ‘Top’, __( ‘Top Navigation’, ‘classipost’ ) );
    if ( !is_nav_menu( ‘Top’ )) {
    $menu_id = wp_create_nav_menu( ‘Top’ );
    $menu = array( ‘menu-item-type’ => ‘custom’, ‘menu-item-url’ => get_home_url(‘/’),’menu-item-title’ => ‘Home’ );
    wp_update_nav_menu_item( $menu_id, 0, $menu );
    }
    }
    add_action( ‘init’, ‘classipost_register_top_menu’ );

    /**
    *Register bootstrap navigation walker
    */
    require_once(get_stylesheet_directory().’/wp_bootstrap_navwalker.php’);

    /**
    * Displays ad thumbnail. Use in the loop.
    *
    * @return void
    */
    if ( ! function_exists( ‘cp_ad_loop_thumbnail’ ) ) :
    function cp_ad_loop_thumbnail() {
    global $post, $cp_options;

    // go see if any images are associated with the ad
    $image_id = cp_get_featured_image_id( $post->ID );

    // set the class based on if the hover preview option is set to “yes”
    $prevclass = ( $cp_options->ad_image_preview ) ? ‘preview’ : ‘nopreview’;

    if ( $image_id > 0 ) {

    // get 450×300 image size
    $adthumbarray = wp_get_attachment_image( $image_id, ‘ad-medium’ );

    // grab the large image for onhover preview
    $adlargearray = wp_get_attachment_image_src( $image_id, ‘ad-large’ );
    $img_large_url_raw = $adlargearray[0];

    // must be a v3.0.5+ created ad
    if ( $adthumbarray ) {
    echo ‘‘. $adthumbarray .’‘;

    // maybe a v3.0 legacy ad
    } else {
    $adthumblegarray = wp_get_attachment_image_src($image_id, ‘thumbnail’);
    $img_thumbleg_url_raw = $adthumblegarray[0];
    echo ‘‘. $adthumblegarray .’‘;
    }

    // no image so return the placeholder thumbnail
    } else {
    echo ‘‘;
    }

    }
    endif;

    /**
    * Displays ad thumbnail for featured ads. Use in the loop.
    *
    * @return void
    */
    if ( ! function_exists( ‘cp_ad_featured_thumbnail’ ) ) :
    function cp_ad_featured_thumbnail() {
    global $post, $cp_options;

    // go see if any images are associated with the ad
    $image_id = cp_get_featured_image_id( $post->ID );

    // set the class based on if the hover preview option is set to “yes”
    $prevclass = ( $cp_options->ad_image_preview ) ? ‘preview’ : ‘nopreview’;

    if ( $image_id > 0 ) {

    // get 500×500 image size
    $adthumbarray = wp_get_attachment_image( $image_id, ‘ad-featured’ );

    // grab the large image for onhover preview
    $adlargearray = wp_get_attachment_image_src( $image_id, ‘ad-large’ );
    $img_large_url_raw = $adlargearray[0];

    // must be a v3.0.5+ created ad
    if ( $adthumbarray ) {
    echo ‘‘. $adthumbarray .’‘;

    // maybe a v3.0 legacy ad
    } else {
    $adthumblegarray = wp_get_attachment_image_src($image_id, ‘thumbnail’);
    $img_thumbleg_url_raw = $adthumblegarray[0];
    echo ‘‘. $adthumblegarray .’‘;
    }

    // no image so return the placeholder thumbnail
    } else {
    echo ‘‘;
    }

    }
    endif;

    /**
    * Displays all the images and thumbnails for the single page ad with support for Owl Carousel 2.
    *
    * @param int $post_id (optional)
    * @param string $size (optional)
    * @param string $title (optional)
    *
    * @return void
    */
    if ( ! function_exists( ‘cp_get_image_url_single’ ) ) {
    function cp_get_image_url_single( $post_id = ”, $size = ”, $title = ” ) {

    $attachment_query = array(
    ‘post_type’ => ‘attachment’,
    ‘post_status’ => null,
    ‘post_parent’ => $post_id,
    ‘order’ => ‘ASC’,
    ‘orderby’ => ‘ID’,
    ‘no_found_rows’ => true
    );

    $attachment_ids = get_post_meta( $post_id, ‘_app_media’, true );

    if ( ! empty( $attachment_ids ) ) {
    $attachment_query = array_merge( $attachment_query, array(
    ‘post__in’ => $attachment_ids,
    ‘orderby’ => ‘post__in’
    ) );
    }

    // go see if any images are associated with the ad
    $images = get_children( $attachment_query );
    $image_count = cp_count_ad_images($post_id);
    $i = 1;
    if ( $images ) {
    foreach ( $images as $image ) {
    $alt = get_post_meta( $image->ID, ‘_wp_attachment_image_alt’, true );
    if ( empty( $alt ) ) {
    $alt = $title . ‘ – ‘ . __( ‘Image ‘, APP_TD ) . $i;
    }
    $iarray = wp_get_attachment_image_src( $image->ID, $size, $icon = false );
    $farray = wp_get_attachment_image_src( $image->ID, ‘full’, $icon = false );
    //$image_count = cp_count_ad_images($post_id);
    if ( $image_count > 1 ) {
    $tarray = wp_get_attachment_image_src( $image->ID, ‘ad-thumb’, $icon = false );
    echo ‘<div class=”ad-thumb” data-src=”‘. $farray[0] .'” data-thumb=”‘. $tarray[0] .'” data-dot=”“>'. $alt .'</div>’;
    }

    if ( $image_count == 1 ) {
    echo ‘<div class=”ad-thumb” data-src=”‘. $farray[0] .'”>'. $alt .'</div>’;
    }

    $i++;
    }
    }
    if ( $image_count < 1 ) {
    echo ‘<div></div>’;
    }
    }
    }

    add_action( ‘init’ , ‘classipost_remove_ad_actions’ );
    function classipost_remove_ad_actions() {
    remove_action( ‘appthemes_before_post_title’, ‘cp_ad_loop_price’ );
    remove_action( ‘appthemes_after_post_title’, ‘cp_ad_loop_meta’ );
    remove_action( ‘appthemes_after_post_content’, ‘cp_do_loop_stats’ );
    remove_action( ‘appthemes_after_blog_post_content’, ‘cp_do_loop_stats’ );
    remove_action(‘appthemes_after_blog_post_title’, ‘cp_blog_post_meta’);
    remove_action( ‘appthemes_advertise_content’, ‘cp_adbox_336x280’ );
    remove_action( ‘appthemes_after_loop’, ‘cp_single_ad_banner’ );
    // Replace them with own functions

    add_action( ‘appthemes_before_post_title’, ‘classipost_ad_loop_price’ );
    add_action( ‘cp_action_after_ad_details’, ‘classipost_ad_single_price’, 10, 3 );
    add_action( ‘appthemes_after_post_title’, ‘classipost_ad_loop_meta’ );
    add_action( ‘appthemes_after_post_content’, ‘classipost_do_loop_stats’ );
    add_action( ‘appthemes_after_blog_post_content’, ‘classipost_do_loop_stats’ );
    add_action(‘appthemes_after_blog_post_title’, ‘classipost_blog_post_meta’);
    add_action( ‘appthemes_before_post_content’, ‘cp_single_ad_banner’ );
    add_action( ‘appthemes_advertise_content’, ‘classipost_adbox_728x90’ );

    }

    /**
    * Displays 728 x 90 ad box on single page.
    * @since 3.3
    *
    * @return void
    */
    function classipost_adbox_728x90() {
    global $cp_options;

    if ( ! $cp_options->adcode_336x280_enable ) {
    return;
    }
    ?>
    <div class=”shadowblock_out”>
    <div class=”shadowblock px2″>
    <div class=”ablock”>
    <?php
    if ( ! empty( $cp_options->adcode_336x280 ) ) {
    echo stripslashes( $cp_options->adcode_336x280 );
    } elseif ( $cp_options->adcode_336x280_url ) {
    $img = html( ‘img’, array( ‘src’ => $cp_options->adcode_336x280_url, ‘border’ => ‘0’, ‘alt’ => ” ) );
    echo html( ‘a’, array( ‘href’ => $cp_options->adcode_336x280_dest, ‘target’ => ‘_blank’ ), $img );
    }
    ?>
    </div>
    </div>
    </div>
    <?php
    }

    /**
    * Displays 728 x 90 ad box on the home page under the slider.
    * @since 3.3
    *
    * @return void
    */
    function classipost_homepage_728x90() {
    global $cp_options;

    if ( ! $cp_options->adcode_468x60_enable ) {
    return;
    }

    ?>
    <div class=”shadowblock_out”>
    <div class=”shadowblock px2″>
    <div class=”ablock”>
    <?php

    if ( ! empty( $cp_options->adcode_468x60 ) ) {
    echo stripslashes( $cp_options->adcode_468x60 );
    } else {
    if ( ! $cp_options->adcode_468x60_url ) {
    $img = html( ‘img’, array( ‘src’ => get_template_directory_uri() . ‘/images/468×60-banner.jpg’, ‘width’ => ‘468’, ‘height’ => ’60’, ‘border’ => ‘0’, ‘alt’ => ‘Premium WordPress Themes – AppThemes’ ) );
    echo html( ‘a’, array( ‘href’ => ‘https://www.appthemes.com&#8217;, ‘target’ => ‘_blank’ ), $img );
    } else {
    $img = html( ‘img’, array( ‘src’ => $cp_options->adcode_468x60_url, ‘border’ => ‘0’, ‘alt’ => ” ) );
    echo html( ‘a’, array( ‘href’ => $cp_options->adcode_468x60_dest, ‘target’ => ‘_blank’ ), $img );
    }
    }

    ?>
    </div>
    </div>
    </div>
    <?php

    }

    /**
    * Adds the ad price field in the loop before the ad title.
    * @since 3.1.3
    *
    * @return void
    */
    function classipost_ad_loop_price() {
    global $post;
    $price = get_post_meta($post->ID, ‘cp_price’, true);
    if ( $post->post_type == ‘page’ || $post->post_type == ‘post’ || empty($price) || $price == 0 || is_singular( APP_POST_TYPE ))
    return;
    ?>
    <div class=”price-wrap”>
    <p class=”post-price”>
    <?php cp_get_price( $post->ID, ‘cp_price’ ); ?>
    </p>
    </div>
    <?php
    }

    function classipost_ad_single_price( $form_fields, $post, $location = ‘list’) {
    global $post;
    $price = get_post_meta($post->ID, ‘cp_price’, true);
    if ( $post->post_type == ‘page’ || $post->post_type == ‘post’ || empty($price) || $price == 0)
    return;

    if ( is_singular( APP_POST_TYPE ) && $location == ‘list’ ) { ?>
    <li id=”cp_price”><span><?php _e( ‘Price:’, APP_TD ); ?></span> <?php cp_get_price( $post->ID, ‘cp_price’ ); ?>
    <?php
    }
    }

    /**
    * Adds the ad meta in the loop after the ad title.
    * @since 3.1
    *
    * @return void
    */
    function classipost_ad_loop_meta() {
    global $post, $cp_options;
    if ( is_singular( APP_POST_TYPE ) )
    return;
    $classipost_meta = of_get_option(‘classipost_custom_meta’, of_get_default(‘classipost_custom_meta’ ));
    $custom_meta = get_post_meta($post->ID, $classipost_meta, true);
    $category_meta = get_the_term_list( $post->ID, APP_TAX_CAT, ”, ‘, ‘, ” );
    $category_location = get_the_terms( $post->ID, APP_TAX_CAT);
    if ($category_location && ! is_wp_error($category_location)) {
    foreach ($category_location as $term){
    $category_link = get_term_link($term, APP_TAX_CAT );
    }
    }
    ?>
    <p class=”item-meta”>
    <span class=”nowsp”><i class=”fa fa-folder-open”></i> <?php if ( $post->post_type == ‘post’ ) the_category(‘, ‘); else echo $category_meta; ?></span>
    <?php $classipost_author = get_the_author_meta(‘ID’);
    if ( is_user_online($classipost_author)) { ?>
    <span class=”nowsp” rel=”tooltip” data-placement=”top” data-original-title=” <?php printf (__( ‘%s is Online’, ‘classipost’ ), get_the_author_meta(‘display_name’)) ?> “><i class=”fa fa-user icon-pulse” style=”color:dimgray”></i> <?php the_author_posts_link(); ?></span>
    <?php } else { ?>
    <span class=”nowsp” rel=”tooltip” data-placement=”top” data-original-title=” <?php _e( ‘Last Login:’, APP_TD ); ?> <?php echo appthemes_get_last_login( get_the_author_meta(‘ID’) ); ?> “><i class=”fa fa-user”></i> <?php the_author_posts_link(); ?></span>
    <?php } ?>
    <span class=”nowsp”><i class=”fa fa-map-marker”></i> ?<?php if ($classipost_meta == ‘cp_city’) echo $classipost_meta; else echo $classipost_meta.'[]’; ?>=<?php echo $custom_meta;?>&sa=search&refine_search=yes” title=”<?php echo $custom_meta; ?>”> <?php echo $custom_meta; ?> </span>
    <span class=”nowsp”><i class=”fa fa-clock-o”></i> <?php echo appthemes_date_posted($post->post_date); ?></span>
    <?php if ( $cp_options->ad_stats_all && current_theme_supports( ‘app-stats’ ) ) { ?>
    <span class=”nowsp”><i class=”fa fa-signal”></i> <?php appthemes_stats_counter( $post->ID ); ?></span>
    <?php } ?>
    </p>
    <?php
    }

    // Post meta

    function classipost_blog_post_meta() {
    if ( is_page() ) return; // don’t do post-meta on pages
    global $post;
    ?>
    <p class=”post-meta”><span class=”nowsp”><i class=”fa fa-user fa-lg”></i> <?php the_author_posts_link(); ?></span> <span class=”nowsp”><i class=”fa fa-folder-open fa-lg”></i> <?php the_category(‘, ‘) ?></span> <span class=”nowsp”><i class=”fa fa-clock-o fa-lg”></i> <?php echo appthemes_date_posted( $post->post_date ); ?></span></p>
    <?php
    }

    function classipost_do_loop_stats() {
    global $post, $cp_options;

    if (( is_singular(‘post’) ) && $cp_options->ad_stats_all && current_theme_supports( ‘app-stats’ )) {
    ?>
    <p class=”stats”><i class=”fa fa-signal”></i>
    <?php appthemes_stats_counter( $post->ID ); ?>
    </p>
    <?php
    }
    }

    // Get meta values of all ads, used mainly for top search location bar
    function get_meta_values( $key = ”, $type = APP_POST_TYPE, $status = ‘publish’ ) {

    global $wpdb;

    if( empty( $key ) )
    return;

    $r = $wpdb->get_col( $wpdb->prepare( ”
    SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm
    LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id
    WHERE pm.meta_key = ‘%s’
    AND p.post_status = ‘%s’
    AND p.post_type = ‘%s’
    ORDER BY meta_value ASC
    “, $key, $status, $type ) );

    return $r;
    }

    // Update user online status
    function update_online_users_status(){

    if(is_user_logged_in()){

    // get the online users list
    if(($logged_in_users = get_transient(‘users_online’)) === false) $logged_in_users = array();

    $current_user = wp_get_current_user();
    $current_user = $current_user->ID;
    $current_time = current_time(‘timestamp’);

    if(!isset($logged_in_users[$current_user]) || ($logged_in_users[$current_user] < ($current_time – (15 * 60)))){
    $logged_in_users[$current_user] = $current_time;
    set_transient(‘users_online’, $logged_in_users, 30 * 60);
    }
    }
    }
    add_action(‘wp’, ‘update_online_users_status’);

    function is_user_online($user_id) {
    global $wpdb;
    // get the online users list
    $logged_in_users = get_transient(‘users_online’);

    // online, if (s)he is in the list and last activity was less than 15 minutes ago
    return isset($logged_in_users[$user_id]) && ($logged_in_users[$user_id] > (current_time(‘timestamp’) – (15 * 60)));
    }

    // Unregister the footer sidebar
    function remove_footer_sidebar(){
    unregister_sidebar( ‘sidebar_footer’ );
    }
    add_action( ‘widgets_init’, ‘remove_footer_sidebar’ );

    function classipost_register_sidebars() {
    // Footer
    $footer_columns = of_get_option(‘footer_columns’, of_get_default(‘footer_columns’ ));
    register_sidebar( array(
    ‘name’ => __( ‘Footer’, APP_TD ),
    ‘id’ => ‘sidebar_footer’,
    ‘description’ => __( ‘This is your ClassiPress footer. You can have ANY number of widgets which will display in the footer from left to right.’, APP_TD ),
    ‘before_widget’ => ‘<div class=”footer-widget ‘ . $footer_columns . ‘ %2$s” id=”%1$s”>’,
    ‘after_widget’ => ‘</div><!– /footer-widget –>’,
    ‘before_title’ => ‘<h2 class=”dotted”>’,
    ‘after_title’ => ‘</h2>’,
    ) );
    }
    add_action( ‘widgets_init’, ‘classipost_register_sidebars’, 11 );

    //Create bootstrap badges for categories within sidebar
    function classipost_cat_count($links) {
    $links = str_replace(‘ (‘, ‘ <span class=”badge badge-primary”>’, $links);
    $links = str_replace(‘)’, ‘</span>’, $links);
    return $links;
    }
    add_filter(‘wp_list_categories’, ‘classipost_cat_count’);

    //Stick featured ads to the top on category and search pages
    class StickyAds {
    public function __construct() {
    add_filter(‘posts_orderby’, array($this, ‘_hookPostsOrderBy’), 11, 2);
    }

    public function _hookPostsOrderBy($orderBy, $query) {
    global $wpdb;
    if ( is_tax(‘ad_cat’) || is_search() && !$query->query_vars[‘ignore_sticky_posts’]) {
    $stickyPosts = get_option(‘sticky_posts’);
    if (is_array($stickyPosts) && !empty($stickyPosts)) {
    $sticky = ‘(‘ . $wpdb->posts . ‘.ID IN (‘ .
    implode(‘,’, $stickyPosts) . ‘)) DESC’;
    $orderBy= empty($orderBy) ? $sticky : $sticky . ‘,’ . $orderBy;

    add_filter(
    ‘pre_option_sticky_posts’, array($this, ‘_hookOptionStickyPosts’)
    );
    }
    }
    return $orderBy;
    }

    public function _hookOptionStickyPosts($option) {
    remove_filter(‘pre_option_sticky_posts’, array($this, ‘_hookOptionStickyPosts’)
    );
    return array();
    }
    }

    $stickyads = new StickyAds();
    // End sticky ads

    function bootstrap_tabs_js() {
    if (is_home() || is_front_page()) {
    $active_tab = of_get_option(‘home_tab’, of_get_default(‘home_tab’ ));
    } else {
    $active_tab = 0;
    }
    ?>
    <script>
    // Save current tab or pill active state in the local storage
    jQuery(document).ready(function ($) {
    var json, tabsState;
    $(‘a[data-toggle=”pill”], a[data-toggle=”tab”]’).on(‘shown.bs.tab’, function(e) {
    var href, json, parentId, tabsState;

    tabsState = localStorage.getItem(“tabs-state”);
    json = JSON.parse(tabsState || “{}”);
    parentId = $(e.target).parents(“ul.nav.nav-pills, ul.nav.nav-tabs”).attr(“id”);
    href = $(e.target).attr(‘href’);
    json[parentId] = href;

    return localStorage.setItem(“tabs-state”, JSON.stringify(json));
    });

    tabsState = localStorage.getItem(“tabs-state”);
    json = JSON.parse(tabsState || “{}”);

    $.each(json, function(containerId, href) {
    return $(‘#’ + containerId + ‘ a[href=”‘ + href + ‘”]’).tab(‘show’);
    });

    $(“ul.nav.nav-pills, ul.nav.nav-tabs”).each(function() {
    var $this = $(this);
    if (!json[$this.attr(“id”)]) {
    return $this.find(“a[data-toggle=tab]:eq(<?php echo $active_tab; ?>), a[data-toggle=pill]:eq(<?php echo $active_tab; ?>)”).tab(“show”);
    }

    $(‘.popular-tab.active, .random-tab.active’).trigger(“click”);

    });

    $(document).on(“shown.bs.collapse”, “.panel-collapse”, function (e) {
    $(‘.popular-tab, .random-tab’).trigger(“click”);
    });

    });

    // End pill or tab state

    /* Bootstrap Accordion.
    Turn the tabs into accordions on mobile devices.
    Scroll to top and animate the accordion.
    */
    jQuery(document).ready(function ($) {
    $(“[id^=tabby-]”).tabCollapse({
    tabsClass: ‘hidden-ms hidden-xs’,
    accordionClass: ‘visible-ms visible-xs’
    });

    $(“[id$=’-accordion’]”).on(‘shown.bs.collapse’, function () {
    var panel = $(this).find(‘.in’);
    $(‘html, body’).animate({
    scrollTop: panel.offset().top -57 }, 500);
    });
    });
    // End Accordion

    <?php if ( is_single() && ! of_get_option(‘remove_maps’, of_get_default(‘remove_maps’ )) == ‘1’ ) { ?>
    // Initialize the Google map upon click on tabs
    jQuery(document).ready(function($) {
    var clicked = false;

    if( $(“[id^=location]”).is(‘:visible’) ) {
    map_init();
    } else {
    jQuery(‘a[href^=”#location”]’).click( function() {
    if( !clicked ) {
    map_init();
    clicked = true;
    }
    });
    }
    });

    jQuery(document).on(“shown.bs.collapse shown.bs.tab”, “.panel-collapse, a[data-toggle=’tab’]”, function (e) {
    setTimeout(function(){
    google.maps.event.trigger(map,’resize’);
    }, 500);
    });
    <?php } ?>

    </script>
    <?php
    }

    add_action( ‘wp_footer’, ‘bootstrap_tabs_js’);

    //Begin infinite scroll
    function infinitescroll_js() {
    if (of_get_option(‘infinitescroll’, of_get_default(‘infinitescroll’ )) == ‘infinite’) {
    ?>
    <script>
    jQuery(document).ready(function($) {

    // infinite scroll
    $(“.loop-items”).infinitescroll({
    navSelector : “.paging”,
    // selector for the paged navigation (it will be hidden)
    nextSelector : “a.page-numbers”,
    // selector for the NEXT link (to page 2)
    itemSelector : “.wrap-item”,
    // selector for all items you’ll retrieve
    contentSelector : “.loop-items”,

    loading: {
    img: “<?php echo get_stylesheet_directory_uri(); ?>/images/ajax-loader.gif”,
    msgText: “<?php _e( ‘Loading next ads…’, ‘classipost’ ); ?>”,
    finishedMsg: “<?php _e( ‘This was the last ad from current category.’, ‘classipost’ ); ?>”
    }
    });

    });
    </script>
    <?php
    }
    }
    add_action( ‘wp_footer’, ‘infinitescroll_js’,100 );

    // Available colors top menu
    if ( class_exists(‘WPUserStylesheetSwitcher’) ) :
    function stylesheet_switch_menu ( $items, $args ) {
    if ( $args->theme_location == ‘Top’ ) {
    global $wpUserStylesheetSwitcher;
    $items = $wpUserStylesheetSwitcher->show_wp_user_stylesheet_switcher(array(‘list_title’=>’Colors: ‘, ‘show_list_title’=>’true’, ‘list_type’=>’icon’));
    }
    return $items;
    }
    add_filter( ‘wp_nav_menu_items’, ‘stylesheet_switch_menu’, 10, 2 );
    endif;

    // Enable the TinyMCE kitchen sink
    function enable_more_buttons($buttons) {
    $buttons[] = ‘fontselect’;
    $buttons[] = ‘fontsizeselect’;
    return $buttons;
    }
    add_filter(‘mce_buttons_2’, ‘enable_more_buttons’);

    function add_search_filter_before_page_loop() {
    do_shortcode(“[searchandfilter id=’3726′ action=’filter_next_query’]”);
    }

    add_action( ‘appthemes_before_blog_loop’, ‘add_search_filter_before_page_loop’ );

    #94874

    robert stojanovic
    Participant

    <?php

    /**

    * Setup ClassiPost Child Theme textdomain.

    *

    * Declare textdomain for this child theme.

    * Translations can be filed in the /languages/ directory.

    */

    function classipost_theme_setup() {

    load_child_theme_textdomain( ‘classipost’, get_stylesheet_directory() . ‘/languages’ );

    /**

    * Add image sizes

    */

    add_theme_support( ‘post-thumbnails’ );

    add_image_size( ‘ad-thumb’, 75, 75, true );

    add_image_size( ‘ad-medium’, 450, 300, true );

    add_image_size( ‘ad-featured’, 500, 500, true );

    add_image_size( ‘ad-large’, 725, 490, true );

    }

    add_action( ‘after_setup_theme’, ‘classipost_theme_setup’ );

    /*

    * Load the Options Panel

    */

    define( ‘OPTIONS_FRAMEWORK_DIRECTORY’, get_stylesheet_directory_uri() . ‘/inc/’ );

    require_once dirname( __FILE__ ) . ‘/inc/options-framework.php’;

    // Loads options.php from child or parent theme

    $optionsfile = locate_template( ‘options.php’ );

    load_template( $optionsfile );

    add_action( ‘optionsframework_after’, ‘optionscheck_display_sidebar’ );

    function optionscheck_display_sidebar() { ?>

    <div id=”optionsframework-sidebar”>

    <div class=”metabox-holder”>

    <div class=”postbox”>

    <h3>ClassiPost Child Theme</h3>

    <div class=”inside”>

    <p>If you’ve reached this far, you probably bought this child theme and you’re looking to set it up for your own needs.</p>

    <p>Don’t forget to follow the installation steps and also to save these options for the first time.</p>

    <p>Feel free to look around and change these settings as you want.</p>

    <p>If you need general help regarding this child theme, or you think you found bugs, you can ask for support on the dedicated forum.</p>

    <p>NOTE: <i>I do not provide support for <u>custom development</u> of the Child Theme. I will generally answer such questions with guidance and even small code samples but do not expect me to do all your work.</i></p>

    </div>

    </div>

    </div>

    </div>

    <?php }

    /*

    * This function loads an additional CSS file for the options panel

    * which allows us to style the sidebar

    */

    if ( is_admin() ) {

    $of_page= ‘classipress_page_classipost-options’;

    add_action( “admin_print_styles-$of_page”, ‘optionsframework_custom_css’, 100);

    }

    function optionsframework_custom_css () {

    wp_enqueue_style(

    ‘optionsframework-custom-css’,

    get_stylesheet_directory_uri() .’/inc/css/options-custom.css’

    );

    }

    /*

    * This one shows/hides the location option when a radio box is clicked.

    */

    add_action( ‘optionsframework_custom_scripts’, ‘optionsframework_custom_scripts’ );

    function optionsframework_custom_scripts() {

    if (is_admin()) {

    ?>

    <script type=”text/javascript”>

    jQuery(document).ready(function($) {

    $(‘#section-classipost_custom_meta’).hide();

    $(‘input[name=classipost-child-theme\\[classipost_location\\]]’).change(function () { //use change event

    if (this.value == ‘custom_location_field’) { //check value if it is custom_location_field

    $(‘#section-classipost_custom_meta’).stop(true,true).show(500); //than show

    } else {

    $(‘#section-classipost_custom_meta’).stop(true,true).hide(500); //else hide

    }

    });

    });

    </script>

    <?php

    }

    }

    add_action(‘admin_init’,’optionscheck_change_santiziation’, 100);

    function optionscheck_change_santiziation() {

    remove_filter( ‘of_sanitize_textarea’, ‘of_sanitize_textarea’ );

    add_filter( ‘of_sanitize_textarea’, ‘of_sanitize_textarea_custom’ );

    }

    function of_sanitize_textarea_custom($input) {

    return $input;

    }

    function of_get_default( $option ) {

    $defaults = optionsframework_options();

    if ( isset( $defaults[$option][‘std’] ) ) {

    return $defaults[$option][‘std’];

    }

    return false; // default if no std is set

    }

    /* Convert hexdec color string to rgb(a) string */

    function hex2rgba($color, $opacity = false) {

    $default = ‘rgb(255,204,51)’;

    //Return default if no color provided

    if(empty($color))

    return $default;

    //Sanitize $color if “#” is provided

    if ($color[0] == ‘#’ ) {

    $color = substr( $color, 1 );

    }

    //Check if color has 6 or 3 characters and get values

    if (strlen($color) == 6) {

    $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );

    } elseif ( strlen( $color ) == 3 ) {

    $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );

    } else {

    return $default;

    }

    //Convert hexadec to rgb

    $rgb = array_map(‘hexdec’, $hex);

    //Check if opacity is set(rgba or rgb)

    if($opacity){

    if(abs($opacity) > 1)

    $opacity = 1.0;

    $output = ‘rgba(‘.implode(“,”,$rgb).’,’.$opacity.’)’;

    } else {

    $output = ‘rgb(‘.implode(“,”,$rgb).’)’;

    }

    //Return rgb(a) color string

    return $output;

    }

    /*

    * Theme options custom CSS

    */

    function classipost_inline_css(){

    $classipost_layout = of_get_option(‘col-layout’, of_get_default(‘col-layout’));

    $body_background = of_get_option(‘background_picker’, of_get_default(‘background_picker’ ));

    $header_image = of_get_option(‘header_image’, of_get_default(‘header_image’ ));

    $header_background = of_get_option(‘header_image’, of_get_default(‘header_image’ ));

    $header_menu_text_color = of_get_option(‘header_menu_text_color’, of_get_default(‘header_menu_text_color’ ));

    $header_text_color = of_get_option(‘header_text_color’, of_get_default(‘header_text_color’ ));

    $header_height = of_get_option(‘header_height’, of_get_default(‘header_height’ ));

    $color_searchbar = of_get_option(‘color_searchbar’, of_get_default(‘color_searchbar’ ));

    $color_link = of_get_option(‘color_link’, of_get_default(‘color_link’ ));

    $color_button = of_get_option(‘color_button’, of_get_default(‘color_button’ ));

    $color_topbar = of_get_option(‘color_topbar’, of_get_default(‘color_topbar’ ));

    $color_footer_menu = of_get_option(‘color_footer_menu’, of_get_default(‘color_footer_menu’ ));

    $color_footer = of_get_option(‘color_footer’, of_get_default(‘color_footer’ ));

    $custom_css = of_get_option(‘custom_css’, of_get_default(‘custom_css’ ));

    ?>

    <style type=”text/css”>

    <?php echo $classipost_layout; ?>

    <?php if (!empty( of_get_option(‘background_picker’) != of_get_default(‘background_picker’ ))) { ?>

    /* Dynamic Body Background Color or Image */

    body {

    background: <?php echo $body_background[‘color’] . ‘ url(‘ . $body_background[‘image’] . ‘) ‘ . $body_background[‘repeat’] . ‘ ‘ . $body_background[‘position’] . ‘ ‘ . $body_background[‘attachment’];?>;

    }

    <?php } ?>

    <?php if ( of_get_option(‘custom_header’, of_get_default(‘custom_header’ )) == 1 ) { ?>

    /* Dynamic Header Background Color or Image */


    @media
    screen and (min-width:768px){

    .header-image {

    background: <?php echo ‘linear-gradient(‘. hex2rgba($header_background[‘color’],0.2) .’,’. hex2rgba($header_background[‘color’],0.2) .’)’,’, url(‘ . $header_background[‘image’] . ‘) ‘ . $header_background[‘repeat’] . ‘ ‘ . $header_background[‘position’] . ‘ ‘ . $header_background[‘attachment’];?>;

    background-size: cover;

    height: <?php echo $header_height; ?>;

    margin-bottom: 15px;

    }

    <?php if (!empty( of_get_option(‘color_searchbar’) == of_get_default(‘color_searchbar’ ))) { ?>

    .main-header.header-image {

    border-top: 5px solid <?php echo $color_searchbar; ?>;

    }

    <?php } ?>

    <?php if ( of_get_option(‘header_position’, of_get_default(‘header_position’ )) == 1 && of_get_option(‘color_searchbar’) == of_get_default(‘color_searchbar’ )) {?>

    .header-image .search-wrap {

    padding-top: 10px;

    }

    <?php } ?>

    .header-message h1.header-title, .header-message .header-text {

    color: <?php echo $header_text_color; ?>;

    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.7));

    }

    .header-message {

    margin: 10px 10px 50px 10px;

    }

    .header-message .btn-lg {

    font-size: 24px;

    font-weight: 700;

    }

    #primary-menu.header-menu-home .navbar-nav>li>a {

    color: <?php echo $header_menu_text_color; ?>;

    }

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘color_topbar’) != of_get_default(‘color_topbar’ ))) { ?>

    /* Dynamic Top Bar Color */

    .top-header {

    background: <?php echo $color_topbar; ?>;

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘color_searchbar’) != of_get_default(‘color_searchbar’ ))) { ?>

    /* Dynamic Search Bar Color */

    #affix-menu.affix-top {

    background: <?php echo hex2rgba($color_searchbar, 0.3); ?>;

    }

    #affix-menu.affix {

    background: <?php echo hex2rgba($color_searchbar, 0.5); ?>;

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘color_link’) != of_get_default(‘color_link’ ))) { ?>

    /* Dynamic Links Color */

    a{

    color: <?php echo $color_link; ?>;

    }

    a:hover, a:focus {

    color: <?php echo $color_link; ?>;

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘color_button’) != of_get_default(‘color_button’ ))) { ?>

    /* Dynamic Button Color */

    .orangebutton {

    background-color: <?php echo $color_button; ?>;

    border-color: <?php echo $color_button; ?>;

    }

    .orangebutton:hover {

    background-color: <?php echo $color_button; ?>;

    border-color: <?php echo $color_button; ?>;

    }

    .btn_orange,

    .reports_form input[type=”submit”] {

    background-color: <?php echo $color_button; ?>;

    }

    .btn_orange:hover,

    .order-gateway input[type=”submit”]:hover,

    .reports_form input[type=”submit”]:hover {

    background-color: <?php echo $color_button; ?>;

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘color_footer_menu’) != of_get_default(‘color_footer_menu’ ))) { ?>

    /* Dynamic Footer Menu Color */

    .footer-nav-menu {

    background: <?php echo $color_footer_menu; ?>;

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘color_footer’) != of_get_default(‘color_footer’ ))) { ?>

    /* Dynamic Footer Background Color */

    .footer {

    background: <?php echo $color_footer; ?>;

    }

    <?php } ?>

    <?php if (!empty( of_get_option(‘custom_css’) != of_get_default(‘custom_css’ ))) { ?>

    /* Dynamic Custom CSS */

    <?php echo $custom_css; ?>

    <?php } ?>

    </style>

    <?php

    }

    add_action(‘wp_head’,’classipost_inline_css’);

    // Load different color stylesheet

    function options_stylesheets_alt_style() {

    if ( of_get_option( ‘stylesheet’, of_get_default(‘stylesheet’ ) ) ) {

    wp_enqueue_style( ‘options_stylesheets_alt_style’, of_get_option(‘stylesheet’, of_get_default(‘stylesheet’ )), array(), null );

    }

    }

    add_action( ‘wp_enqueue_scripts’, ‘options_stylesheets_alt_style’, 100 );

    /**

    * Load ClassiPost custom scripts

    */

    function classipost_enqueue_scripts() {

    global $cp_options;

    // reload gmaps with geolocation support

    wp_deregister_script( ‘google-maps’ );

    $gmap_params = array(

    ‘language’ => $cp_options->gmaps_lang,

    ‘region’ => $cp_options->gmaps_region,

    ‘libraries’ => ‘places’

    );

    if ( $cp_options->api_key ) {

    $gmap_params[‘key’] = $cp_options->api_key;

    }

    $google_maps_url = ( is_ssl() ? ‘https’ : ‘http’ ) . ‘://maps.googleapis.com/maps/api/js’;

    $google_maps_url = add_query_arg( $gmap_params, $google_maps_url );

    $protocol = is_ssl() ? ‘https’ : ‘http’;

    wp_enqueue_script(‘bootstrap-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap.min.js’, false, ‘3.3.6’);

    wp_enqueue_script(‘bootstrap-select-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap-select.min.js’, false, ‘1.10.0’);

    wp_enqueue_script(‘bootstrap-dropdown-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap-hover-dropdown.min.js’, false, ‘2.2.1’);

    wp_enqueue_script(‘tabcollapse-js’, get_stylesheet_directory_uri() . ‘/js/bootstrap-tabcollapse.js’, false, ‘1.0.0’);

    if ( is_single() ) {

    wp_enqueue_script(‘lightgallery-js’, get_stylesheet_directory_uri() . ‘/js/lightgallery/js/lightgallery-all.min.js’, false, ‘1.4.4’);

    wp_enqueue_script(‘mousewheel-js’, get_stylesheet_directory_uri() . ‘/js/jquery.mousewheel.min.js’, false, ‘3.1.12’);

    }

    wp_enqueue_script(‘owl-carousel-js’, get_stylesheet_directory_uri() . ‘/js/owl.carousel2.min.js’, false, ‘2.1.1’);

    if (of_get_option(‘infinitescroll’, of_get_default(‘infinitescroll’ )) == ‘infinite’) {

    wp_enqueue_script(‘infinitescroll’, get_stylesheet_directory_uri() . ‘/js/jquery.infinitescroll.min.js’, array(‘jquery’), ‘1.1’);

    }

    if ( is_page_template( ‘tpl-ads-home.php’ ) && of_get_option(‘custom_header’, of_get_default(‘custom_header’ )) == 1 ) {

    wp_enqueue_script(‘typed’, get_stylesheet_directory_uri() . ‘/js/typed.min.js’, array(‘jquery’), ‘1.1.4’);

    }

    wp_enqueue_script( ‘google-maps’, $google_maps_url, array( ‘jquery’ ), ‘3.0’ );

    if (of_get_option(‘classipost_location’, of_get_default(‘classipost_location’ )) == ‘city_geolocation’) {

    wp_enqueue_script(‘geotext-js’, get_stylesheet_directory_uri() . ‘/js/geotext.min.js’, false, ‘1.0.0’);

    }

    wp_enqueue_script(‘classipost-js’, get_stylesheet_directory_uri() . ‘/js/classipost.js’, false, ‘1.0.0’);

    // only load the general.js if available in child theme

    if ( file_exists( get_stylesheet_directory() . ‘/js/custom.js’ ) ) {

    wp_enqueue_script( ‘custom-js’, get_stylesheet_directory_uri() . ‘/js/custom.js’, array( ‘jquery’ ), ‘1.0’ );

    }

    }

    add_action( ‘wp_enqueue_scripts’, ‘classipost_enqueue_scripts’, 99 );

    /**

    * Enqueue both Parent and child theme stylesheets.

    * This makes sure that the child theme stylesheet is loaded after the parent sheet.

    */

    function classipost_enqueue_styles() {

    $protocol = is_ssl() ? ‘https’ : ‘http’;

    $parent_style = ‘at-main’;

    wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );

    wp_enqueue_style(‘bootstrap’, get_stylesheet_directory_uri() . ‘/js/assets/bootstrap.min.css’, false, ‘3.3.6’);

    wp_deregister_style( ‘font-awesome’);

    wp_register_style( ‘font-awesome’, get_stylesheet_directory_uri() . ‘/js/assets/font-awesome.min.css’, false, ‘4.6.3’ );

    wp_enqueue_style( ‘font-awesome’);

    wp_enqueue_style(‘bootstrap-select-css’, get_stylesheet_directory_uri() . ‘/js/assets/bootstrap-select.min.css’, false, ‘1.10.0’);

    wp_enqueue_style(‘owl-carousel’, get_stylesheet_directory_uri() . ‘/js/assets/owl.carousel.min.css’, false, ‘2.1.1’);

    wp_enqueue_style(‘owl-theme’, get_stylesheet_directory_uri() . ‘/js/assets/owl.theme.default.min.css’, false, ‘2.1.1’);

    if ( is_single() ) {

    wp_enqueue_style(‘lightgallery’, get_stylesheet_directory_uri() . ‘/js/lightgallery/css/lightgallery.min.css’, false, ‘1.4.4’);

    }

    wp_enqueue_style(‘classipost-main’, get_stylesheet_directory_uri() . ‘/style.css’, array( $parent_style ) );

    }

    add_action( ‘wp_enqueue_scripts’, ‘classipost_enqueue_styles’ );

    // Remove Classipress color stylesheets

    function classipost_dequeue_styles() {

    wp_dequeue_style( ‘at-color’);

    wp_dequeue_style( ‘open-sans’ );

    wp_dequeue_script( ‘tinynav’);

    wp_dequeue_script( ‘selectbox’);

    wp_dequeue_script( ‘jqueryeasing’);

    wp_dequeue_script( ‘jcarousellite’);

    wp_dequeue_script( ‘colorbox’ );

    }

    add_action( ‘wp_enqueue_scripts’, ‘classipost_dequeue_styles’, 99 );

    /**

    * Remove emoji

    */

    function disable_wp_emojicons() {

    // all actions related to emojis

    remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );

    remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );

    remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );

    remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );

    remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );

    remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );

    remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );

    // filter to remove TinyMCE emojis

    add_filter( ‘tiny_mce_plugins’, ‘disable_emojicons_tinymce’ );

    // remove DNS prefetch

    add_filter( ’emoji_svg_url’, ‘__return_false’ );

    }

    add_action( ‘init’, ‘disable_wp_emojicons’ );

    function disable_emojicons_tinymce( $plugins ) {

    if ( is_array( $plugins ) ) {

    return array_diff( $plugins, array( ‘wpemoji’ ) );

    } else {

    return array();

    }

    }

    /**

    * Remove cp color customizer for now

    */

    function remove_color_customizer() {

    remove_action( ‘wp_head’, ‘_cp_customize_css’, 999 );

    remove_action( ‘customize_controls_enqueue_scripts’, ‘_cp_enqueue_customizer_color_previewer’ );

    remove_action( ‘customize_register’, ‘_cp_customize_color_scheme’ );

    //remove_action( ‘after_setup_theme’, ‘cp_custom_header_setup’ );

    remove_action( ‘customize_register’, ‘_cp_customize_site’ );

    remove_action( ‘customize_register’, ‘_cp_customize_footer’ );

    }

    add_action (‘init’, ‘remove_color_customizer’);

    /**

    * Register top menu navigation positioon

    */

    function classipost_register_top_menu() {

    register_nav_menu( ‘Top’, __( ‘Top Navigation’, ‘classipost’ ) );

    if ( !is_nav_menu( ‘Top’ )) {

    $menu_id = wp_create_nav_menu( ‘Top’ );

    $menu = array( ‘menu-item-type’ => ‘custom’, ‘menu-item-url’ => get_home_url(‘/’),’menu-item-title’ => ‘Home’ );

    wp_update_nav_menu_item( $menu_id, 0, $menu );

    }

    }

    add_action( ‘init’, ‘classipost_register_top_menu’ );

    /**

    *Register bootstrap navigation walker

    */

    require_once(get_stylesheet_directory().’/wp_bootstrap_navwalker.php’);

    /**

    * Displays ad thumbnail. Use in the loop.

    *

    * @return void

    */

    if ( ! function_exists( ‘cp_ad_loop_thumbnail’ ) ) :

    function cp_ad_loop_thumbnail() {

    global $post, $cp_options;

    // go see if any images are associated with the ad

    $image_id = cp_get_featured_image_id( $post->ID );

    // set the class based on if the hover preview option is set to “yes”

    $prevclass = ( $cp_options->ad_image_preview ) ? ‘preview’ : ‘nopreview’;

    if ( $image_id > 0 ) {

    // get 450×300 image size

    $adthumbarray = wp_get_attachment_image( $image_id, ‘ad-medium’ );

    // grab the large image for onhover preview

    $adlargearray = wp_get_attachment_image_src( $image_id, ‘ad-large’ );

    $img_large_url_raw = $adlargearray[0];

    // must be a v3.0.5+ created ad

    if ( $adthumbarray ) {

    echo ‘‘. $adthumbarray .’‘;

    // maybe a v3.0 legacy ad

    } else {

    $adthumblegarray = wp_get_attachment_image_src($image_id, ‘thumbnail’);

    $img_thumbleg_url_raw = $adthumblegarray[0];

    echo ‘‘. $adthumblegarray .’‘;

    }

    // no image so return the placeholder thumbnail

    } else {

    echo ‘‘;

    }

    }

    endif;

    /**

    * Displays ad thumbnail for featured ads. Use in the loop.

    *

    * @return void

    */

    if ( ! function_exists( ‘cp_ad_featured_thumbnail’ ) ) :

    function cp_ad_featured_thumbnail() {

    global $post, $cp_options;

    // go see if any images are associated with the ad

    $image_id = cp_get_featured_image_id( $post->ID );

    // set the class based on if the hover preview option is set to “yes”

    $prevclass = ( $cp_options->ad_image_preview ) ? ‘preview’ : ‘nopreview’;

    if ( $image_id > 0 ) {

    // get 500×500 image size

    $adthumbarray = wp_get_attachment_image( $image_id, ‘ad-featured’ );

    // grab the large image for onhover preview

    $adlargearray = wp_get_attachment_image_src( $image_id, ‘ad-large’ );

    $img_large_url_raw = $adlargearray[0];

    // must be a v3.0.5+ created ad

    if ( $adthumbarray ) {

    echo ‘‘. $adthumbarray .’‘;

    // maybe a v3.0 legacy ad

    } else {

    $adthumblegarray = wp_get_attachment_image_src($image_id, ‘thumbnail’);

    $img_thumbleg_url_raw = $adthumblegarray[0];

    echo ‘‘. $adthumblegarray .’‘;

    }

    // no image so return the placeholder thumbnail

    } else {

    echo ‘‘;

    }

    }

    endif;

    /**

    * Displays all the images and thumbnails for the single page ad with support for Owl Carousel 2.

    *

    * @param int $post_id (optional)

    * @param string $size (optional)

    * @param string $title (optional)

    *

    * @return void

    */

    if ( ! function_exists( ‘cp_get_image_url_single’ ) ) {

    function cp_get_image_url_single( $post_id = ”, $size = ”, $title = ” ) {

    $attachment_query = array(

    ‘post_type’ => ‘attachment’,

    ‘post_status’ => null,

    ‘post_parent’ => $post_id,

    ‘order’ => ‘ASC’,

    ‘orderby’ => ‘ID’,

    ‘no_found_rows’ => true

    );

    $attachment_ids = get_post_meta( $post_id, ‘_app_media’, true );

    if ( ! empty( $attachment_ids ) ) {

    $attachment_query = array_merge( $attachment_query, array(

    ‘post__in’ => $attachment_ids,

    ‘orderby’ => ‘post__in’

    ) );

    }

    // go see if any images are associated with the ad

    $images = get_children( $attachment_query );

    $image_count = cp_count_ad_images($post_id);

    $i = 1;

    if ( $images ) {

    foreach ( $images as $image ) {

    $alt = get_post_meta( $image->ID, ‘_wp_attachment_image_alt’, true );

    if ( empty( $alt ) ) {

    $alt = $title . ‘ – ‘ . __( ‘Image ‘, APP_TD ) . $i;

    }

    $iarray = wp_get_attachment_image_src( $image->ID, $size, $icon = false );

    $farray = wp_get_attachment_image_src( $image->ID, ‘full’, $icon = false );

    //$image_count = cp_count_ad_images($post_id);

    if ( $image_count > 1 ) {

    $tarray = wp_get_attachment_image_src( $image->ID, ‘ad-thumb’, $icon = false );

    echo ‘<div class=”ad-thumb” data-src=”‘. $farray[0] .'” data-thumb=”‘. $tarray[0] .'” data-dot=”“>'. $alt .'</div>’;

    }

    if ( $image_count == 1 ) {

    echo ‘<div class=”ad-thumb” data-src=”‘. $farray[0] .'”>'. $alt .'</div>’;

    }

    $i++;

    }

    }

    if ( $image_count < 1 ) {

    echo ‘<div></div>’;

    }

    }

    }

    add_action( ‘init’ , ‘classipost_remove_ad_actions’ );

    function classipost_remove_ad_actions() {

    remove_action( ‘appthemes_before_post_title’, ‘cp_ad_loop_price’ );

    remove_action( ‘appthemes_after_post_title’, ‘cp_ad_loop_meta’ );

    remove_action( ‘appthemes_after_post_content’, ‘cp_do_loop_stats’ );

    remove_action( ‘appthemes_after_blog_post_content’, ‘cp_do_loop_stats’ );

    remove_action(‘appthemes_after_blog_post_title’, ‘cp_blog_post_meta’);

    remove_action( ‘appthemes_advertise_content’, ‘cp_adbox_336x280’ );

    remove_action( ‘appthemes_after_loop’, ‘cp_single_ad_banner’ );

    // Replace them with own functions

    add_action( ‘appthemes_before_post_title’, ‘classipost_ad_loop_price’ );

    add_action( ‘cp_action_after_ad_details’, ‘classipost_ad_single_price’, 10, 3 );

    add_action( ‘appthemes_after_post_title’, ‘classipost_ad_loop_meta’ );

    add_action( ‘appthemes_after_post_content’, ‘classipost_do_loop_stats’ );

    add_action( ‘appthemes_after_blog_post_content’, ‘classipost_do_loop_stats’ );

    add_action(‘appthemes_after_blog_post_title’, ‘classipost_blog_post_meta’);

    add_action( ‘appthemes_before_post_content’, ‘cp_single_ad_banner’ );

    add_action( ‘appthemes_advertise_content’, ‘classipost_adbox_728x90’ );

    }

    /**

    * Displays 728 x 90 ad box on single page.

    * @since 3.3

    *

    * @return void

    */

    function classipost_adbox_728x90() {

    global $cp_options;

    if ( ! $cp_options->adcode_336x280_enable ) {

    return;

    }

    ?>

    <div class=”shadowblock_out”>

    <div class=”shadowblock px2″>

    <div class=”ablock”>

    <?php

    if ( ! empty( $cp_options->adcode_336x280 ) ) {

    echo stripslashes( $cp_options->adcode_336x280 );

    } elseif ( $cp_options->adcode_336x280_url ) {

    $img = html( ‘img’, array( ‘src’ => $cp_options->adcode_336x280_url, ‘border’ => ‘0’, ‘alt’ => ” ) );

    echo html( ‘a’, array( ‘href’ => $cp_options->adcode_336x280_dest, ‘target’ => ‘_blank’ ), $img );

    }

    ?>

    </div>

    </div>

    </div>

    <?php

    }

    /**

    * Displays 728 x 90 ad box on the home page under the slider.

    * @since 3.3

    *

    * @return void

    */

    function classipost_homepage_728x90() {

    global $cp_options;

    if ( ! $cp_options->adcode_468x60_enable ) {

    return;

    }

    ?>

    <div class=”shadowblock_out”>

    <div class=”shadowblock px2″>

    <div class=”ablock”>

    <?php

    if ( ! empty( $cp_options->adcode_468x60 ) ) {

    echo stripslashes( $cp_options->adcode_468x60 );

    } else {

    if ( ! $cp_options->adcode_468x60_url ) {

    $img = html( ‘img’, array( ‘src’ => get_template_directory_uri() . ‘/images/468×60-banner.jpg’, ‘width’ => ‘468’, ‘height’ => ’60’, ‘border’ => ‘0’, ‘alt’ => ‘Premium WordPress Themes – AppThemes’ ) );

    echo html( ‘a’, array( ‘href’ => ‘https://www.appthemes.com&#8217;, ‘target’ => ‘_blank’ ), $img );

    } else {

    $img = html( ‘img’, array( ‘src’ => $cp_options->adcode_468x60_url, ‘border’ => ‘0’, ‘alt’ => ” ) );

    echo html( ‘a’, array( ‘href’ => $cp_options->adcode_468x60_dest, ‘target’ => ‘_blank’ ), $img );

    }

    }

    ?>

    </div>

    </div>

    </div>

    <?php

    }

    /**

    * Adds the ad price field in the loop before the ad title.

    * @since 3.1.3

    *

    * @return void

    */

    function classipost_ad_loop_price() {

    global $post;

    $price = get_post_meta($post->ID, ‘cp_price’, true);

    if ( $post->post_type == ‘page’ || $post->post_type == ‘post’ || empty($price) || $price == 0 || is_singular( APP_POST_TYPE ))

    return;

    ?>

    <div class=”price-wrap”>

    <p class=”post-price”>

    <?php cp_get_price( $post->ID, ‘cp_price’ ); ?>

    </p>

    </div>

    <?php

    }

    function classipost_ad_single_price( $form_fields, $post, $location = ‘list’) {

    global $post;

    $price = get_post_meta($post->ID, ‘cp_price’, true);

    if ( $post->post_type == ‘page’ || $post->post_type == ‘post’ || empty($price) || $price == 0)

    return;

    if ( is_singular( APP_POST_TYPE ) && $location == ‘list’ ) { ?>

    <li id=”cp_price”><span><?php _e( ‘Price:’, APP_TD ); ?></span> <?php cp_get_price( $post->ID, ‘cp_price’ ); ?>

    <?php

    }

    }

    /**

    * Adds the ad meta in the loop after the ad title.

    * @since 3.1

    *

    * @return void

    */

    function classipost_ad_loop_meta() {

    global $post, $cp_options;

    if ( is_singular( APP_POST_TYPE ) )

    return;

    $classipost_meta = of_get_option(‘classipost_custom_meta’, of_get_default(‘classipost_custom_meta’ ));

    $custom_meta = get_post_meta($post->ID, $classipost_meta, true);

    $category_meta = get_the_term_list( $post->ID, APP_TAX_CAT, ”, ‘, ‘, ” );

    $category_location = get_the_terms( $post->ID, APP_TAX_CAT);

    if ($category_location && ! is_wp_error($category_location)) {

    foreach ($category_location as $term){

    $category_link = get_term_link($term, APP_TAX_CAT );

    }

    }

    ?>

    <p class=”item-meta”>

    <span class=”nowsp”><i class=”fa fa-folder-open”></i> <?php if ( $post->post_type == ‘post’ ) the_category(‘, ‘); else echo $category_meta; ?></span>

    <?php $classipost_author = get_the_author_meta(‘ID’);

    if ( is_user_online($classipost_author)) { ?>

    <span class=”nowsp” rel=”tooltip” data-placement=”top” data-original-title=” <?php printf (__( ‘%s is Online’, ‘classipost’ ), get_the_author_meta(‘display_name’)) ?> “><i class=”fa fa-user icon-pulse” style=”color:dimgray”></i> <?php the_author_posts_link(); ?></span>

    <?php } else { ?>

    <span class=”nowsp” rel=”tooltip” data-placement=”top” data-original-title=” <?php _e( ‘Last Login:’, APP_TD ); ?> <?php echo appthemes_get_last_login( get_the_author_meta(‘ID’) ); ?> “><i class=”fa fa-user”></i> <?php the_author_posts_link(); ?></span>

    <?php } ?>

    <span class=”nowsp”><i class=”fa fa-map-marker”></i> ?<?php if ($classipost_meta == ‘cp_city’) echo $classipost_meta; else echo $classipost_meta.'[]’; ?>=<?php echo $custom_meta;?>&sa=search&refine_search=yes” title=”<?php echo $custom_meta; ?>”> <?php echo $custom_meta; ?> </span>

    <span class=”nowsp”><i class=”fa fa-clock-o”></i> <?php echo appthemes_date_posted($post->post_date); ?></span>

    <?php if ( $cp_options->ad_stats_all && current_theme_supports( ‘app-stats’ ) ) { ?>

    <span class=”nowsp”><i class=”fa fa-signal”></i> <?php appthemes_stats_counter( $post->ID ); ?></span>

    <?php } ?>

    </p>

    <?php

    }

    // Post meta

    function classipost_blog_post_meta() {

    if ( is_page() ) return; // don’t do post-meta on pages

    global $post;

    ?>

    <p class=”post-meta”><span class=”nowsp”><i class=”fa fa-user fa-lg”></i> <?php the_author_posts_link(); ?></span> <span class=”nowsp”><i class=”fa fa-folder-open fa-lg”></i> <?php the_category(‘, ‘) ?></span> <span class=”nowsp”><i class=”fa fa-clock-o fa-lg”></i> <?php echo appthemes_date_posted( $post->post_date ); ?></span></p>

    <?php

    }

    function classipost_do_loop_stats() {

    global $post, $cp_options;

    if (( is_singular(‘post’) ) && $cp_options->ad_stats_all && current_theme_supports( ‘app-stats’ )) {

    ?>

    <p class=”stats”><i class=”fa fa-signal”></i>

    <?php appthemes_stats_counter( $post->ID ); ?>

    </p>

    <?php

    }

    }

    // Get meta values of all ads, used mainly for top search location bar

    function get_meta_values( $key = ”, $type = APP_POST_TYPE, $status = ‘publish’ ) {

    global $wpdb;

    if( empty( $key ) )

    return;

    $r = $wpdb->get_col( $wpdb->prepare( ”

    SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm

    LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id

    WHERE pm.meta_key = ‘%s’

    AND p.post_status = ‘%s’

    AND p.post_type = ‘%s’

    ORDER BY meta_value ASC

    “, $key, $status, $type ) );

    return $r;

    }

    // Update user online status

    function update_online_users_status(){

    if(is_user_logged_in()){

    // get the online users list

    if(($logged_in_users = get_transient(‘users_online’)) === false) $logged_in_users = array();

    $current_user = wp_get_current_user();

    $current_user = $current_user->ID;

    $current_time = current_time(‘timestamp’);

    if(!isset($logged_in_users[$current_user]) || ($logged_in_users[$current_user] < ($current_time – (15 * 60)))){

    $logged_in_users[$current_user] = $current_time;

    set_transient(‘users_online’, $logged_in_users, 30 * 60);

    }

    }

    }

    add_action(‘wp’, ‘update_online_users_status’);

    function is_user_online($user_id) {

    global $wpdb;

    // get the online users list

    $logged_in_users = get_transient(‘users_online’);

    // online, if (s)he is in the list and last activity was less than 15 minutes ago

    return isset($logged_in_users[$user_id]) && ($logged_in_users[$user_id] > (current_time(‘timestamp’) – (15 * 60)));

    }

    // Unregister the footer sidebar

    function remove_footer_sidebar(){

    unregister_sidebar( ‘sidebar_footer’ );

    }

    add_action( ‘widgets_init’, ‘remove_footer_sidebar’ );

    function classipost_register_sidebars() {

    // Footer

    $footer_columns = of_get_option(‘footer_columns’, of_get_default(‘footer_columns’ ));

    register_sidebar( array(

    ‘name’ => __( ‘Footer’, APP_TD ),

    ‘id’ => ‘sidebar_footer’,

    ‘description’ => __( ‘This is your ClassiPress footer. You can have ANY number of widgets which will display in the footer from left to right.’, APP_TD ),

    ‘before_widget’ => ‘<div class=”footer-widget ‘ . $footer_columns . ‘ %2$s” id=”%1$s”>’,

    ‘after_widget’ => ‘</div><!– /footer-widget –>’,

    ‘before_title’ => ‘<h2 class=”dotted”>’,

    ‘after_title’ => ‘</h2>’,

    ) );

    }

    add_action( ‘widgets_init’, ‘classipost_register_sidebars’, 11 );

    //Create bootstrap badges for categories within sidebar

    function classipost_cat_count($links) {

    $links = str_replace(‘ (‘, ‘ <span class=”badge badge-primary”>’, $links);

    $links = str_replace(‘)’, ‘</span>’, $links);

    return $links;

    }

    add_filter(‘wp_list_categories’, ‘classipost_cat_count’);

    //Stick featured ads to the top on category and search pages

    class StickyAds {

    public function __construct() {

    add_filter(‘posts_orderby’, array($this, ‘_hookPostsOrderBy’), 11, 2);

    }

    public function _hookPostsOrderBy($orderBy, $query) {

    global $wpdb;

    if ( is_tax(‘ad_cat’) || is_search() && !$query->query_vars[‘ignore_sticky_posts’]) {

    $stickyPosts = get_option(‘sticky_posts’);

    if (is_array($stickyPosts) && !empty($stickyPosts)) {

    $sticky = ‘(‘ . $wpdb->posts . ‘.ID IN (‘ .

    implode(‘,’, $stickyPosts) . ‘)) DESC’;

    $orderBy= empty($orderBy) ? $sticky : $sticky . ‘,’ . $orderBy;

    add_filter(

    ‘pre_option_sticky_posts’, array($this, ‘_hookOptionStickyPosts’)

    );

    }

    }

    return $orderBy;

    }

    public function _hookOptionStickyPosts($option) {

    remove_filter(‘pre_option_sticky_posts’, array($this, ‘_hookOptionStickyPosts’)

    );

    return array();

    }

    }

    $stickyads = new StickyAds();

    // End sticky ads

    function bootstrap_tabs_js() {

    if (is_home() || is_front_page()) {

    $active_tab = of_get_option(‘home_tab’, of_get_default(‘home_tab’ ));

    } else {

    $active_tab = 0;

    }

    ?>

    <script>

    // Save current tab or pill active state in the local storage

    jQuery(document).ready(function ($) {

    var json, tabsState;

    $(‘a[data-toggle=”pill”], a[data-toggle=”tab”]’).on(‘shown.bs.tab’, function(e) {

    var href, json, parentId, tabsState;

    tabsState = localStorage.getItem(“tabs-state”);

    json = JSON.parse(tabsState || “{}”);

    parentId = $(e.target).parents(“ul.nav.nav-pills, ul.nav.nav-tabs”).attr(“id”);

    href = $(e.target).attr(‘href’);

    json[parentId] = href;

    return localStorage.setItem(“tabs-state”, JSON.stringify(json));

    });

    tabsState = localStorage.getItem(“tabs-state”);

    json = JSON.parse(tabsState || “{}”);

    $.each(json, function(containerId, href) {

    return $(‘#’ + containerId + ‘ a[href=”‘ + href + ‘”]’).tab(‘show’);

    });

    $(“ul.nav.nav-pills, ul.nav.nav-tabs”).each(function() {

    var $this = $(this);

    if (!json[$this.attr(“id”)]) {

    return $this.find(“a[data-toggle=tab]:eq(<?php echo $active_tab; ?>), a[data-toggle=pill]:eq(<?php echo $active_tab; ?>)”).tab(“show”);

    }

    $(‘.popular-tab.active, .random-tab.active’).trigger(“click”);

    });

    $(document).on(“shown.bs.collapse”, “.panel-collapse”, function (e) {

    $(‘.popular-tab, .random-tab’).trigger(“click”);

    });

    });

    // End pill or tab state

    /* Bootstrap Accordion.

    Turn the tabs into accordions on mobile devices.

    Scroll to top and animate the accordion.

    */

    jQuery(document).ready(function ($) {

    $(“[id^=tabby-]”).tabCollapse({

    tabsClass: ‘hidden-ms hidden-xs’,

    accordionClass: ‘visible-ms visible-xs’

    });

    $(“[id$=’-accordion’]”).on(‘shown.bs.collapse’, function () {

    var panel = $(this).find(‘.in’);

    $(‘html, body’).animate({

    scrollTop: panel.offset().top -57 }, 500);

    });

    });

    // End Accordion

    <?php if ( is_single() && ! of_get_option(‘remove_maps’, of_get_default(‘remove_maps’ )) == ‘1’ ) { ?>

    // Initialize the Google map upon click on tabs

    jQuery(document).ready(function($) {

    var clicked = false;

    if( $(“[id^=location]”).is(‘:visible’) ) {

    map_init();

    } else {

    jQuery(‘a[href^=”#location”]’).click( function() {

    if( !clicked ) {

    map_init();

    clicked = true;

    }

    });

    }

    });

    jQuery(document).on(“shown.bs.collapse shown.bs.tab”, “.panel-collapse, a[data-toggle=’tab’]”, function (e) {

    setTimeout(function(){

    google.maps.event.trigger(map,’resize’);

    }, 500);

    });

    <?php } ?>

    </script>

    <?php

    }

    add_action( ‘wp_footer’, ‘bootstrap_tabs_js’);

    //Begin infinite scroll

    function infinitescroll_js() {

    if (of_get_option(‘infinitescroll’, of_get_default(‘infinitescroll’ )) == ‘infinite’) {

    ?>

    <script>

    jQuery(document).ready(function($) {

    // infinite scroll

    $(“.loop-items”).infinitescroll({

    navSelector : “.paging”,

    // selector for the paged navigation (it will be hidden)

    nextSelector : “a.page-numbers”,

    // selector for the NEXT link (to page 2)

    itemSelector : “.wrap-item”,

    // selector for all items you’ll retrieve

    contentSelector : “.loop-items”,

    loading: {

    img: “<?php echo get_stylesheet_directory_uri(); ?>/images/ajax-loader.gif”,

    msgText: “<?php _e( ‘Loading next ads…’, ‘classipost’ ); ?>”,

    finishedMsg: “<?php _e( ‘This was the last ad from current category.’, ‘classipost’ ); ?>”

    }

    });

    });

    </script>

    <?php

    }

    }

    add_action( ‘wp_footer’, ‘infinitescroll_js’,100 );

    // Available colors top menu

    if ( class_exists(‘WPUserStylesheetSwitcher’) ) :

    function stylesheet_switch_menu ( $items, $args ) {

    if ( $args->theme_location == ‘Top’ ) {

    global $wpUserStylesheetSwitcher;

    $items = $wpUserStylesheetSwitcher->show_wp_user_stylesheet_switcher(array(‘list_title’=>’Colors: ‘, ‘show_list_title’=>’true’, ‘list_type’=>’icon’));

    }

    return $items;

    }

    add_filter( ‘wp_nav_menu_items’, ‘stylesheet_switch_menu’, 10, 2 );

    endif;

    // Enable the TinyMCE kitchen sink

    function enable_more_buttons($buttons) {

    $buttons[] = ‘fontselect’;

    $buttons[] = ‘fontsizeselect’;

    return $buttons;

    }

    add_filter(‘mce_buttons_2’, ‘enable_more_buttons’);

    function add_search_filter_before_page_loop() {

    do_action(‘search_filter_query_posts’, 3726);

    }

    add_action( ‘appthemes_before_blog_loop’, ‘add_search_filter_before_page_loop’ );

    #84577

    Hartley Stone
    Participant

    I am just hiding and showing the option field like so:

    jQuery(document).ready(function($) {

    var
    regions = jQuery(‘.sf-field-post-meta-directory_region’).find(‘.sf-input-select’).val();
    //console.log(regions);
    if(regions !=””){
    if(regions == “Africa”){
    jQuery(‘.sf-field-post-meta-country_africa’).show();
    }
    if(regions == “Asia Pacific”){
    jQuery(‘.sf-field-post-meta-country_asia’).show();
    }
    if(regions == “Central & South America”){
    jQuery(‘.sf-field-post-meta-country_central_south_america’).show();
    }
    if(regions == “Europe”){
    jQuery(‘.sf-field-post-meta-country_europe’).show();
    }
    if(regions == “Middle East”){
    jQuery(‘.sf-field-post-meta-country_middle_east’).show();
    }
    if(regions == “North America”){
    jQuery(‘.sf-field-post-meta-country_north_america’).show();
    }
    if(regions == “Australia & Oceania”){
    jQuery(‘.sf-field-post-meta-country_australia_oceania’).show();
    }
    }

    });

    #80024

    Edgard
    Participant
    This reply has been marked as private.
    #80010

    Edgard
    Participant
    This reply has been marked as private.
    #73526

    Ash
    Participant

    So far only this method worked.

    jQuery(document).on("sf:ajaxstart", ".searchandfilter", function(){
      var tax1 = jQuery('.sf-field-taxonomy-tax1 select').val();
      if(location.search.search('_sft_tax1='+tax1) == -1){
        jQuery('.sf-field-taxonomy-tax2 select').val('');
      }
    });

    (edited by @trevorsf to add code tags to the code)

    #73431

    Ross
    Keymaster

    Hey Ash

    I’ve not tried to do what you are doing exactly but in theory it should work.

    So you want to clear one field if the other field is updated?

    I think what you are doing is fine, setting .val("").. when doing this, do you see the field itself change value? If so, then all you should need to do is submit the form (which will handle the building of the new URL) – $('.searchandfilter').submit(); – this will also work for an ajax powered search form.

    What you suggested above also sounds like it might do the trick (triggering a change event after you have set the val), you might need to trigger input or change and then you would need to do it here in your example:

    jQuery('.sf-field-taxonomy-taxonomy1 select').on('change',function(){
        jQuery('.sf-field-taxonomy-taxonomy2 select').val('').trigger('change');
        
    });

    Our next major version has quite a large rewrite and will include a JS api for doing this kind of thing much more easily.

    Hope that helps

    #73386

    Ash
    Participant

    One more question,
    If I set dropdown value from another filter element’s event,
    url query string remains and result is different from what I expected.

    jQuery(‘.sf-field-taxonomy-taxonomy1 select’).on(‘change’,function(){
    jQuery(‘.sf-field-taxonomy-taxonomy2 select’).val(”);
    });

    url query strings after update
    /search/?_sft_taxonomy1=xxx&_sfm_taxonomy2=yyy
    _sfm_taxonomy2 should be removed.

    #70110

    Trevor
    Moderator

    The script would more likely look like this:

    <script type="text/javascript">
    jQuery(document).ready(function($){
      document.getElementById("myButton").onclick=function() {
        $('.myselectorclassname').val('hello');
      }
    });
    </script>

    Exactly what your code will look like depends on what it is you are doing and want to achieve, and stackexchange is the best place to look for examples. The way I have written the code above
    is not how WordPress would say to do it, but it generally works for me.
    If you have a results shortcode on a page, that page should put the results there, yes.

Viewing 10 results - 41 through 50 (of 70 total)