Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix activation link in extensions page #512

Merged
merged 3 commits into from
May 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions includes/extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}

return self::$instance;
}

Expand Down Expand Up @@ -134,9 +135,8 @@ function filter_plugin_api_info( $false, $action, $args ) {
return $false;
} elseif ( 'plugin_information' == $action && empty( $false ) ) {
/** @internal The querying the api using the filter endpoint doesn't seem to work. For now I'm looping through all the extensions to get the api info for using WordPress install api */
$site = esc_url_raw( parse_url( get_option( 'siteurl' ), PHP_URL_HOST ) );
$license = get_site_option( WP_Stream_Updater::LICENSE_KEY );

$site = esc_url_raw( parse_url( get_option( 'siteurl' ), PHP_URL_HOST ) );
$license = get_site_option( WP_Stream_Updater::LICENSE_KEY );
$join_url = self::API_TRANSPORT . self::API_DOMAIN . '/join/' . $this->get_affiliate();

foreach ( $this->get_extension_data() as $extension ) {
Expand Down Expand Up @@ -203,11 +203,13 @@ private function verify_membership() {
*/
function get_plugin_paths() {
$plugin_paths = array();

foreach ( get_plugins() as $path => $data ) {
if ( isset( $data['TextDomain'] ) && ! empty( $data['TextDomain'] ) ) {
$plugin_paths[ $data['TextDomain'] ] = $path;
}
}

return $plugin_paths;
}

Expand Down Expand Up @@ -291,7 +293,7 @@ function extensions_display_body( $extensions ) {
$image_src = isset( $extension->featured_image->source ) ? $extension->featured_image->source : null;
$image_src = ! empty( $image_src ) ? $image_src : null;
$install_link = wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $extension->slug ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $extension->slug );
$activate_link = wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => $extension->post_meta->plugin_path[0], 'plugin_status' => 'all', 'paged' => '1' ), self_admin_url( 'plugins.php' ) ), 'activate-plugin_' . $extension->post_meta->plugin_path[0] );
$activate_link = wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => $plugin_path, 'plugin_status' => 'all', 'paged' => '1' ), self_admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_path );
$aria_action = esc_attr( $extension->slug . '-action' );
?>

Expand Down Expand Up @@ -370,7 +372,7 @@ function prepare_extensions_for_js( $extensions ) {
'activate18n' => __( 'Activate', 'stream' ),
'active18n' => __( 'Active', 'stream' ),
'actions' => array(
'activate' => wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => $extension->post_meta->plugin_path[0], 'plugin_status' => 'all', 'paged' => '1' ), self_admin_url( 'plugins.php' ) ), 'activate-plugin_' . $extension->post_meta->plugin_path[0] ), // xss ok (todo fix WPCS sniff)
'activate' => wp_nonce_url( add_query_arg( array( 'action' => 'activate', 'plugin' => $plugin_path, 'plugin_status' => 'all', 'paged' => '1' ), self_admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_path ), // xss ok (todo fix WPCS sniff)
'install' => wp_nonce_url( add_query_arg( array( 'action' => 'install-plugin', 'plugin' => $extension->slug ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $extension->slug ), // xss ok (todo fix WPCS sniff)
'delete' => null,
),
Expand Down