title: How to call class function from another file through url?
body: <p><strong>To do:</strong> I want to call a function from <strong>file-1.php</strong> on another file which is <strong>file-2.php</strong> because I need to trigger the function through URL. For example, I access the url <code>http://localhost/sitename/wp-content/plugins/plugin-name/file-2.php</code> it will trigger the <code>import()</code> function from <strong>file-1.php</strong> file. </p>
  
  <p>Extra Info: I'm going to use cron job and point that url to trigger the function.</p>
  
  <p><strong>file-1.php</strong></p>
  
  <pre><code>&lt;?php
  namespace Inc\Core;
  
  class CronMethods
  {
    public static function import() { 
      echo "Test";
    }
  }
  </code></pre>
  
  <p><strong>file-2.php</strong></p>
  
  <pre><code>&lt;?php
  
  use Inc\Core\CronMethods;
  
  CronMethods::import();
  </code></pre>
  
  <p><strong>Problem/Error</strong>:</p>
  
  <blockquote>
    <p>Fatal error: Uncaught Error: Class 'Inc\Core\CronMethods' not found in /var/www/html/padlab/wp-content/plugins/padlab/inc/cron.php:5 Stack trace: #0 {main} thrown in /var/www/html/padlab/wp-content/plugins/padlab/inc/cron.php on line 5</p>
  </blockquote>