Last active
September 7, 2016 15:53
-
-
Save talves/7346027 to your computer and use it in GitHub Desktop.
A Wordpress mu-plugin for use with composer using [roots](https://github.com/roots/roots) to setup the correct paths for a custom path.
Modified `upload_url_path` to work on a windows IIS Server. Change to `/media` when needed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!is_blog_installed()) { return; } | |
$my_server_port = ((!empty ($_SERVER ['SERVER_PORT']) AND $_SERVER ['SERVER_PORT'] <> '80') ? (":" . $_SERVER ['SERVER_PORT']) : ''); | |
$my_server_name = (!empty ($my_server_port) ?($_SERVER['SERVER_NAME'] . $my_server_port) : $_SERVER['SERVER_NAME'] ); | |
if ('http://' . $my_server_name . '/wp' == get_option('home')) { | |
update_option('siteurl', 'http://' . $my_server_name . '/wp'); | |
update_option('home', 'http://' . $my_server_name); | |
update_option('upload_path', $_SERVER['DOCUMENT_ROOT'] . '\media'); | |
update_option('upload_url_path', 'http://' . $my_server_name . '/media'); | |
update_option('permalink_structure', '/%postname%/'); | |
} | |
if (get_option('upload_url_path') == ''){ | |
update_option('upload_url_path', 'http://' . $my_server_name . '/media'); | |
} | |
if (get_option('upload_path') == '' || get_option('upload_path') == 'media'){ | |
update_option('upload_path', $_SERVER['DOCUMENT_ROOT'] . '\media'); | |
} | |
if (defined('FRONT_PAGE') && defined('POSTS_PAGE') && !get_option('page_on_front')) { | |
$front = get_page_by_title(FRONT_PAGE); | |
$posts = get_page_by_title(POSTS_PAGE); | |
if ($front && $posts) { | |
update_option('show_on_front', 'page'); | |
update_option('page_on_front', $front->ID); | |
update_option('page_for_posts', $posts->ID); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minor issue - a few of the media paths are \media, they should be / otherwise it creates a "\media" directory instead of using "media"