Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp widget connector #391

Merged
merged 48 commits into from
Jul 10, 2014
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
10e6dd4
Serialize non-scalar values when inserting meta
westonruter Mar 29, 2014
cc03d23
Eliminate reference to undefined variable
westonruter Mar 29, 2014
025e38d
Refactor widgets connector to track bulk changes and to add support f…
westonruter Apr 3, 2014
8ecc107
Fix detection for sorted action
westonruter Apr 5, 2014
7d1c452
Track widget movement to other sidebars
westonruter Apr 5, 2014
fecc29f
Use alternate summary template for handle_widget_reordering
westonruter Apr 5, 2014
0aa257f
Filter-out non-scalars from being applied to summary tpl
westonruter Apr 5, 2014
e52ea0f
Update addition and deletion handlers to use new summary tpl
westonruter Apr 5, 2014
339aaf2
Re-work widget update callback to also track creates and deletes
westonruter Apr 5, 2014
c010105
Fix logic for looking up a multi widget instance
westonruter Apr 5, 2014
dccd400
Prevent widget movement record if dealing with active/inactive widgets
westonruter Apr 5, 2014
7ba6ba7
Fix widget object lookup for newly-created widgets
westonruter Apr 5, 2014
01d4c4a
Turn deleted action into removed action for removing widget from sidebar
westonruter Apr 6, 2014
d4983c8
Remove moved action
westonruter Apr 6, 2014
2337ca7
Skip logging created and deleted actions by default
westonruter Apr 6, 2014
d9dd001
Break up moved record into one removed and one added record
westonruter Apr 6, 2014
a48e492
Use experimental phpcs rule subset
westonruter Apr 6, 2014
67e2139
Make the PHPCS WordPress ruleset directory
westonruter Apr 6, 2014
870fd53
Apply PHPCS fixes and some phpDoc improvements
westonruter Apr 6, 2014
f792fe9
Merge branch 'master' into widget-customizer
westonruter Apr 6, 2014
9f85ce9
Merge branch 'develop' into widget-customizer
westonruter Apr 17, 2014
6ba3888
Allow PHPCS and WPCS to pull from different locations
westonruter Apr 17, 2014
6b35ebe
Merge branch 'phpcs-improvements' into widget-customizer
westonruter Apr 17, 2014
948280e
Fix .travis.yml syntax error
westonruter Apr 17, 2014
d1a5186
Add xss ok for phpcs
westonruter Apr 17, 2014
aa81069
Use .ci-env.sh (nee .travis.before_script.sh) in pre-commit hook
westonruter Apr 17, 2014
aabe9f8
Merge branch 'develop' into widget-customizer
westonruter Apr 26, 2014
297ccf0
Collapse changes to sidebars_widgets in customizer
westonruter Apr 26, 2014
8f3f088
Fix PHPCS issues
westonruter Apr 26, 2014
af2dfda
Merge branch 'plugin-dev-lib' into widget-customizer
westonruter May 1, 2014
2d172cb
Eliminate apply_tpl_vars(), and restore use of _x()
westonruter May 1, 2014
02309a2
Combined removed/added actions into one moved action
westonruter May 1, 2014
ca2c47d
Merge branch 'develop' into widget-customizer
westonruter May 11, 2014
6f3c39f
Reference sidebar_id instead of sidebar streammeta
westonruter May 11, 2014
033c3a7
Merge branch 'develop' into widget-customizer
frankiejarrett Jun 11, 2014
42ca9e1
Code formatting
frankiejarrett Jun 11, 2014
f78fc45
Merge develop into widget-customizer
frankiejarrett Jul 10, 2014
80e5c31
Summary improvements to widgets added
frankiejarrett Jul 10, 2014
8f15fe5
Summary tweak for widgets reordered
frankiejarrett Jul 10, 2014
64c6bb4
Summary improvements for widgets moved
frankiejarrett Jul 10, 2014
849d2c6
Summary improvements for widgets updated
frankiejarrett Jul 10, 2014
3b87954
Summary improvements for widgets created
frankiejarrett Jul 10, 2014
5e52f17
No need for Sidebar Name in widget created/deleted summaries
frankiejarrett Jul 10, 2014
e31de41
Reordering vars for consistency
frankiejarrett Jul 10, 2014
b8624e4
Summary improvements for widgets removed
frankiejarrett Jul 10, 2014
ed8f623
Summary improvements for widgets reactivated
frankiejarrett Jul 10, 2014
4527a59
Summary improvements for widgets deactivated
frankiejarrett Jul 10, 2014
3b134b1
Widget summary grammar tweaks
frankiejarrett Jul 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Turn deleted action into removed action for removing widget from sidebar
Fix typo in logging deletions
  • Loading branch information
