6b66cbf9 by Kevin Burton

updated TzOption

1 parent aa34346a
...@@ -32,6 +32,17 @@ class Actions { ...@@ -32,6 +32,17 @@ class Actions {
32 #toplevel_page_cbvreport:hover .wp-menu-image, #menu-posts-POSTTYPE.wp-has-current-submenu .wp-menu-image { 32 #toplevel_page_cbvreport:hover .wp-menu-image, #menu-posts-POSTTYPE.wp-has-current-submenu .wp-menu-image {
33 background-position:6px 7px!important; 33 background-position:6px 7px!important;
34 } 34 }
35
36 #toplevel_page_cbv_options .wp-menu-image a img { display:none; }
37 #toplevel_page_cbv_options .wp-menu-image {
38 background: url(<?php echo Tools\url('cpt-icons/switch.png', __FILE__) ?>) no-repeat 6px -17px !important;
39 }
40 #toplevel_page_cbv_options:hover .wp-menu-image, #menu-posts-POSTTYPE.wp-has-current-submenu .wp-menu-image {
41 background-position:6px 7px!important;
42 }
43
44
45
35 </style> 46 </style>
36 <?php 47 <?php
37 48
......
...@@ -2,33 +2,54 @@ ...@@ -2,33 +2,54 @@
2 namespace Tz\WordPress\Tools\TzOption; 2 namespace Tz\WordPress\Tools\TzOption;
3 use Tz\WordPress\Tools; 3 use Tz\WordPress\Tools;
4 4
5 require_once('wp-admin-menu-classes.php');
6
7 const CAPABILITY = "manage_cbv_options";
8
9
5 call_user_func(function() { 10 call_user_func(function() {
11 $role = get_role('administrator');
12 $role->add_cap(CAPABILITY);
13
6 Tools\add_actions(__NAMESPACE__ . '\Actions'); 14 Tools\add_actions(__NAMESPACE__ . '\Actions');
7 Tools\add_shortcodes(__NAMESPACE__ . '\ShortCodes'); 15 Tools\add_shortcodes(__NAMESPACE__ . '\ShortCodes');
8 }); 16 });
17
9 18
10 function GetOption($key) { 19 function GetOption($key) {
11 if ( isset( Vars::$options[$key] ) ) { 20 if ( isset( Vars::$options[$key] ) ) {
12 return Vars::$options[$key]; 21 return Vars::$options[$key];
13 } else { 22 } else {
14 return '-'; 23 return '';
15 } 24 }
16 } 25 }
17 26
27 function display_options() {
28 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'index.php');
29 }
30
18 class Actions { 31 class Actions {
19 public static function init() { 32 public static function init() {
20 global $wpdb; 33 global $wpdb;
21 $results = $wpdb->get_results("SELECT * FROM wp_cbv_options", ARRAY_A); 34 $results = $wpdb->get_results("SELECT * FROM wp_cbv_options", ARRAY_A);
22 foreach($results as $key => $val) { 35 foreach($results as $rs) {
23 Vars::$options[$key] = $val; 36 Vars::$options[$rs['option_name']] = $rs['option_value'];
24 } 37 }
25 } 38 }
39
40 public static function admin_menu() {
41 add_menu_page('CBV Options','CBV Options',CAPABILITY,'cbv_options',__NAMESPACE__ . '\display_options',null,6);
42 rename_admin_menu_section('Posts','Publications');
43 swap_admin_menu_sections('CBV Options','Publications');
44 }
26 } 45 }
27 46
28 class ShortCodes { 47 class ShortCodes {
29 48
30 public static function TzOption($args, $content, $tag) { 49 public static function TzOption($args, $content, $tag) {
31 return TzOption\GetOption($args['key']); 50 if (isset($args['key'])) {
51 return TzOption\GetOption($args['key']);
52 }
32 } 53 }
33 54
34 } 55 }
......
1 <?php
2 namespace Tz\WordPress\Tools\TzOption;
3
4 use Tz\WordPress\Tools;
5
6 print "<pre>";
7 print_r(Vars::$options);
8 print "</pre>";
9
10 ?>
...\ No newline at end of file ...\ No newline at end of file
...@@ -865,7 +865,7 @@ class Actions { ...@@ -865,7 +865,7 @@ class Actions {
865 $timestamp = CEHours\mysqldatetime_to_timestamp($_POST['date']); 865 $timestamp = CEHours\mysqldatetime_to_timestamp($_POST['date']);
866 866
867 if ($_POST['indexed']=="") { 867 if ($_POST['indexed']=="") {
868 $_POST['indexed'] = Sequencer\generate('KCB'); 868 $_POST['indexed'] = Sequencer\generate('CEH');
869 } 869 }
870 870
871 871
......