Test Failed
Pull Request — master (#421)
by Kiran
16:02
created

upgrade.php ➔ geodir_upgrade_1622()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Upgrade related functions.
4
 *
5
 * @since 1.0.0
6
 * @package GeoDirectory
7
 * @global object $wpdb WordPress Database object.
8
 */
9
10
global $wpdb;
11
12
if (get_option('geodirectory' . '_db_version') != GEODIRECTORY_VERSION) {
13
    /**
14
     * Include custom database table related functions.
15
     *
16
     * @since 1.0.0
17
     * @package GeoDirectory
18
     */
19
    include_once('geodirectory-admin/admin_db_install.php');
20
    add_action('plugins_loaded', 'geodirectory_upgrade_all', 10);
21
    if (GEODIRECTORY_VERSION <= '1.3.6') {
22
        add_action('plugins_loaded', 'geodir_upgrade_136', 11);
23
    }
24
25
    if (GEODIRECTORY_VERSION <= '1.4.6') {
26
        add_action('init', 'geodir_upgrade_146', 11);
27
    }
28
29
    if (GEODIRECTORY_VERSION <= '1.4.8') {
30
        add_action('init', 'geodir_upgrade_148', 11);
31
    }
32
33
    if (GEODIRECTORY_VERSION <= '1.5.0') {
34
        add_action('init', 'geodir_upgrade_150', 11);
35
    }
36
37
    if (GEODIRECTORY_VERSION <= '1.5.2') {
38
        add_action('init', 'geodir_upgrade_152', 11);
39
    }
40
41
    if (GEODIRECTORY_VERSION <= '1.5.3') {
42
        add_action('init', 'geodir_upgrade_153', 11);
43
    }
44
45
    if (GEODIRECTORY_VERSION <= '1.5.4') {
46
        add_action('init', 'geodir_upgrade_154', 11);
47
    }
48
    
49
    if (GEODIRECTORY_VERSION <= '1.6.18') {
50
        add_action('init', 'geodir_upgrade_1618', 11);
51
    }
52
    
53
    if (GEODIRECTORY_VERSION <= '1.6.22') {
54
        add_action('init', 'geodir_upgrade_1622', 11);
55
    }
56
57
    add_action('init', 'gd_fix_cpt_rewrite_slug', 11);// this needs to be kept for a few versions
58
59
    update_option('geodirectory' . '_db_version', GEODIRECTORY_VERSION);
60
61
}
62
63
64
/**
65
 * Handles upgrade for all geodirectory versions.
66
 *
67
 * @since 1.0.0
68
 * @package GeoDirectory
69
 */
70
function geodirectory_upgrade_all()
71
{
72
    geodir_create_tables();
73
    geodir_update_review_db();
74
    gd_install_theme_compat();
75
    gd_convert_custom_field_display();
76
}
77
78
/**
79
 * Handles upgrade for geodirectory versions <= 1.3.6.
80
 *
81
 * @since 1.0.0
82
 * @package GeoDirectory
83
 */
84
function geodir_upgrade_136()
85
{
86
    geodir_fix_review_overall_rating();
87
}
88
89
/**
90
 * Handles upgrade for geodirectory versions <= 1.4.6.
91
 *
92
 * @since 1.0.0
93
 * @package GeoDirectory
94
 */
95
function geodir_upgrade_146(){
96
    gd_convert_virtual_pages();
97
}
98
99
/**
100
 * Handles upgrade for geodirectory versions <= 1.5.0.
101
 *
102
 * @since 1.5.0
103
 * @package GeoDirectory
104
 */
105
function geodir_upgrade_150(){
106
    gd_fix_cpt_rewrite_slug();
107
}
108
109
110
111
/**
112
 * Handles upgrade for geodirectory versions <= 1.4.8.
113
 *
114
 * @since 1.4.8
115
 * @package GeoDirectory
116
 */
117
function geodir_upgrade_148(){
118
    /*
119
     * Blank the users google password if present as we now use oAuth 2.0
120
     */
121
    update_option('geodir_ga_pass','');
122
    update_option('geodir_ga_user','');
123
124
}
125
126
127
/**
128
 * Handles upgrade for geodirectory versions <= 1.5.3.
129
 *
130
 * @since 1.5.3
131
 * @package GeoDirectory
132
 */
133
function geodir_upgrade_153(){
134
    geodir_create_page(esc_sql(_x('gd-info', 'page_slug', 'geodirectory')), 'geodir_info_page', __('Info', 'geodirectory'), '');
135
    geodir_create_page(esc_sql(_x('gd-login', 'page_slug', 'geodirectory')), 'geodir_login_page', __('Login', 'geodirectory'), '');
136
}
137
138
/**
139
 * Handles upgrade for geodirectory versions <= 1.5.3.
140
 *
141
 * @since 1.5.3
142
 * @package GeoDirectory
143
 */
144
function geodir_upgrade_154(){
145
    geodir_create_page(esc_sql(_x('gd-home', 'page_slug', 'geodirectory')), 'geodir_home_page', __('GD Home page', 'geodirectory'), '');
146
}
147
148
/**
149
 * Handles upgrade for geodirectory versions <= 1.5.2.
150
 *
151
 * @since 1.5.2
152
 * @package GeoDirectory
153
 */
154
function geodir_upgrade_152(){
155
    gd_fix_address_detail_table_limit();
156
}
157
158
159
160
161
/**
162
 * Handles upgrade for review table.
163
 *
164
 * @since 1.0.0
165
 * @package GeoDirectory
166
 * @global object $wpdb WordPress Database object.
167
 * @global string $plugin_prefix Geodirectory plugin table prefix.
168
 */
169
function geodir_update_review_db()
170
{
171
    global $wpdb, $plugin_prefix;
172
173
    geodir_fix_review_date();
174
    geodir_fix_review_post_status();
175
    geodir_fix_review_content();
176
    geodir_fix_review_location();
177
178
}
179
180
/**
181
 * Fixes review date.
182
 *
183
 * @since 1.0.0
184
 * @package GeoDirectory
185
 * @global object $wpdb WordPress Database object.
186
 */
187
function geodir_fix_review_date()
188
{
189
    global $wpdb;
190
    $wpdb->query("UPDATE " . GEODIR_REVIEW_TABLE . " gdr JOIN $wpdb->comments c ON gdr.comment_id=c.comment_ID SET gdr.post_date = c.comment_date WHERE gdr.post_date='0000-00-00 00:00:00'");
191
}
192
193
/**
194
 * Fixes review post status.
195
 *
196
 * @since 1.0.0
197
 * @package GeoDirectory
198
 * @global object $wpdb WordPress Database object.
199
 */
200
function geodir_fix_review_post_status()
201
{
202
    global $wpdb;
203
    $wpdb->query("UPDATE " . GEODIR_REVIEW_TABLE . " gdr JOIN $wpdb->posts p ON gdr.post_id=p.ID SET gdr.post_status = 1 WHERE gdr.post_status IS NULL AND p.post_status='publish'");
204
}
205
206
/**
207
 * Fixes review content.
208
 *
209
 * @since 1.0.0
210
 * @package GeoDirectory
211
 * @global object $wpdb WordPress Database object.
212
 * @return bool
213
 */
214
function geodir_fix_review_content()
215
{
216
    global $wpdb;
217
    if ($wpdb->query("UPDATE " . GEODIR_REVIEW_TABLE . " gdr JOIN $wpdb->comments c ON gdr.comment_id=c.comment_ID SET gdr.comment_content = c.comment_content WHERE gdr.comment_content IS NULL")) {
218
        return true;
219
    } else {
220
        return false;
221
    }
222
}
223
224
/**
225
 * Fixes review location.
226
 *
227
 * @since 1.0.0
228
 * @package GeoDirectory
229
 * @global object $wpdb WordPress Database object.
230
 * @return bool
231
 */
232
function geodir_fix_review_location()
233
{
234
    global $wpdb;
235
236
    $all_postypes = geodir_get_posttypes();
237
238
    if (!empty($all_postypes)) {
239
        foreach ($all_postypes as $key) {
0 ignored issues
show
Bug introduced by
The expression $all_postypes of type array|object|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
240
            // update each GD CTP
241
242
            $wpdb->query("UPDATE " . GEODIR_REVIEW_TABLE . " gdr JOIN " . $wpdb->prefix . "geodir_" . $key . "_detail d ON gdr.post_id=d.post_id SET gdr.post_latitude = d.post_latitude, gdr.post_longitude = d.post_longitude, gdr.post_city = d.post_city,  gdr.post_region=d.post_region, gdr.post_country=d.post_country WHERE gdr.post_latitude IS NULL OR gdr.post_city IS NULL");
243
244
        }
245
        return true;
246
    }
247
    return false;
248
}
249
250
/**
251
 * Fixes review overall rating.
252
 *
253
 * @since 1.0.0
254
 * @package GeoDirectory
255
 * @global object $wpdb WordPress Database object.
256
 */
257
function geodir_fix_review_overall_rating()
258
{
259
    global $wpdb;
260
261
    $all_postypes = geodir_get_posttypes();
262
263
    if (!empty($all_postypes)) {
264
        foreach ($all_postypes as $key) {
0 ignored issues
show
Bug introduced by
The expression $all_postypes of type array|object|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
265
            // update each GD CTP
266
            $reviews = $wpdb->get_results("SELECT post_id FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
267
268
            if (!empty($reviews)) {
269
                foreach ($reviews as $post_id) {
270
                    geodir_update_postrating($post_id->post_id, $key);
271
                }
272
273
            }
274
275
        }
276
277
    }
278
}
279
280
281
function gd_convert_custom_field_display(){
282
    global $wpdb;
283
284
    $field_info = $wpdb->get_results("select * from " . GEODIR_CUSTOM_FIELDS_TABLE);
285
286
    $has_run = get_option('gd_convert_custom_field_display');
287
    if($has_run){return;}
288
289
    // set the field_type_key for standard fields
290
    $wpdb->query("UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET field_type_key = field_type");
291
292
293
    if(is_array( $field_info)){
294
295
        foreach( $field_info as $cf){
296
297
            $id = $cf->id;
298
299
            if(!property_exists($cf,'show_in') || !$id){return;}
300
301
            $show_in_arr = array();
302
303
            if($cf->is_default){
304
                $show_in_arr[] = "[detail]";
305
            }
306
307
            if($cf->show_on_detail){
308
                $show_in_arr[] = "[moreinfo]";
309
            }
310
311
            if($cf->show_on_listing){
312
                $show_in_arr[] = "[listing]";
313
            }
314
315
            if($cf->show_as_tab || $cf->htmlvar_name=='geodir_video' || $cf->htmlvar_name=='geodir_special_offers'){
316
                $show_in_arr[] = "[owntab]";
317
            }
318
319
            if($cf->htmlvar_name=='post' || $cf->htmlvar_name=='geodir_contact' || $cf->htmlvar_name=='geodir_timing'){
320
                $show_in_arr[] = "[mapbubble]";
321
            }
322
323
            if(!empty($show_in_arr )){
324
                $show_in_arr = implode(',',$show_in_arr);
325
            }else{
326
                $show_in_arr = '';
327
            }
328
329
            $wpdb->query("UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET show_in='$show_in_arr' WHERE id=$id");
330
331
        }
332
333
        update_option('gd_convert_custom_field_display',1);
334
    }
335
}
336
337
############################################
338
########### THEME COMPATIBILITY ############
339
############################################
340
341
/**
342
 * Inserts theme compatibility settings data for supported themes.
343
 *
344
 * @since 1.0.0
345
 * @package GeoDirectory
346
 * @global object $wpdb WordPress Database object.
347
 */
348
function gd_install_theme_compat()
349
{
350
    global $wpdb;
351
352
    $theme_compat = array();
0 ignored issues
show
Unused Code introduced by
$theme_compat is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
353
    $theme_compat = get_option('gd_theme_compats');
354
//GDF
355
    $theme_compat['GeoDirectory_Framework'] = array(
356
        'geodir_wrapper_open_id' => 'geodir_wrapper',
357
        'geodir_wrapper_open_class' => '',
358
        'geodir_wrapper_open_replace' => '',
359
        'geodir_wrapper_close_replace' => '</div></div><!-- content ends here-->',
360
        'geodir_wrapper_content_open_id' => 'geodir_content',
361
        'geodir_wrapper_content_open_class' => '',
362
        'geodir_wrapper_content_open_replace' => '',
363
        'geodir_wrapper_content_close_replace' => '',
364
        'geodir_article_open_id' => '',
365
        'geodir_article_open_class' => '',
366
        'geodir_article_open_replace' => '',
367
        'geodir_article_close_replace' => '',
368
        'geodir_sidebar_right_open_id' => '',
369
        'geodir_sidebar_right_open_class' => '',
370
        'geodir_sidebar_right_open_replace' => '<aside id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
371
        'geodir_sidebar_right_close_replace' => '',
372
        'geodir_sidebar_left_open_id' => '',
373
        'geodir_sidebar_left_open_class' => '',
374
        'geodir_sidebar_left_open_replace' => '<aside  id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
375
        'geodir_sidebar_left_close_replace' => '',
376
        'geodir_main_content_open_id' => '',
377
        'geodir_main_content_open_class' => '',
378
        'geodir_main_content_open_replace' => '<!-- removed -->',
379
        'geodir_main_content_close_replace' => '<!-- removed -->',
380
        'geodir_top_content_add' => '',
381
        'geodir_before_main_content_add' => '<div class="clearfix geodir-common">',
382
        'geodir_before_widget_filter' => '',
383
        'geodir_after_widget_filter' => '',
384
        'geodir_theme_compat_css' => '',
385
        'geodir_theme_compat_js' => '',
386
        'geodir_theme_compat_default_options' => '',
387
        'geodir_theme_compat_code' => ''
388
    );
389
390
//Directory Theme
391
    $theme_compat['Directory_Starter'] = array(
392
        'geodir_wrapper_open_id' => 'geodir_wrapper',
393
        'geodir_wrapper_open_class' => '',
394
        'geodir_wrapper_open_replace' => '',
395
        'geodir_wrapper_close_replace' => '</div></div><!-- content ends here-->',
396
        'geodir_wrapper_content_open_id' => 'geodir_content',
397
        'geodir_wrapper_content_open_class' => '',
398
        'geodir_wrapper_content_open_replace' => '',
399
        'geodir_wrapper_content_close_replace' => '',
400
        'geodir_article_open_id' => '',
401
        'geodir_article_open_class' => '',
402
        'geodir_article_open_replace' => '',
403
        'geodir_article_close_replace' => '',
404
        'geodir_sidebar_right_open_id' => '',
405
        'geodir_sidebar_right_open_class' => '',
406
        'geodir_sidebar_right_open_replace' => '<aside id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
407
        'geodir_sidebar_right_close_replace' => '',
408
        'geodir_sidebar_left_open_id' => '',
409
        'geodir_sidebar_left_open_class' => '',
410
        'geodir_sidebar_left_open_replace' => '<aside  id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
411
        'geodir_sidebar_left_close_replace' => '',
412
        'geodir_main_content_open_id' => '',
413
        'geodir_main_content_open_class' => '',
414
        'geodir_main_content_open_replace' => '<!-- removed -->',
415
        'geodir_main_content_close_replace' => '<!-- removed -->',
416
        'geodir_top_content_add' => '',
417
        'geodir_before_main_content_add' => '<div class="clearfix geodir-common">',
418
        'geodir_before_widget_filter' => '',
419
        'geodir_after_widget_filter' => '',
420
        'geodir_theme_compat_css' => '',
421
        'geodir_theme_compat_js' => '',
422
        'geodir_theme_compat_default_options' => '',
423
        'geodir_theme_compat_code' => ''
424
    );
425
426
//Jobby
427
    $theme_compat['Jobby'] = $theme_compat['Directory_Starter'];
428
429
//GeoProperty
430
    $theme_compat['GeoProperty'] = $theme_compat['Directory_Starter'];
431
432
//Avada
433
    $theme_compat['Avada'] = array(
434
        'geodir_wrapper_open_id' => '',
435
        'geodir_wrapper_open_class' => '',
436
        'geodir_wrapper_open_replace' => '<!-- removed -->',
437
        'geodir_wrapper_close_replace' => '<!-- removed -->',
438
        'geodir_wrapper_content_open_id' => 'content',
439
        'geodir_wrapper_content_open_class' => '',
440
        'geodir_wrapper_content_open_replace' => '',
441
        'geodir_wrapper_content_close_replace' => '',
442
        'geodir_article_open_id' => '',
443
        'geodir_article_open_class' => '',
444
        'geodir_article_open_replace' => '',
445
        'geodir_article_close_replace' => '',
446
        'geodir_sidebar_right_open_id' => '',
447
        'geodir_sidebar_right_open_class' => '',
448
        'geodir_sidebar_right_open_replace' => '<div id="sidebar" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
449
        'geodir_sidebar_right_close_replace' => '</div><!-- end sidebar -->',
450
        'geodir_sidebar_left_open_id' => '',
451
        'geodir_sidebar_left_open_class' => '',
452
        'geodir_sidebar_left_open_replace' => '<div id="sidebar" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
453
        'geodir_sidebar_left_close_replace' => '</div><!-- end sidebar -->',
454
        'geodir_main_content_open_id' => '',
455
        'geodir_main_content_open_class' => '',
456
        'geodir_main_content_open_replace' => '<!-- removed -->',
457
        'geodir_main_content_close_replace' => '<!-- removed -->',
458
        'geodir_top_content_add' => '',
459
        'geodir_before_main_content_add' => '',
460
        'geodir_before_widget_filter' => '',
461
        'geodir_after_widget_filter' => '',
462
        'geodir_theme_compat_css' => stripslashes('.geodir-sidebar-left{float:left}select,textarea{border-style:solid;border-width:1px}.top-menu li > div{visibility:visible}.geodir-chosen-container-single .chosen-single{height:auto}ul li#menu-item-gd-location-switcher ul{width:222px}ul li#menu-item-gd-location-switcher ul li{padding-right:0!important}#mobile-nav li#mobile-menu-item-gd-location-switcher li a{padding-left:10px;padding-right:10px}#menu-item-gd-location-switcher dd,#mobile-menu-item-gd-location-switcher{margin-left:0}#menu-item-gd-location-switcher dd a{display:block}.geodir-chosen-container .chosen-results li.highlighted{background-color:#eee;background-image:none;color:#444}#mobile-nav li.mobile-nav-item li a:before{content:\'\';margin:0}#mobile-nav li.mobile-nav-item li a{padding:10px;width:auto}.geodir-listing-search{text-align:center}.geodir-search{float:none;margin:0}.geodir-search select,.geodir-search .search_by_post,.geodir-search input[type="text"],.geodir-search button[type="button"], .geodir-search input[type="button"],.geodir-search input[type="submit"]{display:inline-block;float:none}.geodir-cat-list ul li,.map_category ul li{list-style-type:none}.wpgeo-avada .page-title ul li:after{content:\'\'}.top_banner_section{margin-bottom:0}.geodir-category-list-in{margin:0;padding:15px}.geodir_full_page .geodir-cat-list .widget-title{margin-top:0}.geodir_full_page .geodir-cat-list ul li{padding-left:0}.geodir-loc-bar{border:none;margin:0;padding:0}.geodir-loc-bar-in{padding:15px 0}.geodir_full_page section.widget{margin-bottom:20px}.sidebar .geodir-loginbox-list li{margin-bottom:10px;padding-bottom:10px}.sidebar .geodir-loginbox-list li a{display:block}.sidebar .geodir-chosen-container .chosen-results li{margin:0;padding:5px 6px}.sidebar .geodir-chosen-container .chosen-results li.highlighted{background:#eee;background-image:none;color:#000}.sidebar .geodir_category_list_view li.geodir-gridview{display:inline-block;margin-bottom:15px}.wpgeo-avada.double-sidebars #main #sidebar{margin-left:3%}.wpgeo-avada.double-sidebars #main #sidebar-2{margin-left:-100%}.wpgeo-avada.double-sidebars #content{float:left;margin-left:0}.geodir_full_page section.widget{margin-bottom: 0px;} .sidebar .widget .geodir-hide {display: none;}li.fusion-mobile-nav-item .geodir_location_tab_container a:before{content: "" !important; margin-right: auto !important;}li.fusion-mobile-nav-item .geodir_location_tab_container a{padding-left:5px !important;}'),
463
        'geodir_theme_compat_js' => '',
464
        'geodir_theme_compat_default_options' => '',
465
        'geodir_theme_compat_code' => 'Avada'
466
    );
467
468
//Enfold
469
    $theme_compat['Enfold'] = array(
470
        'geodir_wrapper_open_id' => '',
471
        'geodir_wrapper_open_class' => '',
472
        'geodir_wrapper_open_replace' => '',
473
        'geodir_wrapper_close_replace' => '</div></div><!-- content ends here-->',
474
        'geodir_wrapper_content_open_id' => '',
475
        'geodir_wrapper_content_open_class' => '',
476
        'geodir_wrapper_content_open_replace' => '',
477
        'geodir_wrapper_content_close_replace' => '</div></main>',
478
        'geodir_article_open_id' => '',
479
        'geodir_article_open_class' => '',
480
        'geodir_article_open_replace' => '',
481
        'geodir_article_close_replace' => '',
482
        'geodir_sidebar_right_open_id' => '',
483
        'geodir_sidebar_right_open_class' => '',
484
        'geodir_sidebar_right_open_replace' => '',
485
        'geodir_sidebar_right_close_replace' => '</div></aside><!-- sidebar ends here-->',
486
        'geodir_sidebar_left_open_id' => '',
487
        'geodir_sidebar_left_open_class' => '',
488
        'geodir_sidebar_left_open_replace' => '',
489
        'geodir_sidebar_left_close_replace' => '</div></aside><!-- sidebar ends here-->',
490
        'geodir_main_content_open_id' => '',
491
        'geodir_main_content_open_class' => '',
492
        'geodir_main_content_open_replace' => '',
493
        'geodir_main_content_close_replace' => '',
494
        'geodir_top_content_add' => '',
495
        'geodir_before_main_content_add' => '',
496
        'geodir_before_widget_filter' => '',
497
        'geodir_after_widget_filter' => '',
498
        'geodir_theme_compat_css' => stripslashes('.geodir_full_page .top_banner_section{margin-bottom:0}.widget .geodir-cat-list ul li{clear:none}.wpgeo-enfold .av-main-nav ul{width:222px}.geodir-listing-search .geodir-loc-bar{border-top:none;padding:0}#main .geodir-listing-search,.geodir-listing-search .geodir-loc-bar{margin-bottom:0}#main .geodir-loc-bar-in,#main .geodir-category-list-in{background-color:#fcfcfc;margin:20px 0;padding:20px}#main .geodir_full_page .geodir-loc-bar-in,#main .geodir_full_page .geodir-loc-bar,#main .geodir_full_page .geodir-category-list-in{margin-top:0;margin-bottom:0}#main .geodir-loc-bar-in{padding:20px}#main .geodir-search{margin:0;width:100%}#main .geodir-search select{margin:0 3% 0 0;padding:8px 10px;width:13%}#main .geodir-search input[type="text"]{margin:0 3% 0 0;padding:10px;width:32.4%}#main .geodir-search input[type="button"],#main .geodir-search input[type="submit"]{font-size:inherit;line-height:2.25;margin:0;padding:7px;width:13%}.enfold-home-top section.widget{margin:0;padding:0}.enfold-home-top .top_banner_section{margin-bottom:0}.enfold-home-top .geodir-loc-bar{background:#fcfcfc;border:none;margin:0;padding:0}#main .enfold-home-top .geodir-loc-bar-in{background:none;border:none;margin:0 auto;padding:20px 0}#main .geodir-breadcrumb{border-bottom-style:solid;border-bottom-width:1px}#gd-tabs dt{clear:none}#geodir_slider ul li{list-style-type:none;margin:0;padding:0}#respond{clear:both}#comments .comments-title span{display:inline;font-size:inherit;font-weight:700}#reviewsTab .comments-area .bypostauthor cite span{display:inline}#top #comments .commentlist .comment,#top #comments .commentlist .comment > div{min-height:0}.commentlist .commenttext{padding-top:15px}#comment_imagesdropbox{margin-bottom:20px}.wpgeo-enfold .geodir_category_list_view li{margin-left:0;padding:0}.widget ul.geodir-loginbox-list{overflow:visible}.geodir_category_list_view li .geodir-post-img{display:block}.wpgeo-enfold .geodir_event_listing_calendar tr.title{background:#ccc}@media only screen and (max-width:480px){.geodir_category_list_view li .geodir-content,.geodir_category_list_view li .geodir-post-img,.geodir_category_list_view li .geodir-addinfo{float:none;width:100%;margin:10px 0}#main .geodir-search input[type="text"],#main .geodir-search input[type="button"],#main .geodir-search input[type="submit"],#main .geodir-search select{margin:10px 0;width:100%}}#main .geodir_full_page section:last-child .geodir-loc-bar{margin-bottom: -1px;border-bottom: none;}'),
499
        'geodir_theme_compat_js' => '',
500
        'geodir_theme_compat_default_options' => '',
501
        'geodir_theme_compat_code' => 'Enfold'
502
    );
503
504
// X
505
    $theme_compat['X'] = array(
506
        'geodir_wrapper_open_id' => '',
507
        'geodir_wrapper_open_class' => '',
508
        'geodir_wrapper_open_replace' => '',
509
        'geodir_wrapper_close_replace' => '',
510
        'geodir_wrapper_content_open_id' => '',
511
        'geodir_wrapper_content_open_class' => '',
512
        'geodir_wrapper_content_open_replace' => '',
513
        'geodir_wrapper_content_close_replace' => '',
514
        'geodir_article_open_id' => '',
515
        'geodir_article_open_class' => '',
516
        'geodir_article_open_replace' => '',
517
        'geodir_article_close_replace' => '',
518
        'geodir_sidebar_right_open_id' => '',
519
        'geodir_sidebar_right_open_class' => '',
520
        'geodir_sidebar_right_open_replace' => '',
521
        'geodir_sidebar_right_close_replace' => '',
522
        'geodir_sidebar_left_open_id' => '',
523
        'geodir_sidebar_left_open_class' => '',
524
        'geodir_sidebar_left_open_replace' => '',
525
        'geodir_sidebar_left_close_replace' => '',
526
        'geodir_main_content_open_id' => '',
527
        'geodir_main_content_open_class' => '',
528
        'geodir_main_content_open_replace' => '',
529
        'geodir_main_content_close_replace' => '',
530
        'geodir_top_content_add' => '',
531
        'geodir_before_main_content_add' => '',
532
        'geodir_before_widget_filter' => '',
533
        'geodir_after_widget_filter' => '',
534
        'geodir_theme_compat_css' => stripslashes('.x-colophon.bottom{clear:both}#geodir-main-content,.geodir_flex-container{margin-top:16px}.geodir-x ul{list-style:none}.widget ul.geodir_category_list_view{border:none}.geodir_category_list_view li.geodir-gridview:last-child{border-bottom:1px solid #e1e1e1}.home .x-header-landmark{display:none}.geodir-x .x-main .geodir_advance_search_widget{margin:0}.geodir-x .top_banner_section{margin-bottom:0}.geodir-loc-bar{background:rgba(0,0,0,0.05);margin:0;padding:0}.geodir-loc-bar-in{background:none;border:none;padding:10px}.geodir-search{margin:0;width:100%}.widget .geodir-search select,.geodir-search input[type="text"],.geodir-search input[type="button"],.geodir-search input[type="submit"]{border:1px solid #ccc;box-shadow:none;height:auto;line-height:21px;margin:0 1% 0 0;padding:5px 10px}.widget .geodir-search select,.geodir-search input[type="text"]{width:28%}.geodir-search input[type="submit"],.geodir-search input[type="button"]{line-height:19px;margin-right:0;width:11%}.geodir-search input:hover[type="submit"],.geodir-search input:hover[type="button"]{background:#333;color:#fff}.geodir-cat-list .widget-title{margin-top:0}.geodir-x .geodir-category-list-in{background:rgba(0,0,0,0.05);border:none}.widget .geodir-cat-list ul.geodir-popular-cat-list{border:none;border-radius:0;box-shadow:none}.geodir_full_page .geodir-cat-list ul li{border:none}.geodir_full_page .geodir-cat-list ul li a{border:none}.post-type-archive .geodir-loc-bar{border:none;margin-top:20px}#menu-item-gd-location-switcher dd{margin-left:0}.geodir-chosen-container-single .chosen-single{height:auto}.widget ul.geodir-loginbox-list{overflow:visible}.geodir_full_page section.widget{clear:both}.x-ethos .entry-title{margin-bottom:20px}.x-ethos .geodir-chosen-container-single .chosen-single{padding:0 0 0 8px}.x-ethos .widget ul li a,.x-ethos .geodir_category_list_view li{color:#333}@media only screen and (max-width:767px){.widget .geodir-search select,.geodir-search input[type="text"],.geodir-search input[type="button"],.geodir-search input[type="submit"]{margin:0 0 10px;width:100%}}.geodir_full_page .geodir-loc-bar-in,.geodir_full_page .geodir-loc-bar,.geodir_full_page .geodir-category-list-in{margin-top:0;margin-bottom:0}.geodir_full_page .geodir-loc-bar-in,.geodir_full_page .geodir-category-list-in{border-bottom:1px solid rgba(0,0,0,0.1)}.geodir_full_page .geodir-listing-search{text-align:center}.geodir_full_page .geodir-search{float:none;margin:0}.geodir_full_page .geodir-search select,.geodir_full_page .geodir-search .search_by_post,.geodir_full_page .geodir-search input[type="text"],.geodir_full_page .geodir-search input[type="button"],.geodir_full_page .geodir-search input[type="submit"]{display:inline-block;float:none}'),
535
        'geodir_theme_compat_js' => '',
536
        'geodir_theme_compat_default_options' => '',
537
        'geodir_theme_compat_code' => 'X'
538
    );
539
540
// Divi
541
    $theme_compat['Divi'] = array(
542
        'geodir_wrapper_open_id' => 'main-content',
543
        'geodir_wrapper_open_class' => '',
544
        'geodir_wrapper_open_replace' => '',
545
        'geodir_wrapper_close_replace' => '',
546
        'geodir_wrapper_content_open_id' => 'left-area',
547
        'geodir_wrapper_content_open_class' => '',
548
        'geodir_wrapper_content_open_replace' => '<div class="container"><div id="content-area" class="clearfix"><div id="[id]" class="[class]" role="main" >',
549
        'geodir_wrapper_content_close_replace' => '',
550
        'geodir_article_open_id' => '',
551
        'geodir_article_open_class' => '',
552
        'geodir_article_open_replace' => '',
553
        'geodir_article_close_replace' => '',
554
        'geodir_sidebar_right_open_id' => 'sidebar',
555
        'geodir_sidebar_right_open_class' => '',
556
        'geodir_sidebar_right_open_replace' => '<aside  id="[id]" class="" role="complementary" itemscope itemtype="[itemtype]" >',
557
        'geodir_sidebar_right_close_replace' => '</aside><!-- sidebar ends here--></div></div>',
558
        'geodir_sidebar_left_open_id' => 'sidebar',
559
        'geodir_sidebar_left_open_class' => '',
560
        'geodir_sidebar_left_open_replace' => '<aside  id="[id]" class="" role="complementary" itemscope itemtype="[itemtype]" >',
561
        'geodir_sidebar_left_close_replace' => '</aside><!-- sidebar ends here--></div></div>',
562
        'geodir_main_content_open_id' => '',
563
        'geodir_main_content_open_class' => '',
564
        'geodir_main_content_open_replace' => '',
565
        'geodir_main_content_close_replace' => '',
566
        'geodir_top_content_add' => '',
567
        'geodir_before_main_content_add' => '',
568
        'geodir_before_widget_filter' => '',
569
        'geodir_after_widget_filter' => '',
570
        'geodir_theme_compat_css' => stripslashes('#left-area ul.geodir-direction-nav{list-style-type:none}#sidebar .geodir-company_info{margin-left:30px}#sidebar .geodir-widget{float:none;margin:0 0 30px 30px}.geodir_full_page .geodir-loc-bar{padding:0;margin:0;border:none}.geodir_full_page .geodir-category-list-in{margin-top:0}.geodir_full_page .top_banner_section{margin-bottom:0}.archive .entry-header,.geodir-breadcrumb{border-bottom:1px solid #e2e2e2}.archive .entry-header h1,ul#breadcrumbs{padding:0 15px;width:100%}#left-area ul.geodir_category_list_view{padding:10px 0}.nav li#menu-item-gd-location-switcher ul{width:222px}#menu-item-gd-location-switcher li.gd-location-switcher-menu-item{padding-right:0}#menu-item-gd-location-switcher dd{margin-left:0}#menu-item-gd-location-switcher .geodir_location_tab_container dd a{padding:5px;width:auto}.geodir_full_page .geodir-listing-search{text-align:center}.geodir_full_page .geodir-search{float:none;margin:0}.geodir_full_page .geodir-search .search_by_post,.geodir_full_page .geodir-search input[type=button],.geodir_full_page .geodir-search input[type=submit],.geodir_full_page .geodir-search input[type=text],.geodir_full_page .geodir-search select{display:inline-block;float:none}'),
571
        'geodir_theme_compat_js' => '',
572
        'geodir_theme_compat_default_options' => '',
573
        'geodir_theme_compat_code' => 'Divi'
574
    );
575
576
// Genesis
577
    $theme_compat['Genesis'] = array(
578
        'geodir_wrapper_open_id' => '',
579
        'geodir_wrapper_open_class' => 'content-sidebar-wrap',
580
        'geodir_wrapper_open_replace' => '',
581
        'geodir_wrapper_close_replace' => '',
582
        'geodir_wrapper_content_open_id' => '',
583
        'geodir_wrapper_content_open_class' => 'content',
584
        'geodir_wrapper_content_open_replace' => '<div class="[class]" role="main" >',
585
        'geodir_wrapper_content_close_replace' => '',
586
        'geodir_article_open_id' => '',
587
        'geodir_article_open_class' => '',
588
        'geodir_article_open_replace' => '',
589
        'geodir_article_close_replace' => '',
590
        'geodir_sidebar_right_open_id' => '',
591
        'geodir_sidebar_right_open_class' => 'sidebar sidebar-primary widget-area',
592
        'geodir_sidebar_right_open_replace' => '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]">',
593
        'geodir_sidebar_right_close_replace' => '',
594
        'geodir_sidebar_left_open_id' => '',
595
        'geodir_sidebar_left_open_class' => 'sidebar sidebar-secondary widget-area',
596
        'geodir_sidebar_left_open_replace' => '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]">',
597
        'geodir_sidebar_left_close_replace' => '',
598
        'geodir_main_content_open_id' => '',
599
        'geodir_main_content_open_class' => '',
600
        'geodir_main_content_open_replace' => '<main  id="[id]" class="entry [class]"  role="main">',
601
        'geodir_main_content_close_replace' => '',
602
        'geodir_top_content_add' => '',
603
        'geodir_before_main_content_add' => '',
604
        'geodir_before_widget_filter' => '',
605
        'geodir_after_widget_filter' => '',
606
        'geodir_location_switcher_menu_li_class_filter' => 'menu-item menu-item-gd-location-switcher menu-item-has-children gd-location-switcher',
607
        'geodir_theme_compat_css' => stripslashes('.full-width-content #geodir-wrapper-content{width:100%}.geodir_full_page .geodir-listing-search{text-align:center}.geodir_full_page .geodir-search{float:none;margin:0}.geodir_full_page .geodir-search select,.geodir_full_page .geodir-search .search_by_post,.geodir_full_page .geodir-search input[type="text"],.geodir_full_page .geodir-search input[type="button"],.geodir_full_page .geodir-search input[type="submit"]{display:inline-block;float:none}.content{float:left}.sidebar-content .content,.sidebar-content #geodir-wrapper-content{float:right}.sidebar .geodir-company_info{background-color:#fff;border:none}.geodir_full_page .geodir-loc-bar{padding:0;margin:0;border:none}.geodir_full_page .geodir-category-list-in{margin-top:0}.geodir_full_page .top_banner_section{margin-bottom:0}.geodir-breadcrumb-bar{margin-bottom:-35px} .search-page .entry-title,.listings-page .entry-title{font-size: 20px;}.site-inner .geodir-breadcrumb-bar{margin-bottom:0px}'),
608
        'geodir_theme_compat_js' => '',
609
        'geodir_theme_compat_default_options' => '',
610
        'geodir_theme_compat_code' => 'Genesis'
611
    );
612
613
// Jupiter
614
    $theme_compat['Jupiter'] = array(
615
        'geodir_wrapper_open_id' => '',
616
        'geodir_wrapper_open_class' => '',
617
        'geodir_wrapper_open_replace' => '<div id="theme-page"><div class="mk-main-wrapper-holder"><div  class="theme-page-wrapper mk-main-wrapper  mk-grid vc_row-fluid">',
618
        'geodir_wrapper_close_replace' => '</div></div></div>',
619
        'geodir_wrapper_content_open_id' => '',
620
        'geodir_wrapper_content_open_class' => '',
621
        'geodir_wrapper_content_open_replace' => '',
622
        'geodir_wrapper_content_close_replace' => '',
623
        'geodir_article_open_id' => '',
624
        'geodir_article_open_class' => '',
625
        'geodir_article_open_replace' => '',
626
        'geodir_article_close_replace' => '',
627
        'geodir_sidebar_right_open_id' => 'mk-sidebar',
628
        'geodir_sidebar_right_open_class' => 'mk-builtin geodir-sidebar-right geodir-listings-sidebar-right',
629
        'geodir_sidebar_right_open_replace' => '',
630
        'geodir_sidebar_right_close_replace' => '',
631
        'geodir_sidebar_left_open_id' => 'mk-sidebar',
632
        'geodir_sidebar_left_open_class' => 'mk-builtin geodir-sidebar-right geodir-listings-sidebar-right',
633
        'geodir_sidebar_left_open_replace' => '',
634
        'geodir_sidebar_left_close_replace' => '',
635
        'geodir_main_content_open_id' => '',
636
        'geodir_main_content_open_class' => '',
637
        'geodir_main_content_open_replace' => '',
638
        'geodir_main_content_close_replace' => '',
639
        'geodir_top_content_add' => '',
640
        'geodir_before_main_content_add' => '',
641
        'geodir_before_widget_filter' => '',
642
        'geodir_after_widget_filter' => '',
643
        'geodir_before_title_filter' => '<h3 class="widgettitle geodir-widget-title">',
644
        'geodir_after_title_filter' => '',
645
        'geodir_menu_li_class_filter' => 'menu-item menu-item-has-children no-mega-menu',
646
        'geodir_sub_menu_ul_class_filter' => '',
647
        'geodir_sub_menu_li_class_filter' => '',
648
        'geodir_menu_a_class_filter' => 'menu-item-link',
649
        'geodir_sub_menu_a_class_filter' => 'menu-item-link one-page-nav-item',
650
        'geodir_location_switcher_menu_li_class_filter' => 'menu-item menu-item-type-social menu-item-type-social gd-location-switcher menu-item-has-children no-mega-menu',
651
        'geodir_location_switcher_menu_a_class_filter' => 'menu-item-link',
652
        'geodir_location_switcher_menu_sub_ul_class_filter' => '',
653
        'geodir_location_switcher_menu_sub_li_class_filter' => '',
654
        'geodir_theme_compat_css' => stripslashes('.geodir-widget li,.geodir_category_list_view li{margin:0}#theme-page h3.geodir-entry-title{font-size:14px}#menu-item-gd-location-switcher dd{line-height:44px}#menu-item-gd-location-switcher .geodir_location_sugestion{line-height:20px}.geodir_loginbox{overflow:visible}.geodir_full_page .geodir-listing-search{text-align:center}.geodir_full_page .geodir-search{float:none;margin:0}.geodir_full_page .geodir-search select,.geodir_full_page .geodir-search .search_by_post,.geodir_full_page .geodir-search input[type="text"],.geodir_full_page .geodir-search input[type="button"],.geodir_full_page .geodir-search input[type="submit"]{display:inline-block;float:none}'),
655
        'geodir_theme_compat_js' => '',
656
        'geodir_theme_compat_default_options' => '',
657
        'geodir_theme_compat_code' => 'Jupiter'
658
    );
659
660
// Multi News
661
    $theme_compat['Multi_News'] = array(
662
        'geodir_wrapper_open_id' => '',
663
        'geodir_wrapper_open_class' => 'main-container clearfix',
664
        'geodir_wrapper_open_replace' => '',
665
        'geodir_wrapper_close_replace' => '',
666
        'geodir_wrapper_content_open_id' => '',
667
        'geodir_wrapper_content_open_class' => '',
668
        'geodir_wrapper_content_open_replace' => '<div class="main-left" ><div class="main-content  "><div class="site-content page-wrap">',
669
        'geodir_wrapper_content_close_replace' => '</div></div></div>',
670
        'geodir_article_open_id' => '',
671
        'geodir_article_open_class' => '',
672
        'geodir_article_open_replace' => '',
673
        'geodir_article_close_replace' => '',
674
        'geodir_sidebar_right_open_id' => '',
675
        'geodir_sidebar_right_open_class' => '',
676
        'geodir_sidebar_right_open_replace' => '<aside  class="sidebar" role="complementary" itemscope itemtype="[itemtype]" >',
677
        'geodir_sidebar_right_close_replace' => '',
678
        'geodir_sidebar_left_open_id' => '',
679
        'geodir_sidebar_left_open_class' => '',
680
        'geodir_sidebar_left_open_replace' => '<aside  class="secondary-sidebar" role="complementary" itemscope itemtype="[itemtype]" >',
681
        'geodir_sidebar_left_close_replace' => '',
682
        'geodir_main_content_open_id' => '',
683
        'geodir_main_content_open_class' => '',
684
        'geodir_main_content_open_replace' => '<div class="site-content page-wrap">',
685
        'geodir_main_content_close_replace' => '</div>',
686
        'geodir_top_content_add' => '',
687
        'geodir_before_main_content_add' => '',
688
        'geodir_full_page_class_filter' => 'section full-width-section',
689
        'geodir_before_widget_filter' => '',
690
        'geodir_after_widget_filter' => '',
691
        'geodir_before_title_filter' => '<div class="widget-title"><h2>',
692
        'geodir_after_title_filter' => '</h2></div>',
693
        'geodir_menu_li_class_filter' => '',
694
        'geodir_sub_menu_ul_class_filter' => '',
695
        'geodir_sub_menu_li_class_filter' => '',
696
        'geodir_menu_a_class_filter' => '',
697
        'geodir_sub_menu_a_class_filter' => '',
698
        'geodir_location_switcher_menu_li_class_filter' => '',
699
        'geodir_location_switcher_menu_a_class_filter' => '',
700
        'geodir_location_switcher_menu_sub_ul_class_filter' => '',
701
        'geodir_location_switcher_menu_sub_li_class_filter' => '',
702
        'geodir_theme_compat_css' => stripslashes('.full-width-section .geodir-search{margin:0;width:100%}.geodir_full_page .geodir-search{margin:0 auto;float:none}.geodir-search input[type=button],.geodir-search input[type=submit]{width:13%}.geodir-search input[type=text]{border:1px solid #ddd;border-radius:0;padding:0 8px}.geodir-category-list-in,.geodir-loc-bar-in{background:#f2f2f2;border-color:#dbdbdb}.geodir-category-list-in{margin-top:0}.geodir-cat-list .widget-title h2{margin:-13px -13px 13px}.widget .geodir-cat-list ul li.geodir-pcat-show a:before{display:none!important}.widget .geodir-cat-list ul li.geodir-pcat-show i{margin-right:5px}.container .geodir-search select{margin:0 3% 0 0;padding:8px 10px;width:13%}#geodir_carousel,#geodir_slider{border-radius:0;-webkit-border-radius:0;-moz-border-radius:0;margin-bottom:20px!important;border:1px solid #e1e1e1;box-shadow:none}#geodir_carousel{padding:10px}.geodir-tabs-content ol.commentlist{margin:40px 0;padding:0}li#post_mapTab{min-height:400px}#reviewsTab ol.commentlist li{border-bottom:none}#reviewsTab ol.commentlist li article.comment{border-bottom:1px solid #e1e1e1;padding-bottom:10px}.comment-content .rating{display:none}.comment-respond .gd_rating{margin-bottom:20px}div.geodir-rating{width:85px!important}.comment-respond .comment-notes{margin-bottom:10px}.average-review span,.comment-form label,.dtreviewed,.geodir-details-sidebar-user-links a,.geodir-viewall,.geodir_more_info span,.reviewer,dl.geodir-tab-head dd a{font-family:"Archivo Narrow",sans-serif}section.comment-content{margin:0 0 0 12%}#reviewsTab .comments-area .comment-content{width:auto}section.comment-content .description,section.comment-content p{margin:15px 0}dl.geodir-tab-head dd a{background:#f3f3f3;margin-top:-1px;font-size:14px;padding:0 15px}dl.geodir-tab-head dd.geodir-tab-active a{padding-bottom:1px}.geodir-widget .geodir_list_heading,.geodir-widget h3.widget-title{padding:0 15px;background:#e9e9e9;border:1px solid #dbdbdb;height:38px;line-height:38px;color:#2d2d2d}.geodir-widget .geodir_list_heading h3{background:0 0;border:none}.geodir-widget .geodir_list_heading{margin:-13px -14px 13px}.geodir-map-listing-page{border-width:1px 0 0;border-style:solid;border-color:#dbdbdb}.geodir-sidebar-wrap .geodir-company_info{margin:15px}.geodir-details-sidebar-social-sharing iframe{float:left}.geodir-details-sidebar-rating{overflow:hidden}.geodir-details-sidebar-rating .gd_rating_show,.geodir-details-sidebar-rating .geodir-rating{float:left;margin-right:15px}.geodir-details-sidebar-rating span.item{float:left;margin-top:5px}.geodir-details-sidebar-rating .average-review{top:-4px;position:relative}.geodir-details-sidebar-rating span.item img{margin-top:5px}.geodir_full_page{background:#fff;border:1px solid #e1e1e1;-webkit-box-shadow:0 1px 0 #e5e5e5;box-shadow:0 1px 0 #e5e5e5;padding:15px;margin-bottom:20px;clear:both}.geodir_map_container .main_list img{margin:0 5px}.geodir_category_list_view li.geodir-gridview .geodir-post-img .geodir_thumbnail{margin-bottom:10px}.geodir-addinfo .geodir-pinpoint,.geodir-addinfo a i{margin-right:5px}.geodir_category_list_view li.geodir-gridview h3{font-size:18px;margin-bottom:10px}#related_listingTab ul.geodir_category_list_view{padding:0!important}#reviewsTab #comments .gd_rating{margin-top:5px}.widget .geodir_category_list_view li .geodir-entry-content,.widget .geodir_category_list_view li a:before{display:none!important}.geodir_category_list_view li .geodir-entry-title{margin-bottom:10px}.widget ul.geodir_category_list_view{padding:15px}.sidebar .widget .geodir_category_list_view li{width:calc(100% - 25px)}.widget .geodir-loginbox-list li{overflow:visible!important}.widget ul.chosen-results{margin:0!important}.main_list_selecter{margin-right:5px}.geodir-viewall{float:right;width:auto!important}.widget-title h2{padding:0 15px;background:#e9e9e9;border:1px solid #dbdbdb;height:38px;line-height:38px}.widget:first-child .geodir_list_heading .widget-title{margin-top:0}.geodir_list_heading .widget-title{float:left;width:80%;margin-top:0}.geodir_list_heading .widget-title h2{padding:0 px;background:0 0;border:none;height:auto;line-height:auto}.chosen-default:before{content:none;display:none;position:absolute;margin-left:-1000000px;float:left}#geodir-wrapper .entry-crumbs{margin-bottom:20px}.geodir-search .mom-select{float:left;width:150px;margin:5px;border:1px solid #ddd;height:40px}.iprelative .gm-style .gm-style-iw{width:100%!important}'),
703
        'geodir_theme_compat_js' => 'jQuery(document).ready(function(e){e(".geodir_full_page").length&&""===e.trim(e(".geodir_full_page").html())&&e(".geodir_full_page").css({display:"none"})});',
704
        'geodir_theme_compat_default_options' => '',
705
        'geodir_theme_compat_code' => 'Multi_News'
706
    );
707
708
    // Kelo
709
    $theme_compat['Kleo'] = array(
710
        'geodir_theme_compat_code' => 'Kleo'
711
    );
712
713
714
    // Twenty Seventeen
715
    $theme_compat['Twenty_Seventeen'] = array(
716
        'geodir_wrapper_open_replace' => '<div class="wrap">',
717
        'geodir_wrapper_content_open_replace' => '<div id="primary" class="content-area" >',
718
        'geodir_sidebar_right_open_replace' => '<aside id="secondary"  class="widget-area" itemscope itemtype="[itemtype]" >',
719
        'geodir_sidebar_left_open_replace' => '<aside id="secondary"  class="widget-area" itemscope itemtype="[itemtype]" >',
720
        'geodir_theme_compat_css' => stripslashes('body.geodir-page #primary header.entry-header {margin-left:0;float:none !important;} .gxeodir_flex-container{float:left;} .geodir-tabs-content.entry-content{width:100% !important;} dl.geodir-tab-head, .geodir_map_container {z-index:2;} .geodir-cat-list ul.geodir-popular-cat-list  li + li {    margin-top: 0;} .geodir-cat-list .geodir-popular-cat-list a img, .entry-content .gm-style a img, .widget .gm-style a img {    box-sizing: none; -webkit-box-shadow: none; -moz-box-shadow: none;}'),
721
        'geodir_theme_compat_code' => 'Twenty_Seventeen'
722
    );
723
724
    // buddyBoss
725
    $theme_compat['Boss.'] = array(
726
        'geodir_wrapper_open_replace' => '<div class="page-right-sidebar">',
727
        'geodir_wrapper_content_open_replace' => '<div id="primary" class="site-content">',
728
        'geodir_article_open_replace' => '<div  id="[id]" class="[class]" itemscope itemtype="[itemtype]">',
729
        'geodir_article_close_replace' => '</div>',
730
        'geodir_sidebar_right_open_replace' => '<div id="secondary" class="widget-area" >',
731
        'geodir_sidebar_right_close_replace' => '</div>',
732
        'geodir_sidebar_left_open_replace' => '<div id="secondary" class="widget-area" >',
733
        'geodir_sidebar_left_close_replace' => '</div>',
734
        'geodir_theme_compat_css' => stripslashes('.geodir-breadcrumb{padding-top:20px;border-bottom:1px solid #ddd;padding-bottom:0} article.geodir-category-listing{padding: 0 !important;}'),
735
        'geodir_theme_compat_code' => 'BuddyBoss'
736
737
738
    );
739
740
    // Flatsome
741
    $theme_compat['Flatsome'] = array(
742
        'geodir_wrapper_open_replace' => '<div class="page-wrapper page-right-sidebar"><div class="row">',
743
        'geodir_wrapper_close_replace' => '</div></div>',
744
        'geodir_wrapper_content_open_replace' => '<div id="content" class="large-9 left col col-divided" role="main"><div class="page-inner">',
745
        'geodir_wrapper_content_close_replace' => '</div></div>',
746
        'geodir_sidebar_right_open_replace' => '<div class="large-3 col"><div id="secondary" class="widget-area " role="complementary">',
747
        'geodir_sidebar_right_close_replace' => '</div></div>',
748
        'geodir_sidebar_left_open_replace' => '<div class="large-3 col"><div id="secondary" class="widget-area " role="complementary">',
749
        'geodir_sidebar_left_close_replace' => '</div></div>',
750
        'geodir_menu_li_class_filter' => 'menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children  has-dropdown',
751
        'geodir_sub_menu_ul_class_filter' => 'nav-dropdown nav-dropdown-default gd-nav-dropdown',
752
        'geodir_sub_menu_li_class_filter' => 'menu-item menu-item-type-custom menu-item-object-custom',
753
        'geodir_menu_a_class_filter' => 'nav-top-link gd-nav-top-link',
754
        'geodir_location_switcher_menu_li_class_filter' => 'menu-item menu-item-type-social menu-item-type-social gd-location-switcher has-dropdown',
755
        'geodir_location_switcher_menu_sub_ul_class_filter' => 'nav-dropdown nav-dropdown-default',
756
        'geodir_theme_compat_css' => stripslashes('dl.geodir_location_tabs_head dt{margin:0;}.header{z-index:90;}'),
757
        'geodir_theme_compat_js' => stripslashes('jQuery(function(){jQuery("#masthead .gd-nav-top-link").append(\'<i class="icon-angle-down"></i>\'),jQuery("#menu-item-gd-location-switcher >  a").append(\'<i class="icon-angle-down"></i>\'),jQuery(".mobile-sidebar .gd-nav-dropdown").addClass("children"),jQuery(".mobile-sidebar .gd-nav-dropdown").removeClass("nav-dropdown nav-dropdown-default"),jQuery(".mobile-sidebar #menu-item-gd-location-switcher ul").removeClass("nav-dropdown nav-dropdown-default"),setTimeout(function(){},5e3)});'),
758
759
760
    );
761
762
763
    update_option('gd_theme_compats', $theme_compat);
764
765
    gd_set_theme_compat();// set the compat pack if avail
766
}
767
768
769
/**
770
 * Converts virtual pages to normal pages.
771
 *
772
 * @since 1.0.0
773
 * @package GeoDirectory
774
 * @global object $wpdb WordPress Database object.
775
 */
776
function gd_convert_virtual_pages(){
777
    global $wpdb;
778
779
    // Update the add listing page settings
780
    $add_listing_page = $wpdb->get_var(
781
        $wpdb->prepare(
782
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
783
            array('add-listing')
784
        )
785
    );
786
787
    if($add_listing_page){
788
        wp_update_post( array('ID' => $add_listing_page, 'post_status' => 'publish') );
789
        update_option( 'geodir_add_listing_page', $add_listing_page);
790
    }
791
792
    // Update the listing preview page settings
793
    $listing_preview_page = $wpdb->get_var(
794
        $wpdb->prepare(
795
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
796
            array('listing-preview')
797
        )
798
    );
799
800
    if($listing_preview_page){
801
        wp_update_post( array('ID' => $listing_preview_page, 'post_status' => 'publish') );
802
        update_option( 'geodir_preview_page', $listing_preview_page);
803
    }
804
805
    // Update the listing success page settings
806
    $listing_success_page = $wpdb->get_var(
807
        $wpdb->prepare(
808
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
809
            array('listing-success')
810
        )
811
    );
812
813
    if($listing_success_page){
814
        wp_update_post( array('ID' => $listing_success_page, 'post_status' => 'publish') );
815
        update_option( 'geodir_success_page', $listing_success_page);
816
    }
817
818
    // Update the listing success page settings
819
    $location_page = $wpdb->get_var(
820
        $wpdb->prepare(
821
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
822
            array('location')
823
        )
824
    );
825
826
    if($location_page){
827
        $location_slug = get_option('geodir_location_prefix');
828
        if(!$location_slug ){$location_slug  = 'location';}
829
        wp_update_post( array('ID' => $location_page, 'post_status' => 'publish','post_name' => $location_slug) );
830
        update_option( 'geodir_location_page', $location_page);
831
    }
832
833
}
834
835
836
/**
837
 * Converts all GD CPT's to the new rewrite slug by removing /%gd_taxonomy% from the slug
838
 *
839
 * @since 1.5.0
840
 * @package GeoDirectory
841
 */
842
function gd_fix_cpt_rewrite_slug()
843
{
844
845
    $alt_post_types = array();
846
    $post_types = get_option('geodir_post_types');
847
848
849
    if (is_array($post_types)){
850
851
        foreach ($post_types as $post_type => $args) {
852
853
854
            if(isset($args['rewrite']['slug'])){
855
                $args['rewrite']['slug'] = str_replace("/%gd_taxonomy%","",$args['rewrite']['slug']);
856
            }
857
858
                $alt_post_types[$post_type] = $args;
859
860
        }
861
    }
862
863
    if(!empty($alt_post_types)) {
864
        update_option('geodir_post_types',$alt_post_types);
865
        }
866
867
868
    // flush the rewrite rules
869
    flush_rewrite_rules();
870
}
871
872
873
/**
874
 * Fixes the address field limit of 30 to 50 in details table.
875
 *
876
 * @since 1.0.0
877
 * @package GeoDirectory
878
 * @global object $wpdb WordPress Database object.
879
 */
880
function gd_fix_address_detail_table_limit()
881
{
882
    global $wpdb;
883
884
    $all_postypes = geodir_get_posttypes();
885
886
    if (!empty($all_postypes)) {
887
        foreach ($all_postypes as $key) {
0 ignored issues
show
Bug introduced by
The expression $all_postypes of type array|object|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
888
            // update each GD CTP
889
            try {
890
                $wpdb->query("ALTER TABLE " . $wpdb->prefix . "geodir_" . $key . "_detail MODIFY post_city VARCHAR( 50 ) NULL,MODIFY post_region VARCHAR( 50 ) NULL,MODIFY post_country VARCHAR( 50 ) NULL");
891
            } catch(Exception $e) {
892
                error_log( 'Error: ' . $e->getMessage() );
893
            }
894
        }
895
    }
896
}
897
898
/**
899
 * Change Czech Republic country name to Czechia.
900
 *
901
 * @since 1.6.18
902
 * @package GeoDirectory
903
 * @global object $wpdb WordPress Database object.
904
 * @return bool
905
 */
906
function geodir_upgrade_1618() {
907
    global $wpdb;
908
909
    $gd_posttypes = geodir_get_posttypes();
910
    $default_location = geodir_get_default_location();
911
    
912
    $old_country = 'Czech Republic';
913
    $old_slug = 'czech-republic';
914
    $new_country = 'Czechia';
915
    $new_slug = 'czechia';
916
    $flush_rewrite_rules = false;
917
918
    if (!empty($gd_posttypes) && defined('POST_LOCATION_TABLE')) {        
919
        // Update locations
920
        if ($wpdb->query($wpdb->prepare("UPDATE `" . POST_LOCATION_TABLE . "` SET `country` = %s, country_slug = %s WHERE `country` LIKE %s OR country_slug LIKE %s", array($new_country, $new_slug, $old_country, $old_slug)))) {
921
            $flush_rewrite_rules = true;
922
        }
923
        
924
        // Update locations seo
925 View Code Duplication
        if ($wpdb->query($wpdb->prepare("UPDATE `" . LOCATION_SEO_TABLE . "` SET `country_slug` = %s WHERE country_slug LIKE %s", array($new_slug, $old_slug)))) {
926
            $flush_rewrite_rules = true;
927
        }
928
929
        // Update term meta
930 View Code Duplication
        if ($wpdb->query($wpdb->prepare("UPDATE `" . GEODIR_TERM_META . "` SET `country_slug` = %s WHERE country_slug LIKE %s", array($new_slug, $old_slug)))) {
931
            $flush_rewrite_rules = true;
932
        }
933
934 View Code Duplication
        if ($wpdb->query($wpdb->prepare("UPDATE `" . GEODIR_TERM_META . "` SET `location_name` = %s WHERE location_type LIKE 'gd_country' AND location_name LIKE %s", array($new_slug, $old_slug)))) {
935
            $flush_rewrite_rules = true;
936
        }
937
938
        // Update detail table
939
        foreach ($gd_posttypes as $pos_type) {
0 ignored issues
show
Bug introduced by
The expression $gd_posttypes of type array|object|string is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
940
            try {
941
                if ($wpdb->query("UPDATE `" . $wpdb->prefix . "geodir_" . $pos_type . "_detail` SET post_country = '" . $new_country . "', post_locations = REPLACE ( post_locations, ',[" . $old_slug . "]', ',[" . $new_slug . "]' ) WHERE post_locations LIKE '%[" . $old_slug . "]' OR post_country LIKE '" . $old_country . "'")) {
942
                    $flush_rewrite_rules = true;
943
                }
944
            } catch(Exception $e) {
945
                error_log( 'Error: ' . $e->getMessage() );
946
            }
947
        }
948
    }
949
    
950
    if (!empty($default_location) && ((isset($default_location->country) && $default_location->country == $old_country) || (isset($default_location->country_slug) && $default_location->country_slug == $old_slug))) {
951
        $default_location->country = $new_country;
952
        $default_location->country_slug = $new_slug;
953
        
954
        update_option('geodir_default_location', $default_location);
955
        
956
        $flush_rewrite_rules = true;
957
    }
958
    
959
    if ($flush_rewrite_rules) {
960
        flush_rewrite_rules();
961
    }
962
    
963
    return true;
964
}
965
966
/**
967
 * Upgrade options for version 1.6.22.
968
 *
969
 * @since 1.6.22
970
 * @package GeoDirectory
971
 * @return bool
972
 */
973
function geodir_upgrade_1622() {
974
    if ( get_option( 'geodir_notify_post_submit', '-1' ) == '-1' ) {
975
        update_option( 'geodir_notify_post_submit', '1' );
976
    }
977
    
978
    return true;
979
}