I am calling a function stored in toolset custom code snippet in another toolset custom code snippet.
This used to work just fine before and now the second snippet cannot discover the function stored in the first snippet.
Both snippets are stored as Toolset custom code files.
I tried to use include_once or require_once but I get errors in formatting.php which is not related to my two snippets.
What am I missing? What do I need to do to have the function available in the second snippet.
Second snippet --
<?php
/**
* New custom code snippet (replace this with snippet description).
*/
toolset_snippet_security_check() or die( 'Direct access is not allowed' );
// Put the code of your snippet below this comment.
include_once 'file-1-name.php'; // this stores the function_A
$user_id = get_current_user_id();
function_A($user_id);
?>
Error without include_once:
Call to undefined function function_A
Error with include_once:
E_DEPRECATED: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in file /nas/content/live/site-name/wp-includes/formatting.php on line 1596
E_DEPRECATED: strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in file /nas/content/live/site-name/wp-includes/formatting.php on line 2262
Hello. Thank you for contacting the Toolset support.
I'm not sure you will have to call include_once as all code snippet you will add will automatically loaded if they are active. What if you try to add the function to once code snippet and check if that helps?