Changeset 3772939
- Timestamp:
- 10/29/2026 12:41:14 PM (2 days ago)
- Location:
- domtoraj-integration
- Files:
-
- 14 edited
- 1 copied
-
tags/1.2.0 (copied) (copied from domtoraj-integration/trunk )
-
tags/1.2.0/domtoraj-integration.php (modified) (2 diffs)
-
tags/1.2.0/includes/Admin/Settings.php (modified) (4 diffs)
-
tags/1.2.0/includes/Frontend/PropertySingle.php (modified) (1 diff)
-
tags/1.2.0/includes/Installer.php (modified) (1 diff)
-
tags/1.2.0/includes/PostTypes/PropertyPostType.php (modified) (2 diffs)
-
tags/1.2.0/readme.txt (modified) (3 diffs)
-
tags/1.2.0/templates/single-property-content.php (modified) (6 diffs)
-
trunk/domtoraj-integration.php (modified) (2 diffs)
-
trunk/includes/Admin/Settings.php (modified) (4 diffs)
-
trunk/includes/Frontend/PropertySingle.php (modified) (1 diff)
-
trunk/includes/Installer.php (modified) (1 diff)
-
trunk/includes/PostTypes/PropertyPostType.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/templates/single-property-content.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
domtoraj-integration/tags/1.2.0/domtoraj-integration.php
r3772658 r3772939 3 3 * Plugin Name: DomToRaj Integration 4 4 * Description: Integracja z systemem DomToRaj - automatyczna synchronizacja ofert nieruchomości 5 * Version: 1. 1.15 * Version: 1.2.0 6 6 * Author: DomToRaj 7 7 * Author URI: https://domtoraj.pl … … 19 19 20 20 // Definicje stałych 21 define('DOMTORAJ_VERSION', '1. 1.1');21 define('DOMTORAJ_VERSION', '1.2.0'); 22 22 define('DOMTORAJ_PLUGIN_DIR', plugin_dir_path(__FILE__)); 23 23 define('DOMTORAJ_PLUGIN_URL', plugin_dir_url(__FILE__)); -
domtoraj-integration/tags/1.2.0/includes/Admin/Settings.php
r3772329 r3772939 120 120 ); 121 121 122 register_setting( 123 'domtoraj_settings', 124 'domtoraj_offer_parts', 125 array( 126 'type' => 'array', 127 'sanitize_callback' => array(\DomToRaj\Frontend\PropertySingle::class, 'sanitize_parts'), 128 'default' => array(), 129 ) 130 ); 131 122 132 add_settings_section( 123 133 'domtoraj_api_section', … … 168 178 add_settings_section( 169 179 'domtoraj_leads_section', 170 'Zapytania i kalkulator',180 'Zapytania i strona oferty', 171 181 array(__CLASS__, 'leads_section_callback'), 172 182 'domtoraj-settings' … … 177 187 'E-mail na zapytania', 178 188 array(__CLASS__, 'leads_email_field_callback'), 189 'domtoraj-settings', 190 'domtoraj_leads_section' 191 ); 192 193 add_settings_field( 194 'domtoraj_offer_parts', 195 'Elementy strony oferty', 196 array(__CLASS__, 'offer_parts_field_callback'), 179 197 'domtoraj-settings', 180 198 'domtoraj_leads_section' … … 308 326 echo '<input type="email" name="domtoraj_leads_email" value="' . esc_attr($value) . '" class="regular-text" placeholder="' . esc_attr($api) . '" />'; 309 327 echo '<p class="description">Puste pole = e-mail biura z DomToRaj (<code>' . esc_html($api) . '</code>).</p>'; 328 } 329 330 public static function offer_parts_field_callback() { 331 echo '<fieldset><legend class="screen-reader-text">Elementy strony oferty</legend>'; 332 foreach (\DomToRaj\Frontend\PropertySingle::parts() as $key => $part) { 333 $on = \DomToRaj\Frontend\PropertySingle::part_enabled($key); 334 echo '<input type="hidden" name="domtoraj_offer_parts[' . esc_attr($key) . ']" value="0" />'; 335 echo '<label style="display:block;margin:0 0 8px"><input type="checkbox" name="domtoraj_offer_parts[' . esc_attr($key) . ']" value="1"' . checked($on, true, false) . ' /> <strong>' . esc_html($part[0]) . '</strong> — <span class="description">' . esc_html($part[1]) . '</span></label>'; 336 } 337 echo '</fieldset>'; 310 338 } 311 339 -
domtoraj-integration/tags/1.2.0/includes/Frontend/PropertySingle.php
r3772329 r3772939 22 22 add_action( 'wp_head', array( __CLASS__, 'head_meta' ), 5 ); 23 23 add_filter( 'document_title_parts', array( __CLASS__, 'title_parts' ) ); 24 } 25 26 /** 27 * Elementy strony oferty, które biuro może wyłączyć (Ustawienia → Strona oferty). 28 * 29 * @return array<string,array{0:string,1:string}> 30 */ 31 public static function parts() { 32 return array( 33 'calculator' => array( __( 'Kalkulator kredytu', 'domtoraj-integration' ), __( 'szacowana rata przy ofertach sprzedaży', 'domtoraj-integration' ) ), 34 'viewing' => array( __( 'Umów prezentację', 'domtoraj-integration' ), __( 'zakładka z wyborem terminu w formularzu kontaktu', 'domtoraj-integration' ) ), 35 'nearby' => array( __( 'Co w okolicy', 'domtoraj-integration' ), __( 'sklepy, szkoły i przystanki w promieniu 1 km pod mapą (dane OpenStreetMap)', 'domtoraj-integration' ) ), 36 'related' => array( __( 'Podobne oferty', 'domtoraj-integration' ), __( '3 oferty pod opisem', 'domtoraj-integration' ) ), 37 ); 38 } 39 40 /** 41 * Czy element strony oferty jest włączony (domyślnie wszystkie). 42 * 43 * @param string $key 44 */ 45 public static function part_enabled( $key ) { 46 $parts = get_option( 'domtoraj_offer_parts', array() ); 47 $on = ! is_array( $parts ) || ! isset( $parts[ $key ] ) || $parts[ $key ] !== '0'; 48 /** 49 * Filtr dla motywów: włącz/wyłącz element strony oferty. 50 * 51 * @param bool $on 52 * @param string $key calculator|viewing|nearby|related 53 */ 54 return (bool) apply_filters( 'domtoraj_offer_part_enabled', $on, $key ); 55 } 56 57 /** 58 * @param mixed $value 59 * @return array<string,string> 60 */ 61 public static function sanitize_parts( $value ) { 62 $out = array(); 63 foreach ( array_keys( self::parts() ) as $key ) { 64 $out[ $key ] = ( is_array( $value ) && isset( $value[ $key ] ) && (string) $value[ $key ] === '0' ) ? '0' : '1'; 65 } 66 return $out; 24 67 } 25 68 -
domtoraj-integration/tags/1.2.0/includes/Installer.php
r3772329 r3772939 67 67 delete_option('domtoraj_site_config'); 68 68 delete_option('domtoraj_schema_prefixed_cpt_tax_v1'); 69 foreach ( array( 'domtoraj_last_sync_time', 'domtoraj_last_sync_count', 'domtoraj_last_sync_error', 'domtoraj_results_page_id', 'domtoraj_list_per_page', 'domtoraj_accent_color', 'domtoraj_leads_email', 'domtoraj_mortgage_rate', 'domtoraj_plugin_version', 'domtoraj_site_name', 'domtoraj_logo_url', 'domtoraj_primary_color', 'domtoraj_contact_email', 'domtoraj_contact_phone', 'domtoraj_contact_phone2', 'domtoraj_contact_phone3', 'domtoraj_website', 'domtoraj_description', 'domtoraj_address', 'domtoraj_social', 'domtoraj_is_developer', 'domtoraj_package', 'domtoraj_team', 'domtoraj_reviews', 'domtoraj_reviews_summary', 'domtoraj_market_fix_v1' ) as $opt ) {69 foreach ( array( 'domtoraj_last_sync_time', 'domtoraj_last_sync_count', 'domtoraj_last_sync_error', 'domtoraj_results_page_id', 'domtoraj_list_per_page', 'domtoraj_accent_color', 'domtoraj_leads_email', 'domtoraj_mortgage_rate', 'domtoraj_plugin_version', 'domtoraj_site_name', 'domtoraj_logo_url', 'domtoraj_primary_color', 'domtoraj_contact_email', 'domtoraj_contact_phone', 'domtoraj_contact_phone2', 'domtoraj_contact_phone3', 'domtoraj_website', 'domtoraj_description', 'domtoraj_address', 'domtoraj_social', 'domtoraj_is_developer', 'domtoraj_package', 'domtoraj_team', 'domtoraj_reviews', 'domtoraj_reviews_summary', 'domtoraj_market_fix_v1', 'domtoraj_offer_parts' ) as $opt ) { 70 70 delete_option( $opt ); 71 71 } -
domtoraj-integration/tags/1.2.0/includes/PostTypes/PropertyPostType.php
r3772329 r3772939 22 22 add_action('init', array(__CLASS__, 'register_post_type')); 23 23 add_action('init', array(__CLASS__, 'register_taxonomies')); 24 add_filter('map_meta_cap', array(__CLASS__, 'lock_synced_offers'), 10, 4); 25 add_action('admin_notices', array(__CLASS__, 'synced_offers_notice')); 26 } 27 28 /** 29 * Oferty pochodzą z synchronizacji z DomToRaj.pl — ręczna edycja i usuwanie w WordPressie 30 * zostałyby nadpisane przy następnej synchronizacji, więc są zablokowane (podgląd zostaje). 31 * Synchronizacja korzysta z funkcji, które nie sprawdzają uprawnień, więc działa dalej. 32 * 33 * @param string[] $caps 34 * @param string $cap 35 * @param int $user_id 36 * @param array $args 37 * @return string[] 38 */ 39 public static function lock_synced_offers($caps, $cap, $user_id, $args) { 40 if (!in_array($cap, array('edit_post', 'delete_post'), true) || empty($args[0])) { 41 return $caps; 42 } 43 if (get_post_type((int) $args[0]) !== ContentTypes::CPT_PROPERTY) { 44 return $caps; 45 } 46 /** 47 * Pozwól edytować oferty w WordPressie (np. własne pola SEO). Domyślnie zablokowane. 48 * 49 * @param bool $allow 50 */ 51 return apply_filters('domtoraj_allow_property_edit', false) ? $caps : array('do_not_allow'); 52 } 53 54 /** 55 * Informacja na liście ofert w panelu: gdzie dodawać i edytować oferty. 56 */ 57 public static function synced_offers_notice() { 58 $screen = function_exists('get_current_screen') ? get_current_screen() : null; 59 if (!$screen || $screen->id !== 'edit-' . ContentTypes::CPT_PROPERTY) { 60 return; 61 } 62 echo '<div class="notice notice-info"><p><strong>' . esc_html__('Oferty dodajesz i edytujesz na DomToRaj.pl.', 'domtoraj-integration') . '</strong> ' 63 . esc_html__('Ta lista to podgląd ofert pobranych z Twojego konta — zmiany wprowadzone na DomToRaj.pl pojawią się tutaj po synchronizacji (automatycznie co godzinę).', 'domtoraj-integration') . '</p><p>' 64 . '<a class="button button-primary" href="https://domtoraj.pl/moje-konto/ogloszenia" target="_blank" rel="noopener">' . esc_html__('Moje ogłoszenia na DomToRaj.pl', 'domtoraj-integration') . '</a> ' 65 . '<a class="button" href="' . esc_url(admin_url('admin.php?page=domtoraj-settings')) . '">' . esc_html__('Synchronizuj teraz', 'domtoraj-integration') . '</a></p></div>'; 24 66 } 25 67 … … 52 94 'rewrite' => array( 'slug' => 'nieruchomosci' ), 53 95 'capability_type' => 'post', 96 // Oferty tworzy wyłącznie synchronizacja z DomToRaj.pl — bez „Dodaj nową” w panelu. 97 'capabilities' => array('create_posts' => 'do_not_allow'), 98 'map_meta_cap' => true, 54 99 'has_archive' => true, 55 100 'hierarchical' => false, -
domtoraj-integration/tags/1.2.0/readme.txt
r3772658 r3772939 6 6 Tested up to: 7.1 7 7 Requires PHP: 7.4 8 Stable tag: 1. 1.18 Stable tag: 1.2.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 112 112 == Changelog == 113 113 114 = 1.2.0 = 115 * Settings → "Offer page elements": turn off the mortgage calculator, "Book a viewing", "What's nearby" or similar offers. 116 * Offers can no longer be added or edited manually in WordPress (they come from DomToRaj.pl and the next sync would overwrite changes). The offer list shows where to edit them. Developers can re-enable editing with the `domtoraj_allow_property_edit` filter. 117 * New filter `domtoraj_offer_part_enabled` for themes. 118 114 119 = 1.1.1 = 115 120 * Offer page: removed the WhatsApp and Print buttons (simpler contact panel; the printout did not look good). … … 143 148 == Upgrade Notice == 144 149 150 = 1.2.0 = 151 Choose which elements appear on the offer page (e.g. hide the mortgage calculator). Offers are now edited only on DomToRaj.pl. 152 145 153 = 1.1.1 = 146 154 Removes the WhatsApp and Print buttons from the offer page. -
domtoraj-integration/tags/1.2.0/templates/single-property-content.php
r3772658 r3772939 29 29 $facts = $p->key_facts( 5 ); 30 30 $phone = preg_replace( '/[^\d+]/', '', $contact['phone'] ); 31 $viewing = PropertySingle::part_enabled( 'viewing' ); 31 32 $listings_url = ListingShortcodes::results_url(); 32 33 $site_cfg = get_option( 'domtoraj_site_config', array() ); … … 190 191 <p class="dtr-muted"><?php echo esc_html( trim( $p->location() . ( $p->region() !== '' ? ', woj. ' . $p->region() : '' ) ) ); ?></p> 191 192 <div class="dtr-map dtr-map--single" data-dtr-single-map data-lat="<?php echo esc_attr( (string) $coords[0] ); ?>" data-lng="<?php echo esc_attr( (string) $coords[1] ); ?>" data-exact="<?php echo $p->street() !== '' ? '1' : '0'; ?>" role="region" aria-label="<?php esc_attr_e( 'Mapa lokalizacji', 'domtoraj-integration' ); ?>"></div> 193 <?php if ( PropertySingle::part_enabled( 'nearby' ) ) : ?> 192 194 <div class="dtr-nearby" data-dtr-nearby data-lat="<?php echo esc_attr( (string) $coords[0] ); ?>" data-lng="<?php echo esc_attr( (string) $coords[1] ); ?>"> 193 195 <p class="dtr-nearby__title"><?php esc_html_e( 'W promieniu 1 km', 'domtoraj-integration' ); ?></p> … … 196 198 </ul> 197 199 </div> 198 </section> 199 <?php endif; ?> 200 201 <?php if ( ! $p->is_rent() && $p->price_value() > 0 ) : ?> 200 <?php endif; ?> 201 </section> 202 <?php endif; ?> 203 204 <?php if ( ! $p->is_rent() && $p->price_value() > 0 && PropertySingle::part_enabled( 'calculator' ) ) : ?> 202 205 <section class="dtr-section dtr-calc" data-dtr-calc aria-labelledby="dtr-calc-h"> 203 206 <h2 class="dtr-section__title" id="dtr-calc-h"><?php Icons::render( 'calculator' ); ?><?php esc_html_e( 'Kalkulator kredytu', 'domtoraj-integration' ); ?></h2> … … 259 262 </div> 260 263 264 <?php if ( $viewing ) : ?> 261 265 <div class="dtr-tabs" role="tablist" aria-label="<?php esc_attr_e( 'Rodzaj zapytania', 'domtoraj-integration' ); ?>"> 262 266 <button type="button" role="tab" class="dtr-tabs__tab is-active" aria-selected="true" data-dtr-lead-tab="offer"><?php esc_html_e( 'Zapytaj', 'domtoraj-integration' ); ?></button> 263 267 <button type="button" role="tab" class="dtr-tabs__tab" aria-selected="false" data-dtr-lead-tab="viewing"><?php Icons::render( 'calendar' ); ?><?php esc_html_e( 'Umów prezentację', 'domtoraj-integration' ); ?></button> 264 268 </div> 269 <?php endif; ?> 265 270 <?php 266 271 $lead_form = array( … … 268 273 'property' => $p->post_id, 269 274 'message' => $msg_default, 270 'viewing' => true,275 'viewing' => $viewing, 271 276 'button' => __( 'Wyślij zapytanie', 'domtoraj-integration' ), 272 277 ); … … 278 283 </div> 279 284 280 <?php $related = PropertySingle:: get_related_properties( $p->post_id, 3); ?>285 <?php $related = PropertySingle::part_enabled( 'related' ) ? PropertySingle::get_related_properties( $p->post_id, 3 ) : array(); ?> 281 286 <?php if ( $related ) : ?> 282 287 <section class="dtr-section dtr-related" aria-labelledby="dtr-rel-h"> -
domtoraj-integration/trunk/domtoraj-integration.php
r3772658 r3772939 3 3 * Plugin Name: DomToRaj Integration 4 4 * Description: Integracja z systemem DomToRaj - automatyczna synchronizacja ofert nieruchomości 5 * Version: 1. 1.15 * Version: 1.2.0 6 6 * Author: DomToRaj 7 7 * Author URI: https://domtoraj.pl … … 19 19 20 20 // Definicje stałych 21 define('DOMTORAJ_VERSION', '1. 1.1');21 define('DOMTORAJ_VERSION', '1.2.0'); 22 22 define('DOMTORAJ_PLUGIN_DIR', plugin_dir_path(__FILE__)); 23 23 define('DOMTORAJ_PLUGIN_URL', plugin_dir_url(__FILE__)); -
domtoraj-integration/trunk/includes/Admin/Settings.php
r3772329 r3772939 120 120 ); 121 121 122 register_setting( 123 'domtoraj_settings', 124 'domtoraj_offer_parts', 125 array( 126 'type' => 'array', 127 'sanitize_callback' => array(\DomToRaj\Frontend\PropertySingle::class, 'sanitize_parts'), 128 'default' => array(), 129 ) 130 ); 131 122 132 add_settings_section( 123 133 'domtoraj_api_section', … … 168 178 add_settings_section( 169 179 'domtoraj_leads_section', 170 'Zapytania i kalkulator',180 'Zapytania i strona oferty', 171 181 array(__CLASS__, 'leads_section_callback'), 172 182 'domtoraj-settings' … … 177 187 'E-mail na zapytania', 178 188 array(__CLASS__, 'leads_email_field_callback'), 189 'domtoraj-settings', 190 'domtoraj_leads_section' 191 ); 192 193 add_settings_field( 194 'domtoraj_offer_parts', 195 'Elementy strony oferty', 196 array(__CLASS__, 'offer_parts_field_callback'), 179 197 'domtoraj-settings', 180 198 'domtoraj_leads_section' … … 308 326 echo '<input type="email" name="domtoraj_leads_email" value="' . esc_attr($value) . '" class="regular-text" placeholder="' . esc_attr($api) . '" />'; 309 327 echo '<p class="description">Puste pole = e-mail biura z DomToRaj (<code>' . esc_html($api) . '</code>).</p>'; 328 } 329 330 public static function offer_parts_field_callback() { 331 echo '<fieldset><legend class="screen-reader-text">Elementy strony oferty</legend>'; 332 foreach (\DomToRaj\Frontend\PropertySingle::parts() as $key => $part) { 333 $on = \DomToRaj\Frontend\PropertySingle::part_enabled($key); 334 echo '<input type="hidden" name="domtoraj_offer_parts[' . esc_attr($key) . ']" value="0" />'; 335 echo '<label style="display:block;margin:0 0 8px"><input type="checkbox" name="domtoraj_offer_parts[' . esc_attr($key) . ']" value="1"' . checked($on, true, false) . ' /> <strong>' . esc_html($part[0]) . '</strong> — <span class="description">' . esc_html($part[1]) . '</span></label>'; 336 } 337 echo '</fieldset>'; 310 338 } 311 339 -
domtoraj-integration/trunk/includes/Frontend/PropertySingle.php
r3772329 r3772939 22 22 add_action( 'wp_head', array( __CLASS__, 'head_meta' ), 5 ); 23 23 add_filter( 'document_title_parts', array( __CLASS__, 'title_parts' ) ); 24 } 25 26 /** 27 * Elementy strony oferty, które biuro może wyłączyć (Ustawienia → Strona oferty). 28 * 29 * @return array<string,array{0:string,1:string}> 30 */ 31 public static function parts() { 32 return array( 33 'calculator' => array( __( 'Kalkulator kredytu', 'domtoraj-integration' ), __( 'szacowana rata przy ofertach sprzedaży', 'domtoraj-integration' ) ), 34 'viewing' => array( __( 'Umów prezentację', 'domtoraj-integration' ), __( 'zakładka z wyborem terminu w formularzu kontaktu', 'domtoraj-integration' ) ), 35 'nearby' => array( __( 'Co w okolicy', 'domtoraj-integration' ), __( 'sklepy, szkoły i przystanki w promieniu 1 km pod mapą (dane OpenStreetMap)', 'domtoraj-integration' ) ), 36 'related' => array( __( 'Podobne oferty', 'domtoraj-integration' ), __( '3 oferty pod opisem', 'domtoraj-integration' ) ), 37 ); 38 } 39 40 /** 41 * Czy element strony oferty jest włączony (domyślnie wszystkie). 42 * 43 * @param string $key 44 */ 45 public static function part_enabled( $key ) { 46 $parts = get_option( 'domtoraj_offer_parts', array() ); 47 $on = ! is_array( $parts ) || ! isset( $parts[ $key ] ) || $parts[ $key ] !== '0'; 48 /** 49 * Filtr dla motywów: włącz/wyłącz element strony oferty. 50 * 51 * @param bool $on 52 * @param string $key calculator|viewing|nearby|related 53 */ 54 return (bool) apply_filters( 'domtoraj_offer_part_enabled', $on, $key ); 55 } 56 57 /** 58 * @param mixed $value 59 * @return array<string,string> 60 */ 61 public static function sanitize_parts( $value ) { 62 $out = array(); 63 foreach ( array_keys( self::parts() ) as $key ) { 64 $out[ $key ] = ( is_array( $value ) && isset( $value[ $key ] ) && (string) $value[ $key ] === '0' ) ? '0' : '1'; 65 } 66 return $out; 24 67 } 25 68 -
domtoraj-integration/trunk/includes/Installer.php
r3772329 r3772939 67 67 delete_option('domtoraj_site_config'); 68 68 delete_option('domtoraj_schema_prefixed_cpt_tax_v1'); 69 foreach ( array( 'domtoraj_last_sync_time', 'domtoraj_last_sync_count', 'domtoraj_last_sync_error', 'domtoraj_results_page_id', 'domtoraj_list_per_page', 'domtoraj_accent_color', 'domtoraj_leads_email', 'domtoraj_mortgage_rate', 'domtoraj_plugin_version', 'domtoraj_site_name', 'domtoraj_logo_url', 'domtoraj_primary_color', 'domtoraj_contact_email', 'domtoraj_contact_phone', 'domtoraj_contact_phone2', 'domtoraj_contact_phone3', 'domtoraj_website', 'domtoraj_description', 'domtoraj_address', 'domtoraj_social', 'domtoraj_is_developer', 'domtoraj_package', 'domtoraj_team', 'domtoraj_reviews', 'domtoraj_reviews_summary', 'domtoraj_market_fix_v1' ) as $opt ) {69 foreach ( array( 'domtoraj_last_sync_time', 'domtoraj_last_sync_count', 'domtoraj_last_sync_error', 'domtoraj_results_page_id', 'domtoraj_list_per_page', 'domtoraj_accent_color', 'domtoraj_leads_email', 'domtoraj_mortgage_rate', 'domtoraj_plugin_version', 'domtoraj_site_name', 'domtoraj_logo_url', 'domtoraj_primary_color', 'domtoraj_contact_email', 'domtoraj_contact_phone', 'domtoraj_contact_phone2', 'domtoraj_contact_phone3', 'domtoraj_website', 'domtoraj_description', 'domtoraj_address', 'domtoraj_social', 'domtoraj_is_developer', 'domtoraj_package', 'domtoraj_team', 'domtoraj_reviews', 'domtoraj_reviews_summary', 'domtoraj_market_fix_v1', 'domtoraj_offer_parts' ) as $opt ) { 70 70 delete_option( $opt ); 71 71 } -
domtoraj-integration/trunk/includes/PostTypes/PropertyPostType.php
r3772329 r3772939 22 22 add_action('init', array(__CLASS__, 'register_post_type')); 23 23 add_action('init', array(__CLASS__, 'register_taxonomies')); 24 add_filter('map_meta_cap', array(__CLASS__, 'lock_synced_offers'), 10, 4); 25 add_action('admin_notices', array(__CLASS__, 'synced_offers_notice')); 26 } 27 28 /** 29 * Oferty pochodzą z synchronizacji z DomToRaj.pl — ręczna edycja i usuwanie w WordPressie 30 * zostałyby nadpisane przy następnej synchronizacji, więc są zablokowane (podgląd zostaje). 31 * Synchronizacja korzysta z funkcji, które nie sprawdzają uprawnień, więc działa dalej. 32 * 33 * @param string[] $caps 34 * @param string $cap 35 * @param int $user_id 36 * @param array $args 37 * @return string[] 38 */ 39 public static function lock_synced_offers($caps, $cap, $user_id, $args) { 40 if (!in_array($cap, array('edit_post', 'delete_post'), true) || empty($args[0])) { 41 return $caps; 42 } 43 if (get_post_type((int) $args[0]) !== ContentTypes::CPT_PROPERTY) { 44 return $caps; 45 } 46 /** 47 * Pozwól edytować oferty w WordPressie (np. własne pola SEO). Domyślnie zablokowane. 48 * 49 * @param bool $allow 50 */ 51 return apply_filters('domtoraj_allow_property_edit', false) ? $caps : array('do_not_allow'); 52 } 53 54 /** 55 * Informacja na liście ofert w panelu: gdzie dodawać i edytować oferty. 56 */ 57 public static function synced_offers_notice() { 58 $screen = function_exists('get_current_screen') ? get_current_screen() : null; 59 if (!$screen || $screen->id !== 'edit-' . ContentTypes::CPT_PROPERTY) { 60 return; 61 } 62 echo '<div class="notice notice-info"><p><strong>' . esc_html__('Oferty dodajesz i edytujesz na DomToRaj.pl.', 'domtoraj-integration') . '</strong> ' 63 . esc_html__('Ta lista to podgląd ofert pobranych z Twojego konta — zmiany wprowadzone na DomToRaj.pl pojawią się tutaj po synchronizacji (automatycznie co godzinę).', 'domtoraj-integration') . '</p><p>' 64 . '<a class="button button-primary" href="https://domtoraj.pl/moje-konto/ogloszenia" target="_blank" rel="noopener">' . esc_html__('Moje ogłoszenia na DomToRaj.pl', 'domtoraj-integration') . '</a> ' 65 . '<a class="button" href="' . esc_url(admin_url('admin.php?page=domtoraj-settings')) . '">' . esc_html__('Synchronizuj teraz', 'domtoraj-integration') . '</a></p></div>'; 24 66 } 25 67 … … 52 94 'rewrite' => array( 'slug' => 'nieruchomosci' ), 53 95 'capability_type' => 'post', 96 // Oferty tworzy wyłącznie synchronizacja z DomToRaj.pl — bez „Dodaj nową” w panelu. 97 'capabilities' => array('create_posts' => 'do_not_allow'), 98 'map_meta_cap' => true, 54 99 'has_archive' => true, 55 100 'hierarchical' => false, -
domtoraj-integration/trunk/readme.txt
r3772658 r3772939 6 6 Tested up to: 7.1 7 7 Requires PHP: 7.4 8 Stable tag: 1. 1.18 Stable tag: 1.2.0 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 112 112 == Changelog == 113 113 114 = 1.2.0 = 115 * Settings → "Offer page elements": turn off the mortgage calculator, "Book a viewing", "What's nearby" or similar offers. 116 * Offers can no longer be added or edited manually in WordPress (they come from DomToRaj.pl and the next sync would overwrite changes). The offer list shows where to edit them. Developers can re-enable editing with the `domtoraj_allow_property_edit` filter. 117 * New filter `domtoraj_offer_part_enabled` for themes. 118 114 119 = 1.1.1 = 115 120 * Offer page: removed the WhatsApp and Print buttons (simpler contact panel; the printout did not look good). … … 143 148 == Upgrade Notice == 144 149 150 = 1.2.0 = 151 Choose which elements appear on the offer page (e.g. hide the mortgage calculator). Offers are now edited only on DomToRaj.pl. 152 145 153 = 1.1.1 = 146 154 Removes the WhatsApp and Print buttons from the offer page. -
domtoraj-integration/trunk/templates/single-property-content.php
r3772658 r3772939 29 29 $facts = $p->key_facts( 5 ); 30 30 $phone = preg_replace( '/[^\d+]/', '', $contact['phone'] ); 31 $viewing = PropertySingle::part_enabled( 'viewing' ); 31 32 $listings_url = ListingShortcodes::results_url(); 32 33 $site_cfg = get_option( 'domtoraj_site_config', array() ); … … 190 191 <p class="dtr-muted"><?php echo esc_html( trim( $p->location() . ( $p->region() !== '' ? ', woj. ' . $p->region() : '' ) ) ); ?></p> 191 192 <div class="dtr-map dtr-map--single" data-dtr-single-map data-lat="<?php echo esc_attr( (string) $coords[0] ); ?>" data-lng="<?php echo esc_attr( (string) $coords[1] ); ?>" data-exact="<?php echo $p->street() !== '' ? '1' : '0'; ?>" role="region" aria-label="<?php esc_attr_e( 'Mapa lokalizacji', 'domtoraj-integration' ); ?>"></div> 193 <?php if ( PropertySingle::part_enabled( 'nearby' ) ) : ?> 192 194 <div class="dtr-nearby" data-dtr-nearby data-lat="<?php echo esc_attr( (string) $coords[0] ); ?>" data-lng="<?php echo esc_attr( (string) $coords[1] ); ?>"> 193 195 <p class="dtr-nearby__title"><?php esc_html_e( 'W promieniu 1 km', 'domtoraj-integration' ); ?></p> … … 196 198 </ul> 197 199 </div> 198 </section> 199 <?php endif; ?> 200 201 <?php if ( ! $p->is_rent() && $p->price_value() > 0 ) : ?> 200 <?php endif; ?> 201 </section> 202 <?php endif; ?> 203 204 <?php if ( ! $p->is_rent() && $p->price_value() > 0 && PropertySingle::part_enabled( 'calculator' ) ) : ?> 202 205 <section class="dtr-section dtr-calc" data-dtr-calc aria-labelledby="dtr-calc-h"> 203 206 <h2 class="dtr-section__title" id="dtr-calc-h"><?php Icons::render( 'calculator' ); ?><?php esc_html_e( 'Kalkulator kredytu', 'domtoraj-integration' ); ?></h2> … … 259 262 </div> 260 263 264 <?php if ( $viewing ) : ?> 261 265 <div class="dtr-tabs" role="tablist" aria-label="<?php esc_attr_e( 'Rodzaj zapytania', 'domtoraj-integration' ); ?>"> 262 266 <button type="button" role="tab" class="dtr-tabs__tab is-active" aria-selected="true" data-dtr-lead-tab="offer"><?php esc_html_e( 'Zapytaj', 'domtoraj-integration' ); ?></button> 263 267 <button type="button" role="tab" class="dtr-tabs__tab" aria-selected="false" data-dtr-lead-tab="viewing"><?php Icons::render( 'calendar' ); ?><?php esc_html_e( 'Umów prezentację', 'domtoraj-integration' ); ?></button> 264 268 </div> 269 <?php endif; ?> 265 270 <?php 266 271 $lead_form = array( … … 268 273 'property' => $p->post_id, 269 274 'message' => $msg_default, 270 'viewing' => true,275 'viewing' => $viewing, 271 276 'button' => __( 'Wyślij zapytanie', 'domtoraj-integration' ), 272 277 ); … … 278 283 </div> 279 284 280 <?php $related = PropertySingle:: get_related_properties( $p->post_id, 3); ?>285 <?php $related = PropertySingle::part_enabled( 'related' ) ? PropertySingle::get_related_properties( $p->post_id, 3 ) : array(); ?> 281 286 <?php if ( $related ) : ?> 282 287 <section class="dtr-section dtr-related" aria-labelledby="dtr-rel-h">
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)