| @@ -26,12 +26,9 @@ | ||
| 26 | 26 | * |
| 27 | 27 | * @param Options_Helper $options_helper The options helper. |
| 28 | 28 | * @param Product_Helper $product_helper The product helper. |
| 29 | 29 | */ |
| 30 | - public function __construct( | |
| 31 | - Options_Helper $options_helper, | |
| 32 | - Product_Helper $product_helper | |
| 33 | - ) { | |
| 30 | + public function __construct( Options_Helper $options_helper, Product_Helper $product_helper ) { | |
| 34 | 31 | $this->options_helper = $options_helper; |
| 35 | 32 | $this->product_helper = $product_helper; |
| 36 | 33 | } |
| 37 | 34 | |
| @@ -60,8 +57,10 @@ | ||
| 60 | 57 | /** |
| 61 | 58 | * Echoes a version of the URL with a utm_content with the current version. |
| 62 | 59 | * |
| 63 | 60 | * @param string $url The URL to build upon. |
| 61 | + * | |
| 62 | + * @return void | |
| 64 | 63 | */ |
| 65 | 64 | public function show( $url ) { |
| 66 | 65 | echo \esc_url( $this->get( $url ) ); |
| 67 | 66 | } |
| @@ -100,9 +99,9 @@ | ||
| 100 | 99 | * |
| 101 | 100 | * @return array The shortlink data. |
| 102 | 101 | */ |
| 103 | 102 | protected function collect_additional_shortlink_data() { |
| 104 | - return [ | |
| 103 | + $data = [ | |
| 105 | 104 | 'php_version' => $this->get_php_version(), |
| 106 | 105 | 'platform' => 'wordpress', |
| 107 | 106 | 'platform_version' => $this->get_platform_version(), |
| 108 | 107 | 'software' => $this->get_software(), |
| @@ -109,8 +108,19 @@ | ||
| 109 | 108 | 'software_version' => \WPSEO_VERSION, |
| 110 | 109 | 'days_active' => $this->get_days_active(), |
| 111 | 110 | 'user_language' => \get_user_locale(), |
| 112 | 111 | ]; |
| 112 | + | |
| 113 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. | |
| 114 | + if ( isset( $_GET['page'] ) && \is_string( $_GET['page'] ) ) { | |
| 115 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. | |
| 116 | + $admin_page = \sanitize_text_field( \wp_unslash( $_GET['page'] ) ); | |
| 117 | + if ( ! empty( $admin_page ) ) { | |
| 118 | + $data['screen'] = $admin_page; | |
| 119 | + } | |
| 120 | + } | |
| 121 | + | |
| 122 | + return $data; | |
| 113 | 123 | } |
| 114 | 124 | |
| 115 | 125 | /** |
| 116 | 126 | * Get our software and whether it's active or not. |
| @@ -132,22 +142,8 @@ | ||
| 132 | 142 | */ |
| 133 | 143 | protected function get_days_active() { |
| 134 | 144 | $date_activated = $this->options_helper->get( 'first_activated_on' ); |
| 135 | 145 | $datediff = ( \time() - $date_activated ); |
| 136 | - $days = (int) \round( $datediff / \DAY_IN_SECONDS ); | |
| 137 | - switch ( $days ) { | |
| 138 | - case 0: | |
| 139 | - case 1: | |
| 140 | - $cohort = '0-1'; | |
| 141 | - break; | |
| 142 | - case ( $days < 5 ): | |
| 143 | - $cohort = '2-5'; | |
| 144 | - break; | |
| 145 | - case ( $days < 30 ): | |
| 146 | - $cohort = '6-30'; | |
| 147 | - break; | |
| 148 | - default: | |
| 149 | - $cohort = '30plus'; | |
| 150 | - } | |
| 151 | - return $cohort; | |
| 146 | + | |
| 147 | + return (int) \round( $datediff / \DAY_IN_SECONDS ); | |
| 152 | 148 | } |
| 153 | 149 | } |