Test Failed
Pull Request — master (#375)
by Kiran
27:48
created

upgrade.php ➔ geodir_upgrade_1618()   C

Complexity

Conditions 16
Paths 68

Size

Total Lines 59
Code Lines 32

Duplication

Lines 9
Ratio 15.25 %

Importance

Changes 0
Metric Value
cc 16
eloc 32
nc 68
nop 0
dl 9
loc 59
rs 6.364
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
    add_action('init', 'gd_fix_cpt_rewrite_slug', 11);// this needs to be kept for a few versions
54
55
    update_option('geodirectory' . '_db_version', GEODIRECTORY_VERSION);
56
57
}
58
59
60
/**
61
 * Handles upgrade for all geodirectory versions.
62
 *
63
 * @since 1.0.0
64
 * @package GeoDirectory
65
 */
66
function geodirectory_upgrade_all()
67
{
68
    geodir_create_tables();
69
    geodir_update_review_db();
70
    gd_install_theme_compat();
71
    gd_convert_custom_field_display();
72
}
73
74
/**
75
 * Handles upgrade for geodirectory versions <= 1.3.6.
76
 *
77
 * @since 1.0.0
78
 * @package GeoDirectory
79
 */
80
function geodir_upgrade_136()
81
{
82
    geodir_fix_review_overall_rating();
83
}
84
85
/**
86
 * Handles upgrade for geodirectory versions <= 1.4.6.
87
 *
88
 * @since 1.0.0
89
 * @package GeoDirectory
90
 */
91
function geodir_upgrade_146(){
92
    gd_convert_virtual_pages();
93
}
94
95
/**
96
 * Handles upgrade for geodirectory versions <= 1.5.0.
97
 *
98
 * @since 1.5.0
99
 * @package GeoDirectory
100
 */
101
function geodir_upgrade_150(){
102
    gd_fix_cpt_rewrite_slug();
103
}
104
105
106
107
/**
108
 * Handles upgrade for geodirectory versions <= 1.4.8.
109
 *
110
 * @since 1.4.8
111
 * @package GeoDirectory
112
 */
113
function geodir_upgrade_148(){
114
    /*
115
     * Blank the users google password if present as we now use oAuth 2.0
116
     */
117
    update_option('geodir_ga_pass','');
118
    update_option('geodir_ga_user','');
119
120
}
121
122
123
/**
124
 * Handles upgrade for geodirectory versions <= 1.5.3.
125
 *
126
 * @since 1.5.3
127
 * @package GeoDirectory
128
 */
129
function geodir_upgrade_153(){
130
    geodir_create_page(esc_sql(_x('gd-info', 'page_slug', 'geodirectory')), 'geodir_info_page', __('Info', 'geodirectory'), '');
131
    geodir_create_page(esc_sql(_x('gd-login', 'page_slug', 'geodirectory')), 'geodir_login_page', __('Login', 'geodirectory'), '');
132
}
133
134
/**
135
 * Handles upgrade for geodirectory versions <= 1.5.3.
136
 *
137
 * @since 1.5.3
138
 * @package GeoDirectory
139
 */
140
function geodir_upgrade_154(){
141
    geodir_create_page(esc_sql(_x('gd-home', 'page_slug', 'geodirectory')), 'geodir_home_page', __('GD Home page', 'geodirectory'), '');
142
}
143
144
/**
145
 * Handles upgrade for geodirectory versions <= 1.5.2.
146
 *
147
 * @since 1.5.2
148
 * @package GeoDirectory
149
 */
150
function geodir_upgrade_152(){
151
    gd_fix_address_detail_table_limit();
152
}
153
154
155
156
157
/**
158
 * Handles upgrade for review table.
159
 *
160
 * @since 1.0.0
161
 * @package GeoDirectory
162
 * @global object $wpdb WordPress Database object.
163
 * @global string $plugin_prefix Geodirectory plugin table prefix.
164
 */
165
function geodir_update_review_db()
166
{
167
    global $wpdb, $plugin_prefix;
168
169
    geodir_fix_review_date();
170
    geodir_fix_review_post_status();
171
    geodir_fix_review_content();
172
    geodir_fix_review_location();
173
174
}
175
176
/**
177
 * Fixes review date.
178
 *
179
 * @since 1.0.0
180
 * @package GeoDirectory
181
 * @global object $wpdb WordPress Database object.
182
 */
