Your core problem is that you are using two shortcodes. shortcodes are not a programing language and should not be used as such. Shortcode should generate HTML in a consistent self contained way. If a shortcode A can not work without having shortcode B in the content as well, it is a sign you are doing it wrong.
From the coding POV, you should never ever never ever use global variables. If you need to cache some resource, use an accessor function which store the value as a static and initializes it only when needed. In addition you do not use good prefixes to your functions which make collision with core and other plugin a likely eventuality, but really, instead for trying to figure out good prefix, just use name spaces.
Related Posts:
- Editing Global Variables from Inside Functions
- Should all plugins be encapsulated in a Class?
- Registering Class methods as hook callbacks
- Get plugin_dir_url() from one level deep within plugin
- How to use classes declared in another plugin?
- Namespaces in WordPress – How do I initiate the main class?
- How do I extend one plugin I’m writing with another I’m writing using classes?
- Adding an admin page – OOP approach not working
- scheduled event not getting executed
- Using the media uploader in a custom plugin
- Trying to get logged-in user data inside php class
- register child class in another plugin
- Check if a class exists within a method
- Should I global $wpdb outside of any of my plugin’s functions scope?
- How to include and use custom class files in plugin?
- Creating a menu page in a Object Oriented developed plugin
- Adding a section to admin menu for global settings
- Current user in plugin returns NULL
- How to structure a plugin into multiple files using classes?
- How to get variables from fucntion.php to my plugin files
- Getting RGBA colour from gutenberg colourpicker
- Override WP Class Private Function
- Calling custom plugin class methods from a template
- Global variables during plugin activation , deactivation and uninstall operarations
- Getting user roles in plugin files
- Plugin activation hook in an abstract class
- Plugin. Html code in Template
- Override global query results without hooks
- plugin class inheritance. cannot change variable
- Set and access global variable
- Most efficient way to use classes to create admin pages using Settings API
- Basic Object Oriented plugin question
- Woocommerce Create custom product type with variations
- Using plugin functions/methods within templates
- Add comments for template variables
- How to handle cookies from a WordPress plugin on a cached page?
- accessing parent variables in child construct without executing action in parent
- Object method calling for global $wpdb in header.php
- Test if php document executed by WordPress or directly
- Why is my custom post type not being activated on plug-in activation?
- Passing stored variables to add_filter
- How do I pass custom shortcode-extracted variables (taxonomy) into a query function for WordPress RoyalSlider?
- How to prevent PHP fatal error if plugin hasn’t been enabled and a method is called in theme file?
- Use conditional logic for woocommerce variable product
- Add text to variable
- get_option / wp_localize_script Not Working in OOP Plug In
- Built a second plugin but it overwrote the first one
- Translation issue with global variables
- profile_update hook doesn’t works inside a class
- WordPress Object Oriented plugin development [closed]
- How to access OOP plugin function inside themes or other plugin
- Plugin: Hooking up classes that have their own hooks
- Passing PHP Variables to AJAX Loaded Pages
- Shortcode and variable
- What’s the best way to echo out a filter variable?
- Defining the value of a variable before a function?
- How to display emails as a post?
- WordPress Custom Hook with Class method
- FPDF for creating pdf diplomas
- Global $wp_admin_bar always returns null
- WordPress plugin blog creation
- Woocommerce functions in custom class, avoid errors
- Passing function into add_action always returns the first argument
- Defining constant in a plugin to use in another plugin
- Get post content inside plugin class method
- How to display variables from plugin?
- fix undefined variable in native wp files
- How to access classes in theme of a plugin?
- Passing variable from template file to the plugin file
- Reorganization of namespaces
- accessibility of an object created in a plugin, from the header
- Best way to access variables in template markup
- Creating a register settings class that supports extended classes
- Autoloading a PHP class – working outside, but not inside WordPress plugin
- Why function hooked using object are executing at all time?
- How do add_action and WP_Query
- private functions in plugins
- Plugin won’t activate, fatal error (widget class not found)
- OOP Plugin: Where should I place the action hooks in the class?
- Strict Standards: Non-static method in sidebar generator
- Plugin: Custom menu item problem
- Function not being called on form submit, only blank admin-post.php page
- Is it possible to use Classes between WordPress plugins with separate namespaces?
- WordPress Action Hook inside Classes
- How to create a dynamically created page on wordpress plugin?
- Open graph issue on my theme
- Visual Composer Data Source?
- Send Processing Order Email from custom payment plugin
- How to do Conact form 7 name field validation? [closed]
- Would deactivating the Simple 301 Redirects plugin deactivate the 301 redirects themselves? [closed]
- White Screen When Includding A Folder With PHP Files
- How to display blog posts only authored by the administrator
- WP Offload S3 Lite “Please setup GD or ImageMagick” noticed
- making a simple plugin
- TypeErrors with Yoast, jQuery in conflict?
- ‘Save settings’ (submit button) ISSET
- How to make temporary expiring link for a downloadable file
- Generate all urls with https
- Add country flags
- Adding a variable to a meta field in the backend?