• tudormv

    (@tudormv)


    Hi Masikonis,

    I recently installed your plugin and very much like the simplicity. During implementation I saw the need of multi country display/hide, so I would like to suggest add to the plugin repo 2 new functions or modification of the existent ones.

    Here are the new functions:

    add_shortcode( 'geolocator_multi_show', array( $this, 'geolocatorMultipleShowShortcode' ) );
    add_shortcode( 'geolocator_multi_hide', array( $this, 'geolocatorMultipleHideShortcode' ) );
    
    function geolocatorMultipleShowShortcode( $attributes, $content = null ) {
    
            $location = $this->location;
    
            if( ! empty( $location ) && array_key_exists( 'for', $attributes ) ) {
    
                $for = trim( $attributes['for'] ); // Country 2-letter ISO code
    
                if ( strpos($for,',') !== FALSE ) {
                    if ( in_array( $location['country'], explode(',', $for) ) ) {
                        return $start_tags . $content . $end_tags;
                    }
                } else {
                    if( $location['country'] == $for ) {
                        return $start_tags . $content . $end_tags;
                    }
                }
            }
    
            return '';
    
        }
    
        function geolocatorMultipleHideShortcode( $attributes, $content = null ) {
    
            $location = $this->location;
    
            if( ! empty( $location ) && array_key_exists( 'for', $attributes ) ) {
    
                $for = trim( $attributes['for'] ); // Country 2-letter ISO code
    
                if ( strpos($for,',') !== FALSE ) {
                    if ( ! in_array( $location['country'], explode(',', $for) ) ) {
                        return $start_tags . $content . $end_tags;
                    }
                } else {
                    if( $location['country'] !== $for ) {
                        return $start_tags . $content . $end_tags;
                    }
                }
            }
    
            return '';
    
        }

    Hope this helps extending the functionality ??

    • This topic was modified 7 years ago by tudormv.
    • This topic was modified 7 years ago by tudormv.
Viewing 1 replies (of 1 total)
  • gfdesign

    (@gfdesign)

    Yes, please. Add support for multiple countries!
    I agree with that feature.

    @tudormv, could you explain how to add your code to our sites?
    Is this something that we just need to add in our functions.php file?
    I’d thank more information.
    Regards from Argentina

Viewing 1 replies (of 1 total)
  • The topic ‘2 new shortcodes suggestion’ is closed to new replies.