| @@ -133,9 +133,9 @@ | ||
| 133 | 133 | */ |
| 134 | 134 | function catch_plugin_information_dialog_contents() { |
| 135 | 135 | if ( |
| 136 | 136 | 'plugin-information' !== fs_request_get( 'tab', false ) || |
| 137 | - $this->_fs->get_slug() !== fs_request_get( 'plugin', false ) | |
| 137 | + $this->_fs->get_slug() !== fs_request_get_raw( 'plugin', false ) | |
| 138 | 138 | ) { |
| 139 | 139 | return; |
| 140 | 140 | } |
| 141 | 141 | |
| @@ -152,9 +152,9 @@ | ||
| 152 | 152 | */ |
| 153 | 153 | function edit_and_echo_plugin_information_dialog_contents( $hook_suffix ) { |
| 154 | 154 | if ( |
| 155 | 155 | 'plugin-information' !== fs_request_get( 'tab', false ) || |
| 156 | - $this->_fs->get_slug() !== fs_request_get( 'plugin', false ) | |
| 156 | + $this->_fs->get_slug() !== fs_request_get_raw( 'plugin', false ) | |
| 157 | 157 | ) { |
| 158 | 158 | return; |
| 159 | 159 | } |
| 160 | 160 | |
| @@ -165,17 +165,21 @@ | ||
| 165 | 165 | null; |
| 166 | 166 | |
| 167 | 167 | $contents = ob_get_clean(); |
| 168 | 168 | |
| 169 | - $update_button_id_attribute_pos = strpos( $contents, 'id="plugin_update_from_iframe"' ); | |
| 169 | + $install_or_update_button_id_attribute_pos = strpos( $contents, 'id="plugin_install_from_iframe"' ); | |
| 170 | 170 | |
| 171 | - if ( false !== $update_button_id_attribute_pos ) { | |
| 172 | - $update_button_start_pos = strrpos( | |
| 173 | - substr( $contents, 0, $update_button_id_attribute_pos ), | |
| 171 | + if ( false === $install_or_update_button_id_attribute_pos ) { | |
| 172 | + $install_or_update_button_id_attribute_pos = strpos( $contents, 'id="plugin_update_from_iframe"' ); | |
| 173 | + } | |
| 174 | + | |
| 175 | + if ( false !== $install_or_update_button_id_attribute_pos ) { | |
| 176 | + $install_or_update_button_start_pos = strrpos( | |
| 177 | + substr( $contents, 0, $install_or_update_button_id_attribute_pos ), | |
| 174 | 178 | '<a' |
| 175 | 179 | ); |
| 176 | 180 | |
| 177 | - $update_button_end_pos = ( strpos( $contents, '</a>', $update_button_id_attribute_pos ) + strlen( '</a>' ) ); | |
| 181 | + $install_or_update_button_end_pos = ( strpos( $contents, '</a>', $install_or_update_button_id_attribute_pos ) + strlen( '</a>' ) ); | |
| 178 | 182 | |
| 179 | 183 | /** |
| 180 | 184 | * The part of the contents without the update button. |
| 181 | 185 | * |
| @@ -181,11 +185,11 @@ | ||
| 181 | 185 | * |
| 182 | 186 | * @author Leo Fajardo (@leorw) |
| 183 | 187 | * @since 2.2.5 |
| 184 | 188 | */ |
| 185 | - $modified_contents = substr( $contents, 0, $update_button_start_pos ); | |
| 189 | + $modified_contents = substr( $contents, 0, $install_or_update_button_start_pos ); | |
| 186 | 190 | |
| 187 | - $update_button = substr( $contents, $update_button_start_pos, ( $update_button_end_pos - $update_button_start_pos ) ); | |
| 191 | + $install_or_update_button = substr( $contents, $install_or_update_button_start_pos, ( $install_or_update_button_end_pos - $install_or_update_button_start_pos ) ); | |
| 188 | 192 | |
| 189 | 193 | /** |
| 190 | 194 | * Replace the plugin information dialog's "Install Update Now" button's text and URL. If there's a license, |
| 191 | 195 | * the text will be "Renew license" and will link to the checkout page with the license's billing cycle |
| @@ -190,13 +194,13 @@ | ||
| 190 | 194 | * Replace the plugin information dialog's "Install Update Now" button's text and URL. If there's a license, |
| 191 | 195 | * the text will be "Renew license" and will link to the checkout page with the license's billing cycle |
| 192 | 196 | * and quota. If there's no license, the text will be "Buy license" and will link to the pricing page. |
| 193 | 197 | */ |
| 194 | - $update_button = preg_replace( | |
| 195 | - '/(\<a.+)(id="plugin_update_from_iframe")(.+href=")([^\s]+)(".*\>)(.+)(\<\/a>)/is', | |
| 198 | + $install_or_update_button = preg_replace( | |
| 199 | + '/(\<a.+)(id="plugin_(install|update)_from_iframe")(.+href=")([^\s]+)(".*\>)(.+)(\<\/a>)/is', | |
| 196 | 200 | is_object( $license ) ? |
| 197 | 201 | sprintf( |
| 198 | - '$1$3%s$5%s$7', | |
| 202 | + '$1$4%s$6%s$8', | |
| 199 | 203 | $this->_fs->checkout_url( |
| 200 | 204 | is_object( $subscription ) ? |
| 201 | 205 | ( 1 == $subscription->billing_cycle ? WP_FS__PERIOD_MONTHLY : WP_FS__PERIOD_ANNUALLY ) : |
| 202 | 206 | WP_FS__PERIOD_LIFETIME, |
| @@ -205,13 +209,13 @@ | ||
| 205 | 209 | ), |
| 206 | 210 | fs_text_inline( 'Renew license', 'renew-license', $this->_fs->get_slug() ) |
| 207 | 211 | ) : |
| 208 | 212 | sprintf( |
| 209 | - '$1$3%s$5%s$7', | |
| 213 | + '$1$4%s$6%s$8', | |
| 210 | 214 | $this->_fs->pricing_url(), |
| 211 | 215 | fs_text_inline( 'Buy license', 'buy-license', $this->_fs->get_slug() ) |
| 212 | 216 | ), |
| 213 | - $update_button | |
| 217 | + $install_or_update_button | |
| 214 | 218 | ); |
| 215 | 219 | |
| 216 | 220 | /** |
| 217 | 221 | * Append the modified button. |
| @@ -218,9 +222,9 @@ | ||
| 218 | 222 | * |
| 219 | 223 | * @author Leo Fajardo (@leorw) |
| 220 | 224 | * @since 2.2.5 |
| 221 | 225 | */ |
| 222 | - $modified_contents .= $update_button; | |
| 226 | + $modified_contents .= $install_or_update_button; | |
| 223 | 227 | |
| 224 | 228 | /** |
| 225 | 229 | * Append the remaining part of the contents after the update button. |
| 226 | 230 | * |
| @@ -226,9 +230,9 @@ | ||
| 226 | 230 | * |
| 227 | 231 | * @author Leo Fajardo (@leorw) |
| 228 | 232 | * @since 2.2.5 |
| 229 | 233 | */ |
| 230 | - $modified_contents .= substr( $contents, $update_button_end_pos ); | |
| 234 | + $modified_contents .= substr( $contents, $install_or_update_button_end_pos ); | |
| 231 | 235 | |
| 232 | 236 | $contents = $modified_contents; |
| 233 | 237 | } |
| 234 | 238 | |
| @@ -837,30 +841,36 @@ | ||
| 837 | 841 | * |
| 838 | 842 | * @return bool|mixed |
| 839 | 843 | */ |
| 840 | 844 | static function _fetch_plugin_info_from_repository( $action, $args ) { |
| 841 | - $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; | |
| 842 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { | |
| 845 | + $url = $http_url = 'http://api.wordpress.org/plugins/info/1.2/'; | |
| 846 | + $url = add_query_arg( | |
| 847 | + array( | |
| 848 | + 'action' => $action, | |
| 849 | + 'request' => $args, | |
| 850 | + ), | |
| 851 | + $url | |
| 852 | + ); | |
| 853 | + | |
| 854 | + if ( wp_http_supports( array( 'ssl' ) ) ) { | |
| 843 | 855 | $url = set_url_scheme( $url, 'https' ); |
| 844 | 856 | } |
| 845 | 857 | |
| 846 | - $args = array( | |
| 847 | - 'timeout' => 15, | |
| 848 | - 'body' => array( | |
| 849 | - 'action' => $action, | |
| 850 | - 'request' => serialize( $args ) | |
| 851 | - ) | |
| 852 | - ); | |
| 858 | + // The new endpoint version serves only GET requests. | |
| 859 | + $request = wp_remote_get( $url, array( 'timeout' => 15 ) ); | |
| 853 | 860 | |
| 854 | - $request = wp_remote_post( $url, $args ); | |
| 855 | - | |
| 856 | 861 | if ( is_wp_error( $request ) ) { |
| 857 | 862 | return false; |
| 858 | 863 | } |
| 859 | 864 | |
| 860 | - $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); | |
| 865 | + $res = json_decode( wp_remote_retrieve_body( $request ), true ); | |
| 861 | 866 | |
| 862 | - if ( ! is_object( $res ) && ! is_array( $res ) ) { | |
| 867 | + if ( is_array( $res ) ) { | |
| 868 | + // Object casting is required in order to match the info/1.0 format. We are not decoding directly into an object as we need some fields to remain an array (e.g., $res->sections). | |
| 869 | + $res = (object) $res; | |
| 870 | + } | |
| 871 | + | |
| 872 | + if ( ! is_object( $res ) || isset( $res->error ) ) { | |
| 863 | 873 | return false; |
| 864 | 874 | } |
| 865 | 875 | |
| 866 | 876 | return $res; |