Plugin Directory

Changeset 3772939


Ignore:
Timestamp:
10/29/2026 12:41:14 PM (2 days ago)
Author:
domtoraj
Message:

Release 1.2.0

Location:
domtoraj-integration
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • domtoraj-integration/tags/1.2.0/domtoraj-integration.php

    r3772658 r3772939  
    33 * Plugin Name: DomToRaj Integration
    44 * Description: Integracja z systemem DomToRaj - automatyczna synchronizacja ofert nieruchomości
    5  * Version: 1.1.1
     5 * Version: 1.2.0
    66 * Author: DomToRaj
    77 * Author URI: https://domtoraj.pl
    … …  
    1919
    2020// Definicje stałych
    21 define('DOMTORAJ_VERSION', '1.1.1');
     21define('DOMTORAJ_VERSION', '1.2.0');
    2222define('DOMTORAJ_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2323define('DOMTORAJ_PLUGIN_URL', plugin_dir_url(__FILE__));
  • domtoraj-integration/tags/1.2.0/includes/Admin/Settings.php

    r3772329 r3772939  
    120120        );
    121121
     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
    122132        add_settings_section(
    123133            'domtoraj_api_section',
    … …  
    168178        add_settings_section(
    169179            'domtoraj_leads_section',
    170             'Zapytania i kalkulator',
     180            'Zapytania i strona oferty',
    171181            array(__CLASS__, 'leads_section_callback'),
    172182            'domtoraj-settings'
    … …  
    177187            'E-mail na zapytania',
    178188            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'),
    179197            'domtoraj-settings',
    180198            'domtoraj_leads_section'
    … …  
    308326        echo '<input type="email" name="domtoraj_leads_email" value="' . esc_attr($value) . '" class="regular-text" placeholder="' . esc_attr($api) . '" />';
    309327        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>';
    310338    }
    311339
  • domtoraj-integration/tags/1.2.0/includes/Frontend/PropertySingle.php

    r3772329 r3772939  
    2222                add_action( 'wp_head', array( __CLASS__, 'head_meta' ), 5 );
    2323                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;
    2467        }
    2568
  • domtoraj-integration/tags/1.2.0/includes/Installer.php

    r3772329 r3772939  
    6767                delete_option('domtoraj_site_config');
    6868                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 ) {
    7070                        delete_option( $opt );
    7171                }
  • domtoraj-integration/tags/1.2.0/includes/PostTypes/PropertyPostType.php

    r3772329 r3772939  
    2222        add_action('init', array(__CLASS__, 'register_post_type'));
    2323        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>';
    2466    }
    2567
    … …  
    5294            'rewrite' => array( 'slug' => 'nieruchomosci' ),
    5395            '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,
    5499            'has_archive' => true,
    55100            'hierarchical' => false,
  • domtoraj-integration/tags/1.2.0/readme.txt

    r3772658 r3772939  
    66Tested up to: 7.1
    77Requires PHP: 7.4
    8 Stable tag: 1.1.1
     8Stable tag: 1.2.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    112112== Changelog ==
    113113
     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
    114119= 1.1.1 =
    115120* Offer page: removed the WhatsApp and Print buttons (simpler contact panel; the printout did not look good).
    … …  
    143148== Upgrade Notice ==
    144149
     150= 1.2.0 =
     151Choose which elements appear on the offer page (e.g. hide the mortgage calculator). Offers are now edited only on DomToRaj.pl.
     152
    145153= 1.1.1 =
    146154Removes the WhatsApp and Print buttons from the offer page.
  • domtoraj-integration/tags/1.2.0/templates/single-property-content.php

    r3772658 r3772939  
    2929$facts    = $p->key_facts( 5 );
    3030$phone    = preg_replace( '/[^\d+]/', '', $contact['phone'] );
     31$viewing  = PropertySingle::part_enabled( 'viewing' );
    3132$listings_url = ListingShortcodes::results_url();
    3233$site_cfg     = get_option( 'domtoraj_site_config', array() );
    … …  
    190191                                        <p class="dtr-muted"><?php echo esc_html( trim( $p->location() . ( $p->region() !== '' ? ', woj. ' . $p->region() : '' ) ) ); ?></p>
    191192                                        <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' ) ) : ?>
    192194                                        <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] ); ?>">
    193195                                                <p class="dtr-nearby__title"><?php esc_html_e( 'W promieniu 1 km', 'domtoraj-integration' ); ?></p>
    … …  
    196198                                                </ul>
    197199                                        </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' ) ) : ?>
    202205                                <section class="dtr-section dtr-calc" data-dtr-calc aria-labelledby="dtr-calc-h">
    203206                                        <h2 class="dtr-section__title" id="dtr-calc-h"><?php Icons::render( 'calculator' ); ?><?php esc_html_e( 'Kalkulator kredytu', 'domtoraj-integration' ); ?></h2>
    … …  
    259262                                </div>
    260263
     264                                <?php if ( $viewing ) : ?>
    261265                                <div class="dtr-tabs" role="tablist" aria-label="<?php esc_attr_e( 'Rodzaj zapytania', 'domtoraj-integration' ); ?>">
    262266                                        <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>
    263267                                        <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>
    264268                                </div>
     269                                <?php endif; ?>
    265270                                <?php
    266271                                $lead_form = array(
    … …  
    268273                                        'property' => $p->post_id,
    269274                                        'message'  => $msg_default,
    270                                         'viewing'  => true,
     275                                        'viewing'  => $viewing,
    271276                                        'button'   => __( 'Wyślij zapytanie', 'domtoraj-integration' ),
    272277                                );
    … …  
    278283        </div>
    279284
    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(); ?>
    281286        <?php if ( $related ) : ?>
    282287                <section class="dtr-section dtr-related" aria-labelledby="dtr-rel-h">
  • domtoraj-integration/trunk/domtoraj-integration.php

    r3772658 r3772939  
    33 * Plugin Name: DomToRaj Integration
    44 * Description: Integracja z systemem DomToRaj - automatyczna synchronizacja ofert nieruchomości
    5  * Version: 1.1.1
     5 * Version: 1.2.0
    66 * Author: DomToRaj
    77 * Author URI: https://domtoraj.pl
    … …  
    1919
    2020// Definicje stałych
    21 define('DOMTORAJ_VERSION', '1.1.1');
     21define('DOMTORAJ_VERSION', '1.2.0');
    2222define('DOMTORAJ_PLUGIN_DIR', plugin_dir_path(__FILE__));
    2323define('DOMTORAJ_PLUGIN_URL', plugin_dir_url(__FILE__));
  • domtoraj-integration/trunk/includes/Admin/Settings.php

    r3772329 r3772939  
    120120        );
    121121
     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
    122132        add_settings_section(
    123133            'domtoraj_api_section',
    … …  
    168178        add_settings_section(
    169179            'domtoraj_leads_section',
    170             'Zapytania i kalkulator',
     180            'Zapytania i strona oferty',
    171181            array(__CLASS__, 'leads_section_callback'),
    172182            'domtoraj-settings'
    … …  
    177187            'E-mail na zapytania',
    178188            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'),
    179197            'domtoraj-settings',
    180198            'domtoraj_leads_section'
    … …  
    308326        echo '<input type="email" name="domtoraj_leads_email" value="' . esc_attr($value) . '" class="regular-text" placeholder="' . esc_attr($api) . '" />';
    309327        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>';
    310338    }
    311339
  • domtoraj-integration/trunk/includes/Frontend/PropertySingle.php

    r3772329 r3772939  
    2222                add_action( 'wp_head', array( __CLASS__, 'head_meta' ), 5 );
    2323                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;
    2467        }
    2568
  • domtoraj-integration/trunk/includes/Installer.php

    r3772329 r3772939  
    6767                delete_option('domtoraj_site_config');
    6868                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 ) {
    7070                        delete_option( $opt );
    7171                }
  • domtoraj-integration/trunk/includes/PostTypes/PropertyPostType.php

    r3772329 r3772939  
    2222        add_action('init', array(__CLASS__, 'register_post_type'));
    2323        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>';
    2466    }
    2567
    … …  
    5294            'rewrite' => array( 'slug' => 'nieruchomosci' ),
    5395            '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,
    5499            'has_archive' => true,
    55100            'hierarchical' => false,
  • domtoraj-integration/trunk/readme.txt

    r3772658 r3772939  
    66Tested up to: 7.1
    77Requires PHP: 7.4
    8 Stable tag: 1.1.1
     8Stable tag: 1.2.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    112112== Changelog ==
    113113
     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
    114119= 1.1.1 =
    115120* Offer page: removed the WhatsApp and Print buttons (simpler contact panel; the printout did not look good).
    … …  
    143148== Upgrade Notice ==
    144149
     150= 1.2.0 =
     151Choose which elements appear on the offer page (e.g. hide the mortgage calculator). Offers are now edited only on DomToRaj.pl.
     152
    145153= 1.1.1 =
    146154Removes the WhatsApp and Print buttons from the offer page.
  • domtoraj-integration/trunk/templates/single-property-content.php

    r3772658 r3772939  
    2929$facts    = $p->key_facts( 5 );
    3030$phone    = preg_replace( '/[^\d+]/', '', $contact['phone'] );
     31$viewing  = PropertySingle::part_enabled( 'viewing' );
    3132$listings_url = ListingShortcodes::results_url();
    3233$site_cfg     = get_option( 'domtoraj_site_config', array() );
    … …  
    190191                                        <p class="dtr-muted"><?php echo esc_html( trim( $p->location() . ( $p->region() !== '' ? ', woj. ' . $p->region() : '' ) ) ); ?></p>
    191192                                        <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' ) ) : ?>
    192194                                        <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] ); ?>">
    193195                                                <p class="dtr-nearby__title"><?php esc_html_e( 'W promieniu 1 km', 'domtoraj-integration' ); ?></p>
    … …  
    196198                                                </ul>
    197199                                        </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' ) ) : ?>
    202205                                <section class="dtr-section dtr-calc" data-dtr-calc aria-labelledby="dtr-calc-h">
    203206                                        <h2 class="dtr-section__title" id="dtr-calc-h"><?php Icons::render( 'calculator' ); ?><?php esc_html_e( 'Kalkulator kredytu', 'domtoraj-integration' ); ?></h2>
    … …  
    259262                                </div>
    260263
     264                                <?php if ( $viewing ) : ?>
    261265                                <div class="dtr-tabs" role="tablist" aria-label="<?php esc_attr_e( 'Rodzaj zapytania', 'domtoraj-integration' ); ?>">
    262266                                        <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>
    263267                                        <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>
    264268                                </div>
     269                                <?php endif; ?>
    265270                                <?php
    266271                                $lead_form = array(
    … …  
    268273                                        'property' => $p->post_id,
    269274                                        'message'  => $msg_default,
    270                                         'viewing'  => true,
     275                                        'viewing'  => $viewing,
    271276                                        'button'   => __( 'Wyślij zapytanie', 'domtoraj-integration' ),
    272277                                );
    … …  
    278283        </div>
    279284
    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(); ?>
    281286        <?php if ( $related ) : ?>
    282287                <section class="dtr-section dtr-related" aria-labelledby="dtr-rel-h">
Note: See TracChangeset for help on using the changeset viewer.