class CustomPostType
Constants
- DEFAULT_NAME
Public Class Methods
new(cpt_name = nil)
click to toggle source
# File lib/wp_scaffold/models/generators/custom_post_type.rb, line 19 def initialize(cpt_name = nil) self.name = cpt_name.nil? ? DEFAULT_NAME : cpt_name.downcase self.destination = "" self.template_path = "custom_post_type" self.relative_to_cwd = true end
Public Instance Methods
generate()
click to toggle source
Calls superclass method
Generator#generate
# File lib/wp_scaffold/models/generators/custom_post_type.rb, line 5 def generate super base_path = USER_DIRECTORY + self.destination # Rename the register CPT file File.rename(base_path + "/custom-post-types/custom.php", base_path + "/custom-post-types/" + self.name.to_dash + ".php") # Rename the CPT's template files File.rename(base_path + "/page-custom.php", base_path + "/page-" + self.name.to_dash + ".php") File.rename(base_path + "/single-custom.php", base_path + "/single-" + self.name.to_dash + ".php") end