| @@ -44,9 +44,14 @@ | ||
| 44 | 44 | { |
| 45 | 45 | global $Winter_MVC_WDK; |
| 46 | 46 | $Winter_MVC_WDK->load_helper('listing'); |
| 47 | 47 | |
| 48 | - if((wdk_field_value('is_activated', $wdk_listing_id,false) && wdk_field_value('is_approved', $wdk_listing_id,false)) || ( get_current_user_id() != 0 && get_current_user_id() == wdk_field_value('user_id_editor', $wdk_listing_id,false))) { | |
| 48 | + if( | |
| 49 | + ( | |
| 50 | + wdk_field_value('is_activated', $wdk_listing_id,false) && wdk_field_value('is_approved', $wdk_listing_id,false)) || | |
| 51 | + (get_current_user_id() != 0 && get_current_user_id() == wdk_field_value('user_id_editor', $wdk_listing_id,false)) || | |
| 52 | + (get_current_user_id() != 0 && wmvc_user_in_role('administrator')) | |
| 53 | + ) { | |
| 49 | 54 | |
| 50 | 55 | $Winter_MVC_WDK->model('listing_m'); |
| 51 | 56 | $Winter_MVC_WDK->listing_m->update_counter($wdk_listing_id); |
| 52 | 57 | |
| @@ -90,9 +95,9 @@ | ||
| 90 | 95 | if(class_exists('Elementor\Plugin')) |
| 91 | 96 | { |
| 92 | 97 | $content = ''; |
| 93 | 98 | |
| 94 | - if(!wdk_field_value('is_approved', $wdk_listing_id, false)) { | |
| 99 | + if(!wdk_field_value('is_approved', $wdk_listing_id, false) || !wdk_field_value('is_activated', $wdk_listing_id, false)) { | |
| 95 | 100 | $content = '<div style="margin: 35px auto;max-width:768px;margin-bottom: 35px"><p class="wdk_alert wdk_alert-danger">'.esc_html__('Listing is not activated/approved and not visible for public', 'wpdirectorykit').'</p></div>'; |
| 96 | 101 | } |
| 97 | 102 | |
| 98 | 103 | $elementor_instance = Elementor\Plugin::instance(); |
| @@ -135,9 +140,9 @@ | ||
| 135 | 140 | } else { |
| 136 | 141 | $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">'.esc_html__('Listing missing or not activated', 'wpdirectorykit').', <a href="'.get_home_url().'">'.esc_html__('return to Homepage', 'wpdirectorykit').'</a></p></div>'; |
| 137 | 142 | } |
| 138 | 143 | } else { |
| 139 | - $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">'.esc_html__('Missing listing Preview Page', 'wpdirectorykit').', <a href="'.get_admin_url().'admin.php?page=wdk_settings&function=import_demo">'.esc_html__('Import demo Page', 'wpdirectorykit').'</a></p></div>'; | |
| 144 | + $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">'.esc_html__('Missing listing Preview Page', 'wpdirectorykit').', <a href="'.esc_url(get_admin_url()).'admin.php?page=wdk_settings&function=import_demo">'.esc_html__('Import demo Page', 'wpdirectorykit').'</a></p></div>'; | |
| 140 | 145 | } |
| 141 | 146 | |
| 142 | 147 | } |
| 143 | 148 | return $content; |
| @@ -436,5 +441,100 @@ | ||
| 436 | 441 | |
| 437 | 442 | } |
| 438 | 443 | |
| 439 | 444 | } |
| 445 | + | |
| 446 | +add_filter( 'plugin_action_links_wpdirectorykit/wpdirectorykit.php', 'wdk_buy_link' ); | |
| 447 | +function wdk_buy_link( $links ) { | |
| 448 | + // Build and escape the URL. | |
| 449 | + $url = esc_url( get_admin_url().'admin.php?page=wdk_addons' ); | |
| 450 | + // Create the link. | |
| 451 | + $settings_link = "<a style=\"color:rgb(0, 163, 42);font-weight:bold;\" href='$url'>" . __( 'Check Premium Features', 'wpdirectorykit') . '</a>'; | |
| 452 | + // Adds the link to the end of the array. | |
| 453 | + $links[] = $settings_link; | |
| 454 | + return $links; | |
| 455 | +} | |
| 456 | + | |
| 457 | + | |
| 458 | +add_filter( 'wpdirectorykit/listing/field/value', 'wdk_filter_field_format_date', 2, 10); | |
| 459 | +if(!function_exists('wdk_filter_field_format_date')) { | |
| 460 | + function wdk_filter_field_format_date ($field_value = '', $field_id = NULL, $number_format = TRUE) { | |
| 461 | + if(in_array($field_id, array('date', 'date-modified'))) { | |
| 462 | + $field_value = wdk_get_date($field_value, TRUE); | |
| 463 | + } | |
| 464 | + | |
| 465 | + return $field_value; | |
| 466 | + } | |
| 467 | +} | |
| 468 | + | |
| 469 | + | |
| 470 | +// fix sitemap issue | |
| 471 | +function wdk_modify_sitemap_index($content) { | |
| 472 | + // Modify the $content as needed | |
| 473 | + // For example, replace & with & | |
| 474 | + $content = str_replace('&', '&', $content); | |
| 475 | + return $content; | |
| 476 | +} | |
| 477 | + | |
| 478 | +// Hook the filter to the wpseo_sitemap_index filter hook | |
| 479 | +add_filter('wpseo_sitemap_index', 'wdk_modify_sitemap_index'); | |
| 480 | + | |
| 481 | +if(false) { | |
| 482 | + // Hook example, custom page title for | |
| 483 | + add_filter( 'document_title_parts', function( $title_parts_array ) { | |
| 484 | + global $wp_query; | |
| 485 | + if(isset($wp_query->post)) | |
| 486 | + if($wp_query->post->post_type == 'wdk-listing') | |
| 487 | + { | |
| 488 | + $wdk_listing_id = $wp_query->post->ID; | |
| 489 | + if($wdk_listing_id) { | |
| 490 | + global $Winter_MVC_WDK; | |
| 491 | + $Winter_MVC_WDK->model('field_m'); | |
| 492 | + $Winter_MVC_WDK->load_helper('listing'); | |
| 493 | + | |
| 494 | + $title_parts_array['title'] = wp_strip_all_tags(wpautop(wdk_field_value('post_title', $wdk_listing_id).' - '.wdk_field_value('address', $wdk_listing_id))); | |
| 495 | + } | |
| 496 | + } | |
| 497 | + return $title_parts_array; | |
| 498 | + } ); | |
| 499 | +} | |
| 500 | + | |
| 501 | +add_filter('tiny_mce_before_init', function($init){ | |
| 502 | + if(get_option('wdk_disable_toolbar_on_content_editor')) { | |
| 503 | + $init['wpautop'] = false; | |
| 504 | + $init['toolbar'] = false; | |
| 505 | + } | |
| 506 | + | |
| 507 | + return $init; | |
| 508 | +}); | |
| 509 | + | |
| 510 | +/* | |
| 511 | +* configuration number_format_i18n | |
| 512 | +*/ | |
| 513 | +add_filter('init', function($init){ | |
| 514 | + if(get_option('wdk_number_format_decimal_point') || get_option('wdk_number_format_thousands_sep')) { | |
| 515 | + global $wp_locale; | |
| 516 | + if(get_option('wdk_number_format_decimal_point')) | |
| 517 | + $wp_locale->number_format['decimal_point'] = get_option('wdk_number_format_decimal_point'); | |
| 518 | + | |
| 519 | + if(get_option('wdk_number_format_thousands_sep')) | |
| 520 | + $wp_locale->number_format['thousands_sep'] = get_option('wdk_number_format_thousands_sep'); | |
| 521 | + } | |
| 522 | +}); | |
| 523 | + | |
| 524 | +add_filter( 'wdk/listings/results', function($listings) { | |
| 525 | + global $Winter_MVC_WDK; | |
| 526 | + $Winter_MVC_WDK->model('field_m'); | |
| 527 | + $Winter_MVC_WDK->load_helper('listing'); | |
| 528 | + | |
| 529 | + $listings_ids = array(); | |
| 530 | + foreach($listings as $listing) { | |
| 531 | + $listings_ids[] = $listing->post_id; | |
| 532 | + } | |
| 533 | + | |
| 534 | + if(!empty($listings_ids)) { | |
| 535 | + $Winter_MVC_WDK->listing_m->update_listings_views($listings_ids); | |
| 536 | + } | |
| 537 | + | |
| 538 | + return $listings; | |
| 539 | +} ) | |
| 440 | 540 | ?> |