Added home button to branding; fixed PagePermission issue on Media. fixes #556, fixes #534
Showing
5 changed files
with
33 additions
and
46 deletions
| ... | @@ -8,6 +8,8 @@ | ... | @@ -8,6 +8,8 @@ |
| 8 | } else { | 8 | } else { |
| 9 | echo($current_user->user_login); | 9 | echo($current_user->user_login); |
| 10 | } | 10 | } |
| 11 | ?></a> | <a href="<?php echo wp_logout_url(); ?>">Log Out</a> | 11 | ?></a> |
| 12 | | <a href="<?php echo get_settings('siteurl');?>">Home</a> | ||
| 13 | | <a href="<?php echo _logout_url(); ?>">Log Out</a> | ||
| 12 | </div> | 14 | </div> |
| 13 | </div> | 15 | </div> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -70,7 +70,7 @@ class PagePermissions { | ... | @@ -70,7 +70,7 @@ class PagePermissions { |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | // Meta value hasn't been set, getting settings defaults | 72 | // Meta value hasn't been set, getting settings defaults |
| 73 | if ('' === $data = get_custom_data(self::META, $post_id)) { | 73 | if ('' === $data = array_shift(get_post_meta($post_id, self::META))) { |
| 74 | $data = Array(self::ELE_SEL => $settings[self::ELE_SEL], self::ELE_CUST => $settings[self::ELE_CUST]); | 74 | $data = Array(self::ELE_SEL => $settings[self::ELE_SEL], self::ELE_CUST => $settings[self::ELE_CUST]); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| ... | @@ -201,7 +201,7 @@ class PagePermissionsAdmin { | ... | @@ -201,7 +201,7 @@ class PagePermissionsAdmin { |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | public static function viewMetaBox($post, $box_info) { | 203 | public static function viewMetaBox($post, $box_info) { |
| 204 | $selected = ($post->ID == 0 ? self::getOptions() : get_custom_data(PagePermissions::META, $post->ID)); | 204 | $selected = ($post->ID == 0 ? self::getOptions() : array_shift(get_post_meta($post->ID, PagePermissions::META))); |
| 205 | 205 | ||
| 206 | // If the post doesn't have the field saved get defaults | 206 | // If the post doesn't have the field saved get defaults |
| 207 | if (empty($selected)) { | 207 | if (empty($selected)) { |
| ... | @@ -262,6 +262,27 @@ class PagePermissions_Actions { | ... | @@ -262,6 +262,27 @@ class PagePermissions_Actions { |
| 262 | if ($file == '/wp-admin/media-new.php' && !PagePermissions::is_admin()) { | 262 | if ($file == '/wp-admin/media-new.php' && !PagePermissions::is_admin()) { |
| 263 | header("Location: " . $file . "?flash=0"); | 263 | header("Location: " . $file . "?flash=0"); |
| 264 | } | 264 | } |
| 265 | |||
| 266 | // This is hackey, but WP does't have hooks for this for some reason... | ||
| 267 | // Ideally this is in its own `edit_attachment` method...but that isn't working | ||
| 268 | if (isset($_POST['action']) && $_POST['action'] == 'editattachment') { | ||
| 269 | $real_id = $_POST['attachment_id']; | ||
| 270 | $current = array_shift(get_post_meta($real_id, PagePermissions::META)); | ||
| 271 | |||
| 272 | $new = Array(); | ||
| 273 | $new[PagePermissions::ELE_SEL] = $_POST[PagePermissions::ELE_SEL]; | ||
| 274 | if (isset($_POST[PagePermissions::ELE_CUST])) { | ||
| 275 | $new[PagePermissions::ELE_CUST] = $_POST[PagePermissions::ELE_CUST]; | ||
| 276 | } else { | ||
| 277 | $new[PagePermissions::ELE_CUST] = Array(); | ||
| 278 | } | ||
| 279 | |||
| 280 | if (empty($current)) { | ||
| 281 | add_post_meta($real_id, PagePermissions::META, $new, true); | ||
| 282 | } else { | ||
| 283 | update_post_meta($real_id, PagePermissions::META, $new); | ||
| 284 | } | ||
| 285 | } | ||
| 265 | } | 286 | } |
| 266 | 287 | ||
| 267 | public static function admin_menu() { | 288 | public static function admin_menu() { |
| ... | @@ -274,7 +295,7 @@ class PagePermissions_Actions { | ... | @@ -274,7 +295,7 @@ class PagePermissions_Actions { |
| 274 | public static function admin_print_scripts() { | 295 | public static function admin_print_scripts() { |
| 275 | $innerhtml = ''; | 296 | $innerhtml = ''; |
| 276 | if ('0' !== ($change_field = (isset($_GET['attachment_id']) ? 'attachments[' . $_GET['attachment_id'] . '][' . PagePermissions::META . ']' : '0'))) { | 297 | if ('0' !== ($change_field = (isset($_GET['attachment_id']) ? 'attachments[' . $_GET['attachment_id'] . '][' . PagePermissions::META . ']' : '0'))) { |
| 277 | $selected = get_custom_data(PagePermissions::META, $_GET['attachment_id']); | 298 | $selected = array_shift(get_post_meta($_GET['attachment_id'], PagePermissions::META)); |
| 278 | if (empty($selected)) { | 299 | if (empty($selected)) { |
| 279 | $selected = PagePermissionsAdmin::getOptions(); | 300 | $selected = PagePermissionsAdmin::getOptions(); |
| 280 | } | 301 | } |
| ... | @@ -292,9 +313,6 @@ class PagePermissions_Actions { | ... | @@ -292,9 +313,6 @@ class PagePermissions_Actions { |
| 292 | , 'change_field' => $change_field | 313 | , 'change_field' => $change_field |
| 293 | , 'innerHTML' => rawurlencode($innerhtml) | 314 | , 'innerHTML' => rawurlencode($innerhtml) |
| 294 | )); | 315 | )); |
| 295 | |||
| 296 | //attachments[304][accessible_to_roles] | ||
| 297 | //a:2:{s:14:"general_access";s:1:"1";s:5:"roles";a:1:{s:6:"editor";s:1:"1";}} | ||
| 298 | } | 316 | } |
| 299 | 317 | ||
| 300 | public static function save_post($post_id) { | 318 | public static function save_post($post_id) { |
| ... | @@ -305,7 +323,7 @@ class PagePermissions_Actions { | ... | @@ -305,7 +323,7 @@ class PagePermissions_Actions { |
| 305 | if (false === ($real_id = _is_post_revision($post_id))) { | 323 | if (false === ($real_id = _is_post_revision($post_id))) { |
| 306 | $real_id = $post_id; | 324 | $real_id = $post_id; |
| 307 | } | 325 | } |
| 308 | $current = get_custom_data(PagePermissions::META, $real_id); | 326 | $current = array_shift(get_post_meta($real_id, PagePermissions::META)); |
| 309 | 327 | ||
| 310 | $new = Array(); | 328 | $new = Array(); |
| 311 | $new[PagePermissions::ELE_SEL] = $_POST[PagePermissions::ELE_SEL]; | 329 | $new[PagePermissions::ELE_SEL] = $_POST[PagePermissions::ELE_SEL]; | ... | ... |
| ... | @@ -74,42 +74,4 @@ function add_filters($class) { | ... | @@ -74,42 +74,4 @@ function add_filters($class) { |
| 74 | add_filter($method->name, Array($class, $method->name)); | 74 | add_filter($method->name, Array($class, $method->name)); |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | |||
| 78 | function get_custom_data($name, $post_id = false) { | ||
| 79 | if (false === $type = get_post_type($post_id)) { | ||
| 80 | throw new InvalidArgumentException("Post {$post_id} does not exist"); | ||
| 81 | } | ||
| 82 | |||
| 83 | $raw_data = call_user_func_array("_custom_{$type}", Array($post_id, $name)); | ||
| 84 | |||
| 85 | if (null === $raw_data) { | ||
| 86 | return ''; | ||
| 87 | } | ||
| 88 | |||
| 89 | return $raw_data; | ||
| 90 | } | ||
| 91 | |||
| 92 | function _custom_attachment($post_id, $custom_name) { | ||
| 93 | if (false === ($tax_object = get_the_terms($post_id, $custom_name))) { | ||
| 94 | return ''; | ||
| 95 | } | ||
| 96 | $tax_data = array_shift($tax_object); | ||
| 97 | |||
| 98 | return $tax_data->name; | ||
| 99 | } | ||
| 100 | |||
| 101 | function _custom_page($post_id, $custom_name) { | ||
| 102 | $custom = get_post_meta($post_id, $custom_name); | ||
| 103 | return array_shift($custom); | ||
| 104 | } | ||
| 105 | |||
| 106 | function _custom_post() { | ||
| 107 | $args = func_get_args(); | ||
| 108 | return call_user_func_array('_custom_page', $args); | ||
| 109 | } | ||
| 110 | |||
| 111 | function _custom_revision() { | ||
| 112 | $args = func_get_args(); | ||
| 113 | return call_user_func_array('_custom_page', $args); | ||
| 114 | } | ||
| 115 | ?> | 77 | ?> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -154,4 +154,9 @@ function _make_link_relative() { | ... | @@ -154,4 +154,9 @@ function _make_link_relative() { |
| 154 | $params = func_get_args(); | 154 | $params = func_get_args(); |
| 155 | return call_user_func_array('wp' . __FUNCTION__, $params); | 155 | return call_user_func_array('wp' . __FUNCTION__, $params); |
| 156 | } | 156 | } |
| 157 | |||
| 158 | function _logout_url() { | ||
| 159 | $params = func_get_args(); | ||
| 160 | return call_user_func_array('wp' . __FUNCTION__, $params); | ||
| 161 | } | ||
| 157 | ?> | 162 | ?> | ... | ... |
-
Please register or sign in to post a comment