Plugin Directory

Changeset 2154896


Ignore:
Timestamp:
09/11/2019 03:18:14 PM (7 years ago)
Author:
marcusraket.nu
Message:

Fix settings update for autolinking

File:
1 edited

Legend:

Unmodified
Added
Removed
  • metapic/trunk/classes/WP_MTPC_Settings.php

    r2154893 r2154896  
    2020            function () use ( $api_url ) {
    2121                check_admin_referer( 'mtpc_site_settings', 'mtpc' );
    22                
     22                $auto_link_default        = get_site_option( 'mtpc_deeplink_auto_default' );
     23                $auto_link_default_update = (bool) $_POST['mtpc_deeplink_auto_default'];
    2324                update_site_option( 'mtpc_deeplink_auto_default',
    24                     (bool) $_POST['mtpc_deeplink_auto_default'] );
     25                    $auto_link_default_update );
    2526                update_site_option( 'mtpc_registration_auto',
    2627                    (bool) $_POST['mtpc_registration_auto'] );
     
    3132                update_site_option( 'mtpc_force_ssl',
    3233                    (bool) $_POST['mtpc_force_ssl'] );
    33                 update_site_option( 'mtpc_commercial_interest_message',
    34                     (bool) $_POST['mtpc_commercial_interest_message'] );
     34                update_site_option( 'mtpc_commercial_interest_message',
     35                    (bool) $_POST['mtpc_commercial_interest_message'] );
    3536               
    3637                $posted_api_url = isset( $_POST['mtpc_api_url'] )
     
    4748                $new_api_key    = $_POST['api_key'];
    4849                $new_secret_key = $_POST['secret_key'];
    49 
     50               
     51                $reset_blogs              = false;
     52                $update_auto_link_default = ( $auto_link_default !== $auto_link_default_update );
     53               
    5054                if ( $current_api_key !== $new_api_key
    5155                     || $current_secret_key !== $new_secret_key
    52                     || ! $is_valid_client
     56                     || ! $is_valid_client
    5357                ) {
    5458                    update_site_option( 'mtpc_api_key', $new_api_key );
     
    7276                    }
    7377                   
     78                    $reset_blogs = true;
     79                }
     80               
     81                if ( $reset_blogs || $update_auto_link_default ) {
    7482                    $current_site = get_current_blog_id();
    75                     $sites        = wp_get_sites();
    76                     if ( count( $sites ) <= 50 ) {
    77                         foreach ( $sites as $site ) {
    78                             switch_to_blog( $site['blog_id'] );
    79                             $this->deactivate_account();
     83                    if ( ! wp_is_large_network() ) {
     84                        foreach ( get_sites() as $site ) {
     85                            /* @var WP_Site $site */
     86                            switch_to_blog( $site->blog_id );
     87                            if ( $reset_blogs ) {
     88                                $this->deactivate_account();
     89                            }
     90                           
     91                            if ( $update_auto_link_default ) {
     92                                update_option( 'mtpc_deeplink_auto_default', $auto_link_default_update );
     93                            }
    8094                        }
    8195                       
    8296                        switch_to_blog( $current_site );
    8397                    }
     98                   
    8499                }
    85100               
     
    98113                $return_url = remove_query_arg( 'mtpc-account-activated',
    99114                    $return_url );
    100 
     115               
    101116                if ( isset( $_POST['deactivate'] )
    102117                     || isset( $_POST['logout'] )
    103118                ) {
    104 
     119                   
    105120                    $this->deactivate_account();
    106121                   
     
    119134                    update_option( 'mtpc_deeplink_auto_default',
    120135                        (bool) $_POST['mtpc_deeplink_auto_default'] );
    121 
    122                     update_option( 'mtpc_commercial_interest_message',
    123                         (bool) $_POST['mtpc_commercial_interest_message'] );
     136                   
     137                    update_option( 'mtpc_commercial_interest_message',
     138                        (bool) $_POST['mtpc_commercial_interest_message'] );
    124139                   
    125140                    if ( $is_debug ) {
     
    172187       
    173188        $ref
    174                  = admin_url( 'admin.php?page=metapic-settings' );
     189            = admin_url( 'admin.php?page=metapic-settings' );
    175190        $fail_ref
    176191            = admin_url( 'admin.php?page=metapic' );
Note: See TracChangeset for help on using the changeset viewer.