Kiran

Forum Replies Created

Viewing 15 posts - 3,811 through 3,825 (of 6,022 total)
  • Author
    Posts
  • in reply to: Custom fields checkbox, add class to item #439368

    Kiran
    Moderator
    Post count: 7069

    Try this

    
    
    /*
     * Add class to multiselect items
     */
    function _gd_custom_multiselect_item_class($html,$location,$cf,$p=''){
        // check we have the post value
        if(is_int($p)){$post = geodir_get_post_info($p);}
        else{ global $post;}
    
        if(!is_array($cf) && $cf!=''){
            $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
            if(!$cf){return NULL;}
        }
    
        $html_var = $cf['htmlvar_name'];
    
        // Check if there is a location specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){
            /**
             * Filter the multiselect html by location.
             *
             * @param string $html The html to filter.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf);
        }
    
        // Check if there is a custom field specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){
            /**
             * Filter the multiselect html by individual custom field.
             *
             * @param string $html The html to filter.
             * @param string $location The location to output the html.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf);
        }
    
        // Check if there is a custom field key specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){
            /**
             * Filter the multiselect html by field type key.
             *
             * @param string $html The html to filter.
             * @param string $location The location to output the html.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf);
        }
    
        // If not html then we run the standard output.
        if(empty($html)){
            if (!empty($post->{$cf['htmlvar_name']})):
                if (is_array($post->{$cf['htmlvar_name']})) {
                    $post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']});
                }
    
                $field_icon = geodir_field_icon_proccess($cf);
                if (strpos($field_icon, 'http') !== false) {
                    $field_icon_af = '';
                } elseif ($field_icon == '') {
                    $field_icon_af = '';
                } else {
                    $field_icon_af = $field_icon;
                    $field_icon = '';
                }
    
                $field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ","));
    
                if(is_array($field_values)){
                    $field_values = array_map('trim', $field_values);
                }
    
                $option_values = array();
                if (!empty($cf['option_values'])) {
                    $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
    
                    if (!empty($cf_option_values)) {
                        foreach ($cf_option_values as $cf_option_value) {
                            if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
                                $option_values[] = $cf_option_value['label'];
                            }
                        }
                    }
                }
    
                $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
                $html .= '</span>';
    
                if (count($option_values) > 1) {
                    $html .= '<ul>';
    
                    foreach ($option_values as $val) {
                        $html .= '<li class="_gd_multi-' . sanitize_html_class( sanitize_title_with_dashes( $val ) ) . '">' . $val . '</li>';
                    }
    
                    $html .= '</ul>';
                } else {
                    $val = __($post->{$cf['htmlvar_name']}, 'geodirectory');
    				$html .= '<ul><li class="_gd_multi-' . sanitize_html_class( sanitize_title_with_dashes( $val ) ) . '">' . $val . '</li></ul>';
                }
    
                $html .= '</div>';
            endif;
    
        }
    
        return $html;
    }
    add_filter('geodir_custom_field_output_multiselect','_gd_custom_multiselect_item_class',9,3);

    Kiran

    in reply to: Map Not Visible #439355

    Kiran
    Moderator
    Post count: 7069

    Hello,

    I have added one test event and it successfully displayed on map. Can you confirm from your side?

    Thanks,
    Kiran

    in reply to: Custom fields in More Tab different html if 1 or 2+ #439255

    Kiran
    Moderator
    Post count: 7069

    Hello Ian,

    Normally UL > LI used when there are more then one list items to display, but for one item we not used it.
    If you want to display UL LI for single item as well then just add following code snippet.

    
    
    /*
     * Add UL to single item for multiselect
     */
    function _gd_custom_multiselect_list_item($html,$location,$cf,$p=''){
    
        // check we have the post value
        if(is_int($p)){$post = geodir_get_post_info($p);}
        else{ global $post;}
    
        if(!is_array($cf) && $cf!=''){
            $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
            if(!$cf){return NULL;}
        }
    
        $html_var = $cf['htmlvar_name'];
    
        // Check if there is a location specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){
            /**
             * Filter the multiselect html by location.
             *
             * @param string $html The html to filter.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf);
        }
    
        // Check if there is a custom field specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){
            /**
             * Filter the multiselect html by individual custom field.
             *
             * @param string $html The html to filter.
             * @param string $location The location to output the html.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf);
        }
    
        // Check if there is a custom field key specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){
            /**
             * Filter the multiselect html by field type key.
             *
             * @param string $html The html to filter.
             * @param string $location The location to output the html.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf);
        }
    
        // If not html then we run the standard output.
        if(empty($html)){
    
            if (!empty($post->{$cf['htmlvar_name']})):
    
                if (is_array($post->{$cf['htmlvar_name']})) {
                    $post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']});
                }
    
                $field_icon = geodir_field_icon_proccess($cf);
                if (strpos($field_icon, 'http') !== false) {
                    $field_icon_af = '';
                } elseif ($field_icon == '') {
                    $field_icon_af = '';
                } else {
                    $field_icon_af = $field_icon;
                    $field_icon = '';
                }
    
                $field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ","));
    
                if(is_array($field_values)){
                    $field_values = array_map('trim', $field_values);
                }
    
                $option_values = array();
                if (!empty($cf['option_values'])) {
                    $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
    
                    if (!empty($cf_option_values)) {
                        foreach ($cf_option_values as $cf_option_value) {
                            if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
                                $option_values[] = $cf_option_value['label'];
                            }
                        }
                    }
                }
    
                $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
                $html .= '</span>';
    
                if (count($option_values) > 1) {
                    $html .= '<ul>';
    
                    foreach ($option_values as $val) {
                        $html .= '<li class="_gd_multi-' . sanitize_html_class( sanitize_title_with_dashes( $val ) ) . '">' . $val . '</li>';
                    }
    
                    $html .= '</ul>';
                } else {
                    $val = __($post->{$cf['htmlvar_name']}, 'geodirectory');
    				$html .= '<ul><li class="_gd_multi-' . sanitize_html_class( sanitize_title_with_dashes( $val ) ) . '">' . $val . '</li></ul>';
                }
    
                $html .= '</div>';
            endif;
    
        }
    
        return $html;
    }
    add_filter('geodir_custom_field_output_multiselect','_gd_custom_multiselect_list_item',9,3);

    Thanks,
    Kiran


    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: Custom fields checkbox, add class to item #439251

    Kiran
    Moderator
    Post count: 7069

    Hello Artur,

    Try following code snippet:

    
    
    /*
     * Add class to multiselect items
     */
    function _gd_custom_multiselect_item_class($html,$location,$cf,$p=''){
        // check we have the post value
        if(is_int($p)){$post = geodir_get_post_info($p);}
        else{ global $post;}
    
        if(!is_array($cf) && $cf!=''){
            $cf = geodir_get_field_infoby('htmlvar_name', $cf, $post->post_type);
            if(!$cf){return NULL;}
        }
    
        $html_var = $cf['htmlvar_name'];
    
        // Check if there is a location specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_loc_{$location}")){
            /**
             * Filter the multiselect html by location.
             *
             * @param string $html The html to filter.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_loc_{$location}",$html,$cf);
        }
    
        // Check if there is a custom field specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_var_{$html_var}")){
            /**
             * Filter the multiselect html by individual custom field.
             *
             * @param string $html The html to filter.
             * @param string $location The location to output the html.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_var_{$html_var}",$html,$location,$cf);
        }
    
        // Check if there is a custom field key specific filter.
        if(has_filter("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}")){
            /**
             * Filter the multiselect html by field type key.
             *
             * @param string $html The html to filter.
             * @param string $location The location to output the html.
             * @param array $cf The custom field array.
             * @since 1.6.6
             */
            $html = apply_filters("geodir_custom_field_output_multiselect_key_{$cf['field_type_key']}",$html,$location,$cf);
        }
    
        // If not html then we run the standard output.
        if(empty($html)){
            if (!empty($post->{$cf['htmlvar_name']})):
                if (is_array($post->{$cf['htmlvar_name']})) {
                    $post->{$cf['htmlvar_name']} = implode(', ', $post->{$cf['htmlvar_name']});
                }
    
                $field_icon = geodir_field_icon_proccess($cf);
                if (strpos($field_icon, 'http') !== false) {
                    $field_icon_af = '';
                } elseif ($field_icon == '') {
                    $field_icon_af = '';
                } else {
                    $field_icon_af = $field_icon;
                    $field_icon = '';
                }
    
                $field_values = explode(',', trim($post->{$cf['htmlvar_name']}, ","));
    
                if(is_array($field_values)){
                    $field_values = array_map('trim', $field_values);
                }
    
                $option_values = array();
                if (!empty($cf['option_values'])) {
                    $cf_option_values = geodir_string_values_to_options(stripslashes_deep($cf['option_values']), true);
    
                    if (!empty($cf_option_values)) {
                        foreach ($cf_option_values as $cf_option_value) {
                            if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
                                $option_values[] = $cf_option_value['label'];
                            }
                        }
                    }
                }
    
                $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af;
                $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : '';
                $html .= '</span>';
    
                if (count($option_values) > 1) {
                    $html .= '<ul>';
    
                    foreach ($option_values as $val) {
                        $html .= '<li class="_gd_multi-' . sanitize_html_class( sanitize_title_with_dashes( $val ) ) . '">' . $val . '</li>';
                    }
    
                    $html .= '</ul>';
                } else {
                    $html .= __($post->{$cf['htmlvar_name']}, 'geodirectory');
                }
    
                $html .= '</div>';
            endif;
    
        }
    
        return $html;
    }
    add_filter('geodir_custom_field_output_multiselect','_gd_custom_multiselect_item_class',9,3);

    This will convert option title in css class.
    Ex: “Gas Central Heating” to “_gd_multi-gas-central-heating”.

    Kiran

    in reply to: Address field is getting blank #439159

    Kiran
    Moderator
    Post count: 7069

    Glad to hear it is working for you 🙂
    Thanks for letting us know.

    Place detail table is created in GeoDirectory core installation.

    Kiran

    in reply to: Address field is getting blank #439146

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: Listing upload problems #439134

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: Popular categories now showing #439123

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: links on map #439056

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: he titles in google for our website are showing wrong #439025

    Kiran
    Moderator
    Post count: 7069

    Hello,

    Can you please help me to find out why I have 2 title tags in source code and if those are maybe caused by our GD child theme in use?

    You have included <title> tag in child theme header.php, remove it to fix 2 title tags issue.

    thanks,
    Kiran

    in reply to: links on map #438934

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: links on map #438917

    Kiran
    Moderator
    Post count: 7069
    This reply has been marked as private.
    in reply to: links on map #438902

    Kiran
    Moderator
    Post count: 7069

    Hello,

    The permalink issue has been fixed and updated on both dev and live site.

    You have disabled place categories translation from WPML settings.
    It is good to use language in url like /en/ or /sl/, because using lang=en may sometimes it looses lang parameter from url.

    Please check and let us know.

    Thanks,
    Kiran

    in reply to: Hide Fields From Logged Out Users #438881

    Kiran
    Moderator
    Post count: 7069

    Hello Luca,

    Add following code snippet to hide fields from guest users.

    
    
    function _gd_custom_setup_guest_hide_field() {
    	if ( is_user_logged_in() ) {
    		return;
    	}
    
    	$fields = array();
    	$fields[] = 'geodir_contact';
    	$fields[] = 'geodir_email';
    	// ADD MORE FIELDS HERE
    
    	if ( ! empty( $fields ) ) {
    		foreach ( $fields as $field ) {
    			add_filter( 'geodir_show_' . $field, '_gd_custom_guest_hide_field', 10, 2 );
    		}
    	}
    }
    add_filter( 'init', '_gd_custom_setup_guest_hide_field', 10 );
    
    function _gd_custom_guest_hide_field( $html, $params ) {
    	if ( ! is_user_logged_in() ) {
    		$html = '';
    	}
    	return $html;
    }

    Currently it is working with phone & email fields but you can add more fields at “// ADD MORE FIELDS HERE”.

    Thanks,
    Kiran

Viewing 15 posts - 3,811 through 3,825 (of 6,022 total)
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount