Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #853768

    Hi support team,

    Is it possible to override Enfold admin options in Child Theme?
    I want to override /wp-content/themes/enfold/includes/register-admin-options.php. To do this i added /wp-content/themes/enfold-child/includes/register-admin-options.php and did my changes in this file.
    But this doesn’t work with Child Theme. I don’t want to change the Parent Theme files.

    I just want to increase the upper limit of the “Header Custom Height” from 300px to 500px.

    Is there an other way to change this?
    Can i do this in the functions.php of Child Theme?

    Thanks,
    Leo

    #854692

    Hey Leo,

    Thank yyou for using our theme.

    In enfold\framework\php\class-superobject.php line 117 you have 2 filters:

    
    			if(isset($avia_pages)) $this->option_pages = apply_filters( 'avf_option_page_init', $avia_pages);
    			if(isset($avia_elements)) $this->option_page_data = apply_filters( 'avf_option_page_data_init', $avia_elements);
    

    There you can alter the option array and the elements with a filter hook in functions.php in the child theme.

    If you need assistance in creating the filter hooks let us know.

    Best regards,
    Günter

    #854766

    oh thats nice – but Günter please give us advice – i can manage it to enter additional tabs here (by $new_elements[]– but the trick of changing an existing one does not go on my end here.

    $customsize = array();
    for ($x=45; $x<=300; $x++){ $customsize[$x.'px'] = $x; }	

    in the :

    $avia_elements[] =	array(
    "slug"	=> "header",
    "name" 	=> __("Header Custom Height", 'avia_framework'),
    "desc" 	=> __("Choose a custom height in pixels (wont be reflected in the preview above, only on your actual page)", 'avia_framework'),
    "id" 	=> "header_custom_size",
    "type" 	=> "select",
    "std" 	=> "150",
    "required" => array('header_size','custom'),
    "no_first"=>true,
    "subtype" => $customsize);	
    #855606

    Hi,

    Please do check the solution and let us know if it does work for you.

    Thank you

    Best regards,
    Basilis

    #855618

    haha – this is a question of mine so please inform günter – maybe he give us advice.
    Thanks Basilis

    #856061

    Hi,

    Sorry for the late reply.

    I added the frame for the filter avf_option_page_data_init to our Enfold library https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/Option%20Settings/General%20Enfold%20Option%20Page%20Settings/avf_option_page_data_init.php.

    Here is also the code:

    https://pastebin.com/jK2QWh2Y

    It should be easy to modify it to your needs. Link is valid for 1 week.

    Best regards,
    Günter

    #856067

    thanks Günter – this goes to my treasure chest :LOL
    on that customization.php memory file – i got a lot of commented code concerning to enfold f.e.

    /**  quick css im Backend auf breit setzen ************************/
    function admin_head_mod() {
    echo '<style type="text/css">
    #avia_quick_css .avia_description {float: none;margin-bottom: 20px !important;padding-left: 0 !important;width: 98%}
    #avia_quick_css .avia_control {float: left;max-width: 98% !important;width: 98% !important}
    .avia_footer_links li {float: left;padding-right: 20px}
    .avia_footer .avia_footer_save {float: left}
    </style>';
    }
    add_action('admin_head', 'admin_head_mod');
    /**********************/

    etc. pp :yoo

    #856074

    for new elements – do i have the opportunity to have influence on what position the tab is placed ?
    This code f.e. is placed at the end of that tab – but i like to have it under fav-icon input field

    add_filter('avf_option_page_data_init', 'custom_option_apple_icon', 10, 1);
    function custom_option_apple_icon($avia_elements){
    	$new_elements[] =	array(
    					"slug"	=> "avia",
    					"name" 	=> __("Apple Icon", 'avia_framework'),
    					"desc" 	=> __("Upload an Apple Icon to use", 'avia_framework'),
    					"id" 	=> "avia_appleicon",
    					"type" 	=> "upload",
    					"label"	=> __("Use Image as Apple Icon", 'avia_framework'));
    
    	$avia_elements = array_merge( $avia_elements, $new_elements );
      return $avia_elements;
    }
    #856340

    Hi,

    Try this code.

    /**
     * Insert a value or key/value pair after a specific key in an array.  If key doesn't exist, value is appended
     * to the end of the array.
     *
     * @param array $array
     * @param string $key
     * @param array $new
     *
     * @return array
     */
    function array_insert_after( array $array, $key, array $new ) {
    	$keys = array_keys( $array );
    	$index = array_search( $key, $keys );
    	$pos = false === $index ? count( $array ) : $index + 1;
    	return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
    }
    
    add_filter('avf_option_page_data_init', 'custom_option_apple_icon', 10, 1);
    function custom_option_apple_icon($avia_elements){
    	$new_elements[] =	array(
    					"slug"	=> "avia",
    					"name" 	=> __("Apple Icon", 'avia_framework'),
    					"desc" 	=> __("Upload an Apple Icon to use", 'avia_framework'),
    					"id" 	=> "avia_appleicon",
    					"type" 	=> "upload",
    					"label"	=> __("Use Image as Apple Icon", 'avia_framework'));
    
    	$avia_elements = array_insert_after($avia_elements, 69, $new_elements);
      return $avia_elements;
    }
    

    Based on: https://gist.github.com/wpscholar/0deadce1bbfa4adb4e4c

    Best regards,
    Ismael

    #856414
    #856422

    thanks alot i will test it .
    and yes it is only a “cosmetic” question – but f.e. the apple touch icon input field looks definitly better after the favicon

    Edit: thanks both works perfect – Ismael your code is a bit shorter but Günters Code it is easier to work with – because i do not have to count the $avia_elements on the way to count (your 69 is correct ) – but i come to the position after logo with 69 – anyway.

    Edit: and is usefull for even older enfold versions – i tested your code on an older version and it fails because the count of favicon was a different one

    Thanks both for your highly professional answers !

    • This reply was modified 7 years, 1 month ago by Guenni007.
    #856438

    Hi,

    Glad we could help you.

    I close this topic – open a new one whenever you need more assistance.

    LG aus Wien
    Günter

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘How to override Enfold admin options in Child Theme?’ is closed to new replies.