I have a PHP class inside my WordPress plugin that is activated in a website. I want to use a method (doc_export function) that is defined inside this class in another plugins (also activated in the same website). I add this one and it seems working:
<?php
// Export doc
if (defined('DOC_ADMIN_MODE')) {
$my_Documentation = new Class_Documentation;
$mydocexport = $my_Documentation->doc_export();
$mydocexport_file = ABSPATH . '_export/' . basename($site['site_url']) . '/doc.xml';
file_put_contents($mydocexport_file, $mydocexport);
}
?>
I want to know if this is the proper approach..Thanks.
Yes that’s the proper approach. You can also read about the OOP basis in PHP at http://php.net/manual/en/language.oop5.basic.php