Plugin Directory

Changeset 3195443


Ignore:
Timestamp:
11/23/2024 10:12:22 AM (17 months ago)
Author:
webbytemplate
Message:

Add Office Category feature and update some layout design

Location:
office-locator
Files:
114 added
9 edited

Legend:

Unmodified
Added
Removed
  • office-locator/trunk/README.txt

    r3009822 r3195443  
    11=== Office Locator ===
    22Plugin URI: https://office-locator.webbytemplate.com/
    3 Contributors: webbytemplate,soniakash,rohit-ghoghari
     3Contributors: webbytemplate,soniakash,rohit-ghoghari,webbycrown
    44Donate link: https://webbytemplate.com/
    55Tags: office locator, offices, office locations, office find locator, find office locator, google maps, office addresses, wp office locator, google maps, geocode, gmaps, google map, map locations, geocoding, map addresses
    66Requires at least: 3.0.1
    77Requires PHP: 7.0 or higher
    8 Tested up to: 6.4.2
    9 Stable tag: 1.2.0
     8Tested up to: 6.7.1
     9Stable tag: 1.3.0
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1212
    13 Looking for a reliable and easy-to-use office locator plugin to enhance your business website? Look no further! Our office locator plugin allows your customers to easily find the nearest office location, providing them with a seamless and efficient experience. Improve your customer's experience and streamline your business operations with our top-notch office locator plugin today!
     13Looking for a reliable and easy-to-use office locator plugin to enhance your business website? Look no further! Our office locator plugin allows your customers to easily find the nearest office location, providing them with a seamless and efficient experience. Improve your customer's experience and streamline your business operations with our top-notch office locator plugin today!.
    1414
    1515== Description ==
    1616
    17 An office locator is a software application that helps you find office locations in a given area. It uses various data sources, including Google Maps and geocoding, to display a map of available offices and their addresses.
     17An office locator is a software application that helps you find office locations in a given area. It uses various data sources, including Google Maps and geocoding, to display a map of available offices and their addresses. It Similar to the Multi Store Locator WordPress plugin, it allows users to search for offices based on location, distance, or other filters.
    1818
    1919In this article, we'll explore the features of an office locator and how it can benefit your business.
     
    119119== Changelog ==
    120120
     121= 1.3.0 =
     122* Add Office Category Features.
     123
    121124= 1.2.0 =
    122125* Add Map Language & Map Region Control.
     
    126129= 1.1.0 =
    127130* Add Map Layout Settings.
    128 * Add Stores Fillter control.
     131* Add Office Fillter control.
    129132* Add 8 Different Layout Of Map.   
    130133* Add Start Location Marker Width & Height.
    131134* Add Store Location Marker Width & Height.
    132 * Add Stores Offices Control.
     135* Add Offices Control.
    133136* Add Start Location Marker Control.
    134137* Add Store Location Marker Control.
  • office-locator/trunk/admin/class-office-locator-custom-setting.php

    r3009822 r3195443  
    123123        "BOTTOM_RIGHT"  => __( "BOTTOM RIGHT", 'office-locator' ),
    124124      );
     125
     126      $officecategoryList = get_terms([
     127        'taxonomy' => 'office_category',
     128        'hide_empty' => false,
     129      ]);
     130      $default_office_category_list = array( 0 => __( "Select Category", 'office-locator' ) );
     131      if( is_array($officecategoryList) && count($officecategoryList) > 0 ){
     132        foreach ( $officecategoryList as $olc_cat_key => $olc_cat_value ) {         
     133          $default_office_category_list[$olc_cat_value->term_id] = $olc_cat_value->name;
     134        }
     135      }
    125136
    126137      $map_language = array(
     
    784795        array(
    785796          'type' => 'select',
     797          'title' => __( 'Default Office Category', 'office-locator' ),
     798          'name' => 'map_office_category',
     799          'options' =>  $default_office_category_list,         
     800        ),
     801        array(
     802          'type' => 'select',
    786803          'title' => __( 'Map Office Results', 'office-locator' ),
    787804          'name' => 'map_office_results',
     
    801818        array(
    802819          'type' => 'switch',
     820          'name' => 'office_category_filter',
     821          'title' => __( 'Enable Office Category Filter', 'office-locator' ),
     822          'desc' => '',
     823          'field_desc' => '',
     824          'default' => 'unable'
     825        ),
     826        array(
     827          'type' => 'switch',
    803828          'name' => 'enable_store_filter',
    804           'title' => __( 'Enable Stores Filter Control', 'office-locator' ),
     829          'title' => __( 'Enable Office Filter Control', 'office-locator' ),
    805830          'desc' => '',
    806831          'field_desc' => '',
     
    810835          'type' => 'switch',
    811836          'name' => 'enable_store_office',
    812           'title' => __( 'Enable Stores Offices Control', 'office-locator' ),
     837          'title' => __( 'Enable Offices Control', 'office-locator' ),
    813838          'desc' => '',
    814839          'field_desc' => '',
     
    826851          'type' => 'switch',
    827852          'name' => 'enable_store_location_marker_control',
    828           'title' => __( 'Enable Store Location Marker Control', 'office-locator' ),
     853          'title' => __( 'Enable Office Location Marker Control', 'office-locator' ),
    829854          'desc' => '',
    830855          'field_desc' => '',
     
    842867          'type' => 'switch',
    843868          'name' => 'enable_store_location_marker_pop_up_control',
    844           'title' => __( 'Enable Store Location Marker Pop-Up Control', 'office-locator' ),
     869          'title' => __( 'Enable Office Location Marker Pop-Up Control', 'office-locator' ),
    845870          'desc' => '',
    846871          'field_desc' => '',
  • office-locator/trunk/admin/includes/class-offices-functions.php

    r3009822 r3195443  
    150150register_post_type( 'offices', $args );
    151151
     152$cat_labels = array(
     153    'name'              => __( 'Office Categories', 'office-locator' ),
     154    'singular_name'     => __( 'Office Category', 'office-locator' ),
     155    'search_items'      => __( 'Search Office Categories', 'office-locator' ),
     156    'all_items'         => __( 'All Office Categories', 'office-locator' ),
     157    'parent_item'       => __( 'Parent Office Category', 'office-locator' ),
     158    'parent_item_colon' => __( 'Parent Office Category:', 'office-locator' ),
     159    'edit_item'         => __( 'Edit Office Category', 'office-locator' ),
     160    'update_item'       => __( 'Update Office Category', 'office-locator' ),
     161    'add_new_item'      => __( 'Add New Office Category', 'office-locator' ),
     162    'new_item_name'     => __( 'New Office Category Name', 'office-locator' ),
     163    'menu_name'         => __( 'Office Categories', 'office-locator' ),
     164);
     165
     166$cat_args = array(
     167    'labels' => $cat_labels,
     168    'public'                => false,
     169    'hierarchical'          => true,
     170    'show_ui'               => true,
     171    'show_admin_column'     => true,       
     172    'query_var'             => true,
     173    'show_in_rest'          => true,
     174);
     175register_taxonomy( 'office_category', 'offices', $cat_args );   
     176
    152177}
    153178
     
    200225    </table>
    201226    <?php
     227    wp_nonce_field( basename( __FILE__ ), 'olcMetaNonce' );
    202228}
    203229
     
    263289
    264290public function save_offices_meta_boxes( $post_id ) {
     291
     292    if ( !isset( $_POST['olcMetaNonce'] ) || !wp_verify_nonce( $_POST['olcMetaNonce'], basename( __FILE__ ) ) ){
     293        return;
     294    }
    265295
    266296    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
     
    508538                        'Office State' => $office_state,
    509539                        'Office Country' => $office_country,
    510                         'Office Postal_code' => $office_postal_code
     540                        'Office Postal Code' => $office_postal_code
    511541                    );
    512542                }
     
    518548
    519549        if( $post_data_arr ){
    520             $this->download_send_headers("office-" . date("Y-m-d") . ".csv");
     550            $this->download_send_headers("office-" . date("Y-m-d") . ".csv");         
    521551            echo $this->array2csv($post_data_arr);
    522552        } else {
    523             echo "No data Found!";
     553            $this->download_send_headers("office-" . date("Y-m-d") . ".csv");
     554            $post_data_arr[0] = array(
     555                'Unique ID' => '',
     556                'Name' => '',
     557                'Office Name' => '',
     558                'Office Phone' => '',
     559                'Office Fax' => '' ,
     560                'Office E-mail' => '',
     561                'Office Address' => '',
     562                'Office City' => '',
     563                'Office State' => '',
     564                'Office Country' => '',
     565                'Office Postal Code' => ''
     566            );
     567            echo $this->array2csv($post_data_arr);
    524568        }
    525569        die();
  • office-locator/trunk/languages/office-locator.pot

    r3009822 r3195443  
    44"Project-Id-Version: Office locator\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2023-12-13 11:49+0000\n"
     6"POT-Creation-Date: 2024-11-22 06:07+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1818#: admin/class-office-locator-custom-setting.php:607
    1919#: admin/class-office-locator-custom-setting.php:638
    20 #: admin/class-office-locator-custom-setting.php:891
     20#: admin/class-office-locator-custom-setting.php:899
    2121msgid "%"
    2222msgstr ""
     
    3737msgstr ""
    3838
    39 #: admin/includes/class-offices-functions.php:164
    40 #: admin/includes/class-offices-functions.php:226
     39#: admin/includes/class-offices-functions.php:161
     40msgid "Add New Office Category"
     41msgstr ""
     42
     43#: admin/includes/class-offices-functions.php:189
     44#: admin/includes/class-offices-functions.php:251
    4145msgid "Address"
    4246msgstr ""
     
    5458msgstr ""
    5559
     60#: admin/includes/class-offices-functions.php:156
     61msgid "All Office Categories"
     62msgstr ""
     63
    5664#: admin/includes/class-offices-functions.php:69
    5765msgid "All Offices"
     
    302310msgstr ""
    303311
    304 #: admin/includes/class-offices-functions.php:230
     312#: admin/includes/class-offices-functions.php:255
    305313msgid "City"
    306314msgstr ""
     
    334342msgstr ""
    335343
    336 #: admin/class-office-locator-custom-setting.php:861
     344#: admin/class-office-locator-custom-setting.php:869
    337345msgid "Container"
    338346msgstr ""
     
    346354msgstr ""
    347355
    348 #: admin/includes/class-offices-functions.php:238
     356#: admin/includes/class-offices-functions.php:263
    349357msgid "Country"
    350358msgstr ""
     
    366374msgstr ""
    367375
    368 #: admin/class-office-locator-custom-setting.php:943
     376#: admin/class-office-locator-custom-setting.php:951
    369377msgid "Custom Start Location Marker"
    370378msgstr ""
    371379
    372 #: admin/class-office-locator-custom-setting.php:965
     380#: admin/class-office-locator-custom-setting.php:973
    373381msgid "Custom Store Location Marker"
    374382msgstr ""
    375383
    376 #: admin/class-office-locator-custom-setting.php:921
     384#: admin/class-office-locator-custom-setting.php:929
    377385msgid "Custom Style"
    378386msgstr ""
     
    410418msgstr ""
    411419
    412 #: public/includes/office-locator-ajax-functions.php:165
     420#: public/includes/office-locator-ajax-functions.php:178
    413421msgid "Direction"
    414422msgstr ""
     
    442450msgstr ""
    443451
    444 #: admin/includes/class-offices-functions.php:197
     452#: admin/includes/class-offices-functions.php:222
    445453msgid "E-Mail"
    446454msgstr ""
     
    454462msgstr ""
    455463
     464#: admin/includes/class-offices-functions.php:159
     465msgid "Edit Office Category"
     466msgstr ""
     467
    456468#: admin/class-office-locator-custom-setting.php:256
    457469msgid "Egypt"
     
    474486msgstr ""
    475487
    476 #: admin/class-office-locator-custom-setting.php:998
     488#: admin/class-office-locator-custom-setting.php:804
     489msgid "Enable Office Category Filter"
     490msgstr ""
     491
     492#: admin/class-office-locator-custom-setting.php:812
     493msgid "Enable Office Filter Control"
     494msgstr ""
     495
     496#: admin/class-office-locator-custom-setting.php:836
     497msgid "Enable Office Location Marker Control"
     498msgstr ""
     499
     500#: admin/class-office-locator-custom-setting.php:852
     501msgid "Enable Office Location Marker Pop-Up Control"
     502msgstr ""
     503
     504#: admin/class-office-locator-custom-setting.php:820
     505msgid "Enable Offices Control"
     506msgstr ""
     507
     508#: admin/class-office-locator-custom-setting.php:1006
    477509msgid "Enable Permalink"
    478510msgstr ""
     
    482514msgstr ""
    483515
    484 #: admin/class-office-locator-custom-setting.php:820
     516#: admin/class-office-locator-custom-setting.php:828
    485517msgid "Enable Start Location Marker Control"
    486518msgstr ""
    487519
    488 #: admin/class-office-locator-custom-setting.php:836
     520#: admin/class-office-locator-custom-setting.php:844
    489521msgid "Enable Start Location Marker Pop-Up Control"
    490 msgstr ""
    491 
    492 #: admin/class-office-locator-custom-setting.php:828
    493 msgid "Enable Store Location Marker Control"
    494 msgstr ""
    495 
    496 #: admin/class-office-locator-custom-setting.php:844
    497 msgid "Enable Store Location Marker Pop-Up Control"
    498 msgstr ""
    499 
    500 #: admin/class-office-locator-custom-setting.php:804
    501 msgid "Enable Stores Filter Control"
    502 msgstr ""
    503 
    504 #: admin/class-office-locator-custom-setting.php:812
    505 msgid "Enable Stores Offices Control"
    506522msgstr ""
    507523
     
    550566msgstr ""
    551567
    552 #: admin/class-office-locator-custom-setting.php:1104
     568#: admin/class-office-locator-custom-setting.php:1112
    553569msgid "Export Office Address"
    554570msgstr ""
     
    566582msgstr ""
    567583
    568 #: admin/includes/class-offices-functions.php:193
     584#: admin/includes/class-offices-functions.php:218
    569585msgid "Fax"
    570586msgstr ""
     
    586602msgstr ""
    587603
    588 #: public/template-parts/layout/global/office-locator-filter.php:47
     604#: public/template-parts/layout/global/office-locator-filter.php:72
    589605msgid "Find Stores"
    590606msgstr ""
     
    622638msgstr ""
    623639
    624 #: admin/class-office-locator-custom-setting.php:862
     640#: admin/class-office-locator-custom-setting.php:870
    625641msgid "Full Width"
    626642msgstr ""
     
    781797
    782798#: admin/class-office-locator-custom-setting.php:79
    783 #: admin/class-office-locator-custom-setting.php:1088
     799#: admin/class-office-locator-custom-setting.php:1096
    784800msgid "Import / Export"
    785801msgstr ""
    786802
    787 #: admin/class-office-locator-custom-setting.php:1096
     803#: admin/class-office-locator-custom-setting.php:1104
    788804msgid "Import Office Address"
    789805msgstr ""
     
    10171033msgstr ""
    10181034
    1019 #: admin/class-office-locator-custom-setting.php:900
     1035#: admin/class-office-locator-custom-setting.php:908
    10201036msgid "Map Background Color"
    10211037msgstr ""
    10221038
    1023 #: admin/class-office-locator-custom-setting.php:901
     1039#: admin/class-office-locator-custom-setting.php:909
    10241040msgid "Map Background Color Colours."
    10251041msgstr ""
    10261042
    1027 #: admin/class-office-locator-custom-setting.php:870
     1043#: admin/class-office-locator-custom-setting.php:878
    10281044msgid "Map Container Max Width"
    10291045msgstr ""
    10301046
    1031 #: admin/class-office-locator-custom-setting.php:858
     1047#: admin/class-office-locator-custom-setting.php:866
    10321048msgid "Map Container Size"
    10331049msgstr ""
     
    10411057msgstr ""
    10421058
    1043 #: admin/class-office-locator-custom-setting.php:975
     1059#: admin/class-office-locator-custom-setting.php:983
    10441060msgid "Map Layout"
    10451061msgstr ""
     
    10611077msgstr ""
    10621078
    1063 #: admin/class-office-locator-custom-setting.php:908
     1079#: admin/class-office-locator-custom-setting.php:916
    10641080msgid "Map Styles"
    10651081msgstr ""
     
    11491165msgstr ""
    11501166
    1151 #: admin/includes/class-offices-functions.php:185
     1167#: admin/includes/class-offices-functions.php:210
    11521168msgid "Name"
    11531169msgstr ""
     
    11791195#: admin/includes/class-offices-functions.php:73
    11801196msgid "New Office"
     1197msgstr ""
     1198
     1199#: admin/includes/class-offices-functions.php:162
     1200msgid "New Office Category Name"
    11811201msgstr ""
    11821202
     
    12501270msgstr ""
    12511271
     1272#: admin/includes/class-offices-functions.php:153
    12521273#: admin/includes/class-offices-functions.php:163
     1274msgid "Office Categories"
     1275msgstr ""
     1276
     1277#: admin/includes/class-offices-functions.php:154
     1278#: public/template-parts/layout/global/office-locator-filter.php:42
     1279msgid "Office Category"
     1280msgstr ""
     1281
     1282#: admin/includes/class-offices-functions.php:188
    12531283msgid "Office Information"
    12541284msgstr ""
    12551285
    1256 #: admin/includes/class-offices-functions.php:250
     1286#: admin/includes/class-offices-functions.php:275
    12571287msgid "Office Latitude"
    12581288msgstr ""
     
    12671297msgstr ""
    12681298
    1269 #: admin/includes/class-offices-functions.php:246
     1299#: admin/includes/class-offices-functions.php:271
    12701300msgid "Office Longitude"
    12711301msgstr ""
     
    12991329msgstr ""
    13001330
    1301 #: admin/class-office-locator-custom-setting.php:1046
    1302 #: admin/class-office-locator-custom-setting.php:1052
     1331#: admin/class-office-locator-custom-setting.php:1054
     1332#: admin/class-office-locator-custom-setting.php:1060
    13031333#: admin/includes/class-offices-functions.php:66
    13041334#: admin/includes/class-offices-functions.php:101
     
    13261356msgstr ""
    13271357
    1328 #: admin/class-office-locator-custom-setting.php:1004
     1358#: admin/class-office-locator-custom-setting.php:1012
    13291359msgid "Open Office New Tab"
    13301360msgstr ""
     
    13711401msgstr ""
    13721402
     1403#: admin/includes/class-offices-functions.php:157
     1404msgid "Parent Office Category"
     1405msgstr ""
     1406
     1407#: admin/includes/class-offices-functions.php:158
     1408msgid "Parent Office Category:"
     1409msgstr ""
     1410
    13731411#: admin/class-office-locator-custom-setting.php:74
    1374 #: admin/class-office-locator-custom-setting.php:992
     1412#: admin/class-office-locator-custom-setting.php:1000
    13751413msgid "Permalink"
    13761414msgstr ""
     
    13841422msgstr ""
    13851423
    1386 #: admin/includes/class-offices-functions.php:189
     1424#: admin/includes/class-offices-functions.php:214
    13871425msgid "Phone"
    13881426msgstr ""
     
    13921430msgstr ""
    13931431
    1394 #: public/template-parts/layout/office-locator-layout-8.php:32
     1432#: public/template-parts/layout/office-locator-layout-5.php:47
     1433#: public/template-parts/layout/office-locator-layout-7.php:41
     1434#: public/template-parts/layout/office-locator-layout-4.php:50
     1435#: public/template-parts/layout/office-locator-layout-6.php:47
    13951436#: public/template-parts/layout/office-locator-layout-1.php:45
    1396 #: public/template-parts/layout/office-locator-layout-6.php:47
    1397 #: public/template-parts/layout/office-locator-layout-7.php:41
    1398 #: public/template-parts/layout/office-locator-layout-5.php:47
    13991437#: public/template-parts/layout/office-locator-layout-3.php:51
    14001438#: public/template-parts/layout/office-locator-layout-2.php:45
    1401 #: public/template-parts/layout/office-locator-layout-4.php:50
     1439#: public/template-parts/layout/office-locator-layout-8.php:32
    14021440msgid "Please Enter Google API First to Load Google Map"
    14031441msgstr ""
     
    14271465msgstr ""
    14281466
    1429 #: admin/includes/class-offices-functions.php:242
     1467#: admin/includes/class-offices-functions.php:267
    14301468msgid "Postal Code"
    14311469msgstr ""
     
    14451483#: admin/class-office-locator-custom-setting.php:729
    14461484#: admin/class-office-locator-custom-setting.php:759
    1447 #: admin/class-office-locator-custom-setting.php:890
     1485#: admin/class-office-locator-custom-setting.php:898
    14481486msgid "PX"
    14491487msgstr ""
     
    15431581#: admin/class-admin.php:178
    15441582msgid "Save"
     1583msgstr ""
     1584
     1585#: admin/includes/class-offices-functions.php:155
     1586msgid "Search Office Categories"
    15451587msgstr ""
    15461588
     
    15551597#: admin/class-office-locator-custom-setting.php:726
    15561598#: admin/class-office-locator-custom-setting.php:756
    1557 #: admin/class-office-locator-custom-setting.php:887
     1599#: admin/class-office-locator-custom-setting.php:895
    15581600msgid "Select"
     1601msgstr ""
     1602
     1603#: public/template-parts/layout/global/office-locator-filter.php:44
     1604msgid "Select Category"
    15591605msgstr ""
    15601606
     
    15911637msgstr ""
    15921638
    1593 #: admin/class-office-locator-custom-setting.php:1066
    1594 #: admin/class-office-locator-custom-setting.php:1073
     1639#: admin/class-office-locator-custom-setting.php:1074
     1640#: admin/class-office-locator-custom-setting.php:1081
    15951641msgid "Shortcode"
    15961642msgstr ""
     
    16681714msgstr ""
    16691715
    1670 #: admin/class-office-locator-custom-setting.php:931
     1716#: admin/class-office-locator-custom-setting.php:939
    16711717msgid "Start Location Marker"
    16721718msgstr ""
     
    16841730msgstr ""
    16851731
    1686 #: admin/includes/class-offices-functions.php:234
     1732#: admin/includes/class-offices-functions.php:259
    16871733msgid "State"
    16881734msgstr ""
    16891735
    1690 #: admin/class-office-locator-custom-setting.php:953
     1736#: admin/class-office-locator-custom-setting.php:961
    16911737msgid "Store Location Marker"
    16921738msgstr ""
     
    17001746msgstr ""
    17011747
    1702 #: admin/class-office-locator-custom-setting.php:1010
     1748#: admin/class-office-locator-custom-setting.php:1018
    17031749msgid "Store Slug"
    17041750msgstr ""
     
    17081754msgstr ""
    17091755
    1710 #: admin/class-office-locator-custom-setting.php:852
     1756#: admin/class-office-locator-custom-setting.php:860
    17111757msgid "Styles"
    17121758msgstr ""
     
    17801826msgstr ""
    17811827
    1782 #: admin/class-office-locator-custom-setting.php:1012
     1828#: admin/class-office-locator-custom-setting.php:1020
    17831829msgid "The <b>permalink slugs</b> must be unique on your site"
    17841830msgstr ""
     
    18761922msgstr ""
    18771923
     1924#: admin/includes/class-offices-functions.php:160
     1925msgid "Update Office Category"
     1926msgstr ""
     1927
    18781928#: admin/includes/class-offices-functions.php:86
    18791929msgid "Uploaded to this Office"
     
    19351985#: admin/class-office-locator-custom-setting.php:657
    19361986#: admin/class-office-locator-custom-setting.php:718
    1937 #: admin/class-office-locator-custom-setting.php:879
     1987#: admin/class-office-locator-custom-setting.php:887
    19381988msgid "Width"
    19391989msgstr ""
  • office-locator/trunk/office-locator.php

    r3009822 r3195443  
    44 * Plugin URI:        https://office-locator.webbytemplate.com/
    55 * Description:       A fully featured office locator plugin that allows to add multiples office on your custom page, customizable style for maps and office makers that suits your site.
    6  * Version:           1.2.0
     6 * Version:           1.3.0
    77 * Author:            webbytemplate
    88 * Author URI:        https://webbytemplate.com/
     
    2121 * Currently plugin name ,version.
    2222 */
    23 define( 'OFFICE_LOCATOR_VERSION', '1.2.0' );
     23define( 'OFFICE_LOCATOR_VERSION', '1.3.0' );
    2424define( 'OFFICE_LOCATOR_NAME', 'office-locator' );
    2525define( 'OFFICE_LOCATOR_PLUGIN_FILE', __FILE__ );
  • office-locator/trunk/public/class-public.php

    r3009822 r3195443  
    99class Office_Locator_Public {
    1010
    11     /**
    12      * The ID of this plugin.
    13      *
    14      * @since    1.0.0
    15      * @access   private
    16      * @var      string    $plugin_name    The ID of this plugin.
    17      */
    18     private $plugin_name;
    19 
    20     /**
    21      * The version of this plugin.
    22      *
    23      * @since    1.0.0
    24      * @access   private
    25      * @var      string    $version    The current version of this plugin.
    26      */
    27     private $version;
    28 
    29     /**
    30      * Initialize the class and set its properties.
    31      *
    32      * @since    1.0.0
    33      * @param      string    $plugin_name       The name of the plugin.
    34      * @param      string    $version           The version of this plugin.
    35      */
    36     public function __construct( $plugin_name, $version ) {
    37 
    38         $this->plugin_name = $plugin_name;
    39         $this->version = $version;
    40 
    41         $this->load_public_dependencies();
    42         $this->init_hooks();
    43 
    44         add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
    45         add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
    46         add_action( 'init', array( $this, 'set_ofc_global_variables' ), 9 );
    47         add_filter( 'body_class',array( $this, 'add_office_locator_classes' ) );
    48         add_action( 'wp_head',array( $this, 'add_office_locator_variables' ) );
    49         add_filter( 'template_include', array( $this, 'offices_locator_set_template' ) );
    50 
    51     }
    52 
    53     /**
    54      * Hook into actions and filters.
    55      *
    56      * @since 1.0.0
    57      */
    58     private function init_hooks() {         
    59         add_action( 'after_setup_theme', array( $this, 'include_office_locators_template_functions' ), 11 );
    60     }
    61 
    62     /**
    63      * That function including the functions files.
    64      *
    65      * @since    1.0.0
    66      */
    67     public function include_office_locators_template_functions() { 
    68 
    69         include 'includes/office-locator-ajax-functions.php';
    70         $Office_Locator_Ajax_Functons = new Office_Locator_Ajax_Functons( $this->plugin_name, $this->version );     
    71 
    72     }
    73 
    74     /**
    75      * Register the stylesheets for the public-facing side of the site.
    76      *
    77      * @since    1.0.0
    78      */
    79     public function enqueue_styles() {
    80 
    81         wp_enqueue_style( 'wt-font-awesome', plugin_dir_url( __DIR__ ) . '/admin/css/all.min.css', array(), $this->version, 'all' );
    82         wp_enqueue_style( 'wt-swiper-style', plugin_dir_url( __FILE__ ) . 'css/swiper-bundle.min.css', array(), $this->version, 'all' );
    83         wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/public.css', array(), $this->version, 'all' );
    84     }
    85 
    86     /**
    87      * Register the JavaScript for the public-facing side of the site.
    88      *
    89      * @since    1.0.0
    90      */
    91     public function enqueue_scripts() {
    92 
    93         global $olc_map_markers, $olc_map_styles;
    94         $tab = 'general';
    95         $option_name = str_replace('-', '_', $this->plugin_name) .'_'.$tab;
    96         $options = get_option($option_name);       
    97         $key = ( isset( $options['map_api_key'] ) && !empty( $options['map_api_key'] ) ) ? '&key='.$options['map_api_key'] : '';           
    98         $map_language = ( isset( $options['map_language'] ) && !empty( $options['map_language'] ) ) ? '&language='.$options['map_language'] : '';
    99         $map_region = ( isset( $options['map_region'] ) && !empty( $options['map_region'] ) ) ? '&region='.$options['map_region'] : '';
    100         wp_enqueue_script( 'wt-font-awesome', plugin_dir_url( __DIR__ ) . '/admin/js/all.min.js', array( 'jquery' ), $this->version, true );
    101         wp_enqueue_script( 'wt-swiper-script', plugin_dir_url( __FILE__ ) . 'js/swiper-bundle.min.js', array( 'jquery' ), $this->version, true );
    102         wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/office-locator-public.js', array( 'jquery' ), $this->version, true );       
    103         wp_localize_script( $this->plugin_name, 'ofcAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ));               
    104         wp_enqueue_script( 'olc-google-map', 'https://maps.googleapis.com/maps/api/js?callback=ofcMpInitialize'.$key.''.$map_language.''.$map_region.'&libraries=places&sensor=false', array( 'jquery' ), $this->version, true );
    105     }
    106 
    107     /**
    108      * Make Office Locator Javascript Varibles.
    109      *
    110      * @since    1.0.0
    111      */
    112 
    113     public function add_office_locator_variables(){
    114         ?>
    115         <script type="text/javascript">
    116             var ofcMapObj = <?php echo esc_js( '[]' ); ?>
    117         </script>
    118         <?php
    119     }
    120 
    121 
    122     /**
    123      * Creat Office Locator Set template Parts.
    124      *
    125      * @since    1.0.0
    126      */
    127 
    128     public function offices_locator_set_template( $offices_template ){
    129        
    130         if( is_singular( 'offices' ) && 'single-offices.php' != $offices_template ){
    131             $offices_template = plugin_dir_path( dirname( __FILE__ ) ) . 'public/template-parts/single-offices.php';
    132         }
    133 
    134         $offices_template = apply_filters( 'single_office_template_override' , $offices_template );
    135 
    136         return $offices_template;
    137     }
    138 
    139      /**
    140      * Make Office Locator Global Varibles.
    141      *
    142      * @since    1.0.0
    143      */
    144 
    145      public function set_ofc_global_variables(){
    146 
    147         global $olc_map_markers, $olc_map_styles;
    148         $map_options = str_replace( '-', '_', $this->plugin_name ) .'_map';
    149         $ofcMapData = get_option( $map_options );                       
    150         $ofcMapData['no_result_msg'] = __( "No offices found.", 'office-locator' );     
    151         $ofcMapData['start_location_marker_msg'] = __( 'Your Start Office Location', 'office-locator' );       
    152         $ofcMapData['back_btn_text'] = __( 'Back', 'office-locator' );     
    153 
    154         $general_options = str_replace( '-', '_', $this->plugin_name ) .'_general';
    155         $ofcGeneralData = get_option( $general_options );   
    156 
    157         $olc_start_point = isset( $ofcMapData['olc_start_point'] ) ? $ofcMapData['olc_start_point'] : array();                     
    158         $olc_lat_long = isset($olc_start_point['lat_long']) ? $olc_start_point['lat_long'] : array();
    159         if( $olc_lat_long ){
    160             $olc_lat_long = explode( ',' , $olc_lat_long );
    161         }
    162         $ofcMapData['olc_lat_long'] = $olc_lat_long;
    163 
    164         $ofcRadiusList = array( 10, 25, 50, 100, 200, 500, 1000 );
    165         $ofcResultList = array( 10, 25, 50, 75, 100 );
    166 
    167         $ofcRadiusList = apply_filters( 'office_store_radius_list', $ofcRadiusList );
    168         $ofcResultList = apply_filters( 'office_store_result_list', $ofcResultList );
    169 
    170         $GLOBALS['ofcMapData'] = $ofcMapData;
    171         $GLOBALS['ofcGeneralData'] = $ofcGeneralData;
    172         $GLOBALS['ofcResultList'] = $ofcResultList;
    173         $GLOBALS['ofcRadiusList'] = $ofcRadiusList;
    174      }
    175 
    176       /**
    177      * Return Value Office Locator Map Settings Varibles.
    178      *
    179      * @since    1.0.0
    180      */
    181 
    182       public function set_olc_map_setting( $olcMapAttr ){
    183 
    184         global $olc_map_markers, $olc_map_styles, $olc_map_layout;
    185 
    186         if( empty( $olcMapAttr ) ){
    187             $olcMapAttr = (object)array();
    188         }else{
    189 
    190             $marker_img = '';
    191             if( isset( $olcMapAttr['custom_store_marker']) && !empty( trim( $olcMapAttr['custom_store_marker'] ) )  ){
    192                 $marker_img = wp_get_attachment_url( $olcMapAttr['custom_store_marker'], 'thumbnail' );             
    193             }   
    194             if( empty($marker_img) ){
    195                 if( isset( $olcMapAttr['store_marker']) && !empty( trim( $olcMapAttr['store_marker'] ) )  ){
    196                     $marker_img = isset($olc_map_markers[$olcMapAttr['store_marker']]['img']) ? $olc_map_markers[$olcMapAttr['store_marker']]['img'] : '';
    197                 }               
    198             }   
    199             $olcMapAttr['store_marker'] = $marker_img;
    200 
    201             $start_marker_img = '';
    202             if( isset( $olcMapAttr['custom_start_location_marker']) && !empty( trim( $olcMapAttr['custom_start_location_marker'] ) )  ){
    203                 $start_marker_img = wp_get_attachment_url( $olcMapAttr['custom_start_location_marker'], 'thumbnail' );             
    204             }   
    205             if( empty($start_marker_img) ){
    206                 if( isset( $olcMapAttr['start_location_marker']) && !empty( trim( $olcMapAttr['start_location_marker'] ) )  ){
    207                     $start_marker_img = isset($olc_map_markers[$olcMapAttr['start_location_marker']]['img']) ? $olc_map_markers[$olcMapAttr['start_location_marker']]['img'] : '';
    208                 }               
    209             }   
    210             $olcMapAttr['start_location_marker'] = $start_marker_img;   
    211 
    212             $olc_map_style = '';
    213             if( isset( $olcMapAttr['custom_style'] ) && !empty( trim( $olcMapAttr['custom_style'] ) )  ){
    214                 $olc_map_style_valid =  ( is_string( $olcMapAttr['custom_style'] ) && is_array( json_decode( $olcMapAttr['custom_style'], true ) ) ) ? true : false;
    215                 if( $olc_map_style_valid == true ){
    216                     $olc_map_style = $olcMapAttr['custom_style'];
    217                 }               
    218             }
    219 
    220             if( empty( $olc_map_style ) ){                         
    221                 $map_style = isset($olcMapAttr['map_style']) ? $olcMapAttr['map_style'] : '';                       
    222                 if( $map_style ){                                           
    223                     $map_style_url = plugin_dir_path( __FILE__ ).'map-style-json/'.$map_style.'.json';                 
    224                     $olc_map_style = file_get_contents( $map_style_url );               
    225                     if( $olc_map_style ){
    226                         $olc_map_style = json_decode( $olc_map_style );
    227                     }
    228                 }
    229             }
    230 
    231             $olcMapAttr['map_style'] = $olc_map_style;
    232         }
    233         return $olcMapAttr;
    234       }
    235 
    236       /**
    237      * That function including the public dependencies.
    238      *
    239      * @since    1.0.0
    240      */
    241       public function load_public_dependencies() {
    242 
    243         add_shortcode( 'office_locator', array( $this, 'office_locators' ) );
    244 
    245       }
    246 
    247     /**
    248      * Displaying office locators.
    249      *
    250      * @since    1.0.0
    251      */
    252     public function office_locators( $atts ) {
    253 
    254         ob_start();
    255         global $olc_map_markers, $olc_map_layout, $olc_map_styles, $ofcMapData, $ofcGeneralData;   
    256 
    257         if( isset($atts['lat_long']) && !empty( trim( $atts['lat_long'] ) ) ){
    258             $atts['olc_lat_long'] = explode( ',', trim( $atts['lat_long'] ) );
    259         }
    260 
    261         $default_attr = array(
    262             'offices' => '',
    263             'custom_store_marker' => isset( $ofcMapData['custom_store_marker'] ) ? $ofcMapData['custom_store_marker'] : '',
    264             'custom_start_location_marker' => isset( $ofcMapData['custom_start_location_marker'] ) ? $ofcMapData['custom_start_location_marker'] : '',
    265             'custom_style' => isset( $ofcMapData['custom_style'] ) ? $ofcMapData['custom_style'] : '',
    266             'map_width' => $ofcMapData['map_width']['width'].$ofcMapData['map_width']['value'],
    267             'map_height' => $ofcMapData['map_height']['height'].$ofcMapData['map_height']['value'],
    268             'map_view_type' => $ofcMapData['map_view_type'],
    269             'map_style' => $ofcMapData['map_style'],   
    270             'store_marker' => $ofcMapData['store_marker'],
    271             'start_location_marker' => $ofcMapData['start_location_marker'],
    272             'no_result_msg' => $ofcMapData['no_result_msg'],
    273             'start_location_marker_msg' => $ofcMapData['start_location_marker_msg'],       
    274             'back_btn_text' => $ofcMapData['back_btn_text'],       
    275             'load_olc_stores' => array(),
    276             'olc_zoom_map' => $ofcMapData['outer_zoom_level'],
    277             'olc_inner_map' => $ofcMapData['inner_zoom_level'],
    278             'street_view_control' => $ofcMapData['street_view_control'],
    279             'map_type_control' => $ofcMapData['map_type_control'],
    280             'wheel_zooming' => $ofcMapData['wheel_zooming'],
    281             'full_screen_control' => $ofcMapData['full_screen_control'],
    282             'zoom_control' => $ofcMapData['zoom_control'],
    283             'zoom_position' => $ofcMapData['zoom_position'],
    284             'full_screen_ctlr_pos' => $ofcMapData['full_screen_ctlr_pos'],
    285             'street_view_ctlr_pos' => $ofcMapData['street_view_ctlr_pos'],
    286             'olc_lat_long' => $ofcMapData['olc_lat_long'],
    287             'map_type_ctlr_pos' => $ofcMapData['map_type_ctlr_pos'],
    288             'map_layout' => isset( $ofcMapData['map_layout'] ) ? $ofcMapData['map_layout'] : 'layout-1',
    289             'enable_store_filter' => isset( $ofcMapData['enable_store_filter'] ) ? $ofcMapData['enable_store_filter'] : 'yes',
    290             'enable_store_office' => isset( $ofcMapData['enable_store_office'] ) ? $ofcMapData['enable_store_office'] : 'yes',
    291             'enable_start_location_marker_control' => isset( $ofcMapData['enable_start_location_marker_control'] ) ? $ofcMapData['enable_start_location_marker_control'] : 'yes',
    292             'enable_store_location_marker_control' => isset( $ofcMapData['enable_store_location_marker_control'] ) ? $ofcMapData['enable_store_location_marker_control'] : 'yes',
    293             'enable_start_location_marker_pop_up_control' => isset( $ofcMapData['enable_start_location_marker_pop_up_control'] ) ? $ofcMapData['enable_start_location_marker_pop_up_control'] : 'yes',
    294             'enable_store_location_marker_pop_up_control' => isset( $ofcMapData['enable_store_location_marker_pop_up_control'] ) ? $ofcMapData['enable_store_location_marker_pop_up_control'] : 'yes',
    295             'start_location_marker_width' => isset( $ofcMapData['start_location_marker_width']['width'] ) ? $ofcMapData['start_location_marker_width']['width'] : '25',
    296             'start_location_marker_height' => isset( $ofcMapData['start_location_marker_height']['height'] ) ? $ofcMapData['start_location_marker_height']['height'] : '35',
    297             'store_location_marker_width' => isset( $ofcMapData['store_location_marker_width']['width'] ) ? $ofcMapData['store_location_marker_width']['width'] : '25',
    298             'store_location_marker_height' => isset( $ofcMapData['store_location_marker_height']['height'] ) ? $ofcMapData['store_location_marker_height']['height'] : '35',
    299             'map_container_max_width' => isset( $ofcMapData['map_container_max_width']['width'] ) ? $ofcMapData['map_container_max_width']['width'].$ofcMapData['map_container_max_width']['value'] : '1650px',
    300             'map_container_size' => isset( $ofcMapData['map_container_size'] ) ? $ofcMapData['map_container_size'] : 'container',
    301             'map_background_color' => isset( $ofcMapData['map_background_color'] ) ? $ofcMapData['map_background_color'] : '#f9f9f9',
    302             'map_office_radius' => isset( $ofcMapData['map_office_radius'] ) ? $ofcMapData['map_office_radius'] : 10,
    303             'map_office_results' => isset( $ofcMapData['map_office_results'] ) ? $ofcMapData['map_office_results'] : 10,
    304             'map_office_unit' => isset( $ofcMapData['map_office_unit'] ) ? $ofcMapData['map_office_unit'] : 'km',
    305             'load_olc_markers' => array(),
    306             'olc_view' => '',
    307             'olc_panel' => '',
    308             'olc_map' => ''
    309         );
     11    /**
     12     * The ID of this plugin.
     13     *
     14     * @since    1.0.0
     15     * @access   private
     16     * @var      string    $plugin_name    The ID of this plugin.
     17     */
     18    private $plugin_name;
     19
     20    /**
     21     * The version of this plugin.
     22     *
     23     * @since    1.0.0
     24     * @access   private
     25     * @var      string    $version    The current version of this plugin.
     26     */
     27    private $version;
     28
     29    /**
     30     * Initialize the class and set its properties.
     31     *
     32     * @since    1.0.0
     33     * @param      string    $plugin_name       The name of the plugin.
     34     * @param      string    $version           The version of this plugin.
     35     */
     36    public function __construct( $plugin_name, $version ) {
     37
     38        $this->plugin_name = $plugin_name;
     39        $this->version = $version;
     40
     41        $this->load_public_dependencies();
     42        $this->init_hooks();
     43
     44        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
     45        add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
     46        add_action( 'init', array( $this, 'set_ofc_global_variables' ), 9 );
     47        add_filter( 'body_class',array( $this, 'add_office_locator_classes' ) );
     48        add_action( 'wp_head',array( $this, 'add_office_locator_variables' ) );
     49        add_filter( 'template_include', array( $this, 'offices_locator_set_template' ) );
     50
     51    }
     52
     53    /**
     54     * Hook into actions and filters.
     55     *
     56     * @since 1.0.0
     57     */
     58    private function init_hooks() {         
     59        add_action( 'after_setup_theme', array( $this, 'include_office_locators_template_functions' ), 11 );
     60    }
     61
     62    /**
     63     * That function including the functions files.
     64     *
     65     * @since    1.0.0
     66     */
     67    public function include_office_locators_template_functions() { 
     68
     69        include 'includes/office-locator-ajax-functions.php';
     70        $Office_Locator_Ajax_Functons = new Office_Locator_Ajax_Functons( $this->plugin_name, $this->version );     
     71
     72    }
     73
     74    /**
     75     * Register the stylesheets for the public-facing side of the site.
     76     *
     77     * @since    1.0.0
     78     */
     79    public function enqueue_styles() {
     80
     81        wp_enqueue_style( 'wt-font-awesome', plugin_dir_url( __DIR__ ) . '/admin/css/all.min.css', array(), $this->version, 'all' );
     82        wp_enqueue_style( 'wt-swiper-style', plugin_dir_url( __FILE__ ) . 'css/swiper-bundle.min.css', array(), $this->version, 'all' );
     83        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/public.css', array(), $this->version, 'all' );
     84    }
     85
     86    /**
     87     * Register the JavaScript for the public-facing side of the site.
     88     *
     89     * @since    1.0.0
     90     */
     91    public function enqueue_scripts() {
     92
     93        global $olc_map_markers, $olc_map_styles;
     94        $tab = 'general';
     95        $option_name = str_replace('-', '_', $this->plugin_name) .'_'.$tab;
     96        $options = get_option($option_name);       
     97        $key = ( isset( $options['map_api_key'] ) && !empty( $options['map_api_key'] ) ) ? '&key='.$options['map_api_key'] : '';           
     98        $map_language = ( isset( $options['map_language'] ) && !empty( $options['map_language'] ) ) ? '&language='.$options['map_language'] : '';
     99        $map_region = ( isset( $options['map_region'] ) && !empty( $options['map_region'] ) ) ? '&region='.$options['map_region'] : '';
     100        wp_enqueue_script( 'wt-font-awesome', plugin_dir_url( __DIR__ ) . '/admin/js/all.min.js', array( 'jquery' ), $this->version, true );
     101        wp_enqueue_script( 'wt-swiper-script', plugin_dir_url( __FILE__ ) . 'js/swiper-bundle.min.js', array( 'jquery' ), $this->version, true );
     102        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/office-locator-public.js', array( 'jquery' ), $this->version, true );       
     103        wp_localize_script( $this->plugin_name, 'ofcAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ));               
     104        wp_enqueue_script( 'olc-google-map', 'https://maps.googleapis.com/maps/api/js?callback=ofcMpInitialize'.$key.''.$map_language.''.$map_region.'&libraries=places&sensor=false', array( 'jquery' ), $this->version, true );
     105    }
     106
     107    /**
     108     * Make Office Locator Javascript Varibles.
     109     *
     110     * @since    1.0.0
     111     */
     112
     113    public function add_office_locator_variables(){
     114        ?>
     115        <script type="text/javascript">
     116            var ofcMapObj = <?php echo esc_js( '[]' ); ?>
     117        </script>
     118        <?php
     119    }
     120
     121
     122    /**
     123     * Creat Office Locator Set template Parts.
     124     *
     125     * @since    1.0.0
     126     */
     127
     128    public function offices_locator_set_template( $offices_template ){
     129
     130        if( is_singular( 'offices' ) && 'single-offices.php' != $offices_template ){
     131            $offices_template = plugin_dir_path( dirname( __FILE__ ) ) . 'public/template-parts/single-offices.php';
     132        }
     133
     134        $offices_template = apply_filters( 'single_office_template_override' , $offices_template );
     135
     136        return $offices_template;
     137    }
     138
     139     /**
     140     * Make Office Locator Global Varibles.
     141     *
     142     * @since    1.0.0
     143     */
     144
     145     public function set_ofc_global_variables(){
     146
     147        global $olc_map_markers, $olc_map_styles;
     148        $map_options = str_replace( '-', '_', $this->plugin_name ) .'_map';
     149        $ofcMapData = get_option( $map_options );                       
     150        $ofcMapData['no_result_msg'] = __( "No offices found.", 'office-locator' );     
     151        $ofcMapData['start_location_marker_msg'] = __( 'Your Start Office Location', 'office-locator' );       
     152        $ofcMapData['back_btn_text'] = __( 'Back', 'office-locator' );     
     153
     154        $general_options = str_replace( '-', '_', $this->plugin_name ) .'_general';
     155        $ofcGeneralData = get_option( $general_options );   
     156
     157        $olc_start_point = isset( $ofcMapData['olc_start_point'] ) ? $ofcMapData['olc_start_point'] : array();                     
     158        $olc_lat_long = isset($olc_start_point['lat_long']) ? $olc_start_point['lat_long'] : array();
     159        if( $olc_lat_long ){
     160            $olc_lat_long = explode( ',' , $olc_lat_long );
     161        }
     162        $ofcMapData['olc_lat_long'] = $olc_lat_long;
     163
     164        $ofcRadiusList = array( 10, 25, 50, 100, 200, 500, 1000 );
     165        $ofcResultList = array( 10, 25, 50, 75, 100 );
     166
     167        $ofcRadiusList = apply_filters( 'office_store_radius_list', $ofcRadiusList );
     168        $ofcResultList = apply_filters( 'office_store_result_list', $ofcResultList );
     169
     170        $GLOBALS['ofcMapData'] = $ofcMapData;
     171        $GLOBALS['ofcGeneralData'] = $ofcGeneralData;
     172        $GLOBALS['ofcResultList'] = $ofcResultList;
     173        $GLOBALS['ofcRadiusList'] = $ofcRadiusList;
     174    }
     175
     176      /**
     177     * Return Value Office Locator Map Settings Varibles.
     178     *
     179     * @since    1.0.0
     180     */
     181
     182      public function set_olc_map_setting( $olcMapAttr ){
     183
     184        global $olc_map_markers, $olc_map_styles, $olc_map_layout;
     185
     186        if( empty( $olcMapAttr ) ){
     187            $olcMapAttr = (object)array();
     188        }else{
     189
     190            $marker_img = '';
     191            if( isset( $olcMapAttr['custom_store_marker']) && !empty( trim( $olcMapAttr['custom_store_marker'] ) )  ){
     192                $marker_img = wp_get_attachment_url( $olcMapAttr['custom_store_marker'], 'thumbnail' );             
     193            }   
     194            if( empty($marker_img) ){
     195                if( isset( $olcMapAttr['store_marker']) && !empty( trim( $olcMapAttr['store_marker'] ) )  ){
     196                    $marker_img = isset($olc_map_markers[$olcMapAttr['store_marker']]['img']) ? $olc_map_markers[$olcMapAttr['store_marker']]['img'] : '';
     197                }               
     198            }   
     199            $olcMapAttr['store_marker'] = $marker_img;
     200
     201            $start_marker_img = '';
     202            if( isset( $olcMapAttr['custom_start_location_marker']) && !empty( trim( $olcMapAttr['custom_start_location_marker'] ) )  ){
     203                $start_marker_img = wp_get_attachment_url( $olcMapAttr['custom_start_location_marker'], 'thumbnail' );             
     204            }   
     205            if( empty($start_marker_img) ){
     206                if( isset( $olcMapAttr['start_location_marker']) && !empty( trim( $olcMapAttr['start_location_marker'] ) )  ){
     207                    $start_marker_img = isset($olc_map_markers[$olcMapAttr['start_location_marker']]['img']) ? $olc_map_markers[$olcMapAttr['start_location_marker']]['img'] : '';
     208                }               
     209            }   
     210            $olcMapAttr['start_location_marker'] = $start_marker_img;   
     211
     212            $olc_map_style = '';
     213            if( isset( $olcMapAttr['custom_style'] ) && !empty( trim( $olcMapAttr['custom_style'] ) )  ){
     214                $olc_map_style_valid =  ( is_string( $olcMapAttr['custom_style'] ) && is_array( json_decode( $olcMapAttr['custom_style'], true ) ) ) ? true : false;
     215                if( $olc_map_style_valid == true ){
     216                    $olc_map_style = $olcMapAttr['custom_style'];
     217                }               
     218            }
     219
     220            if( empty( $olc_map_style ) ){                         
     221                $map_style = isset($olcMapAttr['map_style']) ? $olcMapAttr['map_style'] : '';                       
     222                if( $map_style ){                                           
     223                    $map_style_url = plugin_dir_path( __FILE__ ).'map-style-json/'.$map_style.'.json';                 
     224                    $olc_map_style = file_get_contents( $map_style_url );               
     225                    if( $olc_map_style ){
     226                        $olc_map_style = json_decode( $olc_map_style );
     227                    }
     228                }
     229            }
     230
     231            $olcMapAttr['map_style'] = $olc_map_style;
     232        }
     233        return $olcMapAttr;
     234    }
     235
     236      /**
     237     * That function including the public dependencies.
     238     *
     239     * @since    1.0.0
     240     */
     241      public function load_public_dependencies() {
     242
     243        add_shortcode( 'office_locator', array( $this, 'office_locators' ) );
     244
     245    }
     246
     247    /**
     248     * Displaying office locators.
     249     *
     250     * @since    1.0.0
     251     */
     252    public function office_locators( $atts ) {
     253
     254        ob_start();
     255        global $olc_map_markers, $olc_map_layout, $olc_map_styles, $ofcMapData, $ofcGeneralData;   
     256
     257        if( isset($atts['lat_long']) && !empty( trim( $atts['lat_long'] ) ) ){
     258            $atts['olc_lat_long'] = explode( ',', trim( $atts['lat_long'] ) );
     259        }
     260
     261        $default_attr = array(
     262            'offices' => '',
     263            'custom_store_marker' => isset( $ofcMapData['custom_store_marker'] ) ? $ofcMapData['custom_store_marker'] : '',
     264            'custom_start_location_marker' => isset( $ofcMapData['custom_start_location_marker'] ) ? $ofcMapData['custom_start_location_marker'] : '',
     265            'custom_style' => isset( $ofcMapData['custom_style'] ) ? $ofcMapData['custom_style'] : '',
     266            'map_width' => $ofcMapData['map_width']['width'].$ofcMapData['map_width']['value'],
     267            'map_height' => $ofcMapData['map_height']['height'].$ofcMapData['map_height']['value'],
     268            'map_view_type' => $ofcMapData['map_view_type'],
     269            'map_style' => $ofcMapData['map_style'],   
     270            'store_marker' => $ofcMapData['store_marker'],
     271            'start_location_marker' => $ofcMapData['start_location_marker'],
     272            'no_result_msg' => $ofcMapData['no_result_msg'],
     273            'start_location_marker_msg' => $ofcMapData['start_location_marker_msg'],       
     274            'back_btn_text' => $ofcMapData['back_btn_text'],       
     275            'load_olc_stores' => array(),
     276            'olc_zoom_map' => $ofcMapData['outer_zoom_level'],
     277            'olc_inner_map' => $ofcMapData['inner_zoom_level'],
     278            'street_view_control' => $ofcMapData['street_view_control'],
     279            'map_type_control' => $ofcMapData['map_type_control'],
     280            'wheel_zooming' => $ofcMapData['wheel_zooming'],
     281            'full_screen_control' => $ofcMapData['full_screen_control'],
     282            'zoom_control' => $ofcMapData['zoom_control'],
     283            'zoom_position' => $ofcMapData['zoom_position'],
     284            'full_screen_ctlr_pos' => $ofcMapData['full_screen_ctlr_pos'],
     285            'street_view_ctlr_pos' => $ofcMapData['street_view_ctlr_pos'],
     286            'olc_lat_long' => $ofcMapData['olc_lat_long'],
     287            'map_type_ctlr_pos' => $ofcMapData['map_type_ctlr_pos'],
     288            'map_layout' => isset( $ofcMapData['map_layout'] ) ? $ofcMapData['map_layout'] : 'layout-1',
     289            'enable_store_filter' => isset( $ofcMapData['enable_store_filter'] ) ? $ofcMapData['enable_store_filter'] : 'yes',
     290            'enable_store_office' => isset( $ofcMapData['enable_store_office'] ) ? $ofcMapData['enable_store_office'] : 'yes',
     291            'office_category_filter' => isset( $ofcMapData['office_category_filter'] ) ? $ofcMapData['office_category_filter'] : 'no',
     292            'enable_start_location_marker_control' => isset( $ofcMapData['enable_start_location_marker_control'] ) ? $ofcMapData['enable_start_location_marker_control'] : 'yes',
     293            'enable_store_location_marker_control' => isset( $ofcMapData['enable_store_location_marker_control'] ) ? $ofcMapData['enable_store_location_marker_control'] : 'yes',
     294            'enable_start_location_marker_pop_up_control' => isset( $ofcMapData['enable_start_location_marker_pop_up_control'] ) ? $ofcMapData['enable_start_location_marker_pop_up_control'] : 'yes',
     295            'enable_store_location_marker_pop_up_control' => isset( $ofcMapData['enable_store_location_marker_pop_up_control'] ) ? $ofcMapData['enable_store_location_marker_pop_up_control'] : 'yes',
     296            'start_location_marker_width' => isset( $ofcMapData['start_location_marker_width']['width'] ) ? $ofcMapData['start_location_marker_width']['width'] : '25',
     297            'start_location_marker_height' => isset( $ofcMapData['start_location_marker_height']['height'] ) ? $ofcMapData['start_location_marker_height']['height'] : '35',
     298            'store_location_marker_width' => isset( $ofcMapData['store_location_marker_width']['width'] ) ? $ofcMapData['store_location_marker_width']['width'] : '25',
     299            'store_location_marker_height' => isset( $ofcMapData['store_location_marker_height']['height'] ) ? $ofcMapData['store_location_marker_height']['height'] : '35',
     300            'map_container_max_width' => isset( $ofcMapData['map_container_max_width']['width'] ) ? $ofcMapData['map_container_max_width']['width'].$ofcMapData['map_container_max_width']['value'] : '1650px',
     301            'map_container_size' => isset( $ofcMapData['map_container_size'] ) ? $ofcMapData['map_container_size'] : 'container',
     302            'map_background_color' => isset( $ofcMapData['map_background_color'] ) ? $ofcMapData['map_background_color'] : '#f9f9f9',
     303            'map_office_radius' => isset( $ofcMapData['map_office_radius'] ) ? $ofcMapData['map_office_radius'] : 10,
     304            'map_office_category' => isset( $ofcMapData['map_office_category'] ) ? $ofcMapData['map_office_category'] : 0,
     305            'map_office_results' => isset( $ofcMapData['map_office_results'] ) ? $ofcMapData['map_office_results'] : 10,
     306            'map_office_unit' => isset( $ofcMapData['map_office_unit'] ) ? $ofcMapData['map_office_unit'] : 'km',
     307            'load_olc_markers' => array(),
     308            'olc_view' => '',
     309            'olc_panel' => '',
     310            'olc_map' => ''
     311        );
    310312
    311313if( isset( $atts['map_style'] ) && !empty( $atts['map_style'] ) ){
    312     $default_attr['custom_style'] = '';         
     314    $default_attr['custom_style'] = '';         
    313315}
    314316
     
    320322
    321323if( !empty( $olcMapAttr['map_layout'] ) ){
    322     include 'template-parts/layout/office-locator-'.$olcMapAttr['map_layout'].'.php';
     324    include 'template-parts/layout/office-locator-'.$olcMapAttr['map_layout'].'.php';
    323325}
    324326
     
    326328}
    327329
    328     /**
    329      * Adding Office Locator Class.
    330      *
    331      * @since    1.0.0
    332      */
    333     public function add_office_locator_classes() {
    334         $classes[] = 'store-locater';
    335 
    336         return $classes;
    337     }
     330    /**
     331     * Adding Office Locator Class.
     332     *
     333     * @since    1.0.0
     334     */
     335    public function add_office_locator_classes( $classes ) {
     336        $classes[] = 'store-locater';
     337        return $classes;
     338    }
    338339}
  • office-locator/trunk/public/css/public.css

    r3009822 r3195443  
    544544    height: 100%;
    545545 }
    546 
     546.olc-layout .olc-storelocator-filter.office-category-layout .olc-location-search > .olc-input.olc-location-search-box {
     547    width: 50%;
     548}
    547549 /* Fix for Google map More info details*/
    548550
     
    730732    width: 420px;
    731733  }
     734  .olc-layout.layout-5 .olc-results .olc-input.olc-input-category,.olc-layout.layout-6 .olc-results .olc-input.olc-input-category {
     735      flex-direction: column;
     736      flex-grow: 1;
     737  }
     738
     739  .olc-layout.layout-5 .olc-results .olc-input.olc-input,.olc-layout.layout-6 .olc-results .olc-input.olc-input {
     740      width: calc( 50% - 12.5px );
     741  }
     742
     743  .olc-layout.layout-5 .olc-results,.olc-layout.layout-6 .olc-results {
     744      flex-wrap: wrap;
     745  }
     746.olc-layout.layout-5 .olc-storelocator-filter.office-category-layout .olc-location-search > .olc-input.olc-location-search-box,.olc-layout.layout-6 .olc-storelocator-filter.office-category-layout .olc-location-search > .olc-input.olc-location-search-box{
     747  width:100%;
     748}
     749 
    732750  /*======================================
    733751  end---olc-map-layout-5 css
     
    851869  /*<------------ media css ----------->*/
    852870  @media only screen and (max-width: 991px) {
     871    .olc-layout .olc-storelocator-filter.office-category-layout .olc-location-search > .olc-input.olc-location-search-box {
     872    width: 100%;
     873}
    853874    .office-panel {
    854875        width: 400px;
     
    903924      left: -8px;
    904925    }
     926    .olc-layout .olc-results .olc-input.olc-input {
     927        width: calc( 50% - 7.5px ) !important;
     928    }
     929    .olc-layout .olc-results {
     930        flex-wrap: wrap;
     931    }
     932     .olc-layout .olc-results .olc-input.olc-input-category {
     933        flex-direction: column;
     934        flex-grow: 1;
     935    }
     936   
     937    .olc-layout .olc-storelocator-filter .olc-location-search .olc-results {
     938      gap: 15px;
     939      row-gap: 15px;
     940      width: 100%;
     941    }
     942    .olc-layout form.olc-storelocator-filter .olc-input .olc-submit-btn{
     943    margin-top: 0 !important;
     944    }
     945    .olc-layout .olc-storelocator-filter .olc-location-search {   
     946        gap: 15px;
     947    }
     948
    905949  }
    906950
    907951  @media only screen and (max-width: 575px) {
     952   
     953   
    908954    .olc-layout{
    909955      padding: 8px;
     
    925971      flex-wrap: wrap;
    926972    }
    927     .olc-layout .olc-storelocator-filter .olc-location-search .olc-results {
    928       gap: 15px;
    929       row-gap: 15px;
    930       width: 100%;
    931     }
     973   
    932974    .olc-layout .olc-col-1 form.olc-storelocator-filter .olc-input .olc-submit-btn{
    933975      margin-top: 0;
  • office-locator/trunk/public/includes/office-locator-ajax-functions.php

    r3009822 r3195443  
    6363            $distance_unit = ( $olc_distance_unit == 'km' ) ? 6371 : 3959;
    6464            $olc_where = '';
     65            $olc_category = isset($_POST['olc_category']) ?  sanitize_text_field( $_POST['olc_category'] )  : 0;
     66            if ( $olc_category != 0 ) {
     67                $cat_filter = "INNER JOIN $wpdb->term_relationships AS term_rel ON p.ID = term_rel.object_id
     68                INNER JOIN $wpdb->term_taxonomy AS term_tax ON term_rel.term_taxonomy_id = term_tax.term_taxonomy_id
     69                AND term_tax.taxonomy = 'office_category'
     70                AND term_tax.term_id IN (" .$olc_category .")";
     71            }else {
     72                $cat_filter = '';
     73            }
     74
    6575            if( $olc_office_ids ){
    6676                $olc_where = " AND p.ID IN ( ". $olc_office_ids ." ) ";
     
    6878
    6979            $option_name        = str_replace( '-', '_', $this->plugin_name ) .'_permalink';
    70             $general_data       = get_option( $option_name );               
     80            $general_data       = get_option( $option_name );           
     81
     82            $map_option_name        = str_replace( '-', '_', $this->plugin_name ) .'_map';
     83            $map_general_data       = get_option( $map_option_name );       
    7184
    7285            $store_sql = "SELECT p.ID, ( ".$distance_unit." * acos( cos( radians(".$olc_latitude.") ) * cos( radians( olc_lat.meta_value ) ) * cos( radians( olc_lng.meta_value ) - radians(".$olc_longitude.") ) + sin( radians(".$olc_latitude.") ) * sin( radians( olc_lat.meta_value ) ) ) ) AS calculated_distance FROM ".$wpdb->posts." as
     
    7487            INNER JOIN ".$wpdb->postmeta." AS olc_lat ON olc_lat.post_id = p.ID AND olc_lat.meta_key = 'office_latitude'
    7588            INNER JOIN ".$wpdb->postmeta." AS olc_lng ON olc_lng.post_id = p.ID AND olc_lng.meta_key = 'office_longitude'
     89            $cat_filter
    7690            WHERE p.post_type = 'offices'
    7791            AND p.post_status = 'publish'
     
    89103                }
    90104            }
    91             $office_address = $this->set_office_store_html( $office_address, $olc_layout, $general_data );
     105            $office_address = $this->set_office_store_html( $office_address, $olc_layout, $general_data, $map_general_data );
    92106        }
    93107        wp_send_json( $office_address );
    94 
    95108    }
    96109
  • office-locator/trunk/public/template-parts/layout/global/office-locator-filter.php

    r3009822 r3195443  
    1 <form class="olc-storelocator-filter <?php echo esc_attr( $class ); ?>" method="post">
     1<form class="olc-storelocator-filter <?php echo esc_attr( $class ); ?> <?php echo (isset($olcMapAttr['office_category_filter']) && $olcMapAttr['office_category_filter'] == 'yes') ? "office-category-layout": "";  ?>" method="post">
    22    <div class="olc-location-search">           
    3         <div class="olc-input">
     3        <div class="olc-input olc-location-search-box">
    44            <label for="olc-location-search-input"><?php echo __( 'Office Locations', 'office-locator' ); ?></label>
    55            <input class="olc-location-search-input"  name="location_search" placeholder="<?php echo __( 'Enter office locations', 'office-locator' ); ?>" autocomplete="off">
    66        </div>
    77        <div class="olc-results">
    8             <div class="olc-input">
     8            <div class="olc-input olc-input-radius">
    99                <label for="olc_radius"><?php echo __( 'Office Radius', 'office-locator' ); ?></label>   
    1010                <select id="olc_radius" name="olc_radius" class="olc_radius">
     
    2222                </select>               
    2323            </div> 
    24             <div class="olc-input">
     24            <div class="olc-input olc-input-results">
    2525                <label for="olc_results"><?php echo __( 'Office Results', 'office-locator' ); ?></label>                 
    2626                <select class="olc_results" id="olc_results" name="olc_results">
     
    3636                </select>   
    3737            </div>
     38            <?php             
     39            if( isset($olcMapAttr['office_category_filter']) && $olcMapAttr['office_category_filter'] == 'yes'){
     40                ?>
     41                <div class="olc-input olc-input-category">
     42                    <label for="olc_category"><?php  _e( 'Office Category', 'office-locator' ); ?></label>                 
     43                    <select class="olc_category" name="olc_category">
     44                        <option value="0"><?php _e( 'Select Category', 'office-locator' ); ?></option>
     45                        <?php
     46                        $officecategoryList = get_terms([
     47                            'taxonomy' => 'office_category',
     48                            'hide_empty' => false,
     49                        ]);
     50                        if( $officecategoryList ){
     51                            ?>
     52                            <?php
     53                            foreach ( $officecategoryList as $officecategory ) {
     54                                ?>
     55                                <option value="<?php echo esc_attr($officecategory->term_id ); ?>" <?php echo ( ( $officecategory->term_id == $olcMapAttr['map_office_category'] ) ? 'selected' : '' ); ?>><?php echo esc_html( $officecategory->name ); ?></option>
     56                                <?php
     57                            }
     58                        }
     59                        ?>
     60                    </select>   
     61                </div>
     62            <?php } ?>
    3863        </div>
    3964        <div class="olc-input">
Note: See TracChangeset for help on using the changeset viewer.