diff --git a/.DS_Store b/.DS_Store
deleted file mode 100644
index a124289..0000000
Binary files a/.DS_Store and /dev/null differ
diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json
index 60b745e..19cac3d 100644
--- a/.vscode/ftp-kr.sync.cache.json
+++ b/.vscode/ftp-kr.sync.cache.json
@@ -701,8 +701,8 @@
"widgets": {
"apartaments.php": {
"type": "-",
- "size": 14014,
- "lmtime": 1774271189698,
+ "size": 15744,
+ "lmtime": 1774522885487,
"modified": false
},
"parking-spots.php": {
diff --git a/wp-admin/.DS_Store b/wp-admin/.DS_Store
deleted file mode 100644
index 4bdb570..0000000
Binary files a/wp-admin/.DS_Store and /dev/null differ
diff --git a/wp-content/.DS_Store b/wp-content/.DS_Store
deleted file mode 100644
index 96a872e..0000000
Binary files a/wp-content/.DS_Store and /dev/null differ
diff --git a/wp-content/languages/.DS_Store b/wp-content/languages/.DS_Store
deleted file mode 100644
index 200f73f..0000000
Binary files a/wp-content/languages/.DS_Store and /dev/null differ
diff --git a/wp-content/plugins/.DS_Store b/wp-content/plugins/.DS_Store
deleted file mode 100644
index 76d4807..0000000
Binary files a/wp-content/plugins/.DS_Store and /dev/null differ
diff --git a/wp-content/plugins/elementor-addon/assets/js/main.js b/wp-content/plugins/elementor-addon/assets/js/main.js
index 8b10a3c..9436750 100644
--- a/wp-content/plugins/elementor-addon/assets/js/main.js
+++ b/wp-content/plugins/elementor-addon/assets/js/main.js
@@ -1,4 +1,4 @@
-document.addEventListener('DOMContentLoaded', function () {
+document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('.apartament-gallery-swiper').forEach(function (el) {
new Swiper(el, {
slidesPerView: 1,
@@ -21,6 +21,50 @@ document.addEventListener('DOMContentLoaded', function () {
// Historia cen
document.addEventListener('DOMContentLoaded', function () {
+ function formatPrice(value) {
+ if (value === null || value === undefined) {
+ return '';
+ }
+
+ var normalized = String(value)
+ .replace(/\u00a0/g, '')
+ .replace(/\s+/g, '')
+ .replace(/zł|zl/gi, '')
+ .replace(/[^0-9,.-]/g, '');
+
+ if (!normalized) {
+ return '';
+ }
+
+ var lastComma = normalized.lastIndexOf(',');
+ var lastDot = normalized.lastIndexOf('.');
+
+ if (lastComma !== -1 && lastDot !== -1) {
+ if (lastComma > lastDot) {
+ normalized = normalized.replace(/\./g, '').replace(',', '.');
+ } else {
+ normalized = normalized.replace(/,/g, '');
+ }
+ } else if (lastComma !== -1) {
+ normalized = normalized.replace(/\./g, '').replace(',', '.');
+ } else {
+ var dotParts = normalized.split('.');
+ if (dotParts.length > 2) {
+ normalized = dotParts.slice(0, -1).join('') + '.' + dotParts[dotParts.length - 1];
+ }
+ }
+
+ var amount = Number(normalized);
+ if (Number.isNaN(amount)) {
+ return String(value).trim();
+ }
+
+ return amount.toLocaleString('pl-PL', {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ });
+ }
+
var overlay = document.getElementById('price-history-overlay');
var closeBtn = document.getElementById('price-history-close');
var elTitle = document.getElementById('price-history-title');
@@ -49,20 +93,16 @@ document.addEventListener('DOMContentLoaded', function () {
document.body.style.overflow = '';
}
- // Zamknij przyciskiem X
closeBtn.addEventListener('click', closePopup);
- // Zamknij klikając na overlay (poza modalem)
overlay.addEventListener('click', function (e) {
if (e.target === overlay) closePopup();
});
- // Zamknij klawiszem Escape
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && overlay.classList.contains('is-open')) closePopup();
});
- // Kliknięcie w przycisk Historia cen (apartamenty)
document.querySelectorAll('.btn-historia-cen').forEach(function (btn) {
btn.addEventListener('click', function () {
var postId = this.dataset.postId;
@@ -99,8 +139,8 @@ document.addEventListener('DOMContentLoaded', function () {
var d = json.data;
elTitle.textContent = d.title || '';
- elPrice.textContent = d.price ? d.price + ' zł' : '—';
- elPriceM2.textContent = d.price_m2 ? d.price_m2 + ' zł' : '—';
+ elPrice.textContent = d.price ? formatPrice(d.price) + ' zł' : '—';
+ elPriceM2.textContent = d.price_m2 ? formatPrice(d.price_m2) + ' zł' : '—';
if (!d.history || d.history.length === 0) {
elTbody.innerHTML = '
| Brak historii cen |
';
@@ -110,8 +150,8 @@ document.addEventListener('DOMContentLoaded', function () {
elTbody.innerHTML = d.history.map(function (row) {
return '' +
'| ' + (row.recorded_at || '') + ' | ' +
- '' + (row.price_m2 ? row.price_m2 + ' zł/m²' : '—') + ' | ' +
- '' + (row.price ? row.price + ' zł' : '—') + ' | ' +
+ '' + (row.price_m2 ? formatPrice(row.price_m2) + ' zł/m²' : '—') + ' | ' +
+ '' + (row.price ? formatPrice(row.price) + ' zł' : '—') + ' | ' +
'
';
}).join('');
})
@@ -121,7 +161,6 @@ document.addEventListener('DOMContentLoaded', function () {
});
});
- // Kliknięcie w przycisk Historia cen (miejsca postojowe)
document.querySelectorAll('.btn-parking-historia-cen').forEach(function (btn) {
btn.addEventListener('click', function () {
var parkingType = this.dataset.parkingType;
@@ -158,8 +197,8 @@ document.addEventListener('DOMContentLoaded', function () {
var d = json.data;
elTitle.textContent = d.title || '';
- elPrice.textContent = d.price ? d.price + ' zł' : '—';
- elPriceM2.textContent = d.price_m2 ? d.price_m2 + ' zł' : '—';
+ elPrice.textContent = d.price ? formatPrice(d.price) + ' zł' : '—';
+ elPriceM2.textContent = d.price_m2 ? formatPrice(d.price_m2) + ' zł' : '—';
if (!d.history || d.history.length === 0) {
elTbody.innerHTML = '| Brak historii cen |
';
@@ -169,8 +208,8 @@ document.addEventListener('DOMContentLoaded', function () {
elTbody.innerHTML = d.history.map(function (row) {
return '' +
'| ' + (row.recorded_at || '') + ' | ' +
- '' + (row.price_m2 ? row.price_m2 + ' zł/m²' : '—') + ' | ' +
- '' + (row.price ? row.price + ' zł' : '—') + ' | ' +
+ '' + (row.price_m2 ? formatPrice(row.price_m2) + ' zł/m²' : '—') + ' | ' +
+ '' + (row.price ? formatPrice(row.price) + ' zł' : '—') + ' | ' +
'
';
}).join('');
})
diff --git a/wp-content/plugins/elementor-addon/elementor-addon.php b/wp-content/plugins/elementor-addon/elementor-addon.php
index 21e6934..b0ae938 100644
--- a/wp-content/plugins/elementor-addon/elementor-addon.php
+++ b/wp-content/plugins/elementor-addon/elementor-addon.php
@@ -16,6 +16,53 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
+/**
+ * Formatuje kwotÄ™ do postaci 1 000 000,00.
+ *
+ * @param mixed $price Surowa wartość ceny.
+ * @return string
+ */
+function elementor_addon_format_price( $price ) {
+ if ( '' === $price || null === $price ) {
+ return '';
+ }
+
+ $value = wp_strip_all_tags( (string) $price );
+ $value = str_replace( [ "\xc2\xa0", ' ', 'zł', 'zl' ], '', $value );
+ $value = preg_replace( '/[^\d,.\-]/u', '', $value );
+
+ if ( '' === $value || null === $value ) {
+ return '';
+ }
+
+ $last_comma = strrpos( $value, ',' );
+ $last_dot = strrpos( $value, '.' );
+
+ if ( false !== $last_comma && false !== $last_dot ) {
+ if ( $last_comma > $last_dot ) {
+ $value = str_replace( '.', '', $value );
+ $value = str_replace( ',', '.', $value );
+ } else {
+ $value = str_replace( ',', '', $value );
+ }
+ } elseif ( false !== $last_comma ) {
+ $value = str_replace( '.', '', $value );
+ $value = str_replace( ',', '.', $value );
+ } else {
+ $parts = explode( '.', $value );
+ if ( count( $parts ) > 2 ) {
+ $decimal = array_pop( $parts );
+ $value = implode( '', $parts ) . '.' . $decimal;
+ }
+ }
+
+ if ( ! is_numeric( $value ) ) {
+ return trim( (string) $price );
+ }
+
+ return number_format_i18n( (float) $value, 2 );
+}
+
/**
* Register widget files
*/
@@ -88,7 +135,7 @@ function elementor_addon_register_assets() {
add_action( 'wp_enqueue_scripts', 'elementor_addon_register_assets' );
/**
- * Przekaż dane do JS (ajaxUrl + nonce) gdy skrypt jest enqueue'owany przez widget.
+ * PrzekaĹĽ dane do JS (ajaxUrl + nonce) gdy skrypt jest enqueue'owany przez widget.
*/
function elementor_addon_localize_scripts() {
wp_localize_script( 'elementor-addon-main-js', 'apartamentsData', [
@@ -99,8 +146,8 @@ function elementor_addon_localize_scripts() {
add_action( 'wp_enqueue_scripts', 'elementor_addon_localize_scripts', 20 );
/**
- * Włącza wsparcie "Atrybuty wpisu" (menu_order) dla CPT apartamenty,
- * aby można było ręcznie ustawiać kolejność.
+ * Włącza wsparcie "Atrybuty wpisu" (menu_order) dla CPT apartamenty,
+ * aby można było ręcznie ustawiać kolejność.
*/
function elementor_addon_enable_apartamenty_menu_order( $args, $post_type ) {
if ( 'apartamenty' !== $post_type ) {
@@ -125,11 +172,11 @@ function elementor_addon_enable_apartamenty_menu_order( $args, $post_type ) {
add_filter( 'register_post_type_args', 'elementor_addon_enable_apartamenty_menu_order', 20, 2 );
// ===========================================================
-// HISTORIA CEN — TABELA DB
+// HISTORIA CEN — TABELA DB
// ===========================================================
/**
- * Tworzy tabelę wp_price_history jeśli nie istnieje lub wersja DB jest stara.
+ * Tworzy tabelę wp_price_history jeśli nie istnieje lub wersja DB jest stara.
*/
function elementor_addon_create_price_history_table() {
global $wpdb;
@@ -154,7 +201,7 @@ function elementor_addon_create_price_history_table() {
}
/**
- * Tworzy tabelę wp_parking_price_history dla miejsc postojowych.
+ * Tworzy tabelÄ™ wp_parking_price_history dla miejsc postojowych.
*/
function elementor_addon_create_parking_price_history_table() {
global $wpdb;
@@ -188,7 +235,7 @@ function elementor_addon_create_tables() {
register_activation_hook( __FILE__, 'elementor_addon_create_tables' );
/**
- * Sprawdza wersję DB przy każdym init i tworzy tabele jeśli brakuje.
+ * Sprawdza wersję DB przy każdym init i tworzy tabele jeśli brakuje.
*/
function elementor_addon_maybe_update_db() {
if ( get_option( 'elementor_addon_db_version' ) !== '1.1' ) {
@@ -198,11 +245,11 @@ function elementor_addon_maybe_update_db() {
add_action( 'init', 'elementor_addon_maybe_update_db' );
// ===========================================================
-// HISTORIA CEN — CRON DZIENNY
+// HISTORIA CEN — CRON DZIENNY
// ===========================================================
/**
- * Rejestruje WP Cron jeśli jeszcze nie zaplanowany.
+ * Rejestruje WP Cron jeśli jeszcze nie zaplanowany.
*/
function elementor_addon_schedule_cron() {
if ( ! wp_next_scheduled( 'apartamenty_record_prices' ) ) {
@@ -212,8 +259,8 @@ function elementor_addon_schedule_cron() {
add_action( 'wp', 'elementor_addon_schedule_cron' );
/**
- * Zapisuje aktualne ceny wszystkich apartamentów do tabeli historii.
- * Używa INSERT IGNORE — jeden rekord na apartament na dzień.
+ * Zapisuje aktualne ceny wszystkich apartamentĂłw do tabeli historii.
+ * Używa INSERT IGNORE — jeden rekord na apartament na dzień.
*/
function elementor_addon_record_prices() {
global $wpdb;
@@ -252,7 +299,7 @@ function elementor_addon_record_prices() {
);
}
- // Miejsca postojowe — zapis cen z ACF options (pola w grupach)
+ // Miejsca postojowe - zapis cen z ACF options (pola w grupach)
$parking_table = $wpdb->prefix . 'parking_price_history';
$parking_groups = [
'zwykle' => 'miejsce_postojowe_zwykle',
@@ -281,7 +328,7 @@ function elementor_addon_record_prices() {
add_action( 'apartamenty_record_prices', 'elementor_addon_record_prices' );
// ===========================================================
-// HISTORIA CEN — AJAX ENDPOINT
+// HISTORIA CEN - AJAX ENDPOINT
// ===========================================================
/**
@@ -381,11 +428,11 @@ add_action( 'wp_ajax_parking_get_price_history', 'elementor_addon_get_parking_pr
add_action( 'wp_ajax_nopriv_parking_get_price_history', 'elementor_addon_get_parking_price_history_ajax' );
// ===========================================================
-// JAWNOŚĆ CEN — XML ENDPOINTS
+// JAWNOŚĆCEN — XML ENDPOINTS
// ===========================================================
/**
- * Rejestruje reguły przepisywania dla endpointów XML.
+ * Rejestruje reguły przepisywania dla endpointów XML.
*/
function apartamenty_xml_rewrite_rules() {
add_rewrite_rule( '^ceny-mieszkan\.(xml|md5)$', 'index.php?apartamenty_xml=$matches[1]', 'top' );
@@ -394,7 +441,7 @@ function apartamenty_xml_rewrite_rules() {
add_action( 'init', 'apartamenty_xml_rewrite_rules', 10 );
/**
- * Dodaje query vars dla endpointów XML.
+ * Dodaje query vars dla endpointĂłw XML.
*/
function apartamenty_xml_query_vars( $vars ) {
$vars[] = 'apartamenty_xml';
@@ -404,8 +451,8 @@ function apartamenty_xml_query_vars( $vars ) {
add_filter( 'query_vars', 'apartamenty_xml_query_vars' );
/**
- * Generuje XML z cenami wszystkich apartamentów.
- * Wynik cachowany w transiencie na 1 godzinę.
+ * Generuje XML z cenami wszystkich apartamentĂłw.
+ * Wynik cachowany w transiencie na 1 godzinÄ™.
*
* @return string XML jako string
*/
@@ -485,7 +532,7 @@ function apartamenty_generate_price_xml() {
$parking_table = $wpdb->prefix . 'parking_price_history';
$parking_configs = [
'zwykle' => [
- 'label' => 'Miejsce postojowe zwykłe',
+ 'label' => 'Miejsce postojowe zwykłe',
'group_name' => 'miejsce_postojowe_zwykle',
],
'rodzinne' => [
@@ -593,7 +640,7 @@ function apartamenty_generate_datagov_xml() {
}
/**
- * Obsługuje żądania do endpointów XML — wysyła odpowiedź i kończy.
+ * Obsługuje żądania do endpointów XML — wysyła odpowiedź i kończy.
*/
function apartamenty_xml_template_redirect() {
$xml_type = get_query_var( 'apartamenty_xml' );
@@ -626,16 +673,16 @@ function apartamenty_xml_template_redirect() {
add_action( 'template_redirect', 'apartamenty_xml_template_redirect', 1 );
// ===========================================================
-// JAWNOŚĆ CEN — STRONA ADMINISTRACYJNA
+// JAWNOŚĆCEN — STRONA ADMINISTRACYJNA
// ===========================================================
/**
- * Rejestruje stronę Jawność Cen w menu Narzędzia wp-admin.
+ * Rejestruje stronę Jawność Cen w menu Narzędzia wp-admin.
*/
function apartamenty_jawnosc_cen_menu() {
add_management_page(
- 'Jawność Cen',
- 'Jawność Cen',
+ 'Jawność Cen',
+ 'Jawność Cen',
'manage_options',
'jawnosc-cen',
'apartamenty_jawnosc_cen_page'
@@ -644,17 +691,17 @@ function apartamenty_jawnosc_cen_menu() {
add_action( 'admin_menu', 'apartamenty_jawnosc_cen_menu' );
/**
- * Renderuje stronę administracyjną z URL-ami do zgłoszenia.
+ * Renderuje stronę administracyjną z URL-ami do zgłoszenia.
*/
function apartamenty_jawnosc_cen_page() {
$url_ceny = esc_url( home_url( '/ceny-mieszkan.xml' ) );
$url_datagov = esc_url( home_url( '/dane-gov-pl.xml' ) );
?>
-
Jawność Cen — Wyszyńskiego 12
+
Jawność Cen — Wyszyńskiego 12
-
Dane aktualizowane codziennie przez WP Cron. Zgłoś URL katalogu dane.gov.pl do administratora portalu: kontakt@dane.gov.pl
+
Dane aktualizowane codziennie przez WP Cron. Zgłoś URL katalogu dane.gov.pl do administratora portalu: kontakt@dane.gov.pl
@@ -671,15 +718,15 @@ function apartamenty_jawnosc_cen_page() {
|
- Otwórz XML
+ OtwĂłrz XML
|
- Katalog dane.gov.pl (zgłoś Ministerstwu) |
+ Katalog dane.gov.pl (zgłoś Ministerstwu) |
|
- Otwórz XML
+ OtwĂłrz XML
|
diff --git a/wp-content/plugins/elementor-addon/widgets/apartaments.php b/wp-content/plugins/elementor-addon/widgets/apartaments.php
index dc48b7b..689ef5b 100644
--- a/wp-content/plugins/elementor-addon/widgets/apartaments.php
+++ b/wp-content/plugins/elementor-addon/widgets/apartaments.php
@@ -1,4 +1,4 @@
- 'ASC',
],
]);
-
if ( ! $apartaments->have_posts() ) {
echo 'Brak apartamentów.
';
return;
@@ -70,6 +69,8 @@ class Elementor_Apartaments extends \Elementor\Widget_Base {
$gallery = get_field('gallery');
$information = get_field('information');
$documents = get_field('documents');
+ $formatted_price = elementor_addon_format_price($information['price'] ?? '');
+ $formatted_price_m2 = elementor_addon_format_price($information['price_m2'] ?? '');
?>
@@ -154,16 +155,16 @@ class Elementor_Apartaments extends \Elementor\Widget_Base {
m2 |
-
+
| Cena |
- zł |
+ zł |
-
+
| Cena m2 |
- zł |
+ zł |
@@ -236,7 +237,7 @@ class Elementor_Apartaments extends \Elementor\Widget_Base {
-
+