Answers.Body: <p>Depends what you're doing but try <a href="https://github.com/civicrm/cv" rel="nofollow noreferrer"><code>cv</code></a>.</p>
  <p>Don't add any <code>require</code>'s or <code>CRM_Core_Config::singleton()</code> stuff.  Just write your script and call it with <code>cv scr path_to_your_script</code>.  <code>cv</code> takes care of setting up the Civi environment before running your script.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-20T00:29:49.057Z
Answers.Text: I could not get CV to work which is why I used the above method instead.
Answers.UserDisplayName: jsherk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-20T10:18:07.720Z
Answers.Text: CV is really useful so I'd persevere with getting that to work.  Maybe open a separate question about what's not working with cv.
Answers.UserDisplayName: Aidan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T21:03:20.843Z
Answers.LastActivityDate: 2022-05-19T21:03:20.843Z
Answers.UserDisplayName: Aidan
Body: <p>I am running CiviCRM v5.48.1 with WordPress v5.9.3 and I am writing some functions outside of CiviCRM environment on Wordpress, using this:</p>
  <pre><code>&lt;?php
  
  require_once '/home/me/public_html/wp-content/plugins/civicrm/civicrm/civicrm.config.php';
  require_once '/home/me/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Config.php';
  $civi_config = CRM_Core_Config::singleton();
  
  ?&gt;
  </code></pre>
  <p>This call creates the following deprecated function error in the php log:</p>
  <pre><code>PHP Deprecated:  Deprecated function CRM_Utils_System::getUrlPath, use CRM_Utils_System::currentPath. in /home/me/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php on line 1043
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-24T08:45:10.620Z
Comments.Text: This seems like a duplicate of https://civicrm.stackexchange.com/questions/41780/access-civi-functions-from-outside-wordpress-plugin/41786#41786
  
  Can you clarify how it's a different question please?
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-24T13:16:11.640Z
Comments.Text: No they are not duplicates. The other question is asking HOW to access civicrm functions from external script. In my question, I am already doing that, but I am receiving the PHP DEPRECATED notice in the logs all the time, so was wondering how to get rid of this notice.
Comments.UserDisplayName: jsherk
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-05-25T14:05:19.290Z
Comments.Text: The answers are the same, however. Like Aidan said, don't do what you're doing - use CV, WP-CLI or the REST API.
Comments.UserDisplayName: Christian Wach
Tags: <wordpress><core>
Title: Deprecated function getUrlPath on WordPress when creating external functions from outside of CiviCRM
ThreadText: # Deprecated function getUrlPath on WordPress when creating external functions from outside of CiviCRM
  
  (Asked by: username_0 on 2022-05-19)
  
  I am running CiviCRM v5.48.1 with WordPress v5.9.3 and I am writing some functions outside of CiviCRM environment on Wordpress, using this:
  
  ```
  <?php
  
  require_once '/home/me/public_html/wp-content/plugins/civicrm/civicrm/civicrm.config.php';
  require_once '/home/me/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Config.php';
  $civi_config = CRM_Core_Config::singleton();
  
  ?>
  
  ```
  
  This call creates the following deprecated function error in the php log:
  
  ```
  PHP Deprecated:  Deprecated function CRM_Utils_System::getUrlPath, use CRM_Utils_System::currentPath. in /home/me/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php on line 1043
  
  ```
  
  **Tags:** wordpress, core
  
  > **Comments:**
  > **username_1**: This seems like a duplicate of https://civicrm.stackexchange.com/questions/41780/access-civi-functions-from-outside-wordpress-plugin/41786#41786  Can you clarify how it's a different question please?  
  > **username_0**: No they are not duplicates. The other question is asking HOW to access civicrm functions from external script. In my question, I am already doing that, but I am receiving the PHP DEPRECATED notice in the logs all the time, so was wondering how to get rid of this notice.  
  > **username_1**: The answers are the same, however. Like username_2 said, don't do what you're doing - use CV, WP-CLI or the REST API.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-05-19. Score: 0
  
  Depends what you're doing but try [`cv`](https://github.com/civicrm/cv).
  
  Don't add any `require`'s or `CRM_Core_Config::singleton()` stuff. Just write your script and call it with `cv scr path_to_your_script`. `cv` takes care of setting up the Civi environment before running your script.
  
  > **Comments:**
  > **username_0**: I could not get CV to work which is why I used the above method instead.  
  > **username_2**: CV is really useful so I'd persevere with getting that to work.  Maybe open a separate question about what's not working with cv.  
  
  ---
  
  