php - Define a constant, then retrieve it from a different scope -
if define constant in wordpress on file_1.php
define( 'something', location );
how can use in file_2.php?
if define again sends "constant defined" error. if don't define it, doesn't know is. if detects exists, there must way access it. there way can access file_2.php?
something = specific url, , i'm trying use in file_2,php load script,, "wp_register_script('script', . '/filename.css')"
if don't define again , try use in "wp_register_script" says "use of undefined constant - assumed 'something'"
thanks
you'd need place define()
in file every script come across in wordpress (i.e. file that's included, wp-config.php
site-wide definitions).
if define constant in 1 file, doesn't mean other pages automatically knows exists, until it's 'included'.
at top of functions.php
make sure it's going use something
, can see if exists first:
if ( !defined( 'something' )) { define( 'something', 'location/here/folder' ); }
for testing purposes, before trying use register_script - save expected string variable.
<?php $scriptlocation = soemthing . '/filename.css'; echo $scriptlocation; ?>
Comments
Post a Comment