How can update my theme and plugins without losing my changes? - wordpress

I am using wordpress! I have certain pluginsthat i use that I personally modified and made changes to.
I have even made edits to css files as well
I heard if you update the files , (when a update becomes available) the updates will overwrite the changes you have made
how can I avoid this?
**The theme I am using is not a child theme i believe

When updating WordPress, no theme or plugin files (except for the default WordPress themes maybe) will be overwritten.
When updating a plugin, plugin files will be overwritten indeed. A possible solution is – when that plugin is using hooks – to unhook and than re-hook them with your own copy of that function in the functions.php file of your theme. Furthermore, there is not much you can do.
With themes, it is best to create child-themes.

Related

Css modified after wordpress update

I have updated my WordPress version. The style of the css is modified. I have a backup version. Should I take the oldest file for plugins and theme in order to resolve that issue?
you should have a child theme and put your custom css in the css-file from your child-theme.
Your child-theme would not touch from any update and your custom code is save
Taken from the WordPress Codex:
WARNING: The upgrade process will affect all files and folders included in the main WordPress installation. This includes all the core files used to run WordPress. If you have made any modifications to those files, your changes will be lost.
When you do any theme changes you should always put your changes in either a custom theme you have made yourself (so only you update it), or if you're using someone else's theme, create a child theme.
More information about child themes can be found here:
A child theme is a theme that inherits the functionality and styling of another theme, called the parent theme. Child themes are the recommended way of modifying an existing theme.
As for plugins, they don't work in the same way so you'll need to make sure that any plugins you change are your own otherwise you'll lose the changes when you update them.
Lastly, you can also use the WordPress Customiser (Appearance > Customize in the dashboard) if you don't want a child theme but want to insert custom CSS. That allows you to edit CSS safely within the dashboard and keep your changes safe even when you update things.

Modifying a template part don't do anything

I try to modify a theme in WP and I just noticed that modifying a template part doesn't do anything. How is that possible? Tried on different browser to check if its cached and its not, how do I modify a theme part?
I'm using Academia Theme with LearnPress Plugin. I've made a Child theme and I'm trying to modify a file that is a theme part called content-course_list.php which is exactly the html that appears in the segment I want to modify. I just try to change a simple text that is "Read more". I found it, changed it and it doesn't update. I even put it in the child theme folder to make sure it gets it from there and nothing..
I don't use any cache plugins and the host is local (xampp).
It seems the theme has a "core" plugin (academia-core) as well, where its using some shortcode templates for parts of the website. I managed to find the text by its css class (found with chrome inspect in the page) while I searched in all the php files from theme and plugins. I hope this answer helps someone in the future.

How use theme's function into plugin's file in Wordpress

I am building a simple plugin of wordpress, and trying to use theme's function into plugin's file, but it is saying "Call to undefined function", while that function exists in themes.php of current active theme.that function is in use in theme's files but can't accessible in plugin's file, can anyone guide what to do?
while I have to attach plugin with theme as mandatory plugin.
Thank you
Plugins are loaded before the theme so the function hasn't been defined at the time you're calling it. Execute your code on a hook such as init instead.
E.g.
function wpse_my_plugin_init() {
myPreviouslyUndefinedThemeFunction();
}
add_action( 'init', 'wpse_my_plugin_init' );
See here for a list of hook options: https://codex.wordpress.org/Plugin_API/Action_Reference
The earliest opportunity you have to call this code would be after_setup_theme.
On another note I'd suggest rethinking this approach. A plugin should be an independent module; it shouldn't be tied to your theme.
Your approach/design is serious flawed. Plugin functionality should never rely on theme functionality. As already pointed out by #NathanDawson, plugins get loaded first, then child theme functions then parent theme functions, so your approach will never work as indented or without a lot of unnecessary bloated code
Plugins are meant to extend site functionality, and not theme functionality. I think this is where your idea is seriously flawed, and most probably due to a lack of knowledge on who should do what and when
As I have stated, plugins should give functionality to the site. Functionalities like favicons, custom post types, custom taxonomies, shortcodes, widgets, related posts and rewrite rules should be in a plugin. This gives functionality to your site, which simply mean, when you change the theme, these functionalities won't change or they won't be affected. Also, if the plugin is removed, it doesn't change the way how the theme looks and operate.
Theme specific functions are functions that gives functionality to the theme itself. Without these functions, the theme looses functionality or its looks. It simply means thant the theme changes. These functions includes functions to enqueue your stylesheets and scripts, theme suppport functions, sidebars, custom headers and backgrounds and registering image sizes.
If you are going to make a plugin rely on theme code, you should be looking to create a child theme, as child themes are meant to extend the main theme. Child themes inherit all functionalities from the parent theme, and can extend, modify or add new functionality to the parent theme.
To conclude, by making a plugin rely on theme code, you are making your site very vulnerable to breakage. If you change your theme, you will break your site as you will break your plugin. This is not how plugins and themes were made to interact. By creating a child theme instead, you void that risk as child themes cannot be activated without the parent theme being in the theme's folder and neither can any two themes be activated at the same time.

Changing Behaviour of a Wordpress Plugin

Im new to wordpress plugin development. I want to be able to change the behavior of another wordpress plugin. Is there a good way to do this. ie. Should i create a new plugin to override its behavior, or should I change the plugin directly. If anyone else has some good tips for wordpress plugin development, please let me know.
Thanks
Easiest would be to just edit the plugin's source directly then modify its version number to something high like 99999 so that you won't mistakenly update it through WordPress and wipe out all the edits you've made (that happened to me).
Better would be to make another plugin that will modify the behavior of the original plugin, or code it in the functions.php of the theme if the change is minimal, or just edit the plugin's code then rename it to a different plugin (as plugins hosted at WordPress are GPL2-licensed).
Use, WordPress' remove_action function to remove the original plugin's hooks then redeclare them using your own functions using add_action.

Wordpress Thematic child theme: editing template files

I built a Wordpress child theme based on Thematic framework and edited some template files. When I upgraded to a new version of Thematic all changes to my template files were lost.
I guess it makes sense but that makes me a little disappointed in the child theme concept...
So if I understand correctly, there's no way to edit template files of Thematic (or any other WP theme framework?) and then upgrade easily and keep the changes? The way to modify a Thematic child theme is with styles and hooks, but changing template files is a no-no because all changes will be lost with upgrade?
By child theme, i'm assuming you just made some changes to that Thematic theme but for a specific blog, in which case, yes, your changes would of been over written on upgrade.
To avoid this, create a new theme folder on your sever and copy all the files over to that new theme. Once the files are copied, go into your stylesheet, and modify the comments in the header of the file. This is where you can rename your theme to say something like Thematic Theme Customized or you can rename it to whatever you want.
Once these two steps are complete, you should be good to make any modifications without fear of your data being erased on site upgrade.
Please note, that by going this route, WordPress doesn't know there's a new theme that it needs to upgrade, so if the Thematic theme has a system upgrade it needs to update, you'll need to copy that update over to your newly modified theme.
Hope this helps
Make sure you copy the childtheme out the thematic theme dir into the theme dir and edit the childtheme functions.php. Otherwise if you upgrade the theme changes will be lost.

Resources