HEX
Server: Apache
System: Linux webd003.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: slyfwmm (169339)
PHP: 8.1.34
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/slyfwmm/laretediclo/wp-content/themes/kicker-child/functions.php
<?php
/**
 * Child-Theme functions and definitions
 */

function kicker_child_scripts() {
    wp_enqueue_style( 'kicker-style', get_template_directory_uri(). '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'kicker_child_scripts' );




function LRC_insert_img() {

    $content = get_the_content();	

    if (str_contains($content, '[img1]')) {
        if(get_field('img_1')) {
            $img_alt = get_field('img_1_dida');
            $img_name = get_field('img_1');
            $img_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);            
            $args = array(
                'post_type' => 'attachment',
                'name' => $img_name,
                'posts_per_page' => 1,
                'post_status' => 'inherit',
            );
            $img = get_posts( $args );
            if($img) {
                $img_url = $img[0]->guid;
                $img = '<img class="LRC_img_text" src="'.$img_url.'" alt="'.$img_alt.'" />';
                $content = str_replace('[img1]',$img,$content);
            } else {
                $content = str_replace('[img1]','',$content);
            }
        } else {
            $content = str_replace('[img1]','',$content);
        }
    }
    if (str_contains($content, '[img2]')) {
        if(get_field('img_2')) {
            $img_alt = get_field('img_2_dida');
            $img_name = get_field('img_2');
            $img_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);            
            $args = array(
                'post_type' => 'attachment',
                'name' => $img_name,
                'posts_per_page' => 1,
                'post_status' => 'inherit',
            );
            $img = get_posts( $args );
            if($img) {
                $img_url = $img[0]->guid;
                $img = '<img class="LRC_img_text" src="'.$img_url.'" alt="'.$img_alt.'" />';
                $content = str_replace('[img2]',$img,$content);
            } else {
                $content = str_replace('[img2]','',$content);
            }
        } else {
            $content = str_replace('[img2]','',$content);
        }
    }
    if (str_contains($content, '[img3]')) {
        if(get_field('img_3')) {
            $img_alt = get_field('img_3_dida');
            $img_name = get_field('img_3');
            $img_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);            
            $args = array(
                'post_type' => 'attachment',
                'name' => $img_name,
                'posts_per_page' => 1,
                'post_status' => 'inherit',
            );
            $img = get_posts( $args );
            if($img) {
                $img_url = $img[0]->guid;
                $img = '<img class="LRC_img_text" src="'.$img_url.'" alt="'.$img_alt.'" />';
                $content = str_replace('[img3]',$img,$content);
            } else {
                $content = str_replace('[img3]','',$content);
            }
        } else {
            $content = str_replace('[img3]','',$content);
        }
    }
    
    return $content;

}

function LRC_insert_license_img() {

    $lic_img_pric = NULL;
    $lic_img1 = NULL;
    $lic_img2 = NULL;
    $lic_img3 = NULL;

    if (has_post_thumbnail() ) {
    $img = get_the_post_thumbnail();
    $img_princ_tipo_lic = get_field('img_princ_tipo_lic');
        if(!($img_princ_tipo_lic === 'Ufficio stampa' || $img_princ_tipo_lic === 'Royalty free' || $img_princ_tipo_lic === 'Immagini acquistate')) {
            if($img_princ_tipo_lic === 'Inedita di proprietà') {
                $lic_img_pric =  '<div>'.$img.'<p>Autore della foto <strong>Ad culture: portale di informazione su architettura e design</strong> - sei libero di utilizzare la presente foto secondo la licenza <a href="https://creativecommons.org/licenses/by-nc/3.0/it/" target="_blank">CC by-nc 3.0</a></p></div>';
            } else {
                if( get_field('img_princ_fonte') || get_field('img_princ_titolo') || get_field('img_princ_autore') ) {
                    $link = get_field('img_princ_fonte');
                    if(!($link === '')) { $link = 'href="'.$link.'" target="_blank"'; } 
                    $autor = get_field('img_princ_autore');
                    if(!($autor === '')) { $autor = ' di <strong>'.$autor.'</strong>'; }
                    $link_name = empty(get_field('img_princ_titolo')) ? 'questa foto' : get_field('img_princ_titolo');
                    if(get_field('img_princ_link_lic')) { $license = ' (vedi <a href="'.get_field('img_princ_link_lic').'" target="_blank">licensa</a>)'; } else { $license = NULL; }
                    $lic_img_pric =  '<div>'.$img.'<p>Foto derivata da <a '.$link.'>'.$link_name.'</a>'.$autor.$license.'</p></div>';
                }
            }
        }
    }

    if(get_field('img_1')) {
        $img_name = get_field('img_1');
        $img_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);  
        $args = array(
            'post_type' => 'attachment',
            'name' => $img_name,
            'posts_per_page' => 1,
            'post_status' => 'inherit',
        );
        $img = get_posts( $args );
        if($img) {
            $img_url = $img[0]->guid;
            $img_alt = get_field('img_1_dida');
            $img = '<img src="'.$img_url.'" alt="'.$img_alt.'" />';
            $img_tipo_lic = get_field('img_1_tipo_lic');
            if(!($img_tipo_lic === 'Ufficio stampa' || $img_tipo_lic === 'Royalty free' || $img_tipo_lic === 'Immagini acquistate')) {
                if($img_tipo_lic === 'Inedita di proprietà') {
                    $lic_img1 =  '<div>'.$img.'<p>Autore della foto <strong>Ad culture: portale di informazione su architettura e design</strong> - sei libero di utilizzare la presente foto secondo la licenza <a href="https://creativecommons.org/licenses/by-nc/3.0/it/" target="_blank">CC by-nc 3.0</a></p></div>';
                } else {
                    if( get_field('img_1_fonte') || get_field('img_1_titolo') || get_field('img_1_autore') ) {
                        $link = get_field('img_1_fonte');
                        if(!($link === '')) { $link = 'href="'.$link.'" target="_blank"'; } 
                        $autor = get_field('img_1_autore');
                        if(!($autor === '')) { $autor = ' di <strong>'.$autor.'</strong>'; }
                        $link_name = empty(get_field('img_1_titolo')) ? 'questa foto' : get_field('img_1_titolo');
                        $lic_img1 =  '<div>'.$img.'<p>Foto derivata da <a '.$link.'>'.$link_name.'</a>'.$autor.'</p></div>';
                    }
                }
            }
        }
    }

    if(get_field('img_2')) {
        $img_name = get_field('img_2');
        $img_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);  
        $args = array(
            'post_type' => 'attachment',
            'name' => $img_name,
            'posts_per_page' => 1,
            'post_status' => 'inherit',
        );
        $img = get_posts( $args );
        if($img) {
            $img_url = $img[0]->guid;
            $img_alt = get_field('img_2_dida');
            $img = '<img src="'.$img_url.'" alt="'.$img_alt.'" />';
            $img_tipo_lic = get_field('img_2_tipo_lic');
            if(!($img_tipo_lic === 'Ufficio stampa' || $img_tipo_lic === 'Royalty free' || $img_tipo_lic === 'Immagini acquistate')) {
                if($img_tipo_lic === 'Inedita di proprietà') {
                    $lic_img2 =  '<div>'.$img.'<p>Autore della foto <strong>Ad culture: portale di informazione su architettura e design</strong> - sei libero di utilizzare la presente foto secondo la licenza <a href="https://creativecommons.org/licenses/by-nc/3.0/it/" target="_blank">CC by-nc 3.0</a></p></div>';
                } else {
                    if( get_field('img_2_fonte') || get_field('img_2_titolo') || get_field('img_2_autore') ) {
                        $link = get_field('img_2_fonte');
                        if(!($link === '')) { $link = 'href="'.$link.'" target="_blank"'; } 
                        $autor = get_field('img_2_autore');
                        if(!($autor === '')) { $autor = ' di <strong>'.$autor.'</strong>'; }
                        $link_name = empty(get_field('img_2_titolo')) ? 'questa foto' : get_field('img_2_titolo');
                        $lic_img2 =  '<div>'.$img.'<p>Foto derivata da <a '.$link.'>'.$link_name.'</a>'.$autor.'</p></div>';
                    }
                }
            }
        }
    }

    if(get_field('img_3')) {
        $img_name = get_field('img_3');
        $img_name = preg_replace('/\\.[^.\\s]{3,4}$/', '', $img_name);  
        $args = array(
            'post_type' => 'attachment',
            'name' => $img_name,
            'posts_per_page' => 1,
            'post_status' => 'inherit',
        );
        $img = get_posts( $args );
        if($img) {
            $img_url = $img[0]->guid;
            $img_alt = get_field('img_3_dida');
            $img = '<img src="'.$img_url.'" alt="'.$img_alt.'" />';
            $img_tipo_lic = get_field('img_3_tipo_lic');
            if(!($img_tipo_lic === 'Ufficio stampa' || $img_tipo_lic === 'Royalty free' || $img_tipo_lic === 'Immagini acquistate')) {
                if($img_tipo_lic === 'Inedita di proprietà') {
                    $lic_img3 =  '<div>'.$img.'<p>Autore della foto <strong>Ad culture: portale di informazione su architettura e design</strong> - sei libero di utilizzare la presente foto secondo la licenza <a href="https://creativecommons.org/licenses/by-nc/3.0/it/" target="_blank">CC by-nc 3.0</a></p></div>';
                } else {
                    if( get_field('img_3_fonte') || get_field('img_3_titolo') || get_field('img_3_autore') ) {
                        $link = get_field('img_3_fonte');
                        if(!($link === '')) { $link = 'href="'.$link.'" target="_blank"'; } 
                        $autor = get_field('img_3_autore');
                        if(!($autor === '')) { $autor = ' di <strong>'.$autor.'</strong>'; }
                        $link_name = empty(get_field('img_3_titolo')) ? 'questa foto' : get_field('img_3_titolo');
                        $lic_img3 =  '<div>'.$img.'<p>Foto derivata da <a '.$link.'>'.$link_name.'</a>'.$autor.'</p></div>';
                    }
                }
            }
        }
    }

    return $lic_img_pric.$lic_img1.$lic_img2.$lic_img3;
}

function setPostViews($postID) {
    $countKey = 'post_views_count';
    $count = get_post_meta($postID, $countKey, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $countKey);
        add_post_meta($postID, $countKey, '0');
    }else{
        $count++;
        update_post_meta($postID, $countKey, $count);
    }
}

?>