How to solve it-updating plugins in wordpress? - wordpress

I have made modifications in several of the plugins in wordpress. But
these plugins are now outdated. I have to submit the project to the
client. The client is asking me to update the plugins. But the problem
is that when I would update plugins, the changes that I made in
plugins would have gone away. So, I want to ask is there any concept
of child plugin in wordpress and if so, how to create it; so that my
changes would remain intact.

I don't know which plugins are you using so I am giving an example of WooCommerce Delivery Date plugin. I have disabled updates for that plugin and I have used below code to achieve it :
/* Function which remove Plugin Update Notices – WooCommerce Delivery Date*/
function disable_plugin_updates( $value ) {
unset( $value->response['woocommerce-delivery-date/woocommerce-delivery-date.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );

Just edit the version of the plugin to more than the latest version :
Go to wp-content/plugins/your-plugin/your-plugin.php
generally your-plugin.php is the main file of the plugin and it is having version in the top commented line.
Edit the version of the each plugin
Otherwise install a plugin your admin that will disable updates. Get this plugin from here : https://wordpress.org/plugins/disable-wordpress-updates/

If you're looking to keep a good name, I'd find a way to achieve making the necessary changes without modifying plugins in the first place (this is a bad practice, as I'm sure you know). When people purchase your product or services, they want to know they're not getting a "bad egg" or a "lemon deal"; and that their investment is actually an investment and not a complete waste of effort, money and overall time.
Updates are important! What if they are handling sensitive information on their site? What if their host requires a specific plugin to be a certain version?
Make your change in another way, write your own plugin, include the functionality in a child-theme; you can even handle certain "modifications" by using jQuery to manipulate elements in the DOM (include it in your child theme).
Just don't do something regrettable as some others have suggested. This is only going to last until the next update is released and lead to trouble, a bad reputation, or legal action. Integrity is all a man has. If you throw it away, you're worthless.

Related

Can't access to product's reviews in WooCommerce when using Gutenberg as editor

I know that Gutenberg isn't supported on Woocommerce, but I'm trying it anyway and so far is quite good. Im doing it by:
function wplook_activate_gutenberg_products($can_edit, $post_type){
if($post_type == 'product'){
$can_edit = true;
}
return $can_edit;
}
add_filter('use_block_editor_for_post_type', 'wplook_activate_gutenberg_products', 10, 2);
What I notice that there is error when trying add some of the Woo blocks in products, so I decide to disable Woo blocks on products to avoid it. Works ok now.
But in backend and can't access to reviews. I see only comments section but this not working at all. Does anybody dealing with that somehow?
I found this thread trying to find a solution to your last part too.
When I have Gutenberg active on products, even with reviews enabled in WooCommerce settings, when I go to:
Product Data
Advanced
and try and toggle the "Enable Reviews" option
When I save and then refresh the change doesn't seem to take so I am unable to turn reviews on if they are currently off or turn them off if they are currently on.
I have tried to test all of the other options and checkboxes like virtual and downloadable and they all seem to save fine it just seems to be this one setting that doesn't get saved.
I am keeping note of everything I find on the matter and if I manage to find a solution I will come back to share. I'm not sure if it will help with your other issue though which I haven't faced.

How to apply coupons to CoCart plugin?

I am using CoCart plugin with WooCommerce. I have a cart with products and the plugin counts me the totals and actually everything. I would like to apply coupons, I made a plugin for this, but I had no idea how to get the cart which had been initialized with CoCart. I tried this: WC()->session->get( 'cart_totals' ) and this: WC()->cart, but in both cases the session and cart is null. So I need a solution to make it possible to get the previously created cart.
a mildly different Solution is discussed in this thread, have a look. below is the excerpt copied from there. the question was initially asked by msargenttrue and answered by Freney
the post suggests that you need to do a manual implementation in PHP which is just copypaste , and call the script to apply on the intended product in database. THREAD <-- the PHP implementation part
FOR the problem
So I need a solution to make it possible to get the previously created
cart.
you must try the js implementation of local storage, the stored item remains on the user device until the cart is cleared explicitly.
localStorage.setItem("cart", "CartID-002");
localStorage.clear() #when you want to remove.
Points to remember
The main features of localStorage are:
Shared between all tabs and windows from the same origin.
The data does not expire. It remains after the browser restart and
even OS reboot.

How to create Child Plugin for wordpress

Actually I have changed some code in WordPress Store Locator. I want it to remain when plugin will update. So I want to create a child plugin for that. Any ideas on how I could manage it?
This varies plugin to plugin, and it sometimes isn't even possible, other times plugins have documentation to extend them easily (such as WooCommerce and Gravity Forms). Some of them create Action Hooks with do_action() that let you extend the functionality easily. A common example is updating a post after a Gravity Form is submitted with their gform_after_submission hook.
Effectively, it depends on what you want to do, and how the plugin implements the functionality you want to change. If they add text with a Closure or Anonymous Function, it will be harder to modify said text, and you may have to look at something strange like doing a run-time find and replace using Output Buffering, typically on the template_redirect hook.
If you want to remove something a plugin does, you can often unhook it with remove_action. This can be a bit tricky depending on how the plugin is instantiated, sometimes its as simple as:
remove_action( 'some_hook', 'function_to_remove' );
Other times it's more complicated like:
global $plugin_class_var;
remove_action( 'some_hook', array($plugin_class_var, 'function_to_remove') );
Those are the basics of extending (or even 'shrinking'?) a plugin's functionality, and it's not always doable appropriately. Unfortunately the narrow answer to your question is outside of the scope of what we can provide from StackOverflow.
From here, you'll need to figure out exactly what you want to do with the plugin, and dig through the plugin's files to see if there's an appropriate hook or function you can use. If you're still stuck, you'll need to post a new question (don't update this one) with your exact desired result and anything you've tried, and the relevant code that goes along with it. "I want to change a plugin without editing core files" isn't nearly specific enough. "I want to replace an icon with a custom icon in this plugin, here's what I've tried" is specific enough to possibly answer.
Good luck!
I just went through myself and I had so many changes that I couldn't just override the actions.
I created this tool that allows you to create a child plugin like a child theme. You can make updates to the plugin and still update it without losing your changes.
I'm posting this here because it relates and hopefully becomes useful to the next person who runs into this issue.
https://github.com/ThomasDepole/wordpress-child-plugin-tool
As per WordPress standard, it's called plugin's addon.
if the plugin has provided any action to update that functionality then you can use it with your addon (child plugin).
Here I am sending a link for reference.
https://developer.wordpress.org/reference/functions/add_action/

How to get Wordpress to "notify changes" to a WebService/Uri

We are building a fairly dynamic platform with several functions and a wide dynamic of technologies (F#, C#, MVC, Python, etc). For the CMS/Content, we have elected to use Wordpress to cut down on development time. And, "it is so pretty and functional as-is" -CEO.
The challenge: How to get Wordpress to notify an external service/uri that something has changed.
We do not want to write "background threads" from the other services to constantly "ping" the wordpress site/database for changes, aka "Pull". We want this to be a Push model.
With that said, we are looking to pass some json, xml, or something to another url that we can consume the changes and handle internally.
SQL Azure does support triggers, yes; but, did you shudder as much as I did when you read the word "triggers"? Besides, I wouldn't have a clue where to start on what tables for them.
Here are a few changes we'd like to capture:
Post Drafts
Post Published
Post Deleted (and so on)
Tag added, renamed, deleted
Category added, renamed, deleted
And possibly other event such as when a media file gets uploaded (for the CDN).
Random -almost related- thought: I have found some Wordpress plugins for Windows Azure Blog Storage for media, which may help - I'll try to setup a Storage account for the CDN for the media stuff. If there are other related Wordpress plugins for notifying external services for categories, tags, etc, please let me know - I haven't found them (they all just "email" someone).
I found questions such as this:
Wordpress: How to ping URL from custom field on publish
But it doesn't get me all the way there for all post drafts (I think). And, I'm not even sure where to insert that code (haven't modified a wordpress install before).
The cleanest way to do this is create a Wordpress plugin. That way, your code is separate from both the Wordpress Core and the chosen theme.
The plugin could be pretty simple. You'll need one or more functions to do the notifying, and a bunch of add_action statements for the action hooks to fire a function when that action of interest occurs.
function so23600027_notify_external_site( $post_id ) {
//Your notification code here, probably using cURL
}
// Catch when posts saved (should get both draft and published posts)
add_action ( 'save_post', 'so23600027_notify_external_site' );
//Catch when posts deleted
add_action ( 'delete_post', 'so23600027_notify_external_site' );
//etc.

Wordpress show future, scheduled posts

I am using a newsletter plugin - meenews to extract my posts.
By default it only gets items that are Published and not the future ones.
Ideally I would like to show up and coming events, not ones that have already passed.
Is there a way in my functions.php for my theme that I can tell it to put all posts as published, or what would be a better way?
Never mind - found this plugin 'The Future is now'
Sometimes you just have to ask out loud :P

Resources