WordPress.org

Support

Support » Plugins and Hacks » Plugin uses plugins_url, should be plugin_dir_path?

Plugin uses plugins_url, should be plugin_dir_path?

  • Hi,

    The plugin uses plugins_url (i.e it tries to download the file over HTTP, instead of opening the actual file on disc). This pretty much renders the plugin useless if you have strict PHP settings (i.e can’t download files over http via file()).

    Following code uses the local file, instead of remote:

    [code]
    $file = ‘mime-types.txt’;
    $file = plugin_dir_path(__FILE__) . $file;
    $mime_file_lines = file($file);
    [/code]

    http://wordpress.org/extend/plugins/ap-extended-mime-types/

Viewing 1 replies (of 1 total)
  • lucile
    Participant

    @lucile

    Thanks for the tip, it solved the following warnings:

    Warning: file() [function.file]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /(...)/web/wp-content/plugins/ap-extended-mime-types/ap-extended-mime-types.php on line 40
    
    Warning: file(http://(...)/wp-content/plugins/ap-extended-mime-types/mime-types.txt) [function.file]: failed to open stream: Success in /(...)/web/wp-content/plugins/ap-extended-mime-types/ap-extended-mime-types.php on line 40
    
    Warning: Invalid argument supplied for foreach() in /(...)/web/wp-content/plugins/ap-extended-mime-types/ap-extended-mime-types.php on line 42
Viewing 1 replies (of 1 total)
  • The topic ‘Plugin uses plugins_url, should be plugin_dir_path?’ is closed to new replies.