Save
This commit is contained in:
@@ -294,4 +294,84 @@ function custom_enqueue_scripts() {
|
||||
true
|
||||
);
|
||||
}
|
||||
add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts', PHP_INT_MAX );
|
||||
add_action( 'wp_enqueue_scripts', 'custom_enqueue_scripts', PHP_INT_MAX );
|
||||
|
||||
add_action('save_post', 'acf_default_parametry_produktu', 20, 1);
|
||||
|
||||
function acf_default_parametry_produktu($post_id) {
|
||||
if (get_post_type($post_id) !== 'produkt') return;
|
||||
|
||||
if (have_rows('parametry_produktu', $post_id)) return;
|
||||
|
||||
$defaults = [
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/izolacyjnosc-termiczna.svg'),
|
||||
'tytul' => 'Izolacyjność termiczna',
|
||||
'tekst' => 'Uw do 0,9 W/m2K'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/izolacyjnosc-akustyczna.svg'),
|
||||
'tytul' => 'Izolacyjność akustyczna',
|
||||
'tekst' => 'Rw do 45 dB'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/system.svg'),
|
||||
'tytul' => 'System 5-komorowy',
|
||||
'tekst' => 'Głębokość profili 70 mm'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/odpornosc-na-wlamanie.svg'),
|
||||
'tytul' => 'Odporność na włamanie',
|
||||
'tekst' => 'do klasy RC 2'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/przepuszczalnosc-powietrza.svg'),
|
||||
'tytul' => 'Przepuszczalność powietrza',
|
||||
'tekst' => 'do klasy 4'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/wodoszczelnosc.svg'),
|
||||
'tytul' => 'Wodoszczelność',
|
||||
'tekst' => 'do klasy 9A'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/odpornosc-na-obciazenie-wiatrem.svg'),
|
||||
'tytul' => 'Odporność na obciążenie wiatrem',
|
||||
'tekst' => 'do klasy B5'
|
||||
],
|
||||
[
|
||||
'icon_url' => home_url('/wp-content/uploads/2025/07/download.svg'),
|
||||
'tytul' => 'Przekrój profila - plik PDF',
|
||||
'tekst' => ''
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($defaults as $item) {
|
||||
$attachment_id = attachment_url_to_postid($item['icon_url']);
|
||||
|
||||
add_row('parametry_produktu', [
|
||||
'obrazek' => $attachment_id,
|
||||
'tytul' => $item['tytul'],
|
||||
'tekst' => $item['tekst']
|
||||
], $post_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
add_filter('wpseo_breadcrumb_links', 'custom_breadcrumb_links_replace_taxonomy_urls');
|
||||
function custom_breadcrumb_links_replace_taxonomy_urls($links) {
|
||||
if (get_post_type() !== 'produkt') {
|
||||
return $links;
|
||||
}
|
||||
|
||||
foreach ($links as &$link) {
|
||||
if (isset($link['url']) && strpos($link['url'], '/kategoria-produktu/') !== false) {
|
||||
$clean_path = str_replace('/kategoria-produktu/', '/', $link['url']);
|
||||
$parsed = wp_parse_url($clean_path);
|
||||
$clean_slug = trim($parsed['path'], '/');
|
||||
$link['url'] = home_url('/' . $clean_slug . '/');
|
||||
}
|
||||
}
|
||||
|
||||
return $links;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user