function run($boilerplate_name, $boilerplate_type, $boilerplate_desc, $boilerplate_author, $boilerplate_author_link)
 {
     $this->slug = str_replace(' ', '-', strtolower($boilerplate_name));
     $package = str_replace(' ', '_', foo_title_case($boilerplate_name . ' ' . $boilerplate_type)) . '_FooGallery_Extension';
     $constant = strtoupper($package);
     //setup some variables for replacement
     $variables = array('{name}' => $boilerplate_name, '{slug}' => $this->slug, '{plugin_slug}' => "foogallery-{$this->slug}", '{package}' => $package, '{constant}' => $constant, '{type}' => $boilerplate_type, '{desc}' => $boilerplate_desc, '{author}' => $boilerplate_author, '{author_link}' => $boilerplate_author_link);
     $upload_dir = wp_upload_dir();
     //create the generator
     $zip_generator = new FooGallery_Boilerplate_Zip_Generator(array('name' => 'foogallery', 'process_extensions' => array('php', 'css', 'js', 'txt'), 'source_directory' => FOOGALLERY_PATH . "/includes/admin/boilerplates/{$boilerplate_type}/", 'zip_root_directory' => "foogallery-{$this->slug}-{$boilerplate_type}", 'download_filename' => "foogallery-{$this->slug}-{$boilerplate_type}.zip", 'filename_filter' => array($this, 'process_zip_filename'), 'variables' => $variables, 'zip_temp_directory' => $upload_dir['path']));
     //generate the zip file
     $zip_generator->generate();
     //download it to the client
     $zip_generator->send_download_headers();
     die;
 }
 function init($file, $slug = false, $version = '0.0.1', $title = false)
 {
     //check to make sure the mandatory plugin fields have been set
     if (empty($file)) {
         throw new Exception('Required plugin variable not set : \'plugin_file\'. Please set this in the init() function of your plugin.');
     }
     if (empty($version)) {
         throw new Exception('Required plugin variable not set : \'plugin_version\'. Please set this in the init() function of your plugin.');
     }
     $this->plugin_file = $file;
     $this->plugin_dir = plugin_dir_path($file);
     $this->plugin_dir_name = plugin_basename($this->plugin_dir);
     $this->plugin_url = plugin_dir_url($file);
     $this->plugin_slug = $slug !== false ? $slug : plugin_basename($file);
     $this->plugin_title = $title !== false ? $title : foo_title_case($this->plugin_slug);
     $this->plugin_version = $version;
     //load any plugin dependencies
     $this->load_dependencies();
     //check we are using php 5
     foo_check_php_version($this->plugin_title, '5.0.0');
     // Load plugin text domain
     add_action('init', array($this, 'load_plugin_textdomain'));
     // Render any inline styles that need to go at the end of the head tag
     add_action('wp_head', array($this, 'inline_styles'), 100);
     // Render any inline scripts at the bottom of the page just before the closing body tag
     add_action('wp_footer', array($this, 'inline_scripts'), 200);
     if (is_admin()) {
         // Register any settings for the plugin
         add_action('admin_init', array($this, 'admin_create_settings'));
         // Add a settings page menu item
         add_action('admin_menu', array($this, 'admin_settings_page_menu'));
         // Add a links to the plugin listing
         add_filter('plugin_action_links_' . plugin_basename($this->plugin_file), array($this, 'admin_plugin_listing_actions'));
         // output CSS to the admin pages
         add_action('admin_print_styles', array($this, 'admin_print_styles'));
         // output JS to the admin pages
         add_action('admin_print_scripts', array($this, 'admin_print_scripts'));
     }
     do_action($this->plugin_slug . '-' . (is_admin() ? 'admin' : '') . '_init');
 }
 function add_setting($args = array())
 {
     $defaults = array('id' => 'default_field', 'title' => 'Default Field', 'desc' => '', 'default' => '', 'placeholder' => '', 'type' => 'text', 'section' => '', 'choices' => array(), 'class' => '', 'tab' => '');
     //only declare up front so no debug warnings are shown
     $title = $type = $id = $desc = $default = $placeholder = $choices = $class = $section = $tab = null;
     extract(wp_parse_args($args, $defaults));
     $field_args = array('type' => $type, 'id' => $id, 'desc' => $desc, 'default' => $default, 'placeholder' => $placeholder, 'choices' => $choices, 'label_for' => $id, 'class' => $class);
     if (count($this->_settings) == 0) {
         //only do this once
         register_setting($this->plugin_slug, $this->plugin_slug, array($this, 'validate'));
     }
     $this->_settings[] = $args;
     $section_id = foo_convert_to_key($section);
     //check we have the tab
     if (!empty($tab)) {
         $tab_id = foo_convert_to_key($tab);
         //add the tab
         $this->add_tab($tab_id, foo_title_case($tab));
         //add the section
         $section_id = $this->add_section_to_tab($tab_id, $section_id, foo_title_case($section));
     } else {
         //just add the section
         $this->add_section($section_id, foo_title_case($section));
     }
     do_action($this->plugin_slug . '_admin_settings_before_setting', $args);
     //add the setting!
     add_settings_field($id, $title, array($this, 'render'), $this->plugin_slug, $section_id, $field_args);
     do_action($this->plugin_slug . '_admin_settings_after_setting', $args);
 }