-
AuthorPosts
-
October 3, 2018 at 11:07 am #1017448
Well there is on register-admin-options.php these settings which found there pendents in the Enfold Options we all can see if we like to influence Enfold Settings.
i learned how to insert f.e. a new input field (apple touch icon) and i learned how to change the range on header_custom_size
but now i’m looking for an easy child-theme solution to replace on ID : main_menu_preview only a part of the std value.The aim is to replace th pr-logo which is in that std value integrated as:
<img id='pr-logo' src='".AVIA_BASE_URL."images/layout/logo_modern.png' alt=''/>
i want to set up via a child-theme function a different directory. My trial was:
function change_pr_logo_path( array $avia_elements = array() ) { $slug = "menu"; $id = 'main_menu_preview'; $index = -1; /** Find index of element to change*/ foreach( $avia_elements as $key => $element ){ if( isset( $element['id'] ) && ( $element['id'] == $id ) && isset( $element['slug'] ) && ( $element['slug'] == $slug ) ){ $index = $key; break; } } /*** If key not found, return unmodified array*/ if( $index < 0 ){return $avia_elements;} /*** Make your customizations*/ $avia_elements[ $index ]['std'] = // i stuck here - how to replace only a part and not the whole bunch of the normal std value /*** Return modified */ return $avia_elements; } add_filter( 'avf_option_page_data_init', 'change_pr_logo_path', 10, 1 );
can you help me to find a maybe different way to replace the pr-logo (the easiest way is to replace the logos in the parent theme folder)
October 3, 2018 at 11:12 am #1017449The reason for looking on that was a question here on board to totaly customize the branding of the theme.
To rename the theme and child-theme ; to have the style-sheet name customized etc. Even the nolink was easy to substitute. But this little logo and pr-logo is hard to replace on a child-theme manner.- This reply was modified 6 years, 1 month ago by Guenni007.
October 5, 2018 at 5:05 am #1018113Hi,
Thank you for using Enfold.
That is quite interesting. Try to use the str_replace function to replace a particular string with your own.
std = str_replace("<img id='pr-logo' src='".AVIA_BASE_URL."images/layout/logo_modern.png' alt=''/>", "REPLACEMENT", $avia_elements[ $index ]['std']);
Best regards,
Ismael3`October 5, 2018 at 9:40 am #1018190Yes that was the right hint :
function change_pr_logo_path( array $avia_elements = array() ) { $slug = "menu"; $id = 'main_menu_preview'; $index = -1; /** Find index of element to change*/ foreach( $avia_elements as $key => $element ){ if( isset( $element['id'] ) && ( $element['id'] == $id ) && isset( $element['slug'] ) && ( $element['slug'] == $slug ) ){ $index = $key; break; } } /*** If key not found, return unmodified array*/ if( $index < 0 ){return $avia_elements;} /*** Make your customizations*/ $new = str_replace( "<img id='pr-logo' src='".AVIA_BASE_URL."images/layout/logo_modern.png' alt=''/>", "<img id='pr-logo' src='".get_stylesheet_directory_uri()."/logo_modern.png' alt='MyLogo'/>", $avia_elements[ $index ]['std']); $avia_elements[ $index ]['std'] = $new ; /*** Return modified */ return $avia_elements; } add_filter( 'avf_option_page_data_init', 'change_pr_logo_path', 10, 1 );
_______
but now i see – there is it twice ! it is on :
"slug" => "header", "id" => "default_header_target",
too !
is there a way to have this function not twice but to make an array to run this for both slugs and ids ?and the aim is : to insert the uploaded logo into this replacement
October 5, 2018 at 10:42 am #1018223could it be possible to globaly find an expression and replace it with another one in the whole $avia_elements without defining a slug and id.
it is twice the same expression to change.?By the way : wasn’t it a good idea to have this on default : That preview shows on top the inserted uploaded logo ?
October 8, 2018 at 3:25 am #1018770Hi,
You can try this code.
function change_pr_logo_path( array $avia_elements = array() ) { $old = AVIA_BASE_URL."images/layout/logo_modern.png"; $new = 'http://localhost/kriesi/enfold/wp-content/uploads/2018/10/splash-orange-3.png'; /** Find index of element to change*/ foreach( $avia_elements as $key => $element ){ if( ((isset( $element['id'] ) && ( $element['id'] == 'main_menu_preview' ) && isset( $element['slug'] ) && ( $element['slug'] == 'menu'))) || ((isset( $element['id'] ) && ( $element['id'] == 'default_header_target' ) && isset( $element['slug'] ) && ( $element['slug'] == 'header'))) ) { $avia_elements[$key]['std'] = str_replace("<img id='pr-logo' src='".$old."' alt=''/>", "<img id='pr-logo' src='".$new."' alt='MyLogo'/>", $avia_elements[$key]['std']); } } /*** Return modified */ return $avia_elements; } add_filter( 'avf_option_page_data_init', 'change_pr_logo_path', 10, 1 );
Just change the $new logo url.
Best regards,
IsmaelOctober 9, 2018 at 8:08 am #1019382Great – bowing in awe – can be closed – thats it!
I’ve also written down your code in such a way as to better understand the logic:
function change_pr_logo_path( array $avia_elements = array() ) { $old = AVIA_BASE_URL."images/layout/logo_modern.png"; $new = 'absolute path to the new …/logo_modern.png'; /** Find index of element to change*/ foreach( $avia_elements as $key => $element ){ if( ((isset( $element['id'] ) && ( $element['id'] == 'main_menu_preview' ) && isset( $element['slug'] ) && ( $element['slug'] == 'menu'))) || ((isset( $element['id'] ) && ( $element['id'] == 'default_header_target' ) && isset( $element['slug'] ) && ( $element['slug'] == 'header'))) ) { $avia_elements[$key]['std'] = str_replace( "<img id='pr-logo' src='".$old."' alt=''/>", "<img id='pr-logo' src='".$new."' alt='MyLogo'/>", $avia_elements[$key]['std']); } } /*** Return modified */ return $avia_elements; } add_filter( 'avf_option_page_data_init', 'change_pr_logo_path', 10, 1 );
__________–
Just one question – can we have this line to have automatically have the inserted mainlogo for it:
that way would be more elegant then.
$new = 'path to inserted logo';
Or is it impossible to have this because logo itself is on line 1842 ff inserted – and that is later than the main_menu_preview ( line 480ff) ?
October 10, 2018 at 3:17 am #1019711Hi,
Try to fetch the database option manually.
global $avia; $data = get_option($avia->option_prefix); $old = AVIA_BASE_URL."images/layout/logo_modern.png"; $new = $data['avia']['logo'];
Best regards,
IsmaelOctober 10, 2018 at 11:31 am #1019895yes – as alway from you – perfect solution!
can be closed – you’ve sacrificed enough time for a minor problem now.October 11, 2018 at 3:51 am #1020122 -
AuthorPosts
- The topic ‘child-theme solution for change an avia_element ?’ is closed to new replies.