What happens with WordPress after I activate a plugin - wordpress

I would like to know what happens when I click on activate on a WordPress-Plugin on "Activate". Which files and functions get Triggered by WordPress.
How I actually think WordPress is working are these steps:
A file and function from WordPress is in a loop which gets triggered like this:
WordPress gets from the main-file the Header-fields and calls a file(which?) with the functions and defines it to the public output with echo or return.
WordPress calls the activation_function. When the user has not defined it then it does nothing.
The main file runs now like each other program.
While the program runs, WordPress has a file/function which gets triggered on "plugin->deactivate" and a function which will look similarly:"
(I am a type of human who likes to play compiler)
(I add a picture because I got only: "Your post appears to contain code that is not properly formatted as code" and could not solve like 10 minutes.)
This "Your post appears to contain code that is not properly formatted as code" is driving me crazy. I had to delete a few things.
I have looked on pages like these but no one goes so deep inside:
https://developer.wordpress.org/plugins/plugin-basics/

I appreciate you are thinking this way.
But before you get any answer to this, may i ask why you are asking this?
Meaning, what you want to understand? Is there any specific thing you want to achieve at plugin activation?
There is not much WordPress does while activating plugin.
WordPress scans each file or top level directory inside plugin directory and looks for header comment
See for more details: https://developer.wordpress.org/plugins/plugin-basics/#getting-started
Once it recognizes a plugin, it offers to activate it.
Here is a ruff sketch what happens once you click activate:
WordPress runs any callback function that is bound with register_activation_hook. Its not required to have an activation hook. If you have a callback function, WordPress runs it, if not, WordPress does not do anything. This callback function is used by plugins to do all sort of stuff like creating default options, creating required database tables, checking for dependent plugins , WordPress and PHP required version compatibility to name a few.
WordPress updates an option in DB to keep track of active plugins. so that these can be loaded for each page call. option id is active_plugins. Screenshot: https://snipboard.io/e7sjB9.jpg
On Next page load, WordPress check this option active_plugins and looks for these active plugins and load/run their header comments file code.
Hope it helps.
Regards,
Rao
P.S. this question belongs to https://wordpress.stackexchange.com/

Related

run second instance of a WordPress plugin?

There is this (Business Directory Plugin),
The question is, is it possible to run a second instance of this plugin to run another type of directory in same WordPress installation (not multi-site)?
Tried to bulk rename classes and hooks..etc, but no luck.
Is there a plugin that support this behavior or some hint?
It was possible to reach one post stating it could be possible for a different plugin.
Any help appreciated ,
Thank you.
Update:
Just to clarify the point of the question/solution:
I want to run multiple directory in my WordPress Installation
One for Medicine Directory
The other for Medicine Agents/Marketers Directory
Each directory has its own fields and content
Anyhow, I found the solution bellow
Thanks for all help
Probably not if they're using post types and taxonomies that are regiatered through the plugin. You could probably extend the plugin functionality and create your own post type.
I managed to find the solution and it worked like charm without any errors!!!!
I used notepad++ to search all files and did a bulk replace classes and main plugin's keywords (custom type and meta slugs' names and all possible duplicates ) into 2nd instance names.
I uploaded the plugin into WordPress single installation and it was activated successfully and I was able to add new custom posts and new custom meta data...
Here is a screenshot of second instance of my plugin.....its is possible to do it and it worked like charm!!!
Back end First and Second Instance
Back end
Front End First Instance
Front End Second Instance
After I figure it out , it took from me 10 min to run another instance of the plugin
Thank you
Update:
I was even able to link between the two instance entries
Off course I had also to create another instance of the Shortcode!

Rename-ing some woocommerce fields

I have been having some hard times trying to configure my website.
I have been looking left and right on the internet for how can i rename certain fields on my webpage. I came to a point were i dint find any more snippets that i can use. If someone is kind enough to hekp me with the snippets for the bellow problems i would be extremly grateful :D
1) Login/ Registration form
i have renamed the Login and regitration form, but i cant rename or completly remove the recover password button ( i tried 4-5 snippetes so far and non worked)
2) On my Account page i did some editing with the gettext snipped, but i wasn't able to translate the following word "Logout" and "edit your password and account details"
3) i don't know how to translate the "search producs", the content of the box
4) i dont know how to rename the "apply coupon" button and the content of the box. For this one i used some snippets, but nothing happened :(
bellow, you can see my website
http://www.toner.eurofinconsulting.ro/wp/
Making adjustments like you have referenced are fairly simple to do in Woocommerce. Having said that, one of the first things to understand is how to correctly make changes to Woo template files. The easiest thing to do is to copy the entire directory /wp-content/plugins/woocommerce/templates to the root of your theme in a directory named YOUR_THEME/woocommerce. This now allows you to adjust any of the templates without touching files in the plugin directory (which you should NEVER do) while retaining the ability to update Woocommerce as updates are available.
Now, to make your changes:
Login/registration form - All changes you need can now be made in wp-content/themes/YOUR_THEME/woocommerce/my-account/form-login.php
Changes for this can be made in wp-content/themes/YOUR_THEME/woocommerce/my-account/my-account.php.
Changes to the search form - If this is using the Woocommerce search form, try making your changes in wp-content/themes/YOUR_THEME/woocommerce/product-searchform.php. If it is not there then try finding the search template used by your Wordpress theme.

Why is my Wordpress plugin trying to update as someone else's?

I'm writing a plugin, based on someone else's tutorial.. I've been changing parts of it as I'm building it, such as the name, names of functions and so forth. The basics of the plugin work as expected, and it shows up in the plugin manager UI. However, when I activate it, it shows my custom metadata (plugin name, version, etc), but it INCORRECTLY displays and "Update this plugin" message of someone else's plugin. Now this plugin appears not to be related to the tutorial maker (which was my first suspicion).. it seems not to be directly related to the plugin name, folder name, or filenames.. but I really can't seem to control it – other than remove the whole metadata section, which seems illogical.
What is linking my plugin to someone else's plugin, or otherwise causing it to wrongly identify?
Thanks in advance
The plugin section gathers info from their online repo, so if you have named it to something that's already there, it will pull through that data.
Just give it a unique name:
/*
Plugin Name: My Unique Plugin
*/

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.

Drupal Views Module is stuck on my custom theme

So I was going through the settings in the Views Module and hit a checkbox and clicked save. This unfortunately transformed the entire Views UI into my custom theme's homepage. And trying to go into settings does not allow me to see anything except my custom homepage. I've tried uninstalling the module and deleting EVERYTHING but nothing seems to work. How can I manually undo check whatever box I had checked.
it needs a little bit of debugging.
go into views source code, look for .module files and search for
hook_menu() implementation
find there an URL where you have checked that checkbox
go into page callback function
check for submit callback function and go to that function
look for update queries or variables settings, anything that have a machine name of your checkbox, look for the mysql table and field
go into database and update that field to your needs
you can also use a fresh drupal install to perform this, it will be easier to just copy the value from one database field into another

Resources