Category Icons
[resolved] Incorrect coding of file paths + suggested fix (2 posts)

  1. WPsites
    Posted 3 years ago #

    It's perfectly valid to have your wp-content, plugins, themes or uploads directory under any location a website owner can dream up http://codex.wordpress.org/Editing_wp-config.php#Moving_wp-content_folder

    WordPress sites that have non standard paths will have trouble running this plugin. I've had to fix this plugin for a client so I've included the new code here: https://gist.github.com/4563990

    The correct way to get the path for an image included in your plugin:

    plugins_url( "images/w3c-xhtml1.0.png" , __FILE__ )

    Which would return "http://www.website.co.uk/wp-content/plugins/category-icons/images/w3c-xhtml1.0.png" regardless of where the wp-content folder or plugin folder resides.

    Here is an example of where a theme path is assumed

    $path = WP_CONTENT_DIR.'/themes/'.get_option('template');

    I haven't fixed the above theme path but the correct way of building these paths can be found here: http://codex.wordpress.org/Determining_Plugin_and_Content_Directories#Themes

     * Get the upload & siteurl paths
     * @author Ivan Georgiev
     * @return array (path, url)
    function ig_caticons_defupload() {
    	$def_path = str_replace(ABSPATH, '', get_option('upload_path')); // wordpress's option
    	$def_url = trailingslashit(get_option('siteurl')) . $def_path; // idem
    	return array($def_path, $def_url);

    Do something like this instead

    function ig_caticons_defupload() {
        $upload_dir = wp_upload_dir();
        $def_path = $upload_dir['basedir']; // path
    	$def_url = $upload_dir['baseurl']; // url
    	return array($def_path, $def_url);


    WP Sites Limited


  2. submarine
    Plugin Author

    Posted 3 years ago #

    Hi, many thanks ! I've included your fixes in the 2.2.6 version, which is now compatible with WP 3.5.1.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Category Icons
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic