Skip to content

Commit

Permalink
Switch to get/update_{site_}_option for multisite support
Browse files Browse the repository at this point in the history
  • Loading branch information
shadyvb committed Apr 24, 2014
1 parent d7a3030 commit 475f522
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion includes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public static function render_extensions_page() {
'stream-activation',
'stream_activation',
array(
'action' => get_option( 'stream-license' ) ? 'disconnect' : 'connect',
'action' => get_site_option( 'stream-license' ) ? 'disconnect' : 'connect',
'api' => array(
'connect' => apply_filters( 'stream-api-url', WP_Stream_Updater::instance()->get_api_url() . 'connect', 'connect' ),
'disconnect' => apply_filters( 'stream-api-url', WP_Stream_Updater::instance()->get_api_url() . 'disconnect', 'disconnect' ),
Expand Down
2 changes: 1 addition & 1 deletion includes/extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private function activate_membership() {
* @return bool true if membership active
*/
private function verify_membership() {
if ( get_option( 'stream-license' ) ) {
if ( get_site_option( 'stream-license' ) ) {
return true;
}

Expand Down
16 changes: 8 additions & 8 deletions includes/updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function check( $transient ) {
return $transient;
}
$response = (array) $this->request( array_intersect_key( $transient->checked, $this->plugins ) );
$license = get_option( 'stream-license' );
$license = get_site_option( 'stream-license' );
$site = parse_url( get_site_url(), PHP_URL_HOST );
if ( $response ) {
foreach ( $response as $key => $value ) {
Expand All @@ -98,7 +98,7 @@ public function request( $plugins ) {
'plugins' => $plugins,
'name' => get_bloginfo( 'name' ),
'url' => get_bloginfo( 'url' ),
'license' => get_option( 'stream-license' ),
'license' => get_site_option( 'stream-license' ),
),
);

Expand Down Expand Up @@ -149,8 +149,8 @@ public function license_check() {
wp_send_json_error( $data );
}

update_option( 'stream-license', $license );
update_option( 'stream-licensee', $data->data->user );
update_site_option( 'stream-license', $license );
update_site_option( 'stream-licensee', $data->data->user );

// Invalidate plugin-update transient so we can check for updates
// and restore package urls to existing updates
Expand All @@ -164,8 +164,8 @@ public function license_remove() {
wp_die( __( 'Invalid security check.', 'stream' ) );
}

delete_option( 'stream-license' );
delete_option( 'stream-licensee' );
delete_site_option( 'stream-license' );
delete_site_option( 'stream-licensee' );

// Invalidate plugin-update transient so we can check for updates
// and restore package urls to existing updates
Expand All @@ -175,7 +175,7 @@ public function license_remove() {
}

public function plugin_action_links( $links ) {
if ( ! get_option( 'stream-license' ) ) {
if ( ! get_site_option( 'stream-license' ) ) {
$links[ 'activation' ] = sprintf(
'<a href="%1$s">%2$s</a>',
admin_url(
Expand Down Expand Up @@ -204,7 +204,7 @@ public function install_extension( $slug = null ) {
// TODO: Nonce check

$site = parse_url( get_site_url(), PHP_URL_HOST );
$license = get_option( 'stream-license' );
$license = get_site_option( 'stream-license' );
if ( empty( $license ) ) {
wp_die( __( 'You must subscribe to Stream &copy; to be able to download premium extensions.', 'stream' ) );
}
Expand Down

3 comments on commit 475f522

@frankiejarrett
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadyvb I'd rather the option name be wp_stream_license for consistency, do you agree?

@shadyvb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, sure.

@shadyvb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 113749d

Please sign in to comment.