westonruter committed Apr 6, 2014
commit 01d4c4a28aa31ddb56d3478a9b89a1f578362736
23 changes: 12 additions & 11 deletions connectors/widgets.php
Original file line number Diff line number Diff line change
@@ -36,6 +36,7 @@ public static function get_label() {
public static function get_action_labels() {
return array(
'added' => __( 'Added', 'stream' ),
'removed' => __( 'Removed', 'stream' ),
'created' => __( 'Created', 'stream' ),
'deleted' => __( 'Deleted', 'stream' ),
'deactivated' => __( 'Deactivated', 'stream' ),
@@ -115,7 +116,7 @@ public static function callback_update_option_sidebars_widgets( $old, $new ) {

self::handle_deactivated_widgets( $old, $new );
self::handle_reactivated_widgets( $old, $new );
self::handle_widget_deletion( $old, $new );
self::handle_widget_removal( $old, $new );
self::handle_widget_addition( $old, $new );
self::handle_widget_reordering( $old, $new );
self::handle_widget_moved( $old, $new );
@@ -219,7 +220,7 @@ static protected function handle_reactivated_widgets( $old, $new ) {
* @param array $new New sidebars widgets
* @return void
*/
static protected function handle_widget_deletion( $old, $new ) {
static protected function handle_widget_removal( $old, $new ) {
$all_old_widget_ids = array_unique( call_user_func_array( 'array_merge', $old ) );
$all_new_widget_ids = array_unique( call_user_func_array( 'array_merge', $new ) );
// @todo In the customizer, moving widgets to other sidebars is problematic because each sidebar is registered as a separate setting; so we need to make sure that all $_POST['customized'] are applied?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was addressed in 297ccf0.

@@ -234,20 +235,20 @@ static protected function handle_widget_deletion( $old, $new ) {
break;
}
}
$action = 'deleted';
$action = 'removed';
$title = self::get_widget_title( $widget_id );
$name = self::get_widget_name( $widget_id );
if ( $name && $title ) {
$message = __( '"{title}" ({name}) widget deleted', 'stream' );
$message = __( '"{title}" ({name}) widget removed', 'stream' );
} else if ( $name ) {
// Empty title, but we have the name
$message = __( '{name} widget deleted', 'stream' );
$message = __( '{name} widget removed', 'stream' );
} else if ( $title ) {
// Likely a single widget since no name is available
$message = __( '"{title}" widget deleted', 'stream' );
$message = __( '"{title}" widget removed', 'stream' );
} else {
// Neither a name nor a title are available, so use the widget ID
$message = __( '{widget_id} widget deleted', 'stream' );
$message = __( '{widget_id} widget removed', 'stream' );
}

$tpl_vars = compact( 'name', 'title', 'widget_id' );
@@ -482,7 +483,7 @@ public static function callback_updated_option( $option_name, $old_value, $new_v
$title = ! empty( $instance['title'] ) ? $instance['title'] : null;
$name = self::get_widget_name( $widget_id );
$sidebar_id = self::get_widget_sidebar_id( $widget_id ); // @todo May not be assigned anymore
$creates[] = compact( 'name', 'title', 'widget_id', 'sidebar_id', 'instance' );
$deletes[] = compact( 'name', 'title', 'widget_id', 'sidebar_id', 'instance' );
}
} else {
// Doing our best guess for tracking changes to old single widgets, assuming their options start with 'widget_'
@@ -547,7 +548,7 @@ public static function callback_updated_option( $option_name, $old_value, $new_v
* @todo We should only do these if not captured by an update to the sidebars_widgets option
*/
foreach ( $deletes as $delete ) {
if ( $create['name'] && $delete['title'] ) {
if ( $delete['name'] && $delete['title'] ) {
$message = __( '"{title}" ({name}) deleted', 'stream' );
} else if ( $delete['name'] ) {
// Empty title, but we have the name
@@ -562,8 +563,8 @@ public static function callback_updated_option( $option_name, $old_value, $new_v

$tpl_vars = $delete;
$message = self::apply_tpl_vars( $message, $tpl_vars );
$contexts = array( $create['sidebar_id'] => 'deleted' );
self::log( $message, $create, null, $contexts );
$contexts = array( $delete['sidebar_id'] => 'deleted' );
self::log( $message, $delete, null, $contexts );
}
}