14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/aina.rb', line 14
def self.install(output = false)
unless Dir.exists?(Dir.pwd + '/inc')
Dir.mkdir(Dir.pwd + '/inc')
end
unless self.is_installed?
text = File.read(Aina::TEMPLATES_DIR + '/aina_framework.php')
['{{aina_version}}'].each do |replace|
attribute = replace.gsub(/[{}]/, '')
@output = text.gsub!(/#{replace}/, self.send(attribute))
end
File.open(Dir.pwd + "/inc/aina.php", "w") {|file| file.puts @output}
message = "Aina has been installed in your WordPress theme.\n"
message += "\n\nIf you want your post type to be automatically included, put this is functions.php:\n"
message += "function aina_post_types() {\n"
message += " return array('your_post_type', 'another_post_type', 'etc');\n"
message += "}\n"
else
message = "Aina was already installed in your WordPress theme ;-)\n"
end
unless functions_php_exists?
create_empty_functions_php
end
File.open(functions_php, "a+") {|file| file.puts aina_inclusion}
if output
puts message
end
end
|