Support » Plugin: Category Icons » Incorrect coding of file paths suggested fix

  • Resolved WPsites


    It’s perfectly valid to have your wp-content, plugins, themes or uploads directory under any location a website owner can dream up

    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:

    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 “” 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:

     * 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

Viewing 1 replies (of 1 total)
  • Plugin Author submarine


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

Viewing 1 replies (of 1 total)
  • The topic ‘Incorrect coding of file paths suggested fix’ is closed to new replies.