Tagged: Enfold child theme
-
AuthorPosts
-
September 19, 2017 at 9:33 am #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,
LeoSeptember 21, 2017 at 10:15 am #854692Hey 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ünterSeptember 21, 2017 at 11:58 am #854766oh 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);
September 22, 2017 at 10:10 pm #855606Hi,
Please do check the solution and let us know if it does work for you.
Thank you
Best regards,
BasilisSeptember 22, 2017 at 10:36 pm #855618haha – this is a question of mine so please inform günter – maybe he give us advice.
Thanks BasilisSeptember 24, 2017 at 3:53 pm #856061Hi,
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:
It should be easy to modify it to your needs. Link is valid for 1 week.
Best regards,
GünterSeptember 24, 2017 at 4:03 pm #856067thanks 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
September 24, 2017 at 4:15 pm #856074for 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 fieldadd_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; }
September 25, 2017 at 6:45 am #856340Hi,
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,
IsmaelSeptember 25, 2017 at 10:50 am #856414Hi,
See https://github.com/KriesiMedia/enfold-library/blob/master/actions%20and%20filters/Option%20Settings/General%20Enfold%20Option%20Page%20Settings/avf_option_page_data_init.php for a more common solution.
Added a new snippet.
Best regards,
GünterSeptember 25, 2017 at 11:09 am #856422thanks 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 faviconEdit: 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, 2 months ago by Guenni007.
September 25, 2017 at 12:08 pm #856438 -
AuthorPosts
- The topic ‘How to override Enfold admin options in Child Theme?’ is closed to new replies.