This function is returning the content of the file rather the result of fetch_link_settings_overide()
within it.
The issue is not with the overide function as after the initial error I commented out my modification just to be sure it wasn't something I had done there.
function fetch_link_settings(){
include( plugins_url()."/plugin-child/plugin_overrides.php");
return fetch_link_settings_override();
}
Adding the content of the derived function plugin-child/plugin_overrides.php as we are not getting anywhere currently.
function fetch_link_settings_override(){
global $post;
// If the destination url is set by the user, use that. Otherwise, use the permalink
$destination_url = get_post_meta($post->ID, '_promo_slider_url', true);
// ASAdd additional place to look in the case of the post being via the PODS advert track
if( ! $destination_url )
$destination_url = get_post_meta($post->ID, 'okd_advert_link', true);
if( ! $destination_url )
$destination_url = get_permalink($post->ID);
// If the target attribute is set by the user, use that. Otherwise, set it to _self
$target = get_post_meta($post->ID, '_promo_slider_target', true);
if( ! $target ) $target = '_self';
// Setup the disable links variable
$disable_links = get_post_meta($post->ID, '_promo_slider_disable_links', true);
return compact('destination_url', 'target', 'disable_links');
}
You write this:
Why is
plugins_url()
there? Theinclude
function is strictly based on the file system:As explained in the WordPress docs, the
plugins_url()
would give you the full web URL which is 100% different than the file system WordPress is installed on:So perhaps it should be like this:
Or perhaps you need the
plugin_dir_path()
?But that seems wrong. Where would
/plugin-child/plugin_overides.php
? Try doing this:Just replace
/full/path/to/wordpress/and/this/
with the actual file system path to/plugin-child/plugin_overides.php
.EDIT: Since the original poster is persistent in using
plugins_url()
despite all of the suggestions otherwise, here is my detailed response:Apologies. Functions, classes, strings, constants… Just about anything that you want to be raw, unprocessed PHP will simply not be passed via an
http://
orhttps://
URL because Apache will parse the PHP instructions & simply return the output of that file and not the raw, unprocessed contents of the PHP in that file.Additionally the original poster contents the following:
The examples cited are as follows:
This is a filesystem level include which is the most common way PHP files are included into other files.
These are both
data
URLs. Nothttp
orhttps
. So again when you useplugins_url()
what you are getting is a fullhttp://
orhttps://
URL in which Apache parses the PHP instructions & simply return the output of that file and not the raw, unprocessed contents of the PHP in that file. Or as very clearly explained in the PHP documentation you are linking to; emphasis mine:Going back to your example, you say now the contents of
plugin_overides.php
is$some_var = 'smith';
. How exactly? If it is a PHP file like this:When you call that file via a URL generated by the following code:
Assuming your website is
http://some.cool.website/
the you are basically making a call like this:So the output of
plugin_overides.php
would be 100% blank. If you wanted to get output of that file, you could do the following:And that would return
smith
. Meaning the absolute ONLY output you would get from that call is pure text. Nothing else.Now I see you actually have posted the contents of
plugin_overides.php
. My example explanation above is still apt, but still a basic question. This is your function; just the interface &return
for example:Do you actually call
fetch_link_settings_override()
inplugin_overides.php
when it runs? Well, if that function does not run, then there is 100% no way you will ever get any output. But assuming good faith, look at yourreturn
statement here:If you are returning
compact
, then you are returning an array. You cannot simply return a bare array as a URL call like thishttp://some.cool.website/plugin-child/plugin_overides.php
. The output at most would be simply the wordArray
.If the goal is to take that array & do something, then you should use
json_encode
infetch_link_settings_override
and then usejson_decode
on the receiving side of that. So thereturn
statement would be something like this: