Could you point how to create a custom plugin to prevent that our customizations are lost during updates?

Hi Experts

Could you point how to create a custom plugin to prevent that our customizations are lost during updates?

Directly customized theme functions.php

img004
I followed these steps, but something else must to be done to get it working.

1. Create a folder and a file under plugins' folder to customize to avoid directly customize functions.php

img001
2. The plugin is now avaliable
img002
3. But if it's selected, it doesn't exists.
img003
Thanks in advance!
Eduardo FuerteDeveloper and AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
There's already a mechanism for this.

https://codex.wordpress.org/Child_Themes provides the mechanism for preserving custom theme code across updates.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris StanyonWebDevCommented:
Hey Eduardo,

You need to make sure you've removed the relevant code from the functions.php file - you'll get an error if the same code exists in functions.php and your plugin file.
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
http://wpcandy.com/teaches/how-to-create-a-functionality-plugin provides good detail about developing site functionality plugins.

And the link you show above relates to a theme, not a plugin, so likely best to create a Child Theme for you specific situation.
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Eduardo FuerteDeveloper and AnalystAuthor Commented:
Hi

@Chris
I removed the relevant code and the error persisted.

@David
After following  
create a Child Theme for you specific situation
sugestion everything runs ok...

My doubt is: if it's a much more easyer alternative why is it asked to create a custom plugin?
/**
 * Note: Do not add any custom code here. Please use a custom plugin so that your customizations aren't lost during updates.
 * https://github.com/woocommerce/theme-customisations
 */

Open in new window

Since accordingly to the lessons I had at Youtube, to create a Wordpress plugin is a complex task... Could you explain?
0
Chris StanyonWebDevCommented:
Creating a plugin is as easy or as complicated as you need it to be. For some simple customisations like yours, it really is very simple. Don't know why it's not working for you - I had exactly the same code and it worked fine, so I would suggest going back over it and double-checking.

Whether you use a plugin or a child-theme will depend on your needs. If you want to customise WooCommerce, use a plugin. If you want to customise your theme, use a child theme.

The reason they suggest creating a plugin is that it's independent of the theme you use. If you create a child theme and add the customisations to your functions.php file, they are only available for that child theme. If you decide to switch themes, you would have to add your customisations to the new theme (and every other theme you wanted to use).

By using a plugin, you are customising WooCommerce itself, and not just the theme, so those customisations will persist throughout your website, no matter which theme you use.
0
Eduardo FuerteDeveloper and AnalystAuthor Commented:
@Chris.

Sorry my misconceptions.
I'm getting the concepts I need by better reviewing your answers.
0
Eduardo FuerteDeveloper and AnalystAuthor Commented:
Thanks for help!
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Go through the article I referenced, which has a great table of how to approach different tasks.

In other words, if task is best done at a theme or plugin level.

If you get stumped, just hire someone to work through this with you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.