Connections-Business-Directory / Connections

Directory Plugin for WordPress
https://connections-pro.com
GNU General Public License v2.0
26 stars 18 forks source link

implements regions and countries #338

Closed quantumJLBass closed 10 years ago

quantumJLBass commented 10 years ago

I have tested this out with this plugin https://github.com/jeremyBass/connections-expsearch shown on https://github.com/jeremyBass/connections-expsearch/blob/master/connections_expsearch.php#L426 .. Everything seems stable. I have also added the phone codes too so that one can prefix. I have not added any more to the core till this is ok .. didn't want to do mass changes if this was not ok.

quantumJLBass commented 10 years ago

this references #333

shazahm1 commented 10 years ago

Cool, I'll pull this first thing in the morning and give it a go w/ you plugin.

quantumJLBass commented 10 years ago

Super, the search plugin is still a little rough, I will be doing clean up on that soon and adding settings. Just fyi.

shazahm1 commented 10 years ago

Ok, I pulled down and gave it a whirl using the searchexp plugin. I'm going to merge, make minor changes ... mostly just style. But I will be changing method filter names. Shouldn't effect the search at all. Oh, stupidity on my part ... I already have a cnGEO class. I'm going to move this to that class instead since that makes much more sense.

One question though...

This: public static function getCountryByCode($code="fail"){

Why make $code optional? Wouldn't doing an is_string and ! empty check be better?

shazahm1 commented 10 years ago

Oh, I guess moving the code to cnGEO will effect you searchexp plugin. Also, I have a suggestion on that. I''l open an issue in that plugins github repo rather than mix it in here.

shazahm1 commented 10 years ago

Hmmm, looks like these two methods should stay in the options class and settings added to core for them ... maybe. Whats the use case?

/**
     * Get Base Country
     *
     * @since
     * @return string $country The two letter country code for the base country
     */
    public static function getCountry() {
        global $connections;
        $base_country = $connections->settings->get( 'connections', 'connections_general', 'base_country' );
        $country = $base_country ? $base_country : 'US';
        return apply_filters( 'cn_country', $country );
    }

    /**
     * Get Base State
     *
     * @since
     * @return string $state The base state name
     */
    public static function getRegion() {
        global $connections;
        $base_region = $connections->settings->get( 'connections', 'connections_general', 'base_region' );
        $region = $base_region ? $base_region : 'WA';
        return apply_filters( 'cn_region', $region );
    }
quantumJLBass commented 10 years ago

So on the getCountry() and getRegion() they are just helpers to get the default settings, which are not set in the core yet. if you have a cnGEO please put it in there if your wishing to I can change my stuff right now. On the

public static function getCountryByCode($code="fail"){

Yeah that was just a quickie for the POC thing so please feel free to change.

Please feel to rise issues on the sub plugin. Its a little dirty, although I just go down templating it.

shazahm1 commented 10 years ago

Ok, this is merge,tweaked and pushed back up. Thanks for the code!

Oh, I also added the settings options for base country and base region. Another, untested, method I added was a function to retrieve a dial code by country code. Seemed like it would be useful to call just a single dial code.

quantumJLBass commented 10 years ago

yes that makes sense on the dail code for sure. I figure that if you switched countries that maybe an ajax call happens and the new regoins get pulled in? I figured there area a few ways that can be done, but I didn't want to put that in till this was locked down.

shazahm1 commented 10 years ago

Yeah, doing ajax call would be better. But for now what happens when you set the country the region will default to the first one in the array and if there are no regions for the selected country, the region option simply will not show. after a country is selected and saved, a user can than change regions. It works but when I have more time a chained select and updates via ajax would far better ux.