=== SufiLabs Global Variables Manager ===
Contributors: iamsufyanikram
Tags: global variables, shortcode, elementor, phone number, dynamic content
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.3.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Save your phone number, address or business name once, then use it anywhere with a shortcode, a PHP function or an Elementor dynamic tag.

== Description ==

Have you ever changed your phone number and then had to hunt through twenty pages to update it? Global Variables Manager fixes that. You type each piece of information **once**, on one screen. Everywhere that information appears on your site updates by itself.

**How it works**

1. Go to **Global Variables** in the WordPress admin menu.
2. Add a variable, for example the key `phone_number` with your phone number as the value.
3. Put `[gvmgr key="phone_number"]` anywhere you can write content.

That is all. Change the value later and every page follows.

**Links are built for you**

Phone, WhatsApp, email and address variables also create ready-made links automatically, so you never type `tel:`, `wa.me` or `mailto:` by hand:

* A **Phone** variable gives you an international-format number and a `tel:` link.
* A **WhatsApp Number** variable gives you a `wa.me` link (with an optional pre-filled message) and a readable number.
* An **Email** variable gives you a `mailto:` link.
* An **Address** variable gives you a one-line version, a Google Maps link and a directions link.

These are never stored. They are worked out from the value you saved, so there is only ever one place to change.

= Features =

* Simple admin screen: add, edit and delete variables in one table.
* Seven types: Text, Textarea, Email, URL, Phone, WhatsApp Number and Address.
* Shortcode: `[gvmgr key="your_key"]`.
* PHP function for theme developers: `gvmgr_get_variable( 'your_key' )`.
* Elementor dynamic tag (Site → Global Variable) for text fields and link fields. Elementor is optional.
* Automatic phone, WhatsApp, email and map links.
* All output is escaped, so a variable cannot inject code into your pages.
* No tracking, no ads, no external requests, no JavaScript on your site.
* Optional setting to delete all data when the plugin is deleted. Off by default.
* Translation-ready.

= Good to know =

* Only users who can manage options (Administrators) can create or change variables.
* Anyone who can write a post or page can print any variable with the shortcode, and visitors can see every variable wherever you use it. Do not store passwords or API keys in this plugin.
* Phone numbers typed without a country code are assumed to belong to the United Kingdom (+44). If you are elsewhere, add a variable with the key `country_code` (for example `1` for the USA) and set it once.

== Installation ==

1. In WordPress, go to **Plugins → Add New** and search for "SufiLabs Global Variables Manager".
2. Click **Install Now**, then **Activate**.
3. Open **Global Variables** in the admin menu.
4. Fill in the starter variables (site name, address, phone, WhatsApp, email) or add your own, then click **Save Changes**.

Manual install: upload the `sufilabs-global-variables-manager` folder to `/wp-content/plugins/` and activate it on the **Plugins** screen.

== Frequently Asked Questions ==

= How do I show a variable on a page? =

Add the shortcode where you want it, for example `[gvmgr key="phone_number"]`. The key is shown in the **Shortcode** column of the Global Variables screen.

= How do I use a variable in my theme? =

In a theme file, use `<?php echo gvmgr_get_variable( 'phone_number' ); ?>`. The value is already escaped, so it is safe to echo directly.

= How do I make a clickable phone number? =

Set the variable's type to **Phone**. Then, in an Elementor Link field, click the dynamic tags icon, choose **Site → Global Variable** and pick the "(auto)" entry for the phone link. In a theme file, use `<a href="<?php echo esc_url( gvmgr_get_variable( 'phone_number_link' ) ); ?>">`. Shortcodes are not reliably processed inside link fields of the block editor, so the shortcode is best for visible text.

= What keys are generated automatically? =

For a variable with the key `phone_number`, the plugin creates `phone_number_e164` and `phone_number_link`. WhatsApp creates `_link` and `_display`. Email creates `_link`. Address creates `_one_line`, `_maps_link` and `_directions_link`. The **Built automatically** table on the settings screen lists every one with its current value.

