Editor tema blocked, devo fare lavori su header.php

This topic has 11 replies, 2 voices, and was last updated 1 years, 11 months ago ago by Olga Barlow

  • Avatar: cwagencyit
    cwagencyit
    Participant
    May 5, 2022 at 17:34

    Salve, devo apportare una modifica sull’header php e non posso perché è tutto bloccato, non posso lavorare sul codice?

    10 Answers
    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    May 5, 2022 at 22:45

    Hello,

    Could you, please, write in English?
    What changes do you need to make in header.php? Do you want to add any custom js? Install and use the Insert headers and footers plugin for these purposes.

    Regards

    Avatar: cwagencyit
    cwagencyit
    Participant
    May 6, 2022 at 08:49

    Hi, I have to make a change on the php header and I can’t because everything is blocked, can’t I work on the code?

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    May 6, 2022 at 10:04

    Hello,

    Do you want to edit the header structure? Use header builder to change the header layout https://www.youtube.com/playlist?list=PLMqMSqDgPNmDu3kYqh-SAsfUqutW3ohlG

    Or what changes do you want to make? Explain in more detail, please. Provide an example for a better understanding. I can’t guide you if I don’t understand what exactly you want to change.

    Regards

    Avatar: cwagencyit
    cwagencyit
    Participant
    May 6, 2022 at 10:09

    I need to block the desktop view of the site, I have to insert this php in the header.php, but it doesn’t let me insert it!

    function isMobileDevice(){
    $aMobileUA = array(
    ‘/iphone/i’ => ‘iPhone’,
    ‘/ipod/i’ => ‘iPod’,
    ‘/ipad/i’ => ‘iPad’,
    ‘/android/i’ => ‘Android’,
    ‘/blackberry/i’ => ‘BlackBerry’,
    ‘/webos/i’ => ‘Mobile’
    );

    //Return true if Mobile User Agent is detected
    foreach($aMobileUA as $sMobileKey => $sMobileOS){
    if(preg_match($sMobileKey, $_SERVER[‘HTTP_USER_AGENT’])){
    return true; //telefono o tablet
    }
    }
    //Otherwise return false..
    return false; //fai il redirect o mostri la pagina di errore
    }

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    May 6, 2022 at 10:30

    Hello,

    If you want to make changes in the theme files then copy header.php file to child theme and edit that according to your needs. Don’t make any changes directly in parent theme files because you will lose them after the theme update. Use child theme for any additional customization. But you need to be sure that mentioned code works in general. Did you check if that code works for you with any default WP theme like Storefront or Twenty Twenty-One?

    Regards

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    May 6, 2022 at 10:30

    Hello,

    If you want to make changes in the theme files then copy header.php file to child theme and edit that according to your needs. Don’t make any changes directly in parent theme files because you will lose them after the theme update. Use child theme for any additional customization. But you need to be sure that mentioned code works in general. Did you check if that code works for you with any default WP theme like Storefront or Twenty Twenty-One?

    Regards

    Avatar: cwagencyit
    cwagencyit
    Participant
    May 6, 2022 at 10:33

    yes the code works, otherwise you as a theme have the internal possibility to block the desktop view of the site?

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    May 6, 2022 at 10:44

    Hello,

    1) Could you, please, provide us with WP Dashboard and FTP access to your site to check the issue in more detail and help you?
    2) It’s bad practice to create functions in such files. Because you may get a fatal error “function that already exists” if the file will be called anywhere else.

    Regards

    Avatar: cwagencyit
    cwagencyit
    Participant
    May 6, 2022 at 10:50

    not a problem, the site works correctly, I want to block the view from the desktop

    Avatar: Olga Barlow
    Olga Barlow
    Support staff
    May 6, 2022 at 11:21

    Hello,

    We don’t have the option to block the site from viewing from the desktop. So, we need to check what could be the reason that your custom code does not work.

    Go to Theme Option > General > mobile optimization option is enabled or disabled? Disable that in case it’s enabled.

    Regards

  • Viewing 11 results - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.