*/
public function add_job_menus()
{
- add_submenu_page(
- 'edit.php?post_type=' . GLM_EMP_POST_TYPE,
- 'applications',
- 'Applications',
- 'edit_posts',
- 'applications',
- array($this, 'get_applications')
- );
- add_submenu_page(
- 'edit.php?post_type=' . GLM_EMP_POST_TYPE,
- 'import',
- 'Import',
- 'edit_posts',
- 'import',
- array($this, 'import')
- );
- add_submenu_page(
- 'edit.php?post_type=' . GLM_EMP_POST_TYPE,
- 'settings',
- 'Settings',
- 'edit_posts',
- GLM_EMP_SETTINGS,
- array($this, 'show_job_settings')
- );
+ $plugin_options = get_option(GLM_EMP_SETTING_NAME);
+ $showApplicationLink = $plugin_options['show_applications'];
+ if ( $showApplicationLink ) {
+ add_submenu_page(
+ 'edit.php?post_type=' . GLM_EMP_POST_TYPE,
+ 'applications',
+ 'Applications',
+ 'edit_posts',
+ 'applications',
+ array($this, 'get_applications')
+ );
+ }
+ if ( current_user_can( 'manage_options' ) ) {
+ add_submenu_page(
+ 'edit.php?post_type=' . GLM_EMP_POST_TYPE,
+ 'import',
+ 'Import',
+ 'edit_posts',
+ 'import',
+ array($this, 'import')
+ );
+ add_submenu_page(
+ 'edit.php?post_type=' . GLM_EMP_POST_TYPE,
+ 'settings',
+ 'Settings',
+ 'edit_posts',
+ GLM_EMP_SETTINGS,
+ array($this, 'show_job_settings')
+ );
+ }
}
static public function activate_plugin()
'name' => 'employment_form_page',
'label' => 'Page for the Form',
'type' => 'page'
+ ),
+ array(
+ 'name' => 'show_applications',
+ 'label' => 'Show Application link (deprecated)',
+ 'type' => 'checkbox'
)
);
public function glmjobs_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;
+ case 'checkbox':
+ $callback = 'render_checkbox_field';
+ break;
+ 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,
include $this->pluginDirName . 'views/text.php';
}
+ public function render_checkbox_field( $fieldName )
+ {
+ static $options;
+ if (!$options) {
+ $options = get_option(GLM_EMP_SETTINGS);
+ }
+ include $this->pluginDirName . 'views/checkbox.php';
+ }
+
public function render_textarea_field($fieldName)
{
static $options;