183
function geodir_fix_review_date()
184
{
185
    global $wpdb;
186
    $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'");
187
}
188
189
/**
190
 * Fixes review post status.
191
 *
192
 * @since 1.0.0
193
 * @package GeoDirectory
194
 * @global object $wpdb WordPress Database object.
195
 */
196
function geodir_fix_review_post_status()
197
{
198
    global $wpdb;
199
    $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'");
200
}
201
202
/**
203
 * Fixes review content.
204
 *
205
 * @since 1.0.0
206
 * @package GeoDirectory
207
 * @global object $wpdb WordPress Database object.
208
 * @return bool
209
 */
210
function geodir_fix_review_content()
211
{
212
    global $wpdb;
213
    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")) {
214
        return true;
215
    } else {
216
        return false;
217
    }
218
}
219
220
/**
221
 * Fixes review location.
222
 *
223
 * @since 1.0.0
224
 * @package GeoDirectory
225
 * @global object $wpdb WordPress Database object.
226
 * @return bool
227
 */
228
function geodir_fix_review_location()
229
{
230
    global $wpdb;
231
232
    $all_postypes = geodir_get_posttypes();
233
234
    if (!empty($all_postypes)) {
235
        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...
236
            // update each GD CTP
237
238
            $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");
239
240
        }
241
        return true;
242
    }
243
    return false;
244
}
245
246
/**
247
 * Fixes review overall rating.
248
 *
249
 * @since 1.0.0
250
 * @package GeoDirectory
251
 * @global object $wpdb WordPress Database object.
252
 */
253
function geodir_fix_review_overall_rating()
254
{
255
    global $wpdb;
256
257
    $all_postypes = geodir_get_posttypes();
258
259
    if (!empty($all_postypes)) {
260
        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...
261
            // update each GD CTP
262
            $reviews = $wpdb->get_results("SELECT post_id FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
263
264
            if (!empty($reviews)) {
265
                foreach ($reviews as $post_id) {
266
                    geodir_update_postrating($post_id->post_id, $key);
267
                }
268
269
            }
270
271
        }
272
273
    }
274
}
275
276
277
function gd_convert_custom_field_display(){
278
    global $wpdb;
279
280
    $field_info = $wpdb->get_results("select * from " . GEODIR_CUSTOM_FIELDS_TABLE);
281
282
    $has_run = get_option('gd_convert_custom_field_display');
283
    if($has_run){return;}
284
285
    // set the field_type_key for standard fields
286
    $wpdb->query("UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET field_type_key = field_type");
287
288
289
    if(is_array( $field_info)){
290
291
        foreach( $field_info as $cf){
292
293
            $id = $cf->id;
294
295
            if(!property_exists($cf,'show_in') || !$id){return;}
296
297
            $show_in_arr = array();
298
299
            if($cf->is_default){
300
                $show_in_arr[] = "[detail]";
301
            }
302
303
            if($cf->show_on_detail){
304
                $show_in_arr[] = "[moreinfo]";
305
            }
306
307
            if($cf->show_on_listing){
308
                $show_in_arr[] = "[listing]";
309
            }
310
311
            if($cf->show_as_tab || $cf->htmlvar_name=='geodir_video' || $cf->htmlvar_name=='geodir_special_offers'){
312
                $show_in_arr[] = "[owntab]";
313
            }
314
315
            if($cf->htmlvar_name=='post' || $cf->htmlvar_name=='geodir_contact' || $cf->htmlvar_name=='geodir_timing'){
316
                $show_in_arr[] = "[mapbubble]";
317
            }
318
319
            if(!empty($show_in_arr )){
320
                $show_in_arr = implode(',',$show_in_arr);
321
            }else{
322
                $show_in_arr = '';
323
            }
324
325
            $wpdb->query("UPDATE ".GEODIR_CUSTOM_FIELDS_TABLE." SET show_in='$show_in_arr' WHERE id=$id");
326
327
        }
328
329
        update_option('gd_convert_custom_field_display',1);
330
    }
331
}
332
333
############################################
334
########### THEME COMPATIBILITY ############
335
############################################
336
337
/**
338
 * Inserts theme compatibility settings data for supported themes.
339
 *
340
 * @since 1.0.0
341
 * @package GeoDirectory
342
 * @global object $wpdb WordPress Database object.
343
 */
