Detect and output parent theme

This commit is contained in:
Christian Mehlmauer
2013-12-07 22:04:51 +01:00
parent 2fd11cba15
commit fffcd61cc4
5 changed files with 92 additions and 47 deletions

View File

@@ -0,0 +1,33 @@
# encoding: UTF-8
class WpTheme < WpItem
module Childtheme
def is_child_theme?
return true unless @theme_template.nil?
false
end
def get_parent_theme_style_url
if is_child_theme?
return style_url.sub("/#{name}/style.css", "/#@theme_template/style.css")
end
nil
end
def get_parent_theme
if is_child_theme?
base_url = @uri.clone
base_url.path = base_url.path.sub(/(?<url>.*\/)#{Regexp.escape(@wp_content_dir)}\/.+/, '\k<url>')
return WpTheme.new(base_url,
{
name: @theme_template,
style_url: get_parent_theme_style_url,
wp_content_dir: @wp_content_dir
})
end
nil
end
end
end