Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

always show debug info when debar bar is enabled/activated

  • Loading branch information...
commit af655f279649365b4989b98c3568c6bcd3d48fdc 1 parent f2707fa
Pär Thernström authored
Showing with 25 additions and 46 deletions.
  1. +1 −1  class_simple_fields_debug_panel.php
  2. +21 −42 functions.php
  3. +3 −3 readme.txt
View
2  class_simple_fields_debug_panel.php
@@ -18,7 +18,7 @@ function is_visible() {
function render() {
global $sf;
- echo $sf->simple_fields_content_debug_output("", TRUE);
+ echo $sf->simple_fields_content_debug_output("", array("always_show" => TRUE, "show_expanded" => TRUE));
}
View
63 functions.php
@@ -761,43 +761,49 @@ function simple_fields_register_field_group($slug = "", $new_field_group = array
// existing_field_array_from_slug = the merged array, with old + new options
// new values from arg = $one_new_field
// move new options to sub-array by field type
- #sf_d( $existing_field_array_from_slug );
- if ( ! isset( $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ] ) ) {
+ $arr_merged_options = $one_new_field["options"];
+ // Make sure options key for this field type exists
+ if ( ! isset( $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ] ) ) {
$existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ] = array();
+ }
+ // what about for example type_post_options that may already exist?
+ // if they exist, move to merge with options, then merge with options, before new values are merged
+ // do that first since those values are the oldest (pre-upgrade pre-save values)
+ if ( isset( $existing_field_array_from_slug[ "type_". $existing_field_array_from_slug["type"] . "_options" ] ) ) {
+ $arr_merged_options = simple_fields_merge_arrays( $existing_field_array_from_slug[ "type_". $existing_field_array_from_slug["type"] . "_options" ], $arr_merged_options);
}
// Merge in new values, overwriting existing, but also letting existing keys that have no new value be
- $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ] = simple_fields_merge_arrays( $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ], $one_new_field["options"] );
+ $arr_merged_options = simple_fields_merge_arrays( $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ], $arr_merged_options );
+
+ $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ] = $arr_merged_options;
+ // Remove the keys we added from the options array (just keep them in the sub-array)
$new_options_keys = array_keys( $one_new_field["options"] );
- // Remove the keys we added from the options array (just keep them in the sub-array)
- // TODO: if someone did enter values like this:
+ // if someone did enter values like this:
// options[field_type] => array(options..)
// then don't break that by removing
-
- // Remove the keys we added from the options array (but keep them in the sub-array)
if ( ($key_to_remove_pos = array_search( $one_new_field["type"], $new_options_keys )) !== FALSE ) {
unset( $new_options_keys[ $key_to_remove_pos ] );
unset( $existing_field_array_from_slug["options"][ $one_new_field["type"] ][ $one_new_field["type"] ] );
}
+ // Remove the keys we added from the options array (but keep them in the sub-array)
foreach ( $new_options_keys as $one_key_to_remove ) {
unset( $existing_field_array_from_slug["options"][ $one_key_to_remove ] );
}
- #foreach ( $one_new_field["options"] as $one_option_key => $one_option_value ) {
-
- # $existing_field_array_from_slug["options"][ $existing_field_array_from_slug["type"] ][]
-
- #}
+ // If this is any of the core fields types then save back options to type_<fieldtype>_options
+ // Can remove that reference completly because it's used at so many places
+ if ( $sf->field_type_is_core( $one_new_field["type"] ) ) {
+ $existing_field_array_from_slug[ "type_" . $one_new_field["type"] . "_options"] = $arr_merged_options;
+ }
+ // end move options in place
sf_d($existing_field_array_from_slug);
- #sf_d($one_new_field);
- #exit;
-
} // if field exists among fields by slugs
@@ -805,33 +811,6 @@ function simple_fields_register_field_group($slug = "", $new_field_group = array
} // for each field in a field grouo
- // Options array
- // Store options by field type here
- $options = array();
-#echo "<hr>before";sf_d( $field_groups[$field_group_id]["fields_by_slug"] );
- // For each field group as passed to function as arg
-/*
- foreach ( $field_groups[$field_group_id]["fields_by_slug"] as & $one_field_group) {
-
- if ( isset( $one_field_group["options"] ) && is_array( $one_field_group["options"] ) ) {
-
- $old_keys = array_keys( $one_field_group["options"] );
-
- // Create key for the current field type and move over options there
- $one_field_group["options"][ $one_field_group["type"] ] = $one_field_group["options"];
-
- // Remove keys since they are moved to sub array
- foreach ( $old_keys as $one_key_to_remove ) {
- unset( $one_field_group["options"][ $one_key_to_remove ] );
- }
-
- }
-
- }
-
- echo "<hr>after";sf_d( $field_groups[$field_group_id]["fields_by_slug"] );
-*/
-
$merged_fields = $field_groups[$field_group_id]["fields_by_slug"];
// Update fields (by id) from fields by slugs
View
6 readme.txt
@@ -236,9 +236,9 @@ See that "Add"-link above "Article images"? That means that it is repeatable, so
== Changelog ==
#### Version 1.1.x
-- Added debug panel to debug bar (if installed). Makes it possible to preview stored values when inside WordPress admin and editing posts. Only visible when debug is enabled.
+- Added debug panel to debug bar (if installed). Makes it possible to preview stored values when inside WordPress admin and editing posts. Will automatically be enabled when debug bar is installed and activated.
- Changed debug box to stop using jQuery, so it should work with more themes and in more situations where jQuery may not be available
-- Fixed bug with post field type dialog.
+- Fixed bug with post field type dialog
- Fixed passing additional arguments for field type post
- Fixed memory leak when using cache. When using functions that cleared the cache, for example simple_fields_set_value(), then memory usage could increase pretty much, and when the function is used in a loop then eventionally the script would eat up all memory. Nom nom nom. But in a bad way.
- Changed the way some cache keys where stored, beacuse a key in an array that contains quotes is just silly looking (but valid, apparently)
@@ -275,7 +275,7 @@ See that "Add"-link above "Article images"? That means that it is repeatable, so
simple_fields_get_field_group_by_slug
simple_fields_clear_caches
- Lotsa code cleanups and stuff
-- Fixed so plugin works with jQuery 1.9, beacuse now jQuery(htmlString) requires first char to be < for string to be considered HTML. Was not working due to spaces before first HMTL tag.
+- Fixed so plugin works with jQuery 1.9, because now jQuery(htmlString) requires first char to be < for string to be considered HTML. Was not working due to spaces before first HMTL tag.
#### Version 1.1.6
- Fixed bug that could lead to memoryleak. Thanks to plux/angry creative for patch.
Please sign in to comment.
Something went wrong with that request. Please try again.