Changeset 3349871
- Timestamp:
- 08/25/2025 04:43:55 PM (7 months ago)
- Location:
- gleap
- Files:
-
- 10 edited
- 1 copied
-
tags/13.0.8 (copied) (copied from gleap/trunk)
-
tags/13.0.8/README.txt (modified) (2 diffs)
-
tags/13.0.8/admin/class-gleap-admin.php (modified) (4 diffs)
-
tags/13.0.8/gleap.php (modified) (2 diffs)
-
tags/13.0.8/public/class-gleap-public.php (modified) (1 diff)
-
tags/13.0.8/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/admin/class-gleap-admin.php (modified) (4 diffs)
-
trunk/gleap.php (modified) (2 diffs)
-
trunk/public/class-gleap-public.php (modified) (1 diff)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gleap/tags/13.0.8/README.txt
r3342686 r3349871 4 4 Requires at least: 5.0.0 5 5 Tested up to: 6.8.2 6 Stable tag: 13.0. 76 Stable tag: 13.0.8 7 7 License: Commercial 8 8 License URI: https://github.com/Gleap/Wordpress/blob/main/README.txt … … 38 38 39 39 == Changelog == 40 41 = 13.0.8 = 42 * Added feature to restrict Gleap widget visibility by user role and for frontend/backend separately. 40 43 41 44 = 13.0.7 = -
gleap/tags/13.0.8/admin/class-gleap-admin.php
r3258602 r3349871 73 73 74 74 /** 75 * Migrate old role settings to new separate frontend/admin role settings. 76 * This ensures backward compatibility when updating from older plugin versions. 77 * Uses proper Carbon Fields methods as per documentation. 78 * 79 * @since 1.0.0 80 * @access private 81 */ 82 private function migrate_old_role_settings() 83 { 84 // Check if Carbon Fields functions are available 85 if (!function_exists('carbon_get_theme_option') || !function_exists('carbon_set_theme_option')) { 86 return; 87 } 88 89 // Check if migration has already been performed 90 $migration_done = get_option('gleap_role_migration_done', false); 91 if ($migration_done) { 92 return; 93 } 94 95 // Get old role settings from database directly since these fields are no longer registered 96 // Carbon Fields can't retrieve values for fields that aren't in the current schema 97 $old_roles_only = get_option('_gleap_selected_roles_only', null); 98 $old_selected_roles_raw = get_option('_gleap_selected_roles|||0|value', null); 99 100 // Convert the selected roles to array format 101 $old_selected_roles = null; 102 if ($old_selected_roles_raw !== null && $old_selected_roles_raw !== '') { 103 $old_selected_roles = array($old_selected_roles_raw); 104 } 105 106 // Log what we found for debugging 107 error_log('Gleap Migration: Found old database values - roles_only=' . var_export($old_roles_only, true) . ', selected_roles_raw=' . var_export($old_selected_roles_raw, true) . ', selected_roles=' . var_export($old_selected_roles, true)); 108 109 // Check if we got the expected data types and values 110 $has_valid_roles_only = ($old_roles_only === 'yes'); 111 $has_valid_selected_roles = !empty($old_selected_roles); 112 113 // Only migrate if old settings exist and have meaningful values 114 if ($has_valid_roles_only) { 115 // Convert to boolean (Carbon Fields stores checkbox as 'yes'/'no' or boolean) 116 $roles_only_bool = true; // We know it's enabled if we got here 117 118 // Ensure selected roles is an array 119 if (!is_array($old_selected_roles)) { 120 $old_selected_roles = $old_selected_roles ? array($old_selected_roles) : array(); 121 } 122 123 // Migrate to new frontend settings using direct database insertion (Carbon Fields format) 124 // Since carbon_set_theme_option might not work during field registration, 125 // we'll set the values directly in the database using Carbon Fields format 126 127 // Frontend roles only checkbox 128 update_option('_gleap_frontend_selected_roles_only', $roles_only_bool ? 'yes' : 'no'); 129 130 // Frontend selected roles multiselect 131 if (!empty($old_selected_roles)) { 132 // For multiselect fields, Carbon Fields stores each value with |||index|value format 133 foreach ($old_selected_roles as $index => $role) { 134 update_option('_gleap_frontend_selected_roles|||' . $index . '|value', $role); 135 } 136 } 137 138 // Admin roles only checkbox 139 update_option('_gleap_admin_selected_roles_only', $roles_only_bool ? 'yes' : 'no'); 140 141 // Admin selected roles multiselect 142 if (!empty($old_selected_roles)) { 143 // For multiselect fields, Carbon Fields stores each value with |||index|value format 144 foreach ($old_selected_roles as $index => $role) { 145 update_option('_gleap_admin_selected_roles|||' . $index . '|value', $role); 146 } 147 } 148 149 // Mark migration as completed 150 update_option('gleap_role_migration_done', true); 151 152 // Log successful migration 153 error_log('Gleap Migration: Successfully migrated role settings to separate frontend/admin controls'); 154 } else { 155 // Log when no migration is performed 156 error_log('Gleap Migration: No migration performed - roles_only=' . var_export($old_roles_only, true) . ', has_valid_roles_only=' . var_export($has_valid_roles_only, true)); 157 } 158 } 159 160 /** 161 * Reset migration flag - useful for development/testing 162 * This method can be called to force re-migration of settings 163 * 164 * @since 1.0.0 165 */ 166 public function reset_migration_flag() { 167 delete_option('gleap_role_migration_done'); 168 error_log('Gleap Migration: Reset migration flag - next admin page visit will trigger migration'); 169 } 170 171 /** 75 172 * Register the stylesheets for the admin area. 76 173 * … … 126 223 127 224 if ($gleap_token) { 128 $gleap_ selected_roles_only = carbon_get_theme_option('gleap_selected_roles_only');129 if ($gleap_ selected_roles_only == true) {225 $gleap_admin_selected_roles_only = carbon_get_theme_option('gleap_admin_selected_roles_only'); 226 if ($gleap_admin_selected_roles_only == true) { 130 227 $user_roles = wp_get_current_user()->roles; 131 $gleap_ selected_roles = carbon_get_theme_option('gleap_selected_roles');132 133 if (!array_intersect($user_roles, $gleap_ selected_roles)) {228 $gleap_admin_selected_roles = carbon_get_theme_option('gleap_admin_selected_roles'); 229 230 if (!array_intersect($user_roles, $gleap_admin_selected_roles)) { 134 231 // If the user's role is not in the selected roles, don't show Gleap 135 232 return; … … 209 306 public function setup_settings_ui() 210 307 { 308 // Run migration when Carbon Fields is fully registered 309 // This ensures all Carbon Fields functions are available as per v3.x docs 310 $this->migrate_old_role_settings(); 311 211 312 // Get WordPress roles 212 313 $wp_roles = wp_roles(); … … 221 322 Field::make('text', 'gleap_identity_token', 'Identity verification secret')->set_attribute('type', 'password')->set_help_text("If you'd like to verify the identity of your users, copy the code from Project -> Settings -> Security to the field above."), 222 323 Field::make('text', 'gleap_secret_api_token', 'Secret API token')->set_attribute('type', 'password')->set_help_text("If you'd like to use the Gleap Rest API to send events, copy the code from Project -> Settings -> Security to the field above."), 223 Field::make('checkbox', 'gleap_selected_roles_only', 'Enable Gleap only for the selected WP roles') 324 Field::make('checkbox', 'gleap_activate_in_frontend', 'Activate Gleap widget in Frontend') 325 ->set_default_value(true) 326 ->set_help_text('Enable the Gleap widget in the frontend area.'), 327 Field::make('checkbox', 'gleap_frontend_selected_roles_only', 'Enable Gleap frontend only for selected WP roles') 224 328 ->set_default_value(false) 225 ->set_help_text('Gleap widget will only be visible for users with the selected roles. If no roles are selected, it will be visible to all users.'), 329 ->set_help_text('Gleap widget will only be visible in frontend for users with the selected roles.') 330 ->set_conditional_logic(array( 331 array( 332 'field' => 'gleap_activate_in_frontend', 333 'value' => true, 334 'compare' => '=' 335 ) 336 )), 337 Field::make('multiselect', 'gleap_frontend_selected_roles', 'Select roles for frontend') 338 ->add_options($roles) 339 ->set_conditional_logic(array( 340 array( 341 'field' => 'gleap_frontend_selected_roles_only', 342 'value' => true, 343 'compare' => '=' 344 ) 345 )), 226 346 Field::make('checkbox', 'gleap_activate_in_admin', 'Activate Gleap widget in WP Admin') 227 347 ->set_default_value(false) 228 348 ->set_help_text('Enable the Gleap widget in the WordPress admin area.'), 229 Field::make('checkbox', 'gleap_activate_in_frontend', 'Activate Gleap widget in Frontend') 230 ->set_default_value(true) 231 ->set_help_text('Enable the Gleap widget in the frontend area.'), 232 Field::make('multiselect', 'gleap_selected_roles', 'Select roles') 349 Field::make('checkbox', 'gleap_admin_selected_roles_only', 'Enable Gleap admin only for selected WP roles') 350 ->set_default_value(false) 351 ->set_help_text('Gleap widget will only be visible in WP admin for users with the selected roles.') 352 ->set_conditional_logic(array( 353 array( 354 'field' => 'gleap_activate_in_admin', 355 'value' => true, 356 'compare' => '=' 357 ) 358 )), 359 Field::make('multiselect', 'gleap_admin_selected_roles', 'Select roles for admin') 233 360 ->add_options($roles) 234 361 ->set_conditional_logic(array( 235 362 array( 236 'field' => 'gleap_ selected_roles_only',363 'field' => 'gleap_admin_selected_roles_only', 237 364 'value' => true, 238 365 'compare' => '=' -
gleap/tags/13.0.8/gleap.php
r3342686 r3349871 17 17 * Plugin Name: Gleap 18 18 * Description: Gleap helps developers build the best software faster. It is your affordable in-app bug reporting tool for apps, websites and industrial applications. 19 * Version: 13.0. 719 * Version: 13.0.8 20 20 * Author: Gleap 21 21 * Author URI: https://www.gleap.io … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define('GLEAP_VERSION', '13.0. 7');38 define('GLEAP_VERSION', '13.0.8'); 39 39 40 40 /** -
gleap/tags/13.0.8/public/class-gleap-public.php
r3258602 r3349871 173 173 } 174 174 175 $gleap_ selected_roles_only = carbon_get_theme_option('gleap_selected_roles_only');176 if ($gleap_ selected_roles_only == true) {175 $gleap_frontend_selected_roles_only = carbon_get_theme_option('gleap_frontend_selected_roles_only'); 176 if ($gleap_frontend_selected_roles_only == true) { 177 177 $user_roles = wp_get_current_user()->roles; 178 $gleap_ selected_roles = carbon_get_theme_option('gleap_selected_roles');179 180 if (!array_intersect($user_roles, $gleap_ selected_roles)) {178 $gleap_frontend_selected_roles = carbon_get_theme_option('gleap_frontend_selected_roles'); 179 180 if (!array_intersect($user_roles, $gleap_frontend_selected_roles)) { 181 181 // If the user's role is not in the selected roles, don't show Gleap 182 182 return; -
gleap/tags/13.0.8/vendor/composer/installed.php
r3342686 r3349871 2 2 'root' => array( 3 3 'name' => 'gleap/gleap-wp', 4 'pretty_version' => 'v13.0. 7',5 'version' => '13.0. 7.0',6 'reference' => ' 47d37dbe86166e0230bbea272f019de7d84820ff',4 'pretty_version' => 'v13.0.8', 5 'version' => '13.0.8.0', 6 'reference' => '6fd697a9b9e96e20cbbeac8ecfd7b1028b71e623', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'gleap/gleap-wp' => array( 14 'pretty_version' => 'v13.0. 7',15 'version' => '13.0. 7.0',16 'reference' => ' 47d37dbe86166e0230bbea272f019de7d84820ff',14 'pretty_version' => 'v13.0.8', 15 'version' => '13.0.8.0', 16 'reference' => '6fd697a9b9e96e20cbbeac8ecfd7b1028b71e623', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../', -
gleap/trunk/README.txt
r3342686 r3349871 4 4 Requires at least: 5.0.0 5 5 Tested up to: 6.8.2 6 Stable tag: 13.0. 76 Stable tag: 13.0.8 7 7 License: Commercial 8 8 License URI: https://github.com/Gleap/Wordpress/blob/main/README.txt … … 38 38 39 39 == Changelog == 40 41 = 13.0.8 = 42 * Added feature to restrict Gleap widget visibility by user role and for frontend/backend separately. 40 43 41 44 = 13.0.7 = -
gleap/trunk/admin/class-gleap-admin.php
r3258602 r3349871 73 73 74 74 /** 75 * Migrate old role settings to new separate frontend/admin role settings. 76 * This ensures backward compatibility when updating from older plugin versions. 77 * Uses proper Carbon Fields methods as per documentation. 78 * 79 * @since 1.0.0 80 * @access private 81 */ 82 private function migrate_old_role_settings() 83 { 84 // Check if Carbon Fields functions are available 85 if (!function_exists('carbon_get_theme_option') || !function_exists('carbon_set_theme_option')) { 86 return; 87 } 88 89 // Check if migration has already been performed 90 $migration_done = get_option('gleap_role_migration_done', false); 91 if ($migration_done) { 92 return; 93 } 94 95 // Get old role settings from database directly since these fields are no longer registered 96 // Carbon Fields can't retrieve values for fields that aren't in the current schema 97 $old_roles_only = get_option('_gleap_selected_roles_only', null); 98 $old_selected_roles_raw = get_option('_gleap_selected_roles|||0|value', null); 99 100 // Convert the selected roles to array format 101 $old_selected_roles = null; 102 if ($old_selected_roles_raw !== null && $old_selected_roles_raw !== '') { 103 $old_selected_roles = array($old_selected_roles_raw); 104 } 105 106 // Log what we found for debugging 107 error_log('Gleap Migration: Found old database values - roles_only=' . var_export($old_roles_only, true) . ', selected_roles_raw=' . var_export($old_selected_roles_raw, true) . ', selected_roles=' . var_export($old_selected_roles, true)); 108 109 // Check if we got the expected data types and values 110 $has_valid_roles_only = ($old_roles_only === 'yes'); 111 $has_valid_selected_roles = !empty($old_selected_roles); 112 113 // Only migrate if old settings exist and have meaningful values 114 if ($has_valid_roles_only) { 115 // Convert to boolean (Carbon Fields stores checkbox as 'yes'/'no' or boolean) 116 $roles_only_bool = true; // We know it's enabled if we got here 117 118 // Ensure selected roles is an array 119 if (!is_array($old_selected_roles)) { 120 $old_selected_roles = $old_selected_roles ? array($old_selected_roles) : array(); 121 } 122 123 // Migrate to new frontend settings using direct database insertion (Carbon Fields format) 124 // Since carbon_set_theme_option might not work during field registration, 125 // we'll set the values directly in the database using Carbon Fields format 126 127 // Frontend roles only checkbox 128 update_option('_gleap_frontend_selected_roles_only', $roles_only_bool ? 'yes' : 'no'); 129 130 // Frontend selected roles multiselect 131 if (!empty($old_selected_roles)) { 132 // For multiselect fields, Carbon Fields stores each value with |||index|value format 133 foreach ($old_selected_roles as $index => $role) { 134 update_option('_gleap_frontend_selected_roles|||' . $index . '|value', $role); 135 } 136 } 137 138 // Admin roles only checkbox 139 update_option('_gleap_admin_selected_roles_only', $roles_only_bool ? 'yes' : 'no'); 140 141 // Admin selected roles multiselect 142 if (!empty($old_selected_roles)) { 143 // For multiselect fields, Carbon Fields stores each value with |||index|value format 144 foreach ($old_selected_roles as $index => $role) { 145 update_option('_gleap_admin_selected_roles|||' . $index . '|value', $role); 146 } 147 } 148 149 // Mark migration as completed 150 update_option('gleap_role_migration_done', true); 151 152 // Log successful migration 153 error_log('Gleap Migration: Successfully migrated role settings to separate frontend/admin controls'); 154 } else { 155 // Log when no migration is performed 156 error_log('Gleap Migration: No migration performed - roles_only=' . var_export($old_roles_only, true) . ', has_valid_roles_only=' . var_export($has_valid_roles_only, true)); 157 } 158 } 159 160 /** 161 * Reset migration flag - useful for development/testing 162 * This method can be called to force re-migration of settings 163 * 164 * @since 1.0.0 165 */ 166 public function reset_migration_flag() { 167 delete_option('gleap_role_migration_done'); 168 error_log('Gleap Migration: Reset migration flag - next admin page visit will trigger migration'); 169 } 170 171 /** 75 172 * Register the stylesheets for the admin area. 76 173 * … … 126 223 127 224 if ($gleap_token) { 128 $gleap_ selected_roles_only = carbon_get_theme_option('gleap_selected_roles_only');129 if ($gleap_ selected_roles_only == true) {225 $gleap_admin_selected_roles_only = carbon_get_theme_option('gleap_admin_selected_roles_only'); 226 if ($gleap_admin_selected_roles_only == true) { 130 227 $user_roles = wp_get_current_user()->roles; 131 $gleap_ selected_roles = carbon_get_theme_option('gleap_selected_roles');132 133 if (!array_intersect($user_roles, $gleap_ selected_roles)) {228 $gleap_admin_selected_roles = carbon_get_theme_option('gleap_admin_selected_roles'); 229 230 if (!array_intersect($user_roles, $gleap_admin_selected_roles)) { 134 231 // If the user's role is not in the selected roles, don't show Gleap 135 232 return; … … 209 306 public function setup_settings_ui() 210 307 { 308 // Run migration when Carbon Fields is fully registered 309 // This ensures all Carbon Fields functions are available as per v3.x docs 310 $this->migrate_old_role_settings(); 311 211 312 // Get WordPress roles 212 313 $wp_roles = wp_roles(); … … 221 322 Field::make('text', 'gleap_identity_token', 'Identity verification secret')->set_attribute('type', 'password')->set_help_text("If you'd like to verify the identity of your users, copy the code from Project -> Settings -> Security to the field above."), 222 323 Field::make('text', 'gleap_secret_api_token', 'Secret API token')->set_attribute('type', 'password')->set_help_text("If you'd like to use the Gleap Rest API to send events, copy the code from Project -> Settings -> Security to the field above."), 223 Field::make('checkbox', 'gleap_selected_roles_only', 'Enable Gleap only for the selected WP roles') 324 Field::make('checkbox', 'gleap_activate_in_frontend', 'Activate Gleap widget in Frontend') 325 ->set_default_value(true) 326 ->set_help_text('Enable the Gleap widget in the frontend area.'), 327 Field::make('checkbox', 'gleap_frontend_selected_roles_only', 'Enable Gleap frontend only for selected WP roles') 224 328 ->set_default_value(false) 225 ->set_help_text('Gleap widget will only be visible for users with the selected roles. If no roles are selected, it will be visible to all users.'), 329 ->set_help_text('Gleap widget will only be visible in frontend for users with the selected roles.') 330 ->set_conditional_logic(array( 331 array( 332 'field' => 'gleap_activate_in_frontend', 333 'value' => true, 334 'compare' => '=' 335 ) 336 )), 337 Field::make('multiselect', 'gleap_frontend_selected_roles', 'Select roles for frontend') 338 ->add_options($roles) 339 ->set_conditional_logic(array( 340 array( 341 'field' => 'gleap_frontend_selected_roles_only', 342 'value' => true, 343 'compare' => '=' 344 ) 345 )), 226 346 Field::make('checkbox', 'gleap_activate_in_admin', 'Activate Gleap widget in WP Admin') 227 347 ->set_default_value(false) 228 348 ->set_help_text('Enable the Gleap widget in the WordPress admin area.'), 229 Field::make('checkbox', 'gleap_activate_in_frontend', 'Activate Gleap widget in Frontend') 230 ->set_default_value(true) 231 ->set_help_text('Enable the Gleap widget in the frontend area.'), 232 Field::make('multiselect', 'gleap_selected_roles', 'Select roles') 349 Field::make('checkbox', 'gleap_admin_selected_roles_only', 'Enable Gleap admin only for selected WP roles') 350 ->set_default_value(false) 351 ->set_help_text('Gleap widget will only be visible in WP admin for users with the selected roles.') 352 ->set_conditional_logic(array( 353 array( 354 'field' => 'gleap_activate_in_admin', 355 'value' => true, 356 'compare' => '=' 357 ) 358 )), 359 Field::make('multiselect', 'gleap_admin_selected_roles', 'Select roles for admin') 233 360 ->add_options($roles) 234 361 ->set_conditional_logic(array( 235 362 array( 236 'field' => 'gleap_ selected_roles_only',363 'field' => 'gleap_admin_selected_roles_only', 237 364 'value' => true, 238 365 'compare' => '=' -
gleap/trunk/gleap.php
r3342686 r3349871 17 17 * Plugin Name: Gleap 18 18 * Description: Gleap helps developers build the best software faster. It is your affordable in-app bug reporting tool for apps, websites and industrial applications. 19 * Version: 13.0. 719 * Version: 13.0.8 20 20 * Author: Gleap 21 21 * Author URI: https://www.gleap.io … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define('GLEAP_VERSION', '13.0. 7');38 define('GLEAP_VERSION', '13.0.8'); 39 39 40 40 /** -
gleap/trunk/public/class-gleap-public.php
r3258602 r3349871 173 173 } 174 174 175 $gleap_ selected_roles_only = carbon_get_theme_option('gleap_selected_roles_only');176 if ($gleap_ selected_roles_only == true) {175 $gleap_frontend_selected_roles_only = carbon_get_theme_option('gleap_frontend_selected_roles_only'); 176 if ($gleap_frontend_selected_roles_only == true) { 177 177 $user_roles = wp_get_current_user()->roles; 178 $gleap_ selected_roles = carbon_get_theme_option('gleap_selected_roles');179 180 if (!array_intersect($user_roles, $gleap_ selected_roles)) {178 $gleap_frontend_selected_roles = carbon_get_theme_option('gleap_frontend_selected_roles'); 179 180 if (!array_intersect($user_roles, $gleap_frontend_selected_roles)) { 181 181 // If the user's role is not in the selected roles, don't show Gleap 182 182 return; -
gleap/trunk/vendor/composer/installed.php
r3342686 r3349871 2 2 'root' => array( 3 3 'name' => 'gleap/gleap-wp', 4 'pretty_version' => 'v13.0. 7',5 'version' => '13.0. 7.0',6 'reference' => ' 47d37dbe86166e0230bbea272f019de7d84820ff',4 'pretty_version' => 'v13.0.8', 5 'version' => '13.0.8.0', 6 'reference' => '6fd697a9b9e96e20cbbeac8ecfd7b1028b71e623', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'gleap/gleap-wp' => array( 14 'pretty_version' => 'v13.0. 7',15 'version' => '13.0. 7.0',16 'reference' => ' 47d37dbe86166e0230bbea272f019de7d84820ff',14 'pretty_version' => 'v13.0.8', 15 'version' => '13.0.8.0', 16 'reference' => '6fd697a9b9e96e20cbbeac8ecfd7b1028b71e623', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.