= Can I pre-fill a WhatsApp message? =

Yes. Create a variable with the key `whatsapp_message` (a Textarea works well). It is added to the WhatsApp link. To use a different message for one number, create a variable named after that number's key with `_message` on the end, for example `sales_whatsapp_message` for `sales_whatsapp`.

= My phone number link has the wrong country code. =

Numbers without a country code are assumed to be UK (+44). Add a variable with the key `country_code` and a value such as `1` or `61`. You can also type the number with a plus sign, such as +1 555 010 9999, and it is used as it is.

= Does it work with Elementor? =

Yes. On a text field or a Link field, click the dynamic tags icon and choose **Site → Global Variable**, then pick the variable. Elementor is not required. Without it the plugin still works with shortcodes and PHP.

= Does it work with the block editor and block themes? =

The shortcode works in the Shortcode block, in Paragraph blocks and in most text areas that process shortcodes. There is no dedicated block.

= Why does my shortcode show nothing? =

The key does not exist (check spelling and that it is lowercase), or the value is empty. A missing key prints nothing rather than an error.

= What happens if I delete a variable that is used on my pages? =

The shortcode simply prints nothing. Nothing breaks, but the text will be missing until you add the variable back.

= Can I put HTML in a variable? =

No. Values are stored as plain text and shown as plain text, so HTML tags do not work. Textarea and Address values keep their line breaks.

= Is it safe to store secrets such as API keys? =

No. Visitors can see any variable that is shown on a page, and anyone who can write posts can print any variable using the shortcode. Use it for public information only.

= What happens to my data if I uninstall it? =

By default nothing is deleted. To remove everything when you delete the plugin, tick **Delete all variables and settings when the plugin is deleted** on the settings screen and save before deleting.

= Does it work on multisite? =

Yes. Each site has its own variables, managed by that site's administrators.

= Does it slow my site down? =

No. Variables live in one WordPress option that is loaded with the rest of your settings, and the plugin makes no extra database queries or web requests.

== Screenshots ==

1. The Global Variables screen: your variables in one table, each with its ready-to-copy shortcode.
2. The Add a variable form and the optional uninstall setting.
3. The Built automatically table showing generated phone, WhatsApp, email and map links, and the How to use section.

== External services ==

This plugin does not send any data anywhere and makes no requests to outside services.

The automatically generated links point to third-party sites, but only when a visitor clicks them: WhatsApp (`https://wa.me/`) for WhatsApp links, and Google Maps (`https://www.google.com/maps/`) for map and directions links. Nothing is sent to those services by your website or by this plugin. Once a visitor follows a link, that service's own terms and privacy policy apply: [WhatsApp](https://www.whatsapp.com/legal/) and [Google](https://policies.google.com/privacy).

== Changelog ==

= 1.3.1 =
* Changed: every name the plugin declares now starts with the unique prefix gvmgr. The shortcode is now [gvmgr key="..."] and the saved options are gvmgr_global_variables and gvmgr_delete_data. The Elementor tag id is gvmgr-variable.
* Changed: the old gvm_ function names and the upgrade routine for private pre-1.2.0 installs were removed.
* Fixed: a number pasted as "+44 (0)7700 900123" produced a broken phone or WhatsApp link; the bracketed 0 is now ignored.

= 1.3.0 =
* First release.
* New: option to delete all plugin data on uninstall (off by default).
* New: notice on the settings screen that variables are not for secrets.
* Improved: every visible text is translatable; a .pot file is included.
* Improved: saving can no longer clear your variables if a malformed request is received.
* Improved: damaged or incomplete stored data no longer causes PHP warnings.
* Improved: requires WordPress 6.0 and PHP 7.4.
* Fixed: the list of "saved and generated" keys showed literal code tags.

== Upgrade Notice ==

= 1.3.1 =
All names now use the unique prefix gvmgr, including the shortcode [gvmgr key="..."].

= 1.3.0 =
Adds an uninstall data option and translation support. Your saved variables are kept as they are.
