title = __("Color admin posts", "dagsopt");
}
function start() {
$this->startet = true;
add_action('admin_menu', array(&$this, 'add_submenu'));
add_action('admin_init', array(&$this, 'settings_api_init'));
$this->options = get_option('color_admin_posts');
add_action('admin_print_styles-edit.php', array(&$this, 'load_color'));
add_action('admin_head', array(&$this, 'load_farbtastic'));
if (!is_array(get_option('color_admin_posts'))) {$this->activate();}
}
function activate() {
$options = array(
'color_draft' => '#FFFF99',
'color_pending' => '#87C5D6',
'color_published' => '#',
'color_future' => '#CCFF99',
'color_private' => '#FFCC99',
);
add_option('color_admin_posts', $options);
}
function deactivate() {
delete_option('color_admin_posts');
}
function load_color() {
$options = $this->options;
?>
id == 'appearance_page_color-admin-post') {
wp_enqueue_style('farbtastic');
wp_enqueue_script('farbtastic');
// }
}
function get_color_admin_post_settings() {
$this->settings['color_draft'] = array(
'title' => __('Drafts Posts', 'dagsopt'),
);
$this->settings['color_pending'] = array(
'section' => 'general',
'title' => __('Pendings Posts', 'dagsopt'),
);
$this->settings['color_published'] = array(
'title' => __('Published Posts', 'dagsopt'),
);
$this->settings['color_future'] = array(
'title' => __('Futures Posts', 'dagsopt'),
);
$this->settings['color_private'] = array(
'title' => __('Privates Posts', 'dagsopt'),
);
}
function create_settings($args = array()) {
extract($args);
$field_args = array(
'id' => $id,
'label_for' => $id,
);
add_settings_field($id, $title, array(
$this,
'display_settings',
), __FILE__, 'general', $field_args);
}
public function display_settings($args = array()) {
extract($args);
$options = $this->options;
echo '
' . '
' . __('Leave "#" for the default color.', 'dagsopt') . '
'; } function validate_settings($input) { $input['color_draft'] = (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $input['color_draft'])) ? $input['color_draft'] : '#'; $input['color_pending'] = (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $input['color_pending'])) ? $input['color_pending'] : '#'; $input['color_published'] = (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $input['color_published'])) ? $input['color_published'] : '#'; $input['color_future'] = (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $input['color_future'])) ? $input['color_future'] : '#'; $input['color_private'] = (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $input['color_private'])) ? $input['color_private'] : '#'; return $input; } function add_submenu() { $page = add_submenu_page('xwpplugins', __("Color Admin Posts"), __("Color Admin Posts"), 'edit_theme_options', 'color-admin-post', array(&$this, 'display_page')); } function display_page() { // Check if user can access to the plugin if (!current_user_can('administrator')) { wp_die(__('You do not have sufficient permissions to access this page.', 'dagsopt')); } ?>