WordPress.org

Ready to get started?Download WordPress

Forums

Peter's Blog URL Shortcodes
upload_url_path and upload_path are empty (4 posts)

  1. ChichipioWilson
    Member
    Posted 1 year ago #

    Hello. Thanks for the code. I don't know if you're still maintaining the plugin, but if you are, you might want to take a look at the getSettings() function. The 2 options you check here default to '' for a fresh install. So in order to keep using your plugin I had to modify it so 'uploads' defaults to the standard path if those options are empty.

    public static function getSettings()
        {
            $blogurl_settings = blogurlShortcodes::userSettings();
    
            // It's best not to touch this if / else statement
            if( '' != get_option( 'upload_url_path' ) )
            {
                // This is set in Settings > Miscellaneous > Full URL path to files
                $blogurl_settings['uploads'] = get_option( 'upload_url_path' );
            }
            else if( '' != get_option( 'upload_path' ) )
            {
                $blogurl_settings['uploads'] = $blogurl_settings['wordpress'] . '/' . get_option( 'upload_path' );
            }
            else
            	$blogurl_settings['uploads'] = $blogurl_settings['wordpress'] . '/wp-content/uploads';
    
            // To define your own upload URL path (for [blogurl uploads], comment out the line below
            // $blogurl_settings['uploads'] = 'http://yoursite.com/wp-content/uploads';
    
            return $blogurl_settings;
        }
    }

    http://wordpress.org/extend/plugins/peters-blog-url-shortcodes/

  2. Peter
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks for bringing this up! Perhaps the code should simply be falling back to wp_upload_dir() (http://codex.wordpress.org/Function_Reference/wp_upload_dir), which has a similar purpose.

  3. ChichipioWilson
    Member
    Posted 1 year ago #

    You're right. I'm still discovering wp functions so I sometimes tend to go with the manual solutions until someone points me in the right
    direction.
    Assuming $upload_dir = wp_upload_dir();, then $upload_dir['baseurl'] should work nicely.
    Thanks.

  4. Peter
    Member
    Plugin Author

    Posted 1 year ago #

    Ah good. I've updated the plugin now to consider wp_upload_dir (and the 'baseurl' return element) first. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.