$this->pluginDirName = $path;
$this->wpdb = $wpdb;
$jobs = new emmet_employment_job($path);
- //add_action('admin_menu', array($this, 'add_job_menus'));
+ add_action('admin_menu', array($this, 'add_job_menus'));
+ add_action('admin_init', array($this, 'job_settings_init') );
+ }
+
+ static public function activate_plugin()
+ {
+ emmet_employment_admin::add_capability();
+ }
+
+ static public function add_capability()
+ {
+ $roles = get_editable_roles();
+ foreach ($GLOBALS['wp_roles']->role_objects as $key => $role) {
+ if (isset($roles[$key]) && $role->has_cap(EMMET_EMP_BUILT_IN_CAPABILITY)) {
+ $role->add_cap(EMMET_EMP_NEW_CAPABILITY);
+ }
+ }
}
/**
*/
public function add_job_menus()
{
+ //add_submenu_page(
+ //'edit.php?post_type=' . EMMET_EMP_POST_TYPE,
+ //'applications',
+ //'Applications',
+ //'edit_posts',
+ //'applications',
+ //array($this, 'get_applications')
+ //);
add_submenu_page(
'edit.php?post_type=' . EMMET_EMP_POST_TYPE,
- 'applications',
- 'Applications',
+ 'settings',
+ 'Settings',
'edit_posts',
- 'applications',
- array($this, 'get_applications')
+ EMMET_EMP_SETTINGS,
+ array($this, 'show_job_settings')
+ );
+ }
+
+ public function emmetjobs_option_page_capability()
+ {
+ return EMMET_EMP_NEW_CAPABILITY;
+ }
+
+ public function job_settings_init()
+ {
+ add_settings_section(
+ 'emmetjobs_setting_section',
+ 'Edit Form Settings',
+ array($this, 'emmetjobs_settings_section_callback'),
+ EMMET_EMP_SETTINGS
+ );
+ $fieldNames = array(
+ array(
+ 'name' => 'employment_form_page',
+ 'label' => 'Page for the Form',
+ 'type' => 'page'
+ )
);
-// add_submenu_page(
-// 'edit.php?post_type=' . EMMET_EMP_POST_TYPE,
-// 'settings',
-// 'Settings',
-// 'manage_options',
-// 'job_settings',
-// array($this, 'show_job_settings')
-// );
+
+ foreach ($fieldNames as $field) {
+ $this->emmetjobs_add_setting_text_field(
+ $field['name'],
+ $field['label'],
+ $field['type']
+ );
+ }
+ register_setting(EMMET_EMP_SETTINGS, EMMET_EMP_SETTING_NAME, array($this, 'sanitize_options'));
}
+ public function sanitize_options($input)
+ {
+ return $input;
+ }
/**
* show job settings
*/
public function show_job_settings()
{
- echo '<p>Job Settings</p>';
+ if (current_user_can(EMMET_EMP_NEW_CAPABILITY)) {
+ include $this->pluginDirName . 'views/optionsPage.php';
+ } else {
+ include $this->pluginDirName . 'views/deniedAccess.php';
+ }
}
/**
$this->pluginDirName = $dir;
}
+ public function emmetjobs_settings_section_callback()
+ {
+ echo __('Employment Form Page', 'wordpress');
+ }
+
+ public function emmetjobs_add_setting_text_field($name, $label, $type)
+ {
+ switch ($type) {
+ case 'text':
+ $callback = 'render_text_field';
+ break;
+ case 'textarea':
+ $callback = 'render_textarea_field';
+ break;
+ case 'page':
+ $callback = 'render_page_field';
+ break;
+ default:
+ return false;
+ break;
+ }
+ add_settings_field(
+ $name,
+ $label,
+ array($this, $callback),
+ EMMET_EMP_SETTINGS,
+ 'emmetjobs_setting_section',
+ $name
+ );
+ }
+
+ public function render_page_field($fieldName)
+ {
+ static $options;
+ if (!$options) {
+ $options = get_option(EMMET_EMP_SETTINGS);
+ }
+ include $this->pluginDirName . 'views/page.php';
+ }
}
*/
define('EMMET_EMP_PLUGIN_PATH_FILE', __FILE__);
define('EMMET_EMP_VERSION', '0.0.1');
+define('EMMET_EMP_SETTING_NAME', 'emmetjobs_settings');
+define('EMMET_EMP_SETTINGS', 'emmetjobs_settings');
+define('EMMET_EMP_NEW_CAPABILITY', 'edit_posts');
define('EMMET_EMP_VRS_OPTION_NAME', 'emmet_jobs_db_version');
define('EMMET_EMP_POST_TYPE', 'emmet_jobs');
define('EMMET_EMP_TAX_CATEGORIES', 'emmet_jobscategory');