lundi 11 avril 2016

Proper way for keeping theme/plugin/php edits in WordPress?

I would like to ask some more of a clarification type of questions, as I've looked up on php file editing, scripts and the like on both here and on WordPress related sites; and the results left me a bit intimidated and confused with difficulty to get a proper answer;

1. Is it secure or even wise to make an active script for seeking and replacing the line A with line B via raw php (using Codesnippets plugin) even if I only target the specific files where the change is needed?

This is what I've currently been considering as my to go solutions, but been very unsure of, as I do not wish to risk big holes and specially this seemed to have lot of discussion on it with varying answers. As I am not too experienced with WordPress it also adds to my carefulness of just using a straight out raw php.

2. If this is an OK thing to do, how does one go for the file targeting in WordPress environment?

I assume it has some twist on it as some of my attempts with functions and filters did not really turn out too great, as it either did nothing or broke everything else but the target.

3. If the above isn't a smart move, is there any other methods/paths for WordPress in order to make reinstalling the changes more user friendly?

So far I am using Codesnippets to save the codes so they don't go anywhere and I've read about making your own plugin for this sort of things, however it seems to be a very confusing process for something that doesn't look too much different from the php replace script path. But I might be wrong with that if the replacement isn't an OK thing?

I am aware of the hooks and filters, however I've yet to have much luck with em, and especially woocommerce has been very denial on accepting additional functions through them.

For extra info;

-Codesnippets is basically an outer functions.php for running scripts and saving em. Unfortunately, it seems to hate javascript and jquery.

-Story wise; basically I have been doing changes to a WordPress based site as a task, and the changes I had been requested to make were not really possible to do via the plugins themselves that the site uses, and there was also issues with compatibility between few plugins. To my disappointment, the search results for approaching the issue solving; the only solutions that worked always required replacing lines/actions one way or other, yet constantly having to copy paste the codes over and over after each update can be very annoying/tedious and I am most likely not going to be around to do so forever. The changes are extremely small for most cases, such as adding an extra class or commenting out certain bits. But due of my low WordPress experience and lack of proper testing environment, it has been a large struggle with lot of searching and backups so far to make sure stuff doesnt break as editing the files tend to be a giant no go normally.

-The site uses a commercial theme and few commercial plugins that came with it, however, translation and other utility/specialized plugins on the site are non commercial, which causes some clashes and closed door solutions. The theme also uses the functions.php file so running scripts from that meant bye bye next update, forcing me to use codesnippets

Apologies if this was kinda long but I just kinda wish to get some straight out clarity from the all confusion my searching related to these things in WordPress has left me in so I felt I need to give as much info as I can.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire