|
@@ -1,36 +1,31 @@
|
|
|
<?php
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if (!class_exists("plug_color_admin_posts")) {
|
|
|
- class plug_color_admin_posts {
|
|
|
+ class plug_color_admin_posts {
|
|
|
private $options = array(); // Set $options in array
|
|
|
private $settings = array(); // Set $setting in array
|
|
|
var $hasform = true;
|
|
|
var $startet = false;
|
|
|
function __construct() {
|
|
|
- $this->title = __("Color admin posts","dagsopt");
|
|
|
+ $this->title = __("Color admin posts", "dagsopt");
|
|
|
}
|
|
|
- function start(){
|
|
|
+ function start() {
|
|
|
$this->startet = true;
|
|
|
- add_action('admin_menu', array(&$this,'add_submenu'));
|
|
|
- add_action('admin_init', array(&$this,'settings_api_init'));
|
|
|
+ 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();}
|
|
|
+ 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'
|
|
|
+ 'color_private' => '#FFCC99',
|
|
|
);
|
|
|
add_option('color_admin_posts', $options);
|
|
|
}
|
|
@@ -42,87 +37,87 @@ if (!class_exists("plug_color_admin_posts")) {
|
|
|
?>
|
|
|
<style>
|
|
|
.status-draft {
|
|
|
- background-color: <?php echo$options['color_draft']; ?> !important;
|
|
|
+ background-color: <?php echo $options['color_draft']; ?> !important;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.status-future {
|
|
|
- background-color: <?php echo$options['color_future']; ?> !important;
|
|
|
+ background-color: <?php echo $options['color_future']; ?> !important;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.status-publish {
|
|
|
- background-color: <?php echo$options['color_published']; ?> !important;
|
|
|
+ background-color: <?php echo $options['color_published']; ?> !important;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.status-pending {
|
|
|
- background-color: <?php echo$options['color_pending']; ?> !important;
|
|
|
+ background-color: <?php echo $options['color_pending']; ?> !important;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
.status-private {
|
|
|
- background-color: <?php echo$options['color_private']; ?> !important;
|
|
|
+ background-color: <?php echo $options['color_private']; ?> !important;
|
|
|
}
|
|
|
</style>
|
|
|
<?php
|
|
|
- }
|
|
|
+}
|
|
|
function load_farbtastic() {
|
|
|
global $current_screen;
|
|
|
- // if($current_screen->id == 'appearance_page_color-admin-post') {
|
|
|
- wp_enqueue_style('farbtastic');
|
|
|
- wp_enqueue_script('farbtastic');
|
|
|
- // }
|
|
|
+ // if($current_screen->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')
|
|
|
+ 'title' => __('Drafts Posts', 'dagsopt'),
|
|
|
);
|
|
|
|
|
|
$this->settings['color_pending'] = array(
|
|
|
'section' => 'general',
|
|
|
- 'title' => __('Pendings Posts', 'dagsopt')
|
|
|
+ 'title' => __('Pendings Posts', 'dagsopt'),
|
|
|
);
|
|
|
|
|
|
$this->settings['color_published'] = array(
|
|
|
- 'title' => __('Published Posts', 'dagsopt')
|
|
|
+ 'title' => __('Published Posts', 'dagsopt'),
|
|
|
);
|
|
|
|
|
|
$this->settings['color_future'] = array(
|
|
|
- 'title' => __('Futures Posts', 'dagsopt')
|
|
|
+ 'title' => __('Futures Posts', 'dagsopt'),
|
|
|
);
|
|
|
|
|
|
$this->settings['color_private'] = array(
|
|
|
- 'title' => __('Privates Posts', 'dagsopt')
|
|
|
+ 'title' => __('Privates Posts', 'dagsopt'),
|
|
|
);
|
|
|
}
|
|
|
function create_settings($args = array()) {
|
|
|
extract($args);
|
|
|
$field_args = array(
|
|
|
'id' => $id,
|
|
|
- 'label_for' => $id
|
|
|
+ 'label_for' => $id,
|
|
|
);
|
|
|
add_settings_field($id, $title, array(
|
|
|
$this,
|
|
|
- 'display_settings'
|
|
|
+ 'display_settings',
|
|
|
), __FILE__, 'general', $field_args);
|
|
|
}
|
|
|
public function display_settings($args = array()) {
|
|
|
extract($args);
|
|
|
$options = $this->options;
|
|
|
echo '<input class="regular-text" type="text" maxlength="7" id="' . $id . '" name="color_admin_posts[' . $id . ']" value="' . esc_attr($options[$id]) . '" />
|
|
|
- <br /><span class="description">' . $desc . '</span>
|
|
|
+ <br /><span class="description">' . '</span>
|
|
|
<div id="farbtastic-' . $id . '" class="farbtastic"></div>';
|
|
|
}
|
|
|
function settings_api_init() {
|
|
|
register_setting('color_admin_posts', 'color_admin_posts', array(
|
|
|
&$this,
|
|
|
- 'validate_settings'
|
|
|
+ 'validate_settings',
|
|
|
));
|
|
|
add_settings_section('general', '', array(
|
|
|
&$this,
|
|
|
- 'general_section_callback'
|
|
|
+ 'general_section_callback',
|
|
|
), __FILE__);
|
|
|
// Get the configuration of fields
|
|
|
$this->get_color_admin_post_settings();
|
|
|
// Generate fields
|
|
|
- foreach($this->settings as $id => $setting) {
|
|
|
+ foreach ($this->settings as $id => $setting) {
|
|
|
$setting['id'] = $id;
|
|
|
$this->create_settings($setting);
|
|
|
}
|
|
@@ -139,26 +134,26 @@ if (!class_exists("plug_color_admin_posts")) {
|
|
|
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' ) );
|
|
|
+ $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')) {
|
|
|
+ if (!current_user_can('administrator')) {
|
|
|
wp_die(__('You do not have sufficient permissions to access this page.', 'dagsopt'));
|
|
|
}
|
|
|
?>
|
|
|
<div class="wrap">
|
|
|
<div id="icon-options-general" class="icon32"></div>
|
|
|
<h2>Color Admin Posts</h2>
|
|
|
-
|
|
|
+
|
|
|
<form id="form-color-admin-posts" method="post" action="options.php">
|
|
|
<?php
|
|
|
- settings_fields('color_admin_posts');
|
|
|
- do_settings_sections(__FILE__);
|
|
|
- submit_button(__('Save Changes', 'dagsopt'));
|
|
|
- ?>
|
|
|
+settings_fields('color_admin_posts');
|
|
|
+ do_settings_sections(__FILE__);
|
|
|
+ submit_button(__('Save Changes', 'dagsopt'));
|
|
|
+ ?>
|
|
|
</form>
|
|
|
-
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
@@ -190,46 +185,33 @@ if (!class_exists("plug_color_admin_posts")) {
|
|
|
});
|
|
|
</script>
|
|
|
<?php
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- function help(){
|
|
|
- ?>
|
|
|
- <?php echo(__("Adds colors to","dagsopt")) ?> <a href="/wp-admin/edit.php"><?php echo(__("Posts","dagsopt")) ?></a> <?php echo(__("and","dagsopt")) ?> <a href="/wp-admin/edit.php?post_type=page"><?php echo(__("Pages","dagsopt")) ?></a><br>
|
|
|
-
|
|
|
- <?php echo($this->startet ? __('See below','dagsopt') : '');?>
|
|
|
-
|
|
|
- <?php
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- function admin_line(){
|
|
|
-
|
|
|
- ?>
|
|
|
- <a href="/wp-admin/admin.php?page=color-admin-post"><?php echo(__("Settings","dagsopt")) ?></a>
|
|
|
-<?php
|
|
|
-$this->display_page();
|
|
|
-?>
|
|
|
- <?php
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- // Start this plugin once all other plugins are fully loaded
|
|
|
-
|
|
|
+}
|
|
|
|
|
|
+ function help() {
|
|
|
+ ?>
|
|
|
+ <?php echo (__("Adds colors to", "dagsopt")) ?> <a href="/wp-admin/edit.php"><?php echo (__("Posts", "dagsopt")) ?></a> <?php echo (__("and", "dagsopt")) ?> <a href="/wp-admin/edit.php?post_type=page"><?php echo (__("Pages", "dagsopt")) ?></a><br>
|
|
|
|
|
|
+ <?php echo ($this->startet ? __('See below', 'dagsopt') : ''); ?>
|
|
|
|
|
|
- global $plug_color_admin_posts;
|
|
|
- $plug_color_admin_posts = new plug_color_admin_posts();
|
|
|
- $this->dagsopt['plug_color_admin_posts'] = $plug_color_admin_posts;
|
|
|
-
|
|
|
+ <?php
|
|
|
}
|
|
|
|
|
|
+ function admin_line() {
|
|
|
|
|
|
+ ?>
|
|
|
+ <a href="/wp-admin/admin.php?page=color-admin-post"><?php echo (__("Settings", "dagsopt")) ?></a>
|
|
|
+<?php
|
|
|
+$this->display_page();
|
|
|
+ ?>
|
|
|
+ <?php
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ // Start this plugin once all other plugins are fully loaded
|
|
|
|
|
|
+ global $plug_color_admin_posts;
|
|
|
+ $plug_color_admin_posts = new plug_color_admin_posts();
|
|
|
+ $this->dagsopt['plug_color_admin_posts'] = $plug_color_admin_posts;
|
|
|
|
|
|
+}
|