WordPress.org

Ready to get started?Download WordPress

Forums

Organize Series
[resolved] Series Icons Path Not Rendered Properly (3 posts)

  1. Travis Tubbs
    Member
    Posted 3 years ago #

    Unfortunately, I was still having major issues with the Organize Series plugin, having my WordPress core files separate from my real WordPress core files, and using WP_CONTENT_DIR and WP_CONTENT_URL to store my content elsewhere on my site.

    A quick recap. To try and keep my site secure, my WordPress Core Files are stored in a sub-directory of the root of my site, but using the Site URL feature in the General Settings of WordPress, it looks like WordPress is running from the root of my server. To help continue hiding my core files from the public, I'm using WP_CONTENT_DIR and WP_CONTENT_URL settings in the wp-config.php to store my content outside of the default wp-content folder.

    It seems that the Organize Series does not like people using these available settings to WordPress users as it's just been giving me trouble left and right. This time, Organize Series is not outputting the location of my icons properly.

    When adding an icon to a Series in the Manage Series section of the WordPress admin, I'm having to manually type in the path of my image for the series as the Upload Image feature doesn't work for me. (That's a problem for another day.) Since I like using paths without the domain attached (just in case I decide to move my site to a different domain), I type in the path of /content/media/series/imagefile.png where content is where customizable WordPress content is stored (media, plugins, themes, etc.), media is where uploaded content is store, and series is the folder I created to store images related to Series.

    Adding the series stores the path for the icon I typed in correctly into the wp_orgSeriesIcons table of the database. This is where things start to go wrong. When outputting the URL in the Admin, it spits out not just the WordPress Core Files URL but also the physical path of the icon on the web server AND the actual URL of the icon. So, instead of...
    /content/media/series/google-apps-transition.png

    (which is stored in the database properly) I'm getting...

    http://travistubbs.net/_ttn-201010-wp-core-3x_//home/[Volume]/[host]/[accountID]/[domain]/htdocs/content/media/http://travistubbs.net/content/media/series/google-apps-transition.png

    While browsing through orgSeries-manage.php, the I noticed that the $series_icon variable is showing off the correct path whereas $icon is giving the long, drawn out, and incorrect path instead.

    Looking over the code, it looks like the culprits are the seriesicons_path and seriesicons_url functions in orgSeries-icon.php. TubePress had a similar issue, in which it ignored those were are using the WP_CONTENT_DIR and WP_CONTENT_URL custom values in wp-config.php. To resolve this, I had to change the way that the seriesicons_path and seriesicons_url functions worked, as well as the default_seriesicons_upload function in the same file.

    For the default_seriesicons_upload function, we need to check to see if WP_CONTENT_DIR and WP_CONTENT_URL are defined. If so, the $def_path and $def_url variables need to pay attention to those values as defined in wp-config.php.

    function default_seriesicons_upload() {
        if (!defined('WP_CONTENT_DIR')) {
    		$def_path = str_replace(ABSPATH, '', get_option('upload_path'));
        } else {
    		$def_path = str_replace(WP_CONTENT_DIR, '', get_option('upload_path'));
    	}
    
    	if (!defined('WP_CONTENT_URL')) {
    		$def_url = trailingslashit(get_bloginfo('wpurl')) . $def_path;
    	} else {
    		$def_url = WP_CONTENT_URL . $def_path;
    	}
    
    	return array($def_path, $def_url);
    }

    As for the seriesicons_path function, we need to path attention to the value of WP_CONTENT_DIR if it's defined.

    function seriesicons_path() {
    	$def = default_seriesicons_upload();
    
        if (!defined('WP_CONTENT_DIR')) {
    		$def_path_icons = ABSPATH . $def[0];
        } else {
    		$def_path_icons = WP_CONTENT_DIR . $def[0];
    	}
    
    	return $def_path_icons;
    }

    No changes are needed to be made to the seriesicons_url function.

    After making all the necessary changes to those functions (and several hours of yelling at the computer), Organize Series worked great with my custom paths. Again, hopefully this will help those have had similar issues. It may not be full-proof as I only have my setup to test against, but hopefully this is the answer that others are looking for.

    Oh yeah... I have no idea what this does to the Upload function in Organize Series since uploading doesn't even work for me to begin with.

  2. Darren Ethier (nerrad)
    Member
    Plugin Author

    Posted 3 years ago #

    Again, thanks Travis. I'll do another review of the codebase to make sure that all the path calls are referencing any set WP_CONTENT_DIR and WP_CONTENT_URL calls. For uploading I hook into the built-in WordPress uploader so if it doesn't work for you I'll have to do some investigating to figure out what may be happening, especially if the uploader works for you elsewhere.

  3. Darren Ethier (nerrad)
    Member
    Plugin Author

    Posted 3 years ago #

    Added the fix in Organize Series 2.2.3

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic