@@ -8,97 +8,97 @@ |
||
| 8 | 8 | |
| 9 | 9 | class NoticeController extends Controller |
| 10 | 10 | { |
| 11 | - const USER_META_KEY = '_glsr_notices'; |
|
| 11 | + const USER_META_KEY = '_glsr_notices'; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * @return void |
|
| 15 | - * @action admin_notices |
|
| 16 | - */ |
|
| 17 | - public function filterAdminNotices() |
|
| 18 | - { |
|
| 19 | - $screen = glsr_current_screen(); |
|
| 20 | - $this->renderWelcomeNotice($screen->post_type); |
|
| 21 | - $this->renderRebusifyNotice($screen->post_type); |
|
| 22 | - $this->renderAddonsNotice($screen->id); |
|
| 23 | - } |
|
| 13 | + /** |
|
| 14 | + * @return void |
|
| 15 | + * @action admin_notices |
|
| 16 | + */ |
|
| 17 | + public function filterAdminNotices() |
|
| 18 | + { |
|
| 19 | + $screen = glsr_current_screen(); |
|
| 20 | + $this->renderWelcomeNotice($screen->post_type); |
|
| 21 | + $this->renderRebusifyNotice($screen->post_type); |
|
| 22 | + $this->renderAddonsNotice($screen->id); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @return void |
|
| 27 | - */ |
|
| 28 | - public function routerDismissNotice(array $request) |
|
| 29 | - { |
|
| 30 | - if ($key = glsr_get($request, 'notice')) { |
|
| 31 | - $this->dismissNotice($key); |
|
| 32 | - } |
|
| 33 | - } |
|
| 25 | + /** |
|
| 26 | + * @return void |
|
| 27 | + */ |
|
| 28 | + public function routerDismissNotice(array $request) |
|
| 29 | + { |
|
| 30 | + if ($key = glsr_get($request, 'notice')) { |
|
| 31 | + $this->dismissNotice($key); |
|
| 32 | + } |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param string $key |
|
| 37 | - * @return void |
|
| 38 | - */ |
|
| 39 | - protected function dismissNotice($key) |
|
| 40 | - { |
|
| 41 | - $this->setUserMeta($key, glsr()->version('major')); |
|
| 42 | - } |
|
| 35 | + /** |
|
| 36 | + * @param string $key |
|
| 37 | + * @return void |
|
| 38 | + */ |
|
| 39 | + protected function dismissNotice($key) |
|
| 40 | + { |
|
| 41 | + $this->setUserMeta($key, glsr()->version('major')); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @param string $key |
|
| 46 | - * @param mixed $fallback |
|
| 47 | - * @return mixed |
|
| 48 | - */ |
|
| 49 | - protected function getUserMeta($key, $fallback) |
|
| 50 | - { |
|
| 51 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
| 52 | - return glsr_get($meta, $key, $fallback); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * @param string $key |
|
| 46 | + * @param mixed $fallback |
|
| 47 | + * @return mixed |
|
| 48 | + */ |
|
| 49 | + protected function getUserMeta($key, $fallback) |
|
| 50 | + { |
|
| 51 | + $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
| 52 | + return glsr_get($meta, $key, $fallback); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param string $screenId |
|
| 57 | - * @return void |
|
| 58 | - */ |
|
| 59 | - protected function renderAddonsNotice($screenId) |
|
| 60 | - { |
|
| 61 | - if (Application::POST_TYPE.'_page_addons' == $screenId) { |
|
| 62 | - echo glsr()->render('partials/notices/addons'); |
|
| 63 | - } |
|
| 64 | - } |
|
| 55 | + /** |
|
| 56 | + * @param string $screenId |
|
| 57 | + * @return void |
|
| 58 | + */ |
|
| 59 | + protected function renderAddonsNotice($screenId) |
|
| 60 | + { |
|
| 61 | + if (Application::POST_TYPE.'_page_addons' == $screenId) { |
|
| 62 | + echo glsr()->render('partials/notices/addons'); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * @param string $screenPostType |
|
| 68 | - * @return void |
|
| 69 | - */ |
|
| 70 | - protected function renderRebusifyNotice($screenPostType) |
|
| 71 | - { |
|
| 72 | - if (Application::POST_TYPE == $screenPostType |
|
| 73 | - && version_compare(glsr()->version('major'), $this->getUserMeta('rebusify', 0), '>') |
|
| 74 | - && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) { |
|
| 75 | - echo glsr()->render('partials/notices/rebusify'); |
|
| 76 | - } |
|
| 77 | - } |
|
| 66 | + /** |
|
| 67 | + * @param string $screenPostType |
|
| 68 | + * @return void |
|
| 69 | + */ |
|
| 70 | + protected function renderRebusifyNotice($screenPostType) |
|
| 71 | + { |
|
| 72 | + if (Application::POST_TYPE == $screenPostType |
|
| 73 | + && version_compare(glsr()->version('major'), $this->getUserMeta('rebusify', 0), '>') |
|
| 74 | + && !glsr(OptionManager::class)->getBool('settings.general.rebusify')) { |
|
| 75 | + echo glsr()->render('partials/notices/rebusify'); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @param string $screenPostType |
|
| 81 | - * @return void |
|
| 82 | - */ |
|
| 83 | - protected function renderWelcomeNotice($screenPostType) |
|
| 84 | - { |
|
| 85 | - if (Application::POST_TYPE == $screenPostType |
|
| 86 | - && version_compare(glsr()->version('major'), $this->getUserMeta('welcome', 0), '>')) { |
|
| 87 | - echo glsr()->render('partials/notices/welcome'); |
|
| 88 | - } |
|
| 89 | - } |
|
| 79 | + /** |
|
| 80 | + * @param string $screenPostType |
|
| 81 | + * @return void |
|
| 82 | + */ |
|
| 83 | + protected function renderWelcomeNotice($screenPostType) |
|
| 84 | + { |
|
| 85 | + if (Application::POST_TYPE == $screenPostType |
|
| 86 | + && version_compare(glsr()->version('major'), $this->getUserMeta('welcome', 0), '>')) { |
|
| 87 | + echo glsr()->render('partials/notices/welcome'); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @param string $key |
|
| 93 | - * @param mixed $fallback |
|
| 94 | - * @return mixed |
|
| 95 | - */ |
|
| 96 | - protected function setUserMeta($key, $value) |
|
| 97 | - { |
|
| 98 | - $userId = get_current_user_id(); |
|
| 99 | - $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
| 100 | - $meta = array_filter(wp_parse_args($meta, [])); |
|
| 101 | - $meta[$key] = $value; |
|
| 102 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
| 103 | - } |
|
| 91 | + /** |
|
| 92 | + * @param string $key |
|
| 93 | + * @param mixed $fallback |
|
| 94 | + * @return mixed |
|
| 95 | + */ |
|
| 96 | + protected function setUserMeta($key, $value) |
|
| 97 | + { |
|
| 98 | + $userId = get_current_user_id(); |
|
| 99 | + $meta = (array) get_user_meta($userId, static::USER_META_KEY, true); |
|
| 100 | + $meta = array_filter(wp_parse_args($meta, [])); |
|
| 101 | + $meta[$key] = $value; |
|
| 102 | + update_user_meta($userId, static::USER_META_KEY, $meta); |
|
| 103 | + } |
|
| 104 | 104 | } |