-
AuthorPosts
-
May 28, 2022 at 12:23 am #1353250
Dear Enfold Support
Until now I add a customized version of the shortcode av-helper-masonry.php to my child theme with the following function in my child theme’s functions.php:
add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1); function avia_include_shortcode_template($paths) { $template_url = get_stylesheet_directory(); array_unshift($paths, $template_url.'/shortcodes/'); return $paths; }
Since Enfold version 4.8.9 av-helper-masonry.php is supposed to be deprecated and is moved from the directory avia_shortcodes to the directory legacy_avia_shortcodes. Instead there is a new class-avia-masonry.php in the new directory avia-shortcode-helpers. Do I have to make my customizations in the class-avia-masonry.php now and how can I add this customized version to the child theme? The above function does not the job. Or is there a way to still use the deprecated av-helper-masonry.php?
What do you recommend?
Kind regards
UeliMay 28, 2022 at 3:11 pm #1353275you are right – now you have to work with the new class-avia-masonry.php.
if you look inside the older file – you see at the beginning:
if ( ! class_exists( 'avia_masonry_old' ) )
the method stayes the same as before – your snippet is placed and the edited file could be uploaded to the enfold-child/shortcodes folder as before.
June 3, 2022 at 8:01 pm #1354070Hi Guenni
Do I understand you correctly? I just have to make my customizations in a copy of the new class-avia-masonry.php and upload that altered file to the enfold-child/shortcodes folder and then it is used instead of the original file? Do I also have to create a subfolder avia-shortcode-helpers because the original file is in a directory called like that?
And what exactly do you want to explain with…
if ( ! class_exists( 'avia_masonry_old' ) )
…in the older file? I found that code but what exactly does it? If I have to work with the new file, why does the older file still exist?Sorry, I just know little basics of PHP and don’t understand the concept of classes yet.
Kind regards
UeliJune 4, 2022 at 5:33 am #1354108the code from the first lines shows you that there has been a newer file now – and this is only for older masonry
next – yes thats what i try to describe.
If you do have ftp access, what’s the harm in putting a modified file there and seeing if my claim works. This is not Star Trek and the self-destruction mechanism is triggered. If it doesn’t work then you take the whole thing out of the folder. (If it doesn’t work, it is rather because of the made change within the file – because I always test my assertions before).
That was a substitution of a parent file inside the shortcodes – so it is not necessary to build the same folder structure.
If you substitute a file inside e.g. includes folder – there it might be better to build the same subfolders to your child-theme directory.June 4, 2022 at 3:03 pm #1354149Hi,
In addition to @Guenni007:
If you only modify class-avia-masonry.php you can copy the original file to “$template_url.’/shortcodes/'” and your copy will be loaded before the original file preventing loading this.
There is no need for a directory structure.
Only in case you need control which modified files in your child theme must be loaded before other files you can create a directory structure but must add this structure e.g.
add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1); function avia_include_shortcode_template($paths) { $template_url = get_stylesheet_directory(); array_unshift($paths, $template_url.'/shortcodes_1/', $template_url.'/shortcodes_2/' ); return $paths; }
and then file inside shortcodes_1 are loaded before files in shortcodes_2.
Best regards,
GünterJune 12, 2022 at 1:26 pm #1354967Hi,
@guenni007: I was brave and put my modified class-avia-masonry.php into the enfold-child/shortcodes. The self-destruction mechanism wasn’t triggered and thanks to Enfold’s warp drive, the modifications work well😉.
Thanks for your help.@Günter: Thanks for your additional explanation.
Kind regards
UeliJune 12, 2022 at 10:46 pm #1355001Hi,
Glad that Guenni007 & Günter could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘How to overwrite the new class-avia-masonry.php using the child theme?’ is closed to new replies.