344
function gd_install_theme_compat()
345
{
346
    global $wpdb;
347
348
    $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...
349
    $theme_compat = get_option('gd_theme_compats');
350
//GDF
351
    $theme_compat['GeoDirectory_Framework'] = array(
352
        'geodir_wrapper_open_id' => 'geodir_wrapper',
353
        'geodir_wrapper_open_class' => '',
354
        'geodir_wrapper_open_replace' => '',
355
        'geodir_wrapper_close_replace' => '</div></div><!-- content ends here-->',
356
        'geodir_wrapper_content_open_id' => 'geodir_content',
357
        'geodir_wrapper_content_open_class' => '',
358
        'geodir_wrapper_content_open_replace' => '',
359
        'geodir_wrapper_content_close_replace' => '',
360
        'geodir_article_open_id' => '',
361
        'geodir_article_open_class' => '',
362
        'geodir_article_open_replace' => '',
363
        'geodir_article_close_replace' => '',
364
        'geodir_sidebar_right_open_id' => '',
365
        'geodir_sidebar_right_open_class' => '',
366
        'geodir_sidebar_right_open_replace' => '<aside id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
367
        'geodir_sidebar_right_close_replace' => '',
368
        'geodir_sidebar_left_open_id' => '',
369
        'geodir_sidebar_left_open_class' => '',
370
        'geodir_sidebar_left_open_replace' => '<aside  id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
371
        'geodir_sidebar_left_close_replace' => '',
372
        'geodir_main_content_open_id' => '',
373
        'geodir_main_content_open_class' => '',
374
        'geodir_main_content_open_replace' => '<!-- removed -->',
375
        'geodir_main_content_close_replace' => '<!-- removed -->',
376
        'geodir_top_content_add' => '',
377
        'geodir_before_main_content_add' => '<div class="clearfix geodir-common">',
378
        'geodir_before_widget_filter' => '',
379
        'geodir_after_widget_filter' => '',
380
        'geodir_theme_compat_css' => '',
381
        'geodir_theme_compat_js' => '',
382
        'geodir_theme_compat_default_options' => '',
383
        'geodir_theme_compat_code' => ''
384
    );
385
386
//Directory Theme
387
    $theme_compat['Directory_Starter'] = array(
388
        'geodir_wrapper_open_id' => 'geodir_wrapper',
389
        'geodir_wrapper_open_class' => '',
390
        'geodir_wrapper_open_replace' => '',
391
        'geodir_wrapper_close_replace' => '</div></div><!-- content ends here-->',
392
        'geodir_wrapper_content_open_id' => 'geodir_content',
393
        'geodir_wrapper_content_open_class' => '',
394
        'geodir_wrapper_content_open_replace' => '',
395
        'geodir_wrapper_content_close_replace' => '',
396
        'geodir_article_open_id' => '',
397
        'geodir_article_open_class' => '',
398
        'geodir_article_open_replace' => '',
399
        'geodir_article_close_replace' => '',
400
        'geodir_sidebar_right_open_id' => '',
401
        'geodir_sidebar_right_open_class' => '',
402
        'geodir_sidebar_right_open_replace' => '<aside id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
403
        'geodir_sidebar_right_close_replace' => '',
404
        'geodir_sidebar_left_open_id' => '',
405
        'geodir_sidebar_left_open_class' => '',
406
        'geodir_sidebar_left_open_replace' => '<aside  id="gd-sidebar-wrapper" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
407
        'geodir_sidebar_left_close_replace' => '',
408
        'geodir_main_content_open_id' => '',
409
        'geodir_main_content_open_class' => '',
410
        'geodir_main_content_open_replace' => '<!-- removed -->',
411
        'geodir_main_content_close_replace' => '<!-- removed -->',
412
        'geodir_top_content_add' => '',
413
        'geodir_before_main_content_add' => '<div class="clearfix geodir-common">',
414
        'geodir_before_widget_filter' => '',
415
        'geodir_after_widget_filter' => '',
416
        'geodir_theme_compat_css' => '',
417
        'geodir_theme_compat_js' => '',
418
        'geodir_theme_compat_default_options' => '',
419
        'geodir_theme_compat_code' => ''
420
    );
421
422
//Jobby
423
    $theme_compat['Jobby'] = $theme_compat['Directory_Starter'];
424
425
//GeoProperty
426
    $theme_compat['GeoProperty'] = $theme_compat['Directory_Starter'];
427
428
//Avada
429
    $theme_compat['Avada'] = array(
430
        'geodir_wrapper_open_id' => '',
431
        'geodir_wrapper_open_class' => '',
432
        'geodir_wrapper_open_replace' => '<!-- removed -->',
433
        'geodir_wrapper_close_replace' => '<!-- removed -->',
434
        'geodir_wrapper_content_open_id' => 'content',
435
        'geodir_wrapper_content_open_class' => '',
436
        'geodir_wrapper_content_open_replace' => '',
437
        'geodir_wrapper_content_close_replace' => '',
438
        'geodir_article_open_id' => '',
439
        'geodir_article_open_class' => '',
440
        'geodir_article_open_replace' => '',
441
        'geodir_article_close_replace' => '',
442
        'geodir_sidebar_right_open_id' => '',
443
        'geodir_sidebar_right_open_class' => '',
444
        'geodir_sidebar_right_open_replace' => '<div id="sidebar" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
445
        'geodir_sidebar_right_close_replace' => '</div><!-- end sidebar -->',
446
        'geodir_sidebar_left_open_id' => '',
447
        'geodir_sidebar_left_open_class' => '',
448
        'geodir_sidebar_left_open_replace' => '<div id="sidebar" class="sidebar [class]" role="complementary" itemscope itemtype="[itemtype]" [width_css]>',
449
        'geodir_sidebar_left_close_replace' => '</div><!-- end sidebar -->',
450
        'geodir_main_content_open_id' => '',
451
        'geodir_main_content_open_class' => '',
452
        'geodir_main_content_open_replace' => '<!-- removed -->',
453
        'geodir_main_content_close_replace' => '<!-- removed -->',
454
        'geodir_top_content_add' => '',
455
        'geodir_before_main_content_add' => '',
456
        'geodir_before_widget_filter' => '',
457
        'geodir_after_widget_filter' => '',
458
        '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;}'),
459
        'geodir_theme_compat_js' => '',
460
        'geodir_theme_compat_default_options' => '',
461
        'geodir_theme_compat_code' => 'Avada'
462
    );
463
464
//Enfold
465
    $theme_compat['Enfold'] = array(
466
        'geodir_wrapper_open_id' => '',
467
        'geodir_wrapper_open_class' => '',
468
        'geodir_wrapper_open_replace' => '',
469
        'geodir_wrapper_close_replace' => '</div></div><!-- content ends here-->',
470
        'geodir_wrapper_content_open_id' => '',
471
        'geodir_wrapper_content_open_class' => '',
472
        'geodir_wrapper_content_open_replace' => '',
473
        'geodir_wrapper_content_close_replace' => '</div></main>',
474
        'geodir_article_open_id' => '',
475
        'geodir_article_open_class' => '',
476
        'geodir_article_open_replace' => '',
477
        'geodir_article_close_replace' => '',
478
        'geodir_sidebar_right_open_id' => '',
479
        'geodir_sidebar_right_open_class' => '',
480
        'geodir_sidebar_right_open_replace' => '',
481
        'geodir_sidebar_right_close_replace' => '</div></aside><!-- sidebar ends here-->',
482
        'geodir_sidebar_left_open_id' => '',
483
        'geodir_sidebar_left_open_class' => '',
484
        'geodir_sidebar_left_open_replace' => '',
485
        'geodir_sidebar_left_close_replace' => '</div></aside><!-- sidebar ends here-->',
486
        'geodir_main_content_open_id' => '',
487
        'geodir_main_content_open_class' => '',
488
        'geodir_main_content_open_replace' => '',
489
        'geodir_main_content_close_replace' => '',
490
        'geodir_top_content_add' => '',
491
        'geodir_before_main_content_add' => '',
492
        'geodir_before_widget_filter' => '',
493
        'geodir_after_widget_filter' => '',
494
        '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;}'),
495
        'geodir_theme_compat_js' => '',
496
        'geodir_theme_compat_default_options' => '',
497
        'geodir_theme_compat_code' => 'Enfold'
498
    );
499
500
// X
501
    $theme_compat['X'] = array(
502
        'geodir_wrapper_open_id' => '',
503
        'geodir_wrapper_open_class' => '',
504
        'geodir_wrapper_open_replace' => '',
505
        'geodir_wrapper_close_replace' => '',
506
        'geodir_wrapper_content_open_id' => '',
507
        'geodir_wrapper_content_open_class' => '',
508
        'geodir_wrapper_content_open_replace' => '',
509
        'geodir_wrapper_content_close_replace' => '',
510
        'geodir_article_open_id' => '',
511
        'geodir_article_open_class' => '',
512
        'geodir_article_open_replace' => '',
513
        'geodir_article_close_replace' => '',
514
        'geodir_sidebar_right_open_id' => '',
515
        'geodir_sidebar_right_open_class' => '',
516
        'geodir_sidebar_right_open_replace' => '',
517
        'geodir_sidebar_right_close_replace' => '',
518
        'geodir_sidebar_left_open_id' => '',
519
        'geodir_sidebar_left_open_class' => '',
520
        'geodir_sidebar_left_open_replace' => '',
521
        'geodir_sidebar_left_close_replace' => '',
522
        'geodir_main_content_open_id' => '',
523
        'geodir_main_content_open_class' => '',
524
        'geodir_main_content_open_replace' => '',
525
        'geodir_main_content_close_replace' => '',
526
        'geodir_top_content_add' => '',
527
        'geodir_before_main_content_add' => '',
528
        'geodir_before_widget_filter' => '',
529
        'geodir_after_widget_filter' => '',
530
        '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}'),
531
        'geodir_theme_compat_js' => '',
532
        'geodir_theme_compat_default_options' => '',
533
        'geodir_theme_compat_code' => 'X'
534
    );
535
536
// Divi
537
    $theme_compat['Divi'] = array(
538
        'geodir_wrapper_open_id' => 'main-content',
539
        'geodir_wrapper_open_class' => '',
540
        'geodir_wrapper_open_replace' => '',
541
        'geodir_wrapper_close_replace' => '',
542
        'geodir_wrapper_content_open_id' => 'left-area',
543
        'geodir_wrapper_content_open_class' => '',
544
        'geodir_wrapper_content_open_replace' => '<div class="container"><div id="content-area" class="clearfix"><div id="[id]" class="[class]" role="main" >',
545
        'geodir_wrapper_content_close_replace' => '',
546
        'geodir_article_open_id' => '',
547
        'geodir_article_open_class' => '',
548
        'geodir_article_open_replace' => '',
549
        'geodir_article_close_replace' => '',
550
        'geodir_sidebar_right_open_id' => 'sidebar',
551
        'geodir_sidebar_right_open_class' => '',
552
        'geodir_sidebar_right_open_replace' => '<aside  id="[id]" class="" role="complementary" itemscope itemtype="[itemtype]" >',
553
        'geodir_sidebar_right_close_replace' => '</aside><!-- sidebar ends here--></div></div>',
554
        'geodir_sidebar_left_open_id' => 'sidebar',
555
        'geodir_sidebar_left_open_class' => '',
556
        'geodir_sidebar_left_open_replace' => '<aside  id="[id]" class="" role="complementary" itemscope itemtype="[itemtype]" >',
557
        'geodir_sidebar_left_close_replace' => '</aside><!-- sidebar ends here--></div></div>',
558
        'geodir_main_content_open_id' => '',
559
        'geodir_main_content_open_class' => '',
560
        'geodir_main_content_open_replace' => '',
561
        'geodir_main_content_close_replace' => '',
562
        'geodir_top_content_add' => '',
563
        'geodir_before_main_content_add' => '',
564
        'geodir_before_widget_filter' => '',
565
        'geodir_after_widget_filter' => '',
566
        '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}'),
567
        'geodir_theme_compat_js' => '',
568
        'geodir_theme_compat_default_options' => '',
569
        'geodir_theme_compat_code' => 'Divi'
570
    );
571
572
// Genesis
573
    $theme_compat['Genesis'] = array(
574
        'geodir_wrapper_open_id' => '',
575
        'geodir_wrapper_open_class' => 'content-sidebar-wrap',
576
        'geodir_wrapper_open_replace' => '',
577
        'geodir_wrapper_close_replace' => '',
578
        'geodir_wrapper_content_open_id' => '',
579
        'geodir_wrapper_content_open_class' => 'content',
580
        'geodir_wrapper_content_open_replace' => '<div class="[class]" role="main" >',
581
        'geodir_wrapper_content_close_replace' => '',
582
        'geodir_article_open_id' => '',
583
        'geodir_article_open_class' => '',
584
        'geodir_article_open_replace' => '',
585
        'geodir_article_close_replace' => '',
586
        'geodir_sidebar_right_open_id' => '',
587
        'geodir_sidebar_right_open_class' => 'sidebar sidebar-primary widget-area',
588
        'geodir_sidebar_right_open_replace' => '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]">',
589
        'geodir_sidebar_right_close_replace' => '',
590
        'geodir_sidebar_left_open_id' => '',
591
        'geodir_sidebar_left_open_class' => 'sidebar sidebar-secondary widget-area',
592
        'geodir_sidebar_left_open_replace' => '<aside  id="[id]" class="[class]" role="complementary" itemscope itemtype="[itemtype]">',
593
        'geodir_sidebar_left_close_replace' => '',
594
        'geodir_main_content_open_id' => '',
595
        'geodir_main_content_open_class' => '',
596
        'geodir_main_content_open_replace' => '<main  id="[id]" class="entry [class]"  role="main">',
597
        'geodir_main_content_close_replace' => '',
598
        'geodir_top_content_add' => '',
599
        'geodir_before_main_content_add' => '',
600
        'geodir_before_widget_filter' => '',
601
        'geodir_after_widget_filter' => '',
602
        'geodir_location_switcher_menu_li_class_filter' => 'menu-item menu-item-gd-location-switcher menu-item-has-children gd-location-switcher',
603
        '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}'),
604
        'geodir_theme_compat_js' => '',
605
        'geodir_theme_compat_default_options' => '',
606
        'geodir_theme_compat_code' => 'Genesis'
607
    );
608
609
// Jupiter
610
    $theme_compat['Jupiter'] = array(
611
        'geodir_wrapper_open_id' => '',
612
        'geodir_wrapper_open_class' => '',
613
        '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">',
614
        'geodir_wrapper_close_replace' => '</div></div></div>',
615
        'geodir_wrapper_content_open_id' => '',
616
        'geodir_wrapper_content_open_class' => '',
617
        'geodir_wrapper_content_open_replace' => '',
618
        'geodir_wrapper_content_close_replace' => '',
619
        'geodir_article_open_id' => '',
620
        'geodir_article_open_class' => '',
621
        'geodir_article_open_replace' => '',
622
        'geodir_article_close_replace' => '',
623
        'geodir_sidebar_right_open_id' => 'mk-sidebar',
624
        'geodir_sidebar_right_open_class' => 'mk-builtin geodir-sidebar-right geodir-listings-sidebar-right',
625
        'geodir_sidebar_right_open_replace' => '',
626
        'geodir_sidebar_right_close_replace' => '',
627
        'geodir_sidebar_left_open_id' => 'mk-sidebar',
628
        'geodir_sidebar_left_open_class' => 'mk-builtin geodir-sidebar-right geodir-listings-sidebar-right',
629
        'geodir_sidebar_left_open_replace' => '',
630
        'geodir_sidebar_left_close_replace' => '',
631
        'geodir_main_content_open_id' => '',
632
        'geodir_main_content_open_class' => '',
633
        'geodir_main_content_open_replace' => '',
634
        'geodir_main_content_close_replace' => '',
635
        'geodir_top_content_add' => '',
636
        'geodir_before_main_content_add' => '',
637
        'geodir_before_widget_filter' => '',
638
        'geodir_after_widget_filter' => '',
639
        'geodir_before_title_filter' => '<h3 class="widgettitle geodir-widget-title">',
640
        'geodir_after_title_filter' => '',
641
        'geodir_menu_li_class_filter' => 'menu-item menu-item-has-children no-mega-menu',
642
        'geodir_sub_menu_ul_class_filter' => '',
643
        'geodir_sub_menu_li_class_filter' => '',
644
        'geodir_menu_a_class_filter' => 'menu-item-link',
645
        'geodir_sub_menu_a_class_filter' => 'menu-item-link one-page-nav-item',
646
        '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',
647
        'geodir_location_switcher_menu_a_class_filter' => 'menu-item-link',
648
        'geodir_location_switcher_menu_sub_ul_class_filter' => '',
649
        'geodir_location_switcher_menu_sub_li_class_filter' => '',
650
        '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}'),
651
        'geodir_theme_compat_js' => '',
652
        'geodir_theme_compat_default_options' => '',
653
        'geodir_theme_compat_code' => 'Jupiter'
654
    );
655
656
// Multi News
657
    $theme_compat['Multi_News'] = array(
658
        'geodir_wrapper_open_id' => '',
659
        'geodir_wrapper_open_class' => 'main-container clearfix',
660
        'geodir_wrapper_open_replace' => '',
661
        'geodir_wrapper_close_replace' => '',
662
        'geodir_wrapper_content_open_id' => '',
663
        'geodir_wrapper_content_open_class' => '',
664
        'geodir_wrapper_content_open_replace' => '<div class="main-left" ><div class="main-content  "><div class="site-content page-wrap">',
665
        'geodir_wrapper_content_close_replace' => '</div></div></div>',
666
        'geodir_article_open_id' => '',
667
        'geodir_article_open_class' => '',
668
        'geodir_article_open_replace' => '',
669
        'geodir_article_close_replace' => '',
670
        'geodir_sidebar_right_open_id' => '',
671
        'geodir_sidebar_right_open_class' => '',
672
        'geodir_sidebar_right_open_replace' => '<aside  class="sidebar" role="complementary" itemscope itemtype="[itemtype]" >',
673
        'geodir_sidebar_right_close_replace' => '',
674
        'geodir_sidebar_left_open_id' => '',
675
        'geodir_sidebar_left_open_class' => '',
676
        'geodir_sidebar_left_open_replace' => '<aside  class="secondary-sidebar" role="complementary" itemscope itemtype="[itemtype]" >',
677
        'geodir_sidebar_left_close_replace' => '',
678
        'geodir_main_content_open_id' => '',
679
        'geodir_main_content_open_class' => '',
680
        'geodir_main_content_open_replace' => '<div class="site-content page-wrap">',
681
        'geodir_main_content_close_replace' => '</div>',
682
        'geodir_top_content_add' => '',
683
        'geodir_before_main_content_add' => '',
684
        'geodir_full_page_class_filter' => 'section full-width-section',
685
        'geodir_before_widget_filter' => '',
686
        'geodir_after_widget_filter' => '',
687
        'geodir_before_title_filter' => '<div class="widget-title"><h2>',
688
        'geodir_after_title_filter' => '</h2></div>',
689
        'geodir_menu_li_class_filter' => '',
690
        'geodir_sub_menu_ul_class_filter' => '',
691
        'geodir_sub_menu_li_class_filter' => '',
692
        'geodir_menu_a_class_filter' => '',
693
        'geodir_sub_menu_a_class_filter' => '',
694
        'geodir_location_switcher_menu_li_class_filter' => '',
695
        'geodir_location_switcher_menu_a_class_filter' => '',
696
        'geodir_location_switcher_menu_sub_ul_class_filter' => '',
697
        'geodir_location_switcher_menu_sub_li_class_filter' => '',
698
        '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}'),
699
        '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"})});',
700
        'geodir_theme_compat_default_options' => '',
701
        'geodir_theme_compat_code' => 'Multi_News'
702
    );
703
704
    // Kelo
705
    $theme_compat['Kleo'] = array(
706
        'geodir_theme_compat_code' => 'Kleo'
707
    );
708
709
710
    // Twenty Seventeen
711
    $theme_compat['Twenty_Seventeen'] = array(
712
        'geodir_wrapper_open_replace' => '<div class="wrap">',
713
        'geodir_wrapper_content_open_replace' => '<div id="primary" class="content-area" >',
714
        'geodir_sidebar_right_open_replace' => '<aside id="secondary"  class="widget-area" itemscope itemtype="[itemtype]" >',
715
        'geodir_sidebar_left_open_replace' => '<aside id="secondary"  class="widget-area" itemscope itemtype="[itemtype]" >',
716
        '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;}'),
717
        'geodir_theme_compat_code' => 'Twenty_Seventeen'
718
    );
719
720
721
    update_option('gd_theme_compats', $theme_compat);
722
723
    gd_set_theme_compat();// set the compat pack if avail
724
}
725
726
727
/**
728
 * Converts virtual pages to normal pages.
729
 *
730
 * @since 1.0.0
731
 * @package GeoDirectory
732
 * @global object $wpdb WordPress Database object.
733
 */
734
function gd_convert_virtual_pages(){
735
    global $wpdb;
736
737
    // Update the add listing page settings
738
    $add_listing_page = $wpdb->get_var(
739
        $wpdb->prepare(
740
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
741
            array('add-listing')
742
        )
743
    );
744
745
    if($add_listing_page){
746
        wp_update_post( array('ID' => $add_listing_page, 'post_status' => 'publish') );
747
        update_option( 'geodir_add_listing_page', $add_listing_page);
748
    }
749
750
    // Update the listing preview page settings
751
    $listing_preview_page = $wpdb->get_var(
752
        $wpdb->prepare(
753
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
754
            array('listing-preview')
755
        )
756
    );
757
758
    if($listing_preview_page){
759
        wp_update_post( array('ID' => $listing_preview_page, 'post_status' => 'publish') );
760
        update_option( 'geodir_preview_page', $listing_preview_page);
761
    }
762
763
    // Update the listing success page settings
764
    $listing_success_page = $wpdb->get_var(
765
        $wpdb->prepare(
766
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
767
            array('listing-success')
768
        )
769
    );
770
771
    if($listing_success_page){
772
        wp_update_post( array('ID' => $listing_success_page, 'post_status' => 'publish') );
773
        update_option( 'geodir_success_page', $listing_success_page);
774
    }
775
776
    // Update the listing success page settings
777
    $location_page = $wpdb->get_var(
778
        $wpdb->prepare(
779
            "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s AND post_status='virtual' LIMIT 1;",
780
            array('location')
781
        )
782
    );
783
784
    if($location_page){
785
        $location_slug = get_option('geodir_location_prefix');
786
        if(!$location_slug ){$location_slug  = 'location';}
787
        wp_update_post( array('ID' => $location_page, 'post_status' => 'publish','post_name' => $location_slug) );
788
        update_option( 'geodir_location_page', $location_page);
789
    }
790
791
}
792
793
794
/**
795
 * Converts all GD CPT's to the new rewrite slug by removing /%gd_taxonomy% from the slug
796
 *
797
 * @since 1.5.0
798
 * @package GeoDirectory
799
 */
