Search code examples
phpwordpressflashplugins

How to access static files from inside Wordpress plugin directory


I'm trying to create a custom Wordpress Plugin for one of my websites. And I've created a shortcode inside the plugin and I have one .swf file inside the plugin directory that I want to embed using the created shortcode. I've tried with <embed src="wp-content/plugins/myplugin/obj.swf"> also tried with <iframe> but I get 404 Page not found error. The same error when I try to open the swf file directly from the browser's address bar. Can anyone give me little hand how can I achieve this?

enter image description here


Solution

  • Based on our comments, and the screen shot, you should rename the folder on the server to be in lower case (ie from falja-e-namazit-WP to falja-e-namazit-wp).

    EDIT

    Not sure what you mean by your latest comment, but you should be able to get the URL of your asset using the plugins_url() function. Assuming your SWF file is in /wp-content/plugins/falja-e-namazit-wp/assets, the following code (in /wp-content/plugins/falja-e-namazit-wp/falja-e-namazit-wp.php) should return its URL:

    $swf_url = plugins_url( 'assets/falja.swf', __FILE__ );