How to Access a Backend File inside wp-content subfolder on the frontend in WordPress

If you do not already have, install the snippets plugin and write the following code:

$upload_dir = wp_upload_dir();

$data=array('image_dir' => $upload_dir['basedir'].'/pass_images');

// your data object you want to pass to your front-end script.
$localise = json_encode($data);

add_action('wp_footer', function() use ($localise){
  printf('<script type="text/javascript">var entrypass_images_path = %s</script>', $localise);
});
comments powered by Disqus