800
function gd_fix_cpt_rewrite_slug()
801
{
802
803
    $alt_post_types = array();
804
    $post_types = get_option('geodir_post_types');
805
806
807
    if (is_array($post_types)){
808
809
        foreach ($post_types as $post_type => $args) {
810
811
812
            if(isset($args['rewrite']['slug'])){
813
                $args['rewrite']['slug'] = str_replace("/%gd_taxonomy%","",$args['rewrite']['slug']);
814
            }
815
816
                $alt_post_types[$post_type] = $args;
817
818
        }
819
    }
820
821
    if(!empty($alt_post_types)) {
822
        update_option('geodir_post_types',$alt_post_types);
823
        }
824
825
826
    // flush the rewrite rules
827
    flush_rewrite_rules();
828
}
829
830
831
/**
832
 * Fixes the address field limit of 30 to 50 in details table.
833
 *
834
 * @since 1.0.0
835
 * @package GeoDirectory
836
 * @global object $wpdb WordPress Database object.
837
 */
838
function gd_fix_address_detail_table_limit()
839
{
840
    global $wpdb;
841
842
    $all_postypes = geodir_get_posttypes();
843
844
    if (!empty($all_postypes)) {
845
        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...
846
            // update each GD CTP
847
            try {
848
                $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");
849
            } catch(Exception $e) {
850
                error_log( 'Error: ' . $e->getMessage() );
851
            }
852
        }
853
    }
854
}
855
856
/**
857
 * Change Czech Republic country name to Czechia.
858
 *
859
 * @since 1.6.18
860
 * @package GeoDirectory
861
 * @global object $wpdb WordPress Database object.
862
 * @return bool
863
 */
864
function geodir_upgrade_1618() {
865
    global $wpdb;
866
867
    $gd_posttypes = geodir_get_posttypes();
868
    $default_location = geodir_get_default_location();
869
    
870
    $old_country = 'Czech Republic';
871
    $old_slug = 'czech-republic';
872
    $new_country = 'Czechia';
873
    $new_slug = 'czechia';
874
    $flush_rewrite_rules = false;
875
876
    if (!empty($gd_posttypes) && defined('POST_LOCATION_TABLE')) {        
877
        // Update locations
878
        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)))) {
879
            $flush_rewrite_rules = true;
880
        }
881
        
882
        // Update locations seo
883 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)))) {
884
            $flush_rewrite_rules = true;
885
        }
886
887
        // Update term meta
888 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)))) {
889
            $flush_rewrite_rules = true;
890
        }
891
892 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)))) {
893
            $flush_rewrite_rules = true;
894
        }
895
896
        // Update detail table
897
        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...
898
            try {
899
                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 . "'")) {
900
                    $flush_rewrite_rules = true;
901
                }
902
            } catch(Exception $e) {
903
                error_log( 'Error: ' . $e->getMessage() );
904
            }
905
        }
906
    }
907
    
908
    if (!empty($default_location) && ((isset($default_location->country) && $default_location->country == $old_country) || (isset($default_location->country_slug) && $default_location->country_slug == $old_slug))) {
909
        $default_location->country = $new_country;
910
        $default_location->country_slug = $new_slug;
911
        
912
        update_option('geodir_default_location', $default_location);
913
        
914
        $flush_rewrite_rules = true;
915
    }
916
    
917
    if ($flush_rewrite_rules) {
918
        flush_rewrite_rules();
919
    }
920
    
921
    return true;
922
}