Skip to content

Instantly share code, notes, and snippets.

@markjaquith
Last active December 10, 2015 16:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markjaquith/4463062 to your computer and use it in GitHub Desktop.
Save markjaquith/4463062 to your computer and use it in GitHub Desktop.
Makes a list of allowed WordPress configurations. Plan to use this to make a vagrant box that has all of them, for testing purposes.
#!/usr/bin/ruby
multisitism = [
:single_site,
:multisite_subdirs,
:multisite_subdomains
]
permalinks = [
:default_permalinks,
:pathinfo_permalinks,
:mod_rewrite_permalinks
]
home_location = [
:home_in_root,
:home_in_subdir
]
wp_location = [
:wp_in_home,
:wp_in_subdir,
:wp_in_subdir_siteurl_equals_home
]
def is_forbidden combo
forbidden = false
# Subdomain multisite installs require the 'home' to be in the root
if combo.include?(:multisite_subdomains) && combo.include?(:home_in_subdir)
forbidden = true
# Multisite installs require mod_rewrite permalinks
elsif !combo.include?(:single_site) && !combo.include?(:mod_rewrite_permalinks)
forbidden = true
# WP in subdir with siteurl == home is multisite-specific
elsif combo.include?(:single_site) && combo.include?(:wp_in_subdir_siteurl_equals_home)
forbidden = true
end
forbidden
end
combos = []
for m in multisitism
for p in permalinks
for h in home_location
for w in wp_location
combo = [ m, p, h, w ]
combos << combo unless is_forbidden combo
end
end
end
end
puts combos.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment