badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

Child theme and modified code

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #15891
    grendizer
    Member

    Hello, I need some help with setting up modified code in a CleanRetina Pro child theme.

    Because of an incompatibility between the default slider and the Polylang plugin, I need to edit this file:
    root folder/wp-content/themes/clean-retina-pro/library/structure/header-extensions.php
    In this file I need to edit this function:
    cleanretina_featured_post_slider()
    And I add this line of code before the first IF loop:
    delete_transient( ‘cleanretina_featured_post_slider’ );

    This was something I did each time I updated CleanRetina. However, now, following the advice of Theme Horse, I’m using a child theme.
    This what I did so far:
    – Updated CleanRetina Pro to v1.7
    – Copied the original header-extensions.php to my hard drive and edited it.
    – Created a folder clean-retina-pro-child with the style.css correctly set into it.
    – Created this subfolders : clean-retina-pro-child/library/structure
    – Inside this subfolder, I uploaded the header-extensions.php file.

    Unfortunately, what I did doesn’t seem to have any effect. It was working well on the “parent” theme, but does not seem to work on the child theme.

    So my questions are:
    1) Do I need to put this file into this subfolder, or in the clean-retina-pro-child folder (the root)?
    2) Do I need to have the whole code of header-extensions.php in the child theme’s folder?
    3) Is there another thing I’m doing wrong?

    Thanks,

    David

    #16008

    Hi grendizer,

    you just create a functions.php on the clean retina pro (the root) and first unhook the functions and then only customise the code.

    for more info

    http://themeshaper.com/2009/05/25/action-hooks-wordpress-child-themes/

    Thank you!

    #16102
    grendizer
    Member

    Hello Theme Horse Support, thanks a lot for the help.
    I’m reading this link and also this one : http://venutip.com/content/right-way-override-theme-functions
    So I understood that for this to work, I need to find, in the original header-extensions.php , right before the begining of the cleanretina_featured_post_slider() function, a line that reads:
    add_action(‘phase’,’function’, ‘priority’);
    Unfortunately, I can’t find such a line before the begining of the cleanretina_featured_post_slider() function. Could you please help me?
    Thanks,
    David

    #16137

    hi grendizer,

    I will set you a simple example. Not of this cleanretina_featured_post_slider() function but also helps you to create a child theme

    for example:- (the below code is only the sample code)

    unhook functions
    
    // Unhook default Thematic functions
    function unhook_thematic_functions() {
        // Don't forget the position number if the original function has one
    
    remove_action( 'cleanretina_404_content', 'cleanretina_display_404_page_content', 10 );
    
    }
    add_action('init','unhook_thematic_functions'); // removes the header content by using hook cleanretina_header
    
    add_action( 'cleanretina_404_content', 'cleanretina_child_display_404_page_content', 10 );
    /**
     * function to show the footer info, copyright information
     */
     
     
    function cleanretina_child_display_404_page_content() {      ?>   
    <div id="content">
    		<header class="entry-header">
    			<h1 class="entry-title"><?php _e( 'Error 404-Page NOT Found', 'attitude' ); ?></a></h1>
    		</header>
    		<div class="entry-content clearfix" >
    			<p>Thank you</p> 
    		</div><!-- .entry-content -->
    	</div><!-- #content -->
      <?php 
    }
    
    #16144
    grendizer
    Member

    Hi

    Yes I was aware of this kind of code, and I’m about to add it to my child theme’s function.php, but there is missing information. For example, in your sample code, there is this line :
    remove_action( ‘cleanretina_404_content’, ‘cleanretina_display_404_page_content’, 10 );
    ‘cleanretina_404_content’ : I must replace this by the real “phase”. Where do I find this info?
    ‘cleanretina_display_404_page_content’ : I must replace this by the real function: ‘cleanretina_featured_post_slider’
    10 : I must replace this by the real position number. Where do I find this info?

    Thanks , and sorry for the newbie stance.
    David

    #16208

    hi
    This 404 functions is inside clean retina pro (themefolder) -> library -> functions -> functions.php on line no 472

    You may simply change it by creating header.php file inside child theme and first unhook the functions and then only customise the code. If you are not able to fix it then you may hire a developer to fix it.

    Thank you!

    #16232
    grendizer
    Member

    Hi
    Thanks for pointing me to the location of the function in your example code.

    Let’s look at the example code:
    As I said in my September 16 post, just before the function, there should be a line with:
    add_action(‘phase’,’function’, ‘priority’);
    And indeed, just before the function cleanretina_display_404_page_content() , there is a line reading:
    add_action( ‘cleanretina_404_content’, ‘cleanretina_display_404_page_content’, 10 );
    This line is essential because it gives information to unhook the function.

    Now for the function cleanretina_featured_post_slider: it is located in:
    clean retina pro (themefolder) -> library -> structure -> header-extensions.php on line no 490
    Just before this function, there is NO line reading: add_action(‘phase’,’function’, ‘priority’);
    So I don’t have the necessary information to unhook this function in the child theme.

    This should be easy to fix, thanks for any help!!
    David

    #16279

    Hi grendizer,
    Yes exactly there is not add_action so you need code customisation to fix it.

    First you need to unhook this functions

    add_action( 'cleanretina_header', 'cleanretina_headerdetails', 10 );
    

    by and remove this action using
    `remove_action(‘cleanretina_header’, ‘cleanretina_headerdetails’, 10 );

    }
    add_action(‘init’,’unhook_thematic_functions’); // removes the header content by using hook cleanretina_header

    
    
    Now whatever you need you need to add and where you need modification replace it or remove it and add your code
    
    

    add_action( ‘cleanretina_header’, ‘cleanretina_child_headerdetails’, 10 );
    /**
    * Shows Header Part Content
    *
    * Shows the site logo, title, description, searchbar, social icons etc.
    */
    function cleanretina_child_headerdetails() {

    // add your code under it .just only add the specific code you need. This will work for your header parts from social icons to slogan / slider.

    }`

    If you are still unable then you may hire a developer to fix it or better consult with a programmer.

    Thank you!

    #16436
    grendizer
    Member

    Well I tried editing the code as best as I could but still can’t get it to work.
    So now I should perhaps hire a devlopper but it would mean I would pay more for a bug fix. I’m just trying to fix a conflict between CleanRetina Pro and Polylang.
    So how do I contact a developper and how much would it cost me?
    Thanks

    #16464

    Hi grendizer,
    we actually does not work for customisation. We don’t have the exact idea how much the developer will cost it.
    Thank you!

    #16472
    grendizer
    Member

    However I believe the bugfix for the conflict between CleanRetina and Polylang should be part of the CleanRetina code.

    #16473
    grendizer
    Member

    Hello again. So I have searched again by studying the functions and by reading articles on the web. I finally managed to do what i wanted. I’m putting here my conclusions to help other people with the same problem:

    1) First, I noticed the function cleanretina_featured_post_slider() was OUTSIDE the function cleanretina_headerdetails(). There is a closing “}” before all bottom functions such as cleanretina_featured_post_slider(). As a result, in the child theme’s functions.php, there is NO need to refer to the function cleanretina_headerdetails().

    2) Second, there are 2 ways to replace a parent function with a child fonction.
    – First solution : Deactivate the Parent Function then Activate the Child Function: http://venutip.com/content/right-way-override-theme-functions . This is what I was trying to do.
    – Second solution : use “pluggable” functions : http://codex.wordpress.org/Child_Themes#Using_functions.php : TIP FOR THEME DEVELOPERS. The fact that a child theme’s functions.php is loaded first means that you can make the user functions of your theme pluggable —that is, replaceable by a child theme— by declaring them conditionally. E.g.:
    if ( ! function_exists( ‘theme_special_nav’ ) ) {
    function theme_special_nav() {
    // Do something.
    }
    }

    3) According to the code in header-extension.php, Theme Horse’s developpers are using the second solution for the function I’m interested in. The following line:
    if ( ! function_exists( ‘cleanretina_featured_post_slider’ ) ) :
    means that if the function cleanretina_featured_post_slider does not exist, then it should be run. But, the child theme’s functions.php is loaded before the parent theme’s functions. So if the same function already exists in the child theme, it will not run in the parent theme!

    4) So my code in the child theme’s functions.php is very simple:
    <?php // Opening PHP tag – nothing should be before this, not even whitespace
    function cleanretina_featured_post_slider() {
    //original code pasted here , then modified for my own needs.

    5) It’s a lot of work and research for a simple bug, so I repeat: Theme Horse should fix once and for good the conflict between CleanRetina (Free & Pro) and the Polylang plugin.

    Thanks
    David

    #16549

    Thanks a lot for sharing your experience with us

    Thank you!

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.