Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #33607
    prajakta
    Member

    How to edit theme_options.php without editing the parent theme ??
    I have catch-kathmandu theme.I have created its child theme. I have made certain changes in theme_options.php (inc/panel/theme_options.php -> catchkathmandu_theme_options_do_page() function ). To make the changes work i had to comment following line in my parent’s function.php
    require( get_template_directory() . ‘/inc/panel/theme-options.php’ );
    similarly i had to add the following in my child theme’s function.php
    require( get_stylesheet_directory() . ‘/inc/panel/theme-options.php’ );

    Is there any way to make the changes without making any changes to parent theme ?

    #33669
    Sakin
    Keymaster

    @prajakta: Sorry I don’t think moving the theme-options.php to child theme will work as it depends on so many files. So, it will be better that you create additional option in your child theme or use plugin like Options Framework to add additional option in your child theme.

    #36294
    prajakta
    Member

    @sakin: Moving the file theme_options.php is working…[pls refer my question].I need to change this function
    inc/panel/theme_options.php -> catchkathmandu_theme_options_do_page() function as i am adding one theme option field here.

    I think catchkathmandu_theme_options_do_page() could be overwritten if function_exists was used.Can we do this in future versions ? or is there any way out

    I Just need to add a single field so Options Framework is expensive …can anybody help with the other way…i am new to wordpress

    #36312
    Sakin
    Keymaster

    @prajakta: Option Framework will not be expensive and it is just on backed. Also if you need, you can add option by creating child theme option panel. Here is the sample code that you can add in your child theme functions.php file

    add_action( 'admin_menu', 'catchkathmandu_child_options_menu' );
    /*
     * Create a function for Theme Options Page
     *
     * @uses add_menu_page
     * @add action admin_menu 
     */
    function catchkathmandu_child_options_menu() {
    
    	add_theme_page( 
            __( 'Theme Options Child', 'catchkathmandu' ),	// Name of page
            __( 'Theme Options Child', 'catchkathmandu' ),	// Label in menu
            'edit_theme_options',                           // Capability required
            'child_theme_options',                        	// Menu slug, used to uniquely identify the page
            'catchkathmandu_child_theme_options_do_page'	// Function that renders the options page
        );	
    
    }
    
    /*
     * Render Catch Kathmandu Child Theme Options page
     *
     * @uses settings_fields, get_option, bloginfo
     * @Settings Updated
     */
    function catchkathmandu_child_theme_options_do_page() {
    
    	
    }
    #36396
    prajakta
    Member

    Thanks for the reply …I just need to clarify that will not executing 1200-1400 same lines again for just 10 lines of modification in this function affect the performance…or is there any other efficient way

    or can we do something like this in child’s function.php

    remove_action( ‘admin_menu’, ‘catchkathmandu_options_menu’ );
    add_action( ‘admin_menu’, ‘catchkathmandu_child_options_menu’ );

    function catchkathmandu_child_options_menu() {

    add_theme_page(
    __( ‘Theme Options’, ‘catchkathmandu’ ), // Name of page
    __( ‘Theme Options’, ‘catchkathmandu’ ), // Label in menu
    ‘edit_theme_options’, // Capability required
    ‘theme_options’, // Menu slug, used to uniquely identify the page
    ‘catchkathmandu_child_theme_options_do_page’ // Function that renders the options page
    );

    function catchkathmandu_child_theme_options_do_page() {
    }

    Is this way correct ?
    I am not sure whether removing the action stops it from executing the old function catchkathmandu_theme_options_do_page()

    #36485
    Sakin
    Keymaster

    @prajakta: if you want to remove action and add your own then it will like below:

    // Removing the Default Action Hook
    function unhook_catchkathmandu_functions() {
    	remove_action( 'admin_menu', 'catchkathmandu_options_menu' );
    }
    add_action( 'init', 'unhook_catchkathmandu_functions' );
    
    add_action( 'admin_menu', 'catchkathmandu_child_options_menu' );
    
    function catchkathmandu_options_menu() {
    
    	add_theme_page( 
            __( 'Theme Options', 'catchkathmandu' ),		// Name of page
            __( 'Theme Options', 'catchkathmandu' ),		// Label in menu
            'edit_theme_options',                           // Capability required
            'theme_options',                                // Menu slug, used to uniquely identify the page
            'catchkathmandu_child_theme_options_do_page'	// Function that renders the options page
        );	
    
    }
    
    function catchkathmandu_child_theme_options_do_page() {
    	
    }
    #36570
    prajakta
    Member

    Thanks for the reply..just want to know whether removing the action stops it from executing the old function catchkathmandu_theme_options_do_page() …is there any plugin availbale to see hooks and the actions applied to them while executing…I tried Hook Sniffer but it’s crashing as its outdated.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Unable to edit theme_options.php without editing the parent theme’ is closed to new replies.