@@ -1,3 +1,3 @@ |
||
| 1 | 1 | <div class="notice notice-info is-dismissible glsr-notice" data-dismiss="welcome"> |
| 2 | - <p>Thanks for upgrading to Site Reviews v<?= glsr()->version; ?>, we hope you love it! — <a class="button button-small" href="<?= admin_url('edit.php?post_type='.glsr()->post_type.'&page=welcome'); ?>">See what's new</a></p> |
|
| 2 | + <p>Thanks for upgrading to Site Reviews v<?= glsr()->version; ?>, we hope you love it! — <a class="button button-small" href="<?= admin_url( 'edit.php?post_type='.glsr()->post_type.'&page=welcome' ); ?>">See what's new</a></p> |
|
| 3 | 3 | </div> |
@@ -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 | } |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | public function filterAdminNotices() |
| 18 | 18 | { |
| 19 | 19 | $screen = glsr_current_screen(); |
| 20 | - $this->renderWelcomeNotice($screen->post_type); |
|
| 21 | - $this->renderRebusifyNotice($screen->post_type); |
|
| 22 | - $this->renderAddonsNotice($screen->id); |
|
| 20 | + $this->renderWelcomeNotice( $screen->post_type ); |
|
| 21 | + $this->renderRebusifyNotice( $screen->post_type ); |
|
| 22 | + $this->renderAddonsNotice( $screen->id ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | - public function routerDismissNotice(array $request) |
|
| 28 | + public function routerDismissNotice( array $request ) |
|
| 29 | 29 | { |
| 30 | - if ($key = glsr_get($request, 'notice')) { |
|
| 31 | - $this->dismissNotice($key); |
|
| 30 | + if( $key = glsr_get( $request, 'notice' ) ) { |
|
| 31 | + $this->dismissNotice( $key ); |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * @param string $key |
| 37 | 37 | * @return void |
| 38 | 38 | */ |
| 39 | - protected function dismissNotice($key) |
|
| 39 | + protected function dismissNotice( $key ) |
|
| 40 | 40 | { |
| 41 | - $this->setUserMeta($key, glsr()->version('major')); |
|
| 41 | + $this->setUserMeta( $key, glsr()->version( 'major' ) ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -46,20 +46,20 @@ discard block |
||
| 46 | 46 | * @param mixed $fallback |
| 47 | 47 | * @return mixed |
| 48 | 48 | */ |
| 49 | - protected function getUserMeta($key, $fallback) |
|
| 49 | + protected function getUserMeta( $key, $fallback ) |
|
| 50 | 50 | { |
| 51 | - $meta = get_user_meta(get_current_user_id(), static::USER_META_KEY, true); |
|
| 52 | - return glsr_get($meta, $key, $fallback); |
|
| 51 | + $meta = get_user_meta( get_current_user_id(), static::USER_META_KEY, true ); |
|
| 52 | + return glsr_get( $meta, $key, $fallback ); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @param string $screenId |
| 57 | 57 | * @return void |
| 58 | 58 | */ |
| 59 | - protected function renderAddonsNotice($screenId) |
|
| 59 | + protected function renderAddonsNotice( $screenId ) |
|
| 60 | 60 | { |
| 61 | - if (Application::POST_TYPE.'_page_addons' == $screenId) { |
|
| 62 | - echo glsr()->render('partials/notices/addons'); |
|
| 61 | + if( Application::POST_TYPE.'_page_addons' == $screenId ) { |
|
| 62 | + echo glsr()->render( 'partials/notices/addons' ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | * @param string $screenPostType |
| 68 | 68 | * @return void |
| 69 | 69 | */ |
| 70 | - protected function renderRebusifyNotice($screenPostType) |
|
| 70 | + protected function renderRebusifyNotice( $screenPostType ) |
|
| 71 | 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'); |
|
| 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 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -80,11 +80,11 @@ discard block |
||
| 80 | 80 | * @param string $screenPostType |
| 81 | 81 | * @return void |
| 82 | 82 | */ |
| 83 | - protected function renderWelcomeNotice($screenPostType) |
|
| 83 | + protected function renderWelcomeNotice( $screenPostType ) |
|
| 84 | 84 | { |
| 85 | - if (Application::POST_TYPE == $screenPostType |
|
| 86 | - && version_compare(glsr()->version('major'), $this->getUserMeta('welcome', 0), '>')) { |
|
| 87 | - echo glsr()->render('partials/notices/welcome'); |
|
| 85 | + if( Application::POST_TYPE == $screenPostType |
|
| 86 | + && version_compare( glsr()->version( 'major' ), $this->getUserMeta( 'welcome', 0 ), '>' ) ) { |
|
| 87 | + echo glsr()->render( 'partials/notices/welcome' ); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | |
@@ -93,12 +93,12 @@ discard block |
||
| 93 | 93 | * @param mixed $fallback |
| 94 | 94 | * @return mixed |
| 95 | 95 | */ |
| 96 | - protected function setUserMeta($key, $value) |
|
| 96 | + protected function setUserMeta( $key, $value ) |
|
| 97 | 97 | { |
| 98 | 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, [])); |
|
| 99 | + $meta = (array)get_user_meta( $userId, static::USER_META_KEY, true ); |
|
| 100 | + $meta = array_filter( wp_parse_args( $meta, [] ) ); |
|
| 101 | 101 | $meta[$key] = $value; |
| 102 | - update_user_meta($userId, static::USER_META_KEY, $meta); |
|
| 102 | + update_user_meta( $userId, static::USER_META_KEY, $meta ); |
|
| 103 | 103 | } |
| 104 | 104 | } |