Plugin Directory

Changeset 3057019


Ignore:
Timestamp:
03/22/2024 06:20:47 PM (2 years ago)
Author:
Tkama
Message:

Update to version 6.0.1 from GitHub

Location:
democracy-poll
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • democracy-poll/tags/6.0.1/classes/Admin/Admin_Page_Design.php

    r3056337 r3057019  
    3939        }
    4040
     41        $up = null;
    4142        if( isset( $_POST['dem_save_design_options'] ) ){
    4243            $up = options()->update_options( 'design' );
     
    4445        if( isset( $_POST['dem_reset_design_options'] ) ){
    4546            $up = options()->reset_options( 'design' );
     47        }
     48
     49        if( $up !== null ){
     50            $up
     51                ? plugin()->msg->add_ok( __( 'Updated', 'democracy-poll' ) )
     52                : plugin()->msg->add_notice( __( 'Nothing was updated', 'democracy-poll' ) );
    4653        }
    4754
  • democracy-poll/tags/6.0.1/classes/Admin/Admin_Page_Settings.php

    r3056337 r3057019  
    2323        }
    2424
     25        $up = null;
    2526        if( isset( $_POST['dem_save_main_options'] ) ){
    2627            $up = options()->update_options( 'main' );
     
    2829        if( isset( $_POST['dem_reset_main_options'] ) ){
    2930            $up = options()->reset_options( 'main' );
     31        }
     32
     33        if( $up !== null ){
     34            $up
     35                ? plugin()->msg->add_ok( __( 'Updated', 'democracy-poll' ) )
     36                : plugin()->msg->add_notice( __( 'Nothing was updated', 'democracy-poll' ) );
    3037        }
    3138
  • democracy-poll/tags/6.0.1/classes/Helpers/Kses.php

    r3056337 r3057019  
    44
    55use function DemocracyPoll\plugin;
    6 use function DemocracyPoll\options;
    76
    87class Kses {
  • democracy-poll/tags/6.0.1/classes/Options.php

    r3056337 r3057019  
    123123
    124124    public function __construct() {
    125         $this->set_opt();
    126125    }
    127126
     
    138137    }
    139138
    140     public function default_options(): array {
     139    public function get_default_options(): array {
    141140        return $this->default_options;
    142141    }
     
    147146     * @return void
    148147     */
    149     private function set_opt() {
     148    public function set_opt() {
    150149
    151150        if( ! $this->opt ){
    152             $this->opt = get_option( self::OPT_NAME );
     151            $this->opt = get_option( self::OPT_NAME, [] );
    153152
    154153            if( ! $this->opt ){
     
    188187
    189188        // sanitize on POST request
    190         $POSTDATA = wp_unslash( $_POST );
     189        $POSTDATA = wp_unslash( $_POST ); // TODO: move it out of here
    191190        if( isset( $POSTDATA['dem'] ) && ( $type === 'main' || $type === 'design' ) ){
    192191            $this->sanitize_request_options( $POSTDATA, $type );
     
    202201        }
    203202
    204         return $this->update_in_db();
     203        return (bool) update_option( self::OPT_NAME, $this->opt );
    205204    }
    206205
     
    225224        }
    226225
    227         return $this->update_in_db();
    228     }
    229 
    230     private function update_in_db(): bool {
    231 
    232         $up = update_option( self::OPT_NAME, $this->opt );
    233 
    234         $up
    235             ? plugin()->msg->add_ok( __( 'Updated', 'democracy-poll' ) )
    236             : plugin()->msg->add_notice( __( 'Nothing was updated', 'democracy-poll' ) );
    237 
    238         return (bool) $up;
     226        return (bool) update_option( self::OPT_NAME, $this->opt );
    239227    }
    240228
  • democracy-poll/tags/6.0.1/classes/Plugin.php

    r3056337 r3057019  
    3636        $this->opt = new Options();
    3737        $this->msg = new Messages();
     38    }
     39
     40    public function basic_init() {
     41        $this->opt->set_opt();
     42
     43        Activator::set_db_tables();
     44        if( is_multisite() ){
     45            add_action( 'switch_blog', [ Activator::class, 'set_db_tables' ] );
     46        }
    3847
    3948        $this->set_access_caps();
    40     }
    41 
    42     public function init() {
    43         \DemocracyPoll\Utils\Activator::set_db_tables();
    44 
    45         $this->set_is_cachegear_on();
    46 
    4749        Kses::set_allowed_tags();
    4850        $this->load_textdomain();
     51    }
     52
     53    public function init() {
     54        $this->basic_init();
     55
     56        $this->set_is_cachegear_on();
    4957
    5058        // admin part
    51         if(
    52             Activator::$activation_running
    53             ||
    54             ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
    55         ){
     59        if( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
    5660            $this->admin = new Admin();
    5761            $this->admin->init();
     
    6266        $this->poll_ajax->init();
    6367
    64         // For front part localisation and custom translation setup
     68        // For front-end localisation and custom translation
    6569        Admin_Page_l10n::add_gettext_filter();
    6670
    67         if( is_multisite() ){
    68             add_action( 'switch_blog', [ Activator::class, 'set_db_tables' ] );
    69         }
    70 
    7171        // menu in the admin bar
    72         if( $this->admin_access && options()->toolbar_menu ){
     72        if( $this->admin_access && $this->opt->toolbar_menu ){
    7373            add_action( 'admin_bar_menu', [ $this, 'add_toolbar_node' ], 99 );
    7474        }
     
    107107
    108108        // open admin manage access for other roles
    109         if( ! $this->admin_access && options()->access_roles ){
     109        if( ! $this->admin_access && $this->opt->access_roles ){
    110110            foreach( wp_get_current_user()->roles as $role ){
    111                 if( in_array( $role, options()->access_roles, true ) ){
     111                if( in_array( $role, $this->opt->access_roles, true ) ){
    112112                    $this->admin_access = true;
    113113                    break;
     
    119119    private function set_is_cachegear_on() {
    120120
    121         if( options()->force_cachegear ){
     121        if( $this->opt->force_cachegear ){
    122122            $this->is_cachegear_on = true;
    123123            return;
     
    236236
    237237        // inline HTML
    238         if( options()->inline_js_css ){
     238        if( $this->opt->inline_js_css ){
    239239            wp_enqueue_script( 'jquery' );
    240240            add_action( ( is_admin() ? 'admin_footer' : 'wp_footer' ), [ __CLASS__, '_add_js_wp_footer' ], 0 );
  • democracy-poll/tags/6.0.1/classes/Utils/Activator.php

    r3056337 r3057019  
    44
    55use function DemocracyPoll\plugin;
    6 use function DemocracyPoll\options;
    76
    87class Activator {
    9 
    10     public static $activation_running = false;
    118
    129    public static function set_db_tables() {
     
    1815
    1916    public static function activate() {
    20 
    21         // in order to activation works - activate_plugin() function works
    22         self::$activation_running = true;
     17        plugin()->basic_init();
    2318
    2419        if( is_multisite() ){
     
    3631
    3732    private static function _activate() {
    38         self::set_db_tables();
    39 
    40         plugin()->load_textdomain();
    41         options(); // add default options (if there is no any).
    42 
    4333        // create tables
    4434        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     
    148138            KEY userid (userid)
    149139        ) $charset_collate;
    150     ";
     140        ";
    151141    }
    152142
  • democracy-poll/tags/6.0.1/democracy.php

    r3056337 r3057019  
    1414 * Requires PHP: 7.0
    1515 *
    16  * Version: 6.0.0
     16 * Version: 6.0.1
    1717 */
    1818
  • democracy-poll/tags/6.0.1/readme.txt

    r3056376 r3057019  
    11
    22=== Plugin Name ===
    3 Stable tag: 6.0.0
     3Stable tag: 6.0.1
    44Tested up to: 6.4.3
    55Requires at least: 4.7
     
    140140
    141141== Changelog ==
     142
     143= 6.0.1 =
     144* BUG: Fix v6.0.0 bug: short-circuit recursion on plugin object construct for the not logged-in users.
     145* IMP: Minor improvements.
    142146
    143147= 6.0.0 =
  • democracy-poll/trunk/classes/Admin/Admin_Page_Design.php

    r3056337 r3057019  
    3939        }
    4040
     41        $up = null;
    4142        if( isset( $_POST['dem_save_design_options'] ) ){
    4243            $up = options()->update_options( 'design' );
     
    4445        if( isset( $_POST['dem_reset_design_options'] ) ){
    4546            $up = options()->reset_options( 'design' );
     47        }
     48
     49        if( $up !== null ){
     50            $up
     51                ? plugin()->msg->add_ok( __( 'Updated', 'democracy-poll' ) )
     52                : plugin()->msg->add_notice( __( 'Nothing was updated', 'democracy-poll' ) );
    4653        }
    4754
  • democracy-poll/trunk/classes/Admin/Admin_Page_Settings.php

    r3056337 r3057019  
    2323        }
    2424
     25        $up = null;
    2526        if( isset( $_POST['dem_save_main_options'] ) ){
    2627            $up = options()->update_options( 'main' );
     
    2829        if( isset( $_POST['dem_reset_main_options'] ) ){
    2930            $up = options()->reset_options( 'main' );
     31        }
     32
     33        if( $up !== null ){
     34            $up
     35                ? plugin()->msg->add_ok( __( 'Updated', 'democracy-poll' ) )
     36                : plugin()->msg->add_notice( __( 'Nothing was updated', 'democracy-poll' ) );
    3037        }
    3138
  • democracy-poll/trunk/classes/Helpers/Kses.php

    r3056337 r3057019  
    44
    55use function DemocracyPoll\plugin;
    6 use function DemocracyPoll\options;
    76
    87class Kses {
  • democracy-poll/trunk/classes/Options.php

    r3056337 r3057019  
    123123
    124124    public function __construct() {
    125         $this->set_opt();
    126125    }
    127126
     
    138137    }
    139138
    140     public function default_options(): array {
     139    public function get_default_options(): array {
    141140        return $this->default_options;
    142141    }
     
    147146     * @return void
    148147     */
    149     private function set_opt() {
     148    public function set_opt() {
    150149
    151150        if( ! $this->opt ){
    152             $this->opt = get_option( self::OPT_NAME );
     151            $this->opt = get_option( self::OPT_NAME, [] );
    153152
    154153            if( ! $this->opt ){
     
    188187
    189188        // sanitize on POST request
    190         $POSTDATA = wp_unslash( $_POST );
     189        $POSTDATA = wp_unslash( $_POST ); // TODO: move it out of here
    191190        if( isset( $POSTDATA['dem'] ) && ( $type === 'main' || $type === 'design' ) ){
    192191            $this->sanitize_request_options( $POSTDATA, $type );
     
    202201        }
    203202
    204         return $this->update_in_db();
     203        return (bool) update_option( self::OPT_NAME, $this->opt );
    205204    }
    206205
     
    225224        }
    226225
    227         return $this->update_in_db();
    228     }
    229 
    230     private function update_in_db(): bool {
    231 
    232         $up = update_option( self::OPT_NAME, $this->opt );
    233 
    234         $up
    235             ? plugin()->msg->add_ok( __( 'Updated', 'democracy-poll' ) )
    236             : plugin()->msg->add_notice( __( 'Nothing was updated', 'democracy-poll' ) );
    237 
    238         return (bool) $up;
     226        return (bool) update_option( self::OPT_NAME, $this->opt );
    239227    }
    240228
  • democracy-poll/trunk/classes/Plugin.php

    r3056337 r3057019  
    3636        $this->opt = new Options();
    3737        $this->msg = new Messages();
     38    }
     39
     40    public function basic_init() {
     41        $this->opt->set_opt();
     42
     43        Activator::set_db_tables();
     44        if( is_multisite() ){
     45            add_action( 'switch_blog', [ Activator::class, 'set_db_tables' ] );
     46        }
    3847
    3948        $this->set_access_caps();
    40     }
    41 
    42     public function init() {
    43         \DemocracyPoll\Utils\Activator::set_db_tables();
    44 
    45         $this->set_is_cachegear_on();
    46 
    4749        Kses::set_allowed_tags();
    4850        $this->load_textdomain();
     51    }
     52
     53    public function init() {
     54        $this->basic_init();
     55
     56        $this->set_is_cachegear_on();
    4957
    5058        // admin part
    51         if(
    52             Activator::$activation_running
    53             ||
    54             ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
    55         ){
     59        if( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ){
    5660            $this->admin = new Admin();
    5761            $this->admin->init();
     
    6266        $this->poll_ajax->init();
    6367
    64         // For front part localisation and custom translation setup
     68        // For front-end localisation and custom translation
    6569        Admin_Page_l10n::add_gettext_filter();
    6670
    67         if( is_multisite() ){
    68             add_action( 'switch_blog', [ Activator::class, 'set_db_tables' ] );
    69         }
    70 
    7171        // menu in the admin bar
    72         if( $this->admin_access && options()->toolbar_menu ){
     72        if( $this->admin_access && $this->opt->toolbar_menu ){
    7373            add_action( 'admin_bar_menu', [ $this, 'add_toolbar_node' ], 99 );
    7474        }
     
    107107
    108108        // open admin manage access for other roles
    109         if( ! $this->admin_access && options()->access_roles ){
     109        if( ! $this->admin_access && $this->opt->access_roles ){
    110110            foreach( wp_get_current_user()->roles as $role ){
    111                 if( in_array( $role, options()->access_roles, true ) ){
     111                if( in_array( $role, $this->opt->access_roles, true ) ){
    112112                    $this->admin_access = true;
    113113                    break;
     
    119119    private function set_is_cachegear_on() {
    120120
    121         if( options()->force_cachegear ){
     121        if( $this->opt->force_cachegear ){
    122122            $this->is_cachegear_on = true;
    123123            return;
     
    236236
    237237        // inline HTML
    238         if( options()->inline_js_css ){
     238        if( $this->opt->inline_js_css ){
    239239            wp_enqueue_script( 'jquery' );
    240240            add_action( ( is_admin() ? 'admin_footer' : 'wp_footer' ), [ __CLASS__, '_add_js_wp_footer' ], 0 );
  • democracy-poll/trunk/classes/Utils/Activator.php

    r3056337 r3057019  
    44
    55use function DemocracyPoll\plugin;
    6 use function DemocracyPoll\options;
    76
    87class Activator {
    9 
    10     public static $activation_running = false;
    118
    129    public static function set_db_tables() {
     
    1815
    1916    public static function activate() {
    20 
    21         // in order to activation works - activate_plugin() function works
    22         self::$activation_running = true;
     17        plugin()->basic_init();
    2318
    2419        if( is_multisite() ){
     
    3631
    3732    private static function _activate() {
    38         self::set_db_tables();
    39 
    40         plugin()->load_textdomain();
    41         options(); // add default options (if there is no any).
    42 
    4333        // create tables
    4434        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     
    148138            KEY userid (userid)
    149139        ) $charset_collate;
    150     ";
     140        ";
    151141    }
    152142
  • democracy-poll/trunk/democracy.php

    r3056337 r3057019  
    1414 * Requires PHP: 7.0
    1515 *
    16  * Version: 6.0.0
     16 * Version: 6.0.1
    1717 */
    1818
  • democracy-poll/trunk/readme.txt

    r3056376 r3057019  
    11
    22=== Plugin Name ===
    3 Stable tag: 6.0.0
     3Stable tag: 6.0.1
    44Tested up to: 6.4.3
    55Requires at least: 4.7
     
    140140
    141141== Changelog ==
     142
     143= 6.0.1 =
     144* BUG: Fix v6.0.0 bug: short-circuit recursion on plugin object construct for the not logged-in users.
     145* IMP: Minor improvements.
    142146
    143147= 6.0.0 =
Note: See TracChangeset for help on using the changeset viewer.