Changeset 3057019
- Timestamp:
- 03/22/2024 06:20:47 PM (2 years ago)
- Location:
- democracy-poll
- Files:
-
- 16 edited
- 1 copied
-
tags/6.0.1 (copied) (copied from democracy-poll/trunk)
-
tags/6.0.1/classes/Admin/Admin_Page_Design.php (modified) (2 diffs)
-
tags/6.0.1/classes/Admin/Admin_Page_Settings.php (modified) (2 diffs)
-
tags/6.0.1/classes/Helpers/Kses.php (modified) (1 diff)
-
tags/6.0.1/classes/Options.php (modified) (6 diffs)
-
tags/6.0.1/classes/Plugin.php (modified) (5 diffs)
-
tags/6.0.1/classes/Utils/Activator.php (modified) (4 diffs)
-
tags/6.0.1/democracy.php (modified) (1 diff)
-
tags/6.0.1/readme.txt (modified) (2 diffs)
-
trunk/classes/Admin/Admin_Page_Design.php (modified) (2 diffs)
-
trunk/classes/Admin/Admin_Page_Settings.php (modified) (2 diffs)
-
trunk/classes/Helpers/Kses.php (modified) (1 diff)
-
trunk/classes/Options.php (modified) (6 diffs)
-
trunk/classes/Plugin.php (modified) (5 diffs)
-
trunk/classes/Utils/Activator.php (modified) (4 diffs)
-
trunk/democracy.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
democracy-poll/tags/6.0.1/classes/Admin/Admin_Page_Design.php
r3056337 r3057019 39 39 } 40 40 41 $up = null; 41 42 if( isset( $_POST['dem_save_design_options'] ) ){ 42 43 $up = options()->update_options( 'design' ); … … 44 45 if( isset( $_POST['dem_reset_design_options'] ) ){ 45 46 $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' ) ); 46 53 } 47 54 -
democracy-poll/tags/6.0.1/classes/Admin/Admin_Page_Settings.php
r3056337 r3057019 23 23 } 24 24 25 $up = null; 25 26 if( isset( $_POST['dem_save_main_options'] ) ){ 26 27 $up = options()->update_options( 'main' ); … … 28 29 if( isset( $_POST['dem_reset_main_options'] ) ){ 29 30 $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' ) ); 30 37 } 31 38 -
democracy-poll/tags/6.0.1/classes/Helpers/Kses.php
r3056337 r3057019 4 4 5 5 use function DemocracyPoll\plugin; 6 use function DemocracyPoll\options;7 6 8 7 class Kses { -
democracy-poll/tags/6.0.1/classes/Options.php
r3056337 r3057019 123 123 124 124 public function __construct() { 125 $this->set_opt();126 125 } 127 126 … … 138 137 } 139 138 140 public function default_options(): array {139 public function get_default_options(): array { 141 140 return $this->default_options; 142 141 } … … 147 146 * @return void 148 147 */ 149 p rivatefunction set_opt() {148 public function set_opt() { 150 149 151 150 if( ! $this->opt ){ 152 $this->opt = get_option( self::OPT_NAME );151 $this->opt = get_option( self::OPT_NAME, [] ); 153 152 154 153 if( ! $this->opt ){ … … 188 187 189 188 // sanitize on POST request 190 $POSTDATA = wp_unslash( $_POST ); 189 $POSTDATA = wp_unslash( $_POST ); // TODO: move it out of here 191 190 if( isset( $POSTDATA['dem'] ) && ( $type === 'main' || $type === 'design' ) ){ 192 191 $this->sanitize_request_options( $POSTDATA, $type ); … … 202 201 } 203 202 204 return $this->update_in_db();203 return (bool) update_option( self::OPT_NAME, $this->opt ); 205 204 } 206 205 … … 225 224 } 226 225 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 ); 239 227 } 240 228 -
democracy-poll/tags/6.0.1/classes/Plugin.php
r3056337 r3057019 36 36 $this->opt = new Options(); 37 37 $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 } 38 47 39 48 $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 47 49 Kses::set_allowed_tags(); 48 50 $this->load_textdomain(); 51 } 52 53 public function init() { 54 $this->basic_init(); 55 56 $this->set_is_cachegear_on(); 49 57 50 58 // 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 ) ){ 56 60 $this->admin = new Admin(); 57 61 $this->admin->init(); … … 62 66 $this->poll_ajax->init(); 63 67 64 // For front part localisation and custom translation setup68 // For front-end localisation and custom translation 65 69 Admin_Page_l10n::add_gettext_filter(); 66 70 67 if( is_multisite() ){68 add_action( 'switch_blog', [ Activator::class, 'set_db_tables' ] );69 }70 71 71 // menu in the admin bar 72 if( $this->admin_access && options()->toolbar_menu ){72 if( $this->admin_access && $this->opt->toolbar_menu ){ 73 73 add_action( 'admin_bar_menu', [ $this, 'add_toolbar_node' ], 99 ); 74 74 } … … 107 107 108 108 // open admin manage access for other roles 109 if( ! $this->admin_access && options()->access_roles ){109 if( ! $this->admin_access && $this->opt->access_roles ){ 110 110 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 ) ){ 112 112 $this->admin_access = true; 113 113 break; … … 119 119 private function set_is_cachegear_on() { 120 120 121 if( options()->force_cachegear ){121 if( $this->opt->force_cachegear ){ 122 122 $this->is_cachegear_on = true; 123 123 return; … … 236 236 237 237 // inline HTML 238 if( options()->inline_js_css ){238 if( $this->opt->inline_js_css ){ 239 239 wp_enqueue_script( 'jquery' ); 240 240 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 4 4 5 5 use function DemocracyPoll\plugin; 6 use function DemocracyPoll\options;7 6 8 7 class Activator { 9 10 public static $activation_running = false;11 8 12 9 public static function set_db_tables() { … … 18 15 19 16 public static function activate() { 20 21 // in order to activation works - activate_plugin() function works 22 self::$activation_running = true; 17 plugin()->basic_init(); 23 18 24 19 if( is_multisite() ){ … … 36 31 37 32 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 43 33 // create tables 44 34 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; … … 148 138 KEY userid (userid) 149 139 ) $charset_collate; 150 ";140 "; 151 141 } 152 142 -
democracy-poll/tags/6.0.1/democracy.php
r3056337 r3057019 14 14 * Requires PHP: 7.0 15 15 * 16 * Version: 6.0. 016 * Version: 6.0.1 17 17 */ 18 18 -
democracy-poll/tags/6.0.1/readme.txt
r3056376 r3057019 1 1 2 2 === Plugin Name === 3 Stable tag: 6.0. 03 Stable tag: 6.0.1 4 4 Tested up to: 6.4.3 5 5 Requires at least: 4.7 … … 140 140 141 141 == 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. 142 146 143 147 = 6.0.0 = -
democracy-poll/trunk/classes/Admin/Admin_Page_Design.php
r3056337 r3057019 39 39 } 40 40 41 $up = null; 41 42 if( isset( $_POST['dem_save_design_options'] ) ){ 42 43 $up = options()->update_options( 'design' ); … … 44 45 if( isset( $_POST['dem_reset_design_options'] ) ){ 45 46 $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' ) ); 46 53 } 47 54 -
democracy-poll/trunk/classes/Admin/Admin_Page_Settings.php
r3056337 r3057019 23 23 } 24 24 25 $up = null; 25 26 if( isset( $_POST['dem_save_main_options'] ) ){ 26 27 $up = options()->update_options( 'main' ); … … 28 29 if( isset( $_POST['dem_reset_main_options'] ) ){ 29 30 $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' ) ); 30 37 } 31 38 -
democracy-poll/trunk/classes/Helpers/Kses.php
r3056337 r3057019 4 4 5 5 use function DemocracyPoll\plugin; 6 use function DemocracyPoll\options;7 6 8 7 class Kses { -
democracy-poll/trunk/classes/Options.php
r3056337 r3057019 123 123 124 124 public function __construct() { 125 $this->set_opt();126 125 } 127 126 … … 138 137 } 139 138 140 public function default_options(): array {139 public function get_default_options(): array { 141 140 return $this->default_options; 142 141 } … … 147 146 * @return void 148 147 */ 149 p rivatefunction set_opt() {148 public function set_opt() { 150 149 151 150 if( ! $this->opt ){ 152 $this->opt = get_option( self::OPT_NAME );151 $this->opt = get_option( self::OPT_NAME, [] ); 153 152 154 153 if( ! $this->opt ){ … … 188 187 189 188 // sanitize on POST request 190 $POSTDATA = wp_unslash( $_POST ); 189 $POSTDATA = wp_unslash( $_POST ); // TODO: move it out of here 191 190 if( isset( $POSTDATA['dem'] ) && ( $type === 'main' || $type === 'design' ) ){ 192 191 $this->sanitize_request_options( $POSTDATA, $type ); … … 202 201 } 203 202 204 return $this->update_in_db();203 return (bool) update_option( self::OPT_NAME, $this->opt ); 205 204 } 206 205 … … 225 224 } 226 225 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 ); 239 227 } 240 228 -
democracy-poll/trunk/classes/Plugin.php
r3056337 r3057019 36 36 $this->opt = new Options(); 37 37 $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 } 38 47 39 48 $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 47 49 Kses::set_allowed_tags(); 48 50 $this->load_textdomain(); 51 } 52 53 public function init() { 54 $this->basic_init(); 55 56 $this->set_is_cachegear_on(); 49 57 50 58 // 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 ) ){ 56 60 $this->admin = new Admin(); 57 61 $this->admin->init(); … … 62 66 $this->poll_ajax->init(); 63 67 64 // For front part localisation and custom translation setup68 // For front-end localisation and custom translation 65 69 Admin_Page_l10n::add_gettext_filter(); 66 70 67 if( is_multisite() ){68 add_action( 'switch_blog', [ Activator::class, 'set_db_tables' ] );69 }70 71 71 // menu in the admin bar 72 if( $this->admin_access && options()->toolbar_menu ){72 if( $this->admin_access && $this->opt->toolbar_menu ){ 73 73 add_action( 'admin_bar_menu', [ $this, 'add_toolbar_node' ], 99 ); 74 74 } … … 107 107 108 108 // open admin manage access for other roles 109 if( ! $this->admin_access && options()->access_roles ){109 if( ! $this->admin_access && $this->opt->access_roles ){ 110 110 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 ) ){ 112 112 $this->admin_access = true; 113 113 break; … … 119 119 private function set_is_cachegear_on() { 120 120 121 if( options()->force_cachegear ){121 if( $this->opt->force_cachegear ){ 122 122 $this->is_cachegear_on = true; 123 123 return; … … 236 236 237 237 // inline HTML 238 if( options()->inline_js_css ){238 if( $this->opt->inline_js_css ){ 239 239 wp_enqueue_script( 'jquery' ); 240 240 add_action( ( is_admin() ? 'admin_footer' : 'wp_footer' ), [ __CLASS__, '_add_js_wp_footer' ], 0 ); -
democracy-poll/trunk/classes/Utils/Activator.php
r3056337 r3057019 4 4 5 5 use function DemocracyPoll\plugin; 6 use function DemocracyPoll\options;7 6 8 7 class Activator { 9 10 public static $activation_running = false;11 8 12 9 public static function set_db_tables() { … … 18 15 19 16 public static function activate() { 20 21 // in order to activation works - activate_plugin() function works 22 self::$activation_running = true; 17 plugin()->basic_init(); 23 18 24 19 if( is_multisite() ){ … … 36 31 37 32 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 43 33 // create tables 44 34 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; … … 148 138 KEY userid (userid) 149 139 ) $charset_collate; 150 ";140 "; 151 141 } 152 142 -
democracy-poll/trunk/democracy.php
r3056337 r3057019 14 14 * Requires PHP: 7.0 15 15 * 16 * Version: 6.0. 016 * Version: 6.0.1 17 17 */ 18 18 -
democracy-poll/trunk/readme.txt
r3056376 r3057019 1 1 2 2 === Plugin Name === 3 Stable tag: 6.0. 03 Stable tag: 6.0.1 4 4 Tested up to: 6.4.3 5 5 Requires at least: 4.7 … … 140 140 141 141 == 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. 142 146 143 147 = 6.0.0 =
Note: See TracChangeset
for help on using the changeset viewer.