Plugin Directory

Changeset 2223674


Ignore:
Timestamp:
01/07/2020 04:16:15 PM (6 years ago)
Author:
256hax
Message:

fix: failed to save pw to DB when first activated plugin

Location:
wp-similar-basic-auth/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-similar-basic-auth/trunk/includes/admin/admin-plugins-page.php

    r2223360 r2223674  
    1010    function __construct() {
    1111        add_filter( 'plugin_action_links', array( $this, 'plugin_settings_link' ) );
     12        add_action( 'activated_plugin', array($this, 'action_activated_plugin') );
    1213    }
    1314
     15    // Add Settings menu in plugins page
    1416    function plugin_settings_link( $link ) {
    1517        global $hax_wsba_config;
     
    2022        array_unshift( $link, $url ); // Settings link first For order
    2123        return $link;
     24    }
     25
     26    public function action_activated_plugin() {
     27        global $hax_wsba_config;
     28
     29        // It need wp_options what use in DB.
     30        // register_settings sanitize callback will be launched twice if no wp_options.
     31        $init_options = array(
     32            $hax_wsba_config->register_settings_title,
     33            $hax_wsba_config->register_settings_message,
     34            $hax_wsba_config->register_settings_user_name,
     35            $hax_wsba_config->register_settings_password
     36        );
     37
     38        foreach( $init_options as $value) {
     39            if ( !get_option( $value ) ) {
     40                add_option($value);
     41            }
     42        }
    2243    }
    2344
  • wp-similar-basic-auth/trunk/includes/public/login-page.php

    r2223360 r2223674  
    6767        $hax_wsba_cookie = new Hax_Wsba_Cookie();
    6868
    69         // [Pass] If not set User Name and Password, pass WSBA page.
     69        // [Pass] If no set User Name and Password, pass WSBA page.
    7070        // It suppose just activate plugin or forget set User Name or Password.
    71         if ( $saved_user_name === false || $saved_password === false ) {
    72             return 'data_does_not_exist'; // For phpunit
     71        if ( $saved_user_name === false || $saved_password === false || $saved_user_name === '' || $saved_password === '' ) {
     72            return 'no_data'; // For phpunit
    7373        }
    7474
  • wp-similar-basic-auth/trunk/wp-similar-basic-auth.php

    r2223360 r2223674  
    5656
    5757        if ( is_admin() ) {
     58            include_once( $hax_wsba_config->path_admin . 'admin-plugins-page.php' );
    5859            include_once( $hax_wsba_config->path_admin . 'admin-options-page.php' );
    59             include_once( $hax_wsba_config->path_admin . 'admin-plugins-page.php' );
    6060        }
    6161    }
Note: See TracChangeset for help on using the changeset viewer.