• I have created a child theme and add a style.css file which imports the script from the parent file and then I made changes within that child style.css file.

    Here’s the code:

    /*
    Theme Name: KarmaChild
    Description: Child Theme for Karma
    Author: Kristian Bowman
    Template: Karma
    Version: 1.0
    */

    @import url(“../Karma/style.css”);

    /* Change Post Title size and font style to italic */
    .home-banner-main h2 {
    color:#222!important;
    font-size:1.8em!important;
    font-style:italic;
    padding-bottom:5px!important;
    font-weight:400!important;
    }

    This approach works and is simple and concise.

    I tried the same approach with header.php file but without success:

    /*
    Theme Name: KarmaChild
    Description: Child Theme for Karma
    Author: Kristian Bowman
    Template: Karma
    Version: 1.0
    */

    @import url(“../Karma/header.php”);

    I have managed to take an exact copy of the parent header.php and edit the child version successfully but I was wondering can I use the @import functionality in the same way I have with the style.css file?

Viewing 12 replies - 1 through 12 (of 12 total)
  • https://codex.www.ads-software.com/Child_Themes

    you need to create a copy of header.php in the child theme, possibly using ftp .

    https://codex.www.ads-software.com/Child_Themes#Template_files

    Thread Starter Katsura

    (@katsura)

    I have already read these help references. Like I say, I’ve successfully created a copy of header.php in the child theme and edited that but I was hoping to use the @import functionality in a similar way to the style.css methodology.

    Can anyone advise if this is possible and if so how?

    The method you are describing is not advisable to import the functions from the parent theme header.php into the child theme’s header.php.

    You could use an “include” or “require_once(‘../../maintheme/

    But completely and utterly advising you not to, it’s bad mojo.

    Thread Starter Katsura

    (@katsura)

    Ok.

    It may help if I explain why I’m wanting to do this.
    I need to prevent right click (copy image) on my site, I’ve been provided a piece of script which I can change in the header.php file (which works).

    I’ve been advised to use a child theme to make changes :
    a) so I don’t break the master file
    b) so the script changes aren’t overwritten when I upgrade the theme etc

    If there are other, safer, easier ways to do this then I’m all ears.

    is it a .js file you add the link to, or is just <script> </script> style

    I ask because there are multiple methods to do this..

    and yes, basically the advice they’re giving you is copy the header.php to the child theme and edit that header.php in the child theme.

    However, if it’s a .js file you can ‘enqueue’ it from the child themes function.php file which would be better all around.

    Got a pastebin for that code?

    Thread Starter Katsura

    (@katsura)

    Ok – that’s where I’d got to – I’ve taken a copy of the header.php file and then changed script in the Child header.php file as follows:

    Replace
    <body <?php body_class(); ?>>

    with
    <body onload=”;init_start(); ” id=”bodytag” class=”bodyContent” oncontextmenu=”return false;” <?php body_class(); ?>>

    I may be wrong but i think that protects the parent header.php but means I’d still have to repeat that process of copying and editing the child theme file every time I upgrade the theme right?

    I am happy to try and use a js.file if this possible a better way.
    I’ve no idea how to do this.

    sorry – I don’t know what a paste bin is.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Putting aside the fact that those scripts are not effective and tick off your readers… I think you may be going about this the wrong way.

    If all you want to do is insert some javascript into the head section of your child theme, then consider this plugin.

    https://www.ads-software.com/extend/plugins/header-footer/

    That will let you insert what you want and you won’t have to maintain a copy of the header.php file.

    Edit: Oh, and Pastebin.com is a magical place where you can share code and even get line numbers. ?? Give it a try, it’s easy to use.

    Thread Starter Katsura

    (@katsura)

    All I want to do is prevent readers from right clicking and copying images, being a professional photographer it is imperative to protect my images. I want to do so in a way that means I don’t have to keep on changing code every time I upgrade the Theme version.

    I read link Re: Header-footer plugins, will this do what I want?
    If so is there a particular one you;d recommend?

    FYI – I’m using the Karma theme.

    All I want to do is prevent readers from right clicking and copying images, being a professional photographer it is imperative to protect my images. I want to do so in a way that means I don’t have to keep on changing code every time I upgrade the Theme version.

    I have been there before, but how do you prevent them from

    • “Print Screen” and paste into paint
    • screen grab products like Snagit,
    • “file save page as”
    • website download software will download the images
    • the Snipping Tool?
    • view page source and get the image link

    Would it stop the FireFox AddOns:
    Image Toolbar
    Image Download
    Would it stop Harvesting Software.

    Look at all the ‘stock image websites’ if there was a way to stop someone making a copy they would have used it.

    You would also need to consider accessibility and disability options where the right mouse key could be mapped to a different action.

    The only viable universal way I found was to create and upload a composite image, a low resolution minimum sized image and added a watermark.

    Most graphic packages will have a batch action for this, accept that this is the internet, if it is there it will get copied one way or another!

    The time I spent trying to prevent a right click could have been much better spent on my creative photography, after a lot of testing it was only adding a watermark that worked, accepting that the watermarked image could be downloaded and cropped.

    TinEye is constantly crawling the web and updating our image database regularly. We also accept direct contributions of complete online image collections. To date, TinEye has indexed 2,163,266,343 images from the web. We add tens of millions of new images to TinEye every month, and our index is on the grow.

    If someone likes your little image and downloaded it for personal use then is it a big issue, for image abuse there is also Tineye that might find your images if they are used on the web, this is what some of the big stock website use to find where an image is used.

    HTH

    David

    Watermarks are your friend, big huge ones that display on the images, and for people to purchase the image they get the ones without it.

    Thread Starter Katsura

    (@katsura)

    I’m guessing from you indirect response that the plugins don’t function as desired.

    I’m VERY familiar with watermarks. Watermarks are suitable when providing a portfolio of a shoot to a client but are inappropriate for website general gallery/viewing purposes.

    I’m VERY familiar with watermarks. Watermarks are suitable when providing a portfolio of a shoot to a client but are inappropriate for website general gallery/viewing purposes.

    Watermarks are an acceptable way of presenting any media where you want to protect your IP and copyright, website mockups are presented to blue chip companies with watermarked composite images inserted.

    Just ‘disable the right mouse click’ will not stop anyone from grabbing the images, if someone wants a copy there are a large number of ways to get it, and as Jan said:

    those scripts are not effective and tick off your readers… I think you may be going about this the wrong way.

    The right way is just to minimise the risk, only display an image on the internet if you are prepared for some copies being made as you cannot prevent it.

    Minimise the infringement risk, only upload a low resolution image at a fixed size for the website, with or without a watermark.

    If your clients are visiting the website and you think they might grab a copy then you could put up a small clean thumbnail linked to a larger watermarked image.

    Maybe an over reaction as there are billions upon billions of images on the internet, the chances of someone visiting and stealing an image are minute and a risk you have to take, if you want to have your portfolio online.

    Ideas:
    Looking at websites for top photograpers they seem to use flash or sprite scripts.

    Have a look to see if ther is a sprite plugin or script, something that would chop the image into little pieces and rebuild it on the page.

    Splice the image yourself say sixteen bits, then upload it to the post and rebuild it in the content, a lot of work though.

    David

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Child Theme Header.php’ is closed to new replies.