Its likely due to the WordPress load process. Plugins are not all loaded at once. It’s possible that when you in the constructor phase on one plugin the other plugin is not yet loaded.
This means you need to “hook” into the “init” of WordPress and check your function or class exists before running your class constructor.
Ways to deal with this:
-
Use an init hook and registration to make sure the class exists before your dependant function is loaded.
-
Update your Autoloader inside the dependant plugin to use the PSR-4 or what ever autoloader you are using to get the class so you know it will exist.
-
Directly require the file inside your plugin init that has the child class.
-
Convert you classes to a composer package so you can load it and namespace it in each plugin.
All are a bit messy but plugins are meant to be isolated. Look up pluggable functions and it should give you an idea of some next steps.
Related Posts:
- Get plugin_dir_url() from one level deep within plugin
- Namespaces in WordPress – How do I initiate the main class?
- How to include and use custom class files in plugin?
- Current user in plugin returns NULL
- Why is my custom post type not being activated on plug-in activation?
- get_option / wp_localize_script Not Working in OOP Plug In
- Built a second plugin but it overwrote the first one
- WordPress Object Oriented plugin development [closed]
- How to access OOP plugin function inside themes or other plugin
- WordPress plugin blog creation
- Get post content inside plugin class method
- How to access classes in theme of a plugin?
- Autoloading a PHP class – working outside, but not inside WordPress plugin
- Why function hooked using object are executing at all time?
- Plugin: Custom menu item problem
- Function not being called on form submit, only blank admin-post.php page
- Does the number of downloads displayed for a plug-in in the WordPress.org plug-in directory include automatic updates?
- Why do I get this “plugin does not have a valid header” error?
- Which method is best to enqueue scripts
- WordPress Capabilities: edit_user vs edit_users
- Function to activate WordPress theme inside a plugin
- What is the correct way to check if WP_Filesystem can write to a directory without aking for username / password?
- Is there a WordPress Plugin that allows voting “does this coupon work” on specific links like Retailmenot
- Pass A Value From Outside To A Plugin Variable
- shortcode doesn’t work
- Built in admin ajax hooks?
- Force plugin to fail activation
- Could someone please help me to add category id with in this query so this will return posts from a certain category?
- What are the benefit in adding hook in the init() hook?
- Plugin not saving values when placed in a folder within /wp-content/plugins
- building plugin and it is displaying above plugins page
- load_theme_textdomain path
- Dynamic CSS Vs Inline Issues in Code any Way around in a WordPress Themes?
- Is license need for free wordpress plugin
- plugin development: problem with functions
- Getting a List of Categories for Use in a Plugin?
- Building plugin with changeable custom post type values…advice needed
- How to get all of the activate_plugin action parameters?
- Display update notification messages like ‘What’s New’
- How can I make 2 plugins that include different versions of a framework to both use the latest version?
- What can be reason for no plugin-strings available under stable section on translate.wordpress.org?
- Conditional attributes and logic per product category
- Why Is This Code Causing The Admin Bar to Disappear?
- WP_Terms_List_Table Quick Edit not working
- Git Hosting for WordPress SVN Plugin Repository [closed]
- Displaying Custom Sidebar Without Modifying Theme’s Core File?
- Is there a directory my plugin can write files to that cannot be viewed via the browser/url?
- How to exclude certain files from the plugin editor?
- How to reset wordpress but not plugins and settings
- Include a php file from another plugin
- How do I make a secure API call from a shortcode when a button is clicked?
- WordPress REST API Plugin Development – Add Custom Endpoint
- Hook into the rendering of a WordPress Template
- Can the uniqueness of the plugin file/plugin slug and version number be trusted?
- Save user total active time after login in wordpress [closed]
- WordPress gtag.js with User ID tracking
- Switch from wp-cron to a server cron job
- Calling a save function from a “submit” button
- WordPress plugin: efficient way to store large data
- The Events Calendar Plugin – List View Background Colour Issue [closed]
- Select Form Element Not Saving from Plugin Options
- My widget won’t update its values when save is clicked
- Can we give Pending as a Role to wp_insert_user?
- How to automatically activate users after registration without activation email?
- Themes conflicts and overrides my WordPress Support widget Plugin styles
- Disable Author Archive just for certain roles in bulk
- Seperate plugin and theme files
- Pass PHP variable to javascript
- Table of contents (TOC) plugin is not showing header tag
- Custom page from wp admin area
- Unexpected add action function in WP plugin
- Avada Live is broken on WP
- How to implement color picker from WordPress in my boilerplate plugin?
- custom post type plugin error [closed]
- Make downloadable ebook read online without download option
- WordPress rewrite rule depend on meta values not ids
- Problem with wordpress has_action() function
- Offering a freemium plugin (a free version + paid version)
- In woocommerce, is there any way to empty wordpress default mini cart when order placed?
- Admin menu hilighting wrong item for CPT
- Making a Custom Post Type Plugin – keep getting the white screen of death
- Limit Google Ads to particular blog posts
- Communicating to plugins from webserver
- Buddypress Member list not showing admin and mods
- Inactive Plugin Files
- Hook into install email
- Shortcode in a blog post, footer and related products stop working
- Editing a built plugin: How to activate it only on a single post page
- Linking Plugin Files to WP
- Plugin – including external javascript calling google maps
- How to create post comparison in wordpress
- How can I create a navigation menu in the sidebar that can also act like a slider?
- How to host a WordPress plugin on my own server and provide updates?
- How to set meta-data for my plugin
- WordPress isn’t sending welcome email with the password reset
- A splash page on landing page
- Inline AJAX script passing variables to PHP
- CPT template is not being automatically used single post pages
- How to trigger plugin migration code when plugin updates?
- How to Save Category and Delete Category in same Function