Module: WpTheme::Childtheme

Included in:
WpTheme
Defined in:
lib/common/models/wp_theme/childtheme.rb

Instance Method Summary collapse

Instance Method Details

#get_parent_themeObject


22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/common/models/wp_theme/childtheme.rb', line 22

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

#get_parent_theme_style_urlObject


15
16
17
18
19
20
# File 'lib/common/models/wp_theme/childtheme.rb', line 15

def get_parent_theme_style_url
  if is_child_theme?
    return style_url.sub("/#{name}/style.css", "/#@theme_template/style.css")
  end
  nil
end

#is_child_theme?Boolean

Returns:

  • (Boolean)

10
11
12
13
# File 'lib/common/models/wp_theme/childtheme.rb', line 10

def is_child_theme?
  return true unless @theme_template.nil?
  false
end

#parent_theme_limitObject


6
7
8
# File 'lib/common/models/wp_theme/childtheme.rb', line 6

def parent_theme_limit
  3
end