You can check if the class is already include / exists, and if it not exists include it.
In your plugin, depending on how you can be sure that the install has plugin activated, you’ll maybe need to include your class inw every plugin.
if(!class_exists('Excel_Writer'){
include_once('excelwriter.inc.php');
$excel = new Excel_Writer('myxls.xls');
}
Be carefull with files paths.
If you really want to include your file only in one plugin, the main plugin (with the required file) must be load first.
Then the other plugin will be able to find and work with the class.
You can add some code to desactivate “sub” plugins if the main is not available with is_plugin_active
Hope it gives you some hints to help you !
Related Posts:
- __(): What if I have to pass in a variable?
- Run WP-CLI using PHP
- How to build an API as a plugin
- category_name not working (not showing up in sql query debug)
- How can I make my custom shortcode work in a Custom HTML Widget?
- PHP Deprecated: Non-static method should not be called statically
- Update Multiple Post Meta for the Same Post In One call?
- WordPress Hook that will run when media file deleted
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- Post source link plugin – small modification
- Which hook callback has priority if both plugin and theme use the same hook?
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- Check if a class exists within a method
- How can I make the “Preview Post” button save and preview in the same window?
- Escape special characters in image link
- Cannot run the code after I activate the plugin
- Displaying admin notice dynamically
- Unable to activate wordpress importer after installing it
- Get total number of comment of the posts written by an author
- WordPress Ajax Callback
- printf – problem to understand code
- Auto delete WordPress users according to time
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- add_query_arg not working
- Programatically download a plugin
- Error shown for Trying to get property ‘roles’ of non-object in WordPress After Content for User Roles
- Theme my Login plugin, how to update fields
- CSS from textarea in options page to frontend what to do
- How would I go about creating a user ranked post popularity page?
- WordPress: PHP code rendering in the wrong place
- New to wordpress, Question about editing PHP
- wp_set_auth_cookie causes 403 error in the wooCommerce checkout
- add image crop function like in wp customizer
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- How to edit content before post update
- Why is one phpunit test throwing an error on one class when all other classes are similar without error?
- WordPress call_user_func_array() expects parameter 1 to be a valid callback, class
- Why is my custom post type not being activated on plug-in activation?
- Setting Up PHP Workflow in WordPress
- What happens when WordPress memory limit is exceeded?
- iframe not showing in post (with “allow php in posts” plugin activated)
- how can I do something on new user registration?
- Any idea how to get something like this to work? [closed]
- wp_dequeue_script for a Plugin
- How do I add $_SESSION[”] to my wordpress page?
- Built a second plugin but it overwrote the first one
- WordPress: Add custom add_filter for custom functions
- How can i add simple code in only in posts by function.php
- How to change layout of shop page in wordpress? [closed]
- preg_replace() No ending delimiter ‘.’ found [closed]
- Categories from front-end, checkbox selection doesn’t work
- WordPress Stats Plugin: Display Post Views [closed]
- Pagination not working
- Can you echo PHP code from a variable?
- How to fix these PHP Warnings with the “Feed JSON” plug-in?
- need to find duplicated meta value in custom filed and view the posts that have the same value
- Can I disable xml-rpc by setting it to false?
- How can I adjust my function so the page editor still loads in the backend?
- Push Contact form 7 variable to front end after submission
- Add a parameter at the end of the url and prettify
- Calling PHP function with AJAX
- Share my WordPress plugin for updating how?
- Submitting form to PHP
- Looping the data from WordPress database using foreach
- Rename a folder via HTML POST request
- How can I change page content for good once a button is pressed?
- Google Maps for Woocommerce Checkout
- WordPress plugin blog creation
- Add two row of code to the public static function init of a plugin
- Get and Update Most Meta Value as an array in HTML form
- Modifying server’s response to API endpoint
- Change Jobs for WordPress templates
- Defining constant in a plugin to use in another plugin
- Failed to load resource: the server responded with a status of 500 () post.php
- WordPress filter from custom table is not working properly
- Configuring default woo commerce login with modal popup
- submit form data to wordpress existing database table using my plugin
- Custom SportsPress list
- My ajax request don´t work and return 0
- Adding link for logged in user? [closed]
- How to change text in a page by utilizing a custom user id?
- Adding link on title its in description but not in title see screenshots attached
- How can I insert a record into a custom table from my custom form in my custom admin page?
- Editing Global Variables from Inside Functions
- How to save information related to post in database?
- Save selectlist value (taxonomy) in wp:wp_set_object_terms
- Page doesn’t load
- Posting code inside the post instead of in the template file using shortcode
- Metabox Data not saving
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- Xml output not places where i want
- Including a PHP file via a function that is part of a plugin?
- How to fix ‘Call to undefined function do_settings()’ error?
- Integrate Razorpay quick payments plugin with contact form7 plugin
- Translate text for empty product
- Passing an input variable through a switch statement
- how to show selected options drop down menu values in attributes field in after saving post.php
- Can’t use updated variables in handle function
- How to get URL param for pagination in shortcode?
- Is there any WordPress Plugin that provides video editing from front end side? [closed]