← All changes
|
src/integrations/admin/addon-installation/installation-integration.php
+17
-8
18.6
→
trunk
View file →
| @@ -15,8 +15,9 @@ | ||
| 15 | 15 | use Yoast\WP\SEO\Exceptions\Addon_Installation\Addon_Installation_Error_Exception; |
| 16 | 16 | use Yoast\WP\SEO\Exceptions\Addon_Installation\User_Cannot_Activate_Plugins_Exception; |
| 17 | 17 | use Yoast\WP\SEO\Exceptions\Addon_Installation\User_Cannot_Install_Plugins_Exception; |
| 18 | 18 | use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 19 | +use Yoast\WP\SEO\Plans\User_Interface\Plans_Page_Integration; | |
| 19 | 20 | |
| 20 | 21 | /** |
| 21 | 22 | * Represents the Addon installation feature. |
| 22 | 23 | */ |
| @@ -72,8 +73,10 @@ | ||
| 72 | 73 | } |
| 73 | 74 | |
| 74 | 75 | /** |
| 75 | 76 | * Registers all hooks to WordPress. |
| 77 | + * | |
| 78 | + * @return void | |
| 76 | 79 | */ |
| 77 | 80 | public function register_hooks() { |
| 78 | 81 | \add_action( 'wpseo_install_and_activate_addons', [ $this, 'install_and_activate_addons' ] ); |
| 79 | 82 | } |
| @@ -83,12 +86,18 @@ | ||
| 83 | 86 | * |
| 84 | 87 | * @return void |
| 85 | 88 | */ |
| 86 | 89 | public function install_and_activate_addons() { |
| 87 | - if ( \filter_input( \INPUT_GET, 'action' ) !== 'install' ) { | |
| 90 | + if ( ! isset( $_GET['action'] ) || ! \is_string( $_GET['action'] ) ) { | |
| 88 | 91 | return; |
| 89 | 92 | } |
| 90 | 93 | |
| 94 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only strictly comparing action below. | |
| 95 | + $action = \wp_unslash( $_GET['action'] ); | |
| 96 | + if ( $action !== 'install' ) { | |
| 97 | + return; | |
| 98 | + } | |
| 99 | + | |
| 91 | 100 | \check_admin_referer( 'wpseo_addon_installation', 'nonce' ); |
| 92 | 101 | |
| 93 | 102 | echo '<div class="wrap yoast wpseo_table_page">'; |
| 94 | 103 | |
| @@ -93,9 +102,9 @@ | ||
| 93 | 102 | echo '<div class="wrap yoast wpseo_table_page">'; |
| 94 | 103 | |
| 95 | 104 | \printf( |
| 96 | 105 | '<h1 id="wpseo-title" class="yoast-h1">%s</h1>', |
| 97 | - \esc_html__( 'Installing and activating addons', 'wordpress-seo' ) | |
| 106 | + \esc_html__( 'Installing and activating addons', 'wordpress-seo' ), | |
| 98 | 107 | ); |
| 99 | 108 | |
| 100 | 109 | $licensed_addons = $this->addon_manager->get_myyoast_site_information()->subscriptions; |
| 101 | 110 | |
| @@ -101,9 +110,9 @@ | ||
| 101 | 110 | |
| 102 | 111 | foreach ( $licensed_addons as $addon ) { |
| 103 | 112 | \printf( '<p><strong>%s</strong></p>', \esc_html( $addon->product->name ) ); |
| 104 | 113 | |
| 105 | - list( $installed, $output ) = $this->install_addon( $addon->product->slug, $addon->product->download ); | |
| 114 | + [ $installed, $output ] = $this->install_addon( $addon->product->slug, $addon->product->download ); | |
| 106 | 115 | |
| 107 | 116 | if ( $installed ) { |
| 108 | 117 | $activation_output = $this->activate_addon( $addon->product->slug ); |
| 109 | 118 | |
| @@ -117,16 +126,16 @@ | ||
| 117 | 126 | |
| 118 | 127 | \printf( |
| 119 | 128 | /* translators: %1$s expands to an anchor tag to the admin premium page, %2$s expands to Yoast SEO Premium, %3$s expands to a closing anchor tag */ |
| 120 | 129 | \esc_html__( '%1$s Continue to %2$s%3$s', 'wordpress-seo' ), |
| 121 | - '<a href="' . \esc_url( \admin_url( 'admin.php?page=wpseo_licenses' ) ) . '">', | |
| 130 | + '<a href="' . \esc_url( \admin_url( 'admin.php?page=' . Plans_Page_Integration::PAGE ) ) . '">', | |
| 122 | 131 | 'Yoast SEO Premium', |
| 123 | - '</a>' | |
| 132 | + '</a>', | |
| 124 | 133 | ); |
| 125 | 134 | |
| 126 | 135 | echo '</div>'; |
| 127 | 136 | |
| 128 | - exit; | |
| 137 | + exit(); | |
| 129 | 138 | } |
| 130 | 139 | |
| 131 | 140 | /** |
| 132 | 141 | * Activates an addon. |
| @@ -148,9 +157,9 @@ | ||
| 148 | 157 | } catch ( Addon_Activation_Error_Exception $exception ) { |
| 149 | 158 | $output[] = \sprintf( |
| 150 | 159 | /* Translators:%s expands to the error message. */ |
| 151 | 160 | \__( 'Addon activation failed because of an error: %s.', 'wordpress-seo' ), |
| 152 | - $exception->getMessage() | |
| 161 | + $exception->getMessage(), | |
| 153 | 162 | ); |
| 154 | 163 | } |
| 155 | 164 | |
| 156 | 165 | return $output; |
| @@ -180,9 +189,9 @@ | ||
| 180 | 189 | } catch ( Addon_Installation_Error_Exception $exception ) { |
| 181 | 190 | $output[] = \sprintf( |
| 182 | 191 | /* Translators: %s expands to the error message. */ |
| 183 | 192 | \__( 'Addon installation failed because of an error: %s.', 'wordpress-seo' ), |
| 184 | - $exception->getMessage() | |
| 193 | + $exception->getMessage(), | |
| 185 | 194 | ); |
| 186 | 195 | } |
| 187 | 196 | |
| 188 | 197 | return [ $installed, $output ]; |