Stream - Version 3.4.3

Version Description

  • March 19, 2020 =

  • Fix: Stream records can be filtered by users again #929, props @tareiking.

  • New: Composer releases now include the built assets #1054.

Download this release

Release Info

Developer kasparsd
Plugin Icon 128x128 Stream
Version 3.4.3
Comparing to
See all releases

Code changes from version 3.4.2 to 3.4.3

classes/class-list-table.php CHANGED
@@ -718,55 +718,46 @@ class List_Table extends \WP_List_Table {
718
  }
719
 
720
  public function filter_select( $name, $title, $items, $ajax = false ) {
721
- if ( $ajax ) {
722
- $out = sprintf(
723
- '<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />',
724
- esc_attr( $name ),
725
- esc_attr( wp_stream_filter_input( INPUT_GET, $name ) ),
726
- esc_attr( $title )
 
 
 
 
 
 
 
 
727
  );
728
- } else {
729
- $options = array( '<option value=""></option>' );
730
- $selected = wp_stream_filter_input( INPUT_GET, $name );
731
-
732
- foreach ( $items as $key => $item ) {
733
- $value = isset( $item['children'] ) ? 'group-' . $key : $key;
734
- $option_args = array(
735
- 'value' => $value,
736
- 'selected' => selected( $value, $selected, false ),
737
- 'disabled' => isset( $item['disabled'] ) ? $item['disabled'] : null,
738
- 'icon' => isset( $item['icon'] ) ? $item['icon'] : null,
739
- 'group' => isset( $item['children'] ) ? $key : null,
740
- 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null,
741
- 'class' => isset( $item['children'] ) ? 'level-1' : null,
742
- 'label' => isset( $item['label'] ) ? $item['label'] : null,
743
- );
744
- $options[] = $this->filter_option( $option_args );
745
-
746
- if ( isset( $item['children'] ) ) {
747
- foreach ( $item['children'] as $child_value => $child_item ) {
748
- $option_args = array(
749
- 'value' => $child_value,
750
- 'selected' => selected( $child_value, $selected, false ),
751
- 'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
752
- 'icon' => isset( $child_item['icon'] ) ? $child_item['icon'] : null,
753
- 'group' => $key,
754
- 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null,
755
- 'class' => 'level-2',
756
- 'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
757
- );
758
- $options[] = $this->filter_option( $option_args );
759
- }
760
  }
761
  }
762
- $out = sprintf(
763
- '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
764
- esc_attr( $name ),
765
- // translators: Placeholder refers to the title of the dropdown menu (e.g. "users")
766
- sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ),
767
- implode( '', $options )
768
- );
769
  }
 
 
 
 
 
 
 
770
 
771
  return $out;
772
  }
@@ -895,6 +886,7 @@ class List_Table extends \WP_List_Table {
895
  }
896
  echo '</select></div>';
897
  wp_nonce_field( 'stream_record_actions_nonce', 'stream_record_actions_nonce' );
 
898
 
899
  printf( '<input type="hidden" name="page" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'page' ) ) );
900
  printf( '<input type="hidden" name="date_predefined" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'date_predefined' ) ) );
718
  }
719
 
720
  public function filter_select( $name, $title, $items, $ajax = false ) {
721
+ $options = array( '<option value=""></option>' );
722
+ $selected = wp_stream_filter_input( INPUT_GET, $name );
723
+
724
+ foreach ( $items as $key => $item ) {
725
+ $value = isset( $item['children'] ) ? 'group-' . $key : $key;
726
+ $option_args = array(
727
+ 'value' => $value,
728
+ 'selected' => selected( $value, $selected, false ),
729
+ 'disabled' => isset( $item['disabled'] ) ? $item['disabled'] : null,
730
+ 'icon' => isset( $item['icon'] ) ? $item['icon'] : null,
731
+ 'group' => isset( $item['children'] ) ? $key : null,
732
+ 'tooltip' => isset( $item['tooltip'] ) ? $item['tooltip'] : null,
733
+ 'class' => isset( $item['children'] ) ? 'level-1' : null,
734
+ 'label' => isset( $item['label'] ) ? $item['label'] : null,
735
  );
736
+ $options[] = $this->filter_option( $option_args );
737
+
738
+ if ( isset( $item['children'] ) ) {
739
+ foreach ( $item['children'] as $child_value => $child_item ) {
740
+ $option_args = array(
741
+ 'value' => $child_value,
742
+ 'selected' => selected( $child_value, $selected, false ),
743
+ 'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
744
+ 'icon' => isset( $child_item['icon'] ) ? $child_item['icon'] : null,
745
+ 'group' => $key,
746
+ 'tooltip' => isset( $child_item['tooltip'] ) ? $child_item['tooltip'] : null,
747
+ 'class' => 'level-2',
748
+ 'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
749
+ );
750
+ $options[] = $this->filter_option( $option_args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
  }
752
  }
 
 
 
 
 
 
 
753
  }
754
+ $out = sprintf(
755
+ '<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
756
+ esc_attr( $name ),
757
+ // translators: Placeholder refers to the title of the dropdown menu (e.g. "users")
758
+ sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ),
759
+ implode( '', $options )
760
+ );
761
 
762
  return $out;
763
  }
886
  }
887
  echo '</select></div>';
888
  wp_nonce_field( 'stream_record_actions_nonce', 'stream_record_actions_nonce' );
889
+ wp_nonce_field( 'stream_filters_user_search_nonce', 'stream_filters_user_search_nonce' );
890
 
891
  printf( '<input type="hidden" name="page" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'page' ) ) );
892
  printf( '<input type="hidden" name="date_predefined" value="%s">', esc_attr( wp_stream_filter_input( INPUT_GET, 'date_predefined' ) ) );
classes/class-plugin.php CHANGED
@@ -9,7 +9,7 @@ class Plugin {
9
  *
10
  * @const string
11
  */
12
- const VERSION = '3.4.2';
13
 
14
  /**
15
  * WP-CLI command
9
  *
10
  * @const string
11
  */
12
+ const VERSION = '3.4.3';
13
 
14
  /**
15
  * WP-CLI command
readme.md CHANGED
@@ -1,6 +1,6 @@
1
  # Stream for WordPress
2
 
3
- [![Build Status](https://travis-ci.org/xwp/stream.svg?branch=master)](https://travis-ci.org/xwp/stream)
4
 
5
  **Track WordPress user and system actions for debugging, logging and compliance purposes.**
6
 
1
  # Stream for WordPress
2
 
3
+ [![Build Status](https://travis-ci.com/xwp/stream.svg?branch=master)](https://travis-ci.com/xwp/stream)
4
 
5
  **Track WordPress user and system actions for debugging, logging and compliance purposes.**
6
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: lukecarbis, fjarrett, stream, xwp, kasparsd
3
  Tags: wp stream, stream, activity, logs, track
4
  Requires at least: 4.5
5
- Tested up to: 5.2
6
- Stable tag: 3.4.2
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -87,6 +87,11 @@ Thank you for wanting to make Stream better for everyone!
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
90
  = 3.4.2 - September 26, 2019 =
91
 
92
  * Fix: Visiting the plugin settings page no longer produces PHP warnings for undefined variables [#1031](https://github.com/xwp/stream/issues/1031).
@@ -99,7 +104,7 @@ Thank you for wanting to make Stream better for everyone!
99
  = 3.4.0 - July 13, 2019 =
100
 
101
  * New: Add development environment and documentation, update tooling [#1016](https://github.com/xwp/stream/pull/1016).
102
- * New: Add [Mercator](https://github.com/humanmade/Mercator) connector [#993](https://github.com/xwp/stream/pull/993), props [@spacedmonkey](https://github.com/spacedmonkey)).
103
  * Fix: Respect the `DISALLOW_FILE_MODS` constant and prevent plugin uninstall, if set. [#997](https://github.com/xwp/stream/pull/997) fixes [#988](https://github.com/xwp/stream/issues/988), props [@lukecarbis](https://github.com/lukecarbis) and [@josephfusco](https://github.com/josephfusco).
104
 
105
  = 3.3.0 - June 18, 2019 =
2
  Contributors: lukecarbis, fjarrett, stream, xwp, kasparsd
3
  Tags: wp stream, stream, activity, logs, track
4
  Requires at least: 4.5
5
+ Tested up to: 5.4
6
+ Stable tag: 3.4.3
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
87
 
88
  == Changelog ==
89
 
90
+ = 3.4.3 - March 19, 2020 =
91
+
92
+ * Fix: Stream records can be filtered by users again [#929](https://github.com/xwp/stream/issues/929), props [@tareiking](https://github.com/tareiking).
93
+ * New: Composer releases now include the built assets [#1054](https://github.com/xwp/stream/issues/1054).
94
+
95
  = 3.4.2 - September 26, 2019 =
96
 
97
  * Fix: Visiting the plugin settings page no longer produces PHP warnings for undefined variables [#1031](https://github.com/xwp/stream/issues/1031).
104
  = 3.4.0 - July 13, 2019 =
105
 
106
  * New: Add development environment and documentation, update tooling [#1016](https://github.com/xwp/stream/pull/1016).
107
+ * New: Add [Mercator](https://github.com/humanmade/Mercator) connector [#993](https://github.com/xwp/stream/pull/993), props [@spacedmonkey](https://github.com/spacedmonkey).
108
  * Fix: Respect the `DISALLOW_FILE_MODS` constant and prevent plugin uninstall, if set. [#997](https://github.com/xwp/stream/pull/997) fixes [#988](https://github.com/xwp/stream/issues/988), props [@lukecarbis](https://github.com/lukecarbis) and [@josephfusco](https://github.com/josephfusco).
109
 
110
  = 3.3.0 - June 18, 2019 =
stream.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * Plugin Name: Stream
4
- * Plugin URI: https://wp-stream.com/
5
  * Description: Stream tracks logged-in user activity so you can monitor every change made on your WordPress site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action.
6
- * Version: 3.4.2
7
  * Author: XWP
8
- * Author URI: https://xwp.co/
9
  * License: GPLv2+
10
  * Text Domain: stream
11
  * Domain Path: /languages
1
  <?php
2
  /**
3
  * Plugin Name: Stream
4
+ * Plugin URI: https://wp-stream.com
5
  * Description: Stream tracks logged-in user activity so you can monitor every change made on your WordPress site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action.
6
+ * Version: 3.4.3
7
  * Author: XWP
8
+ * Author URI: https://xwp.co
9
  * License: GPLv2+
10
  * Text Domain: stream
11
  * Domain Path: /languages
ui/js/admin.js CHANGED
@@ -25,7 +25,7 @@ jQuery(
25
  record.text = record.text.substring( 2 );
26
  }
27
 
28
- if ( 'undefined' !== typeof record.id ) {
29
  if ( record.id.indexOf( 'group-' ) === 0 ) {
30
  $result.addClass( 'parent' );
31
  } else if ( $elem.hasClass( 'level-2' ) ) {
25
  record.text = record.text.substring( 2 );
26
  }
27
 
28
+ if ( 'undefined' !== typeof record.id && 'string' === typeof record.id ) {
29
  if ( record.id.indexOf( 'group-' ) === 0 ) {
30
  $result.addClass( 'parent' );
31
  } else if ( $elem.hasClass( 'level-2' ) ) {
ui/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){"en"===wp_stream.locale&&void 0!==e.timeago&&(e.timeago.settings.strings.seconds="seconds",e.timeago.settings.strings.minute="a minute",e.timeago.settings.strings.hour="an hour",e.timeago.settings.strings.hours="%d hours",e.timeago.settings.strings.month="a month",e.timeago.settings.strings.year="a year"),e("li.toplevel_page_wp_stream ul li.wp-first-item.current").parent().parent().find(".update-plugins").remove(),e(".toplevel_page_wp_stream :input.chosen-select").each(function(t,a){var i={},n=function(t){var a=e("<span>"),i=e(t.element),n="";return"- "===t.text.substring(0,2)&&(t.text=t.text.substring(2)),void 0!==t.id&&(0===t.id.indexOf("group-")?a.addClass("parent"):i.hasClass("level-2")&&a.addClass("child")),void 0!==t.icon?n=t.icon:void 0!==i&&""!==i.data("icon")&&(n=i.data("icon")),n&&a.html('<img src="'+n+'" class="wp-stream-select2-icon">'),a.append(t.text),a},r=function(e){return"- "===e.text.substring(0,2)&&(e.text=e.text.substring(2)),e.text};i=e(a).find("option").not(":selected").not(":empty").length>0?{minimumResultsForSearch:10,templateResult:n,templateSelection:r,allowClear:!0,width:"165px"}:{minimumInputLength:3,allowClear:!0,width:"165px",ajax:{url:ajaxurl,dataType:"json",quietMillis:100,data:function(t){return{action:"wp_stream_filters",nonce:e("#stream_filters_user_search_nonce").val(),filter:e(a).attr("name"),q:t.term}},processResults:function(t){var a=[];return e.each(t,function(e,t){a.push({id:t.id,text:t.label})}),{results:a}}},templateResult:n,templateSelection:r},e(a).select2(i)});var t=e.streamGetQueryVars(),a=e('.toplevel_page_wp_stream select.chosen-select[name="context"]');void 0!==t.context&&""!==t.context||void 0===t.connector||(a.val("group-"+t.connector),a.trigger("change")),e("input[type=submit]","#record-filter-form").click(function(){e("input[type=submit]",e(this).parents("form")).removeAttr("clicked"),e(this).attr("clicked","true")}),e("#record-filter-form").submit(function(){var t=e('.toplevel_page_wp_stream :input.chosen-select[name="context"]'),a=t.find("option:selected"),i=t.parent().find(".record-filter-connector"),n=a.data("group"),r=a.prop("class"),s=e(".recordactions select");"true"!==e("#record-actions-submit").attr("clicked")&&s.val(""),i.val(n),"level-1"===r&&a.val("")}),e(window).load(function(){e('.toplevel_page_wp_stream input[type="search"]').off("mousedown")}),e("body").on("click","#wp_stream_advanced_delete_all_records, #wp_stream_network_advanced_delete_all_records",function(e){window.confirm(wp_stream.i18n.confirm_purge)||e.preventDefault()}),e("body").on("click","#wp_stream_advanced_reset_site_settings, #wp_stream_network_advanced_reset_site_settings",function(e){window.confirm(wp_stream.i18n.confirm_defaults)||e.preventDefault()}),e("body").on("click","#wp_stream_uninstall",function(e){window.confirm(wp_stream.i18n.confirm_uninstall)||e.preventDefault()});var i=e(".wp_stream_screen .nav-tab-wrapper"),n=e(".wp_stream_screen .nav-tab-content table.form-table"),r=i.find(".nav-tab-active"),s=r.length>0?i.find("a").index(r):0,o=window.location.hash.match(/^#(\d+)$/),c=null!==o?o[1]:s,d=function(t){var a=e('input[name="option_page"][value^="wp_stream"]').closest("form");if(0!==a.length){var i=a.attr("action");a.prop("action",i.replace(/(^[^#]*).*$/,"$1#"+t))}};i.on("click","a",function(){var t=i.find("a").index(e(this)),a=window.location.hash.match(/^#(\d+)$/);return n.hide().eq(t).show(),i.find("a").removeClass("nav-tab-active").filter(e(this)).addClass("nav-tab-active"),""!==window.location.hash&&null===a||(window.location.hash=t),d(t),!1}),i.children().eq(c).trigger("click"),e(document).ready(function(){function t(){var t=!0;e('div.metabox-prefs [name="date-hide"]').is(":checked")&&(t=!1),e("div.alignleft.actions div.select2-container").each(function(){if(!e(this).is(":hidden"))return t=!1,!1}),t?(e("input#record-query-submit").hide(),e("span.filter_info").show()):(e("input#record-query-submit").show(),e("span.filter_info").hide())}e("#enable_live_update").click(function(){var t=e("#stream_live_update_nonce").val(),a=e("#enable_live_update_user").val(),i="unchecked",n="true";e("#enable_live_update").is(":checked")&&(i="checked"),n=e("#enable_live_update").data("heartbeat"),e.ajax({type:"POST",url:ajaxurl,data:{action:"stream_enable_live_update",nonce:t,user:a,checked:i,heartbeat:n},dataType:"json",beforeSend:function(){e(".stream-live-update-checkbox .spinner").show().css({display:"inline-block"})},success:function(t){e(".stream-live-update-checkbox .spinner").hide(),!1===t.success&&(e("#enable_live_update").prop("checked",!1),t.data&&window.alert(t.data))}})}),e('div.metabox-prefs [name="date-hide"]').is(":checked")?e("div.date-interval").show():e("div.date-interval").hide(),e("div.actions select.chosen-select").each(function(){var t=e(this).prop("name");e('div.metabox-prefs [name="'+t+'-hide"]').is(":checked")?e(this).prev(".select2-container").show():e(this).prev(".select2-container").hide()}),t(),e('div.metabox-prefs [type="checkbox"]').click(function(){var a=e(this).prop("id");"date-hide"===a?e(this).is(":checked")?e("div.date-interval").show():e("div.date-interval").hide():(a=a.replace("-hide",""),e(this).is(":checked")?e('[name="'+a+'"]').prev(".select2-container").show():e('[name="'+a+'"]').prev(".select2-container").hide()),t()}),e("#ui-datepicker-div").addClass("stream-datepicker")}),e("table.wp-list-table").on("updated",function(){e(this).find("time.relative-time").each(function(t,a){var i=e(a);i.removeClass("relative-time"),e('<strong><time datetime="'+i.attr("datetime")+'" class="timeago"/></time></strong><br/>').prependTo(i.parent().parent()).find("time.timeago").timeago()})}).trigger("updated");var l={init:function(t){this.wrapper=t,this.save_interval(this.wrapper.find(".button-primary"),this.wrapper),this.$=this.wrapper.each(function(t,a){var i=e(a),n=i.find(".date-inputs"),r=i.find(".field-from"),s=i.find(".field-to"),o=s.prev(".date-remove"),c=r.prev(".date-remove"),d=i.children(".field-predefined"),l=e("").add(s).add(r);if(jQuery.datepicker){var p=parseFloat(wp_stream.gmt_offset)-(new Date).getTimezoneOffset()/60*-1,u=new Date,h=new Date(u.getTime()+60*p*60*1e3),m=0;u.getDate()===h.getDate()&&u.getMonth()===h.getMonth()||(m=u.getTime()<h.getTime()?"+1d":"-1d"),l.datepicker({dateFormat:"yy/mm/dd",minDate:null,maxDate:m,defaultDate:h,beforeShow:function(){e(this).prop("disabled",!0)},onClose:function(){e(this).prop("disabled",!1)}}),l.datepicker("widget").addClass("stream-datepicker")}d.select2({allowClear:!0}),""!==r.val()&&c.show(),""!==s.val()&&o.show(),d.on({change:function(){var t=e(this).val(),a=d.find('[value="'+t+'"]'),i=a.data("to"),o=a.data("from");if("custom"===t)return n.show(),!1;n.hide(),l.datepicker("hide"),r.val(o).trigger("change",[!0]),s.val(i).trigger("change",[!0]),jQuery.datepicker&&l.datepicker("widget").is(":visible")&&l.datepicker("refresh").datepicker("hide")},"select2-removed":function(){d.val("").trigger("change")},check_options:function(){if(""!==s.val()&&""!==r.val()){var e=d.find("option").filter('[data-to="'+s.val()+'"]').filter('[data-from="'+r.val()+'"]');0!==e.length?d.val(e.attr("value")).trigger("change",[!0]):d.val("custom").trigger("change",[!0])}else""===s.val()&&""===r.val()?d.val("").trigger("change",[!0]):d.val("custom").trigger("change",[!0])}}),r.on("change",function(){if(""!==r.val()?(c.show(),s.datepicker("option","minDate",r.val())):c.hide(),!0===arguments[arguments.length-1])return!1;d.trigger("check_options")}),s.on("change",function(){if(""!==s.val()?(o.show(),r.datepicker("option","maxDate",s.val())):o.hide(),!0===arguments[arguments.length-1])return!1;d.trigger("check_options")}),d.trigger("change"),e("").add(c).add(o).on("click",function(){e(this).next("input").val("").trigger("change")})})},save_interval:function(t){var a=this.wrapper;t.click(function(){var t={key:a.find("select.field-predefined").find(":selected").val(),start:a.find(".date-inputs .field-from").val(),end:a.find(".date-inputs .field-to").val()};e(this).attr("href",e(this).attr("href")+"&"+e.param(t))})}};e(document).ready(function(){l.init(e(".date-interval")),e('select[name="context"] .level-1').each(function(){var t=!0;e(this).nextUntil(".level-1").each(function(){if(e(this).is(":not(:disabled)"))return t=!1,!1}),!0===t&&e(this).prop("disabled",!0)})})}),jQuery.extend({streamGetQueryVars:function(e){return(e||document.location.search).replace(/(^\?)/,"").split("&").map(function(e){return e=e.split("="),this[e[0]]=e[1],this}.bind({}))[0]}});
1
+ jQuery(function(e){"en"===wp_stream.locale&&void 0!==e.timeago&&(e.timeago.settings.strings.seconds="seconds",e.timeago.settings.strings.minute="a minute",e.timeago.settings.strings.hour="an hour",e.timeago.settings.strings.hours="%d hours",e.timeago.settings.strings.month="a month",e.timeago.settings.strings.year="a year"),e("li.toplevel_page_wp_stream ul li.wp-first-item.current").parent().parent().find(".update-plugins").remove(),e(".toplevel_page_wp_stream :input.chosen-select").each(function(t,a){var i={},n=function(t){var a=e("<span>"),i=e(t.element),n="";return"- "===t.text.substring(0,2)&&(t.text=t.text.substring(2)),void 0!==t.id&&"string"==typeof t.id&&(0===t.id.indexOf("group-")?a.addClass("parent"):i.hasClass("level-2")&&a.addClass("child")),void 0!==t.icon?n=t.icon:void 0!==i&&""!==i.data("icon")&&(n=i.data("icon")),n&&a.html('<img src="'+n+'" class="wp-stream-select2-icon">'),a.append(t.text),a},r=function(e){return"- "===e.text.substring(0,2)&&(e.text=e.text.substring(2)),e.text};i=e(a).find("option").not(":selected").not(":empty").length>0?{minimumResultsForSearch:10,templateResult:n,templateSelection:r,allowClear:!0,width:"165px"}:{minimumInputLength:3,allowClear:!0,width:"165px",ajax:{url:ajaxurl,dataType:"json",quietMillis:100,data:function(t){return{action:"wp_stream_filters",nonce:e("#stream_filters_user_search_nonce").val(),filter:e(a).attr("name"),q:t.term}},processResults:function(t){var a=[];return e.each(t,function(e,t){a.push({id:t.id,text:t.label})}),{results:a}}},templateResult:n,templateSelection:r},e(a).select2(i)});var t=e.streamGetQueryVars(),a=e('.toplevel_page_wp_stream select.chosen-select[name="context"]');void 0!==t.context&&""!==t.context||void 0===t.connector||(a.val("group-"+t.connector),a.trigger("change")),e("input[type=submit]","#record-filter-form").click(function(){e("input[type=submit]",e(this).parents("form")).removeAttr("clicked"),e(this).attr("clicked","true")}),e("#record-filter-form").submit(function(){var t=e('.toplevel_page_wp_stream :input.chosen-select[name="context"]'),a=t.find("option:selected"),i=t.parent().find(".record-filter-connector"),n=a.data("group"),r=a.prop("class"),s=e(".recordactions select");"true"!==e("#record-actions-submit").attr("clicked")&&s.val(""),i.val(n),"level-1"===r&&a.val("")}),e(window).load(function(){e('.toplevel_page_wp_stream input[type="search"]').off("mousedown")}),e("body").on("click","#wp_stream_advanced_delete_all_records, #wp_stream_network_advanced_delete_all_records",function(e){window.confirm(wp_stream.i18n.confirm_purge)||e.preventDefault()}),e("body").on("click","#wp_stream_advanced_reset_site_settings, #wp_stream_network_advanced_reset_site_settings",function(e){window.confirm(wp_stream.i18n.confirm_defaults)||e.preventDefault()}),e("body").on("click","#wp_stream_uninstall",function(e){window.confirm(wp_stream.i18n.confirm_uninstall)||e.preventDefault()});var i=e(".wp_stream_screen .nav-tab-wrapper"),n=e(".wp_stream_screen .nav-tab-content table.form-table"),r=i.find(".nav-tab-active"),s=r.length>0?i.find("a").index(r):0,o=window.location.hash.match(/^#(\d+)$/),c=null!==o?o[1]:s,d=function(t){var a=e('input[name="option_page"][value^="wp_stream"]').closest("form");if(0!==a.length){var i=a.attr("action");a.prop("action",i.replace(/(^[^#]*).*$/,"$1#"+t))}};i.on("click","a",function(){var t=i.find("a").index(e(this)),a=window.location.hash.match(/^#(\d+)$/);return n.hide().eq(t).show(),i.find("a").removeClass("nav-tab-active").filter(e(this)).addClass("nav-tab-active"),""!==window.location.hash&&null===a||(window.location.hash=t),d(t),!1}),i.children().eq(c).trigger("click"),e(document).ready(function(){function t(){var t=!0;e('div.metabox-prefs [name="date-hide"]').is(":checked")&&(t=!1),e("div.alignleft.actions div.select2-container").each(function(){if(!e(this).is(":hidden"))return t=!1,!1}),t?(e("input#record-query-submit").hide(),e("span.filter_info").show()):(e("input#record-query-submit").show(),e("span.filter_info").hide())}e("#enable_live_update").click(function(){var t=e("#stream_live_update_nonce").val(),a=e("#enable_live_update_user").val(),i="unchecked",n="true";e("#enable_live_update").is(":checked")&&(i="checked"),n=e("#enable_live_update").data("heartbeat"),e.ajax({type:"POST",url:ajaxurl,data:{action:"stream_enable_live_update",nonce:t,user:a,checked:i,heartbeat:n},dataType:"json",beforeSend:function(){e(".stream-live-update-checkbox .spinner").show().css({display:"inline-block"})},success:function(t){e(".stream-live-update-checkbox .spinner").hide(),!1===t.success&&(e("#enable_live_update").prop("checked",!1),t.data&&window.alert(t.data))}})}),e('div.metabox-prefs [name="date-hide"]').is(":checked")?e("div.date-interval").show():e("div.date-interval").hide(),e("div.actions select.chosen-select").each(function(){var t=e(this).prop("name");e('div.metabox-prefs [name="'+t+'-hide"]').is(":checked")?e(this).prev(".select2-container").show():e(this).prev(".select2-container").hide()}),t(),e('div.metabox-prefs [type="checkbox"]').click(function(){var a=e(this).prop("id");"date-hide"===a?e(this).is(":checked")?e("div.date-interval").show():e("div.date-interval").hide():(a=a.replace("-hide",""),e(this).is(":checked")?e('[name="'+a+'"]').prev(".select2-container").show():e('[name="'+a+'"]').prev(".select2-container").hide()),t()}),e("#ui-datepicker-div").addClass("stream-datepicker")}),e("table.wp-list-table").on("updated",function(){e(this).find("time.relative-time").each(function(t,a){var i=e(a);i.removeClass("relative-time"),e('<strong><time datetime="'+i.attr("datetime")+'" class="timeago"/></time></strong><br/>').prependTo(i.parent().parent()).find("time.timeago").timeago()})}).trigger("updated");var l={init:function(t){this.wrapper=t,this.save_interval(this.wrapper.find(".button-primary"),this.wrapper),this.$=this.wrapper.each(function(t,a){var i=e(a),n=i.find(".date-inputs"),r=i.find(".field-from"),s=i.find(".field-to"),o=s.prev(".date-remove"),c=r.prev(".date-remove"),d=i.children(".field-predefined"),l=e("").add(s).add(r);if(jQuery.datepicker){var p=parseFloat(wp_stream.gmt_offset)-(new Date).getTimezoneOffset()/60*-1,u=new Date,h=new Date(u.getTime()+60*p*60*1e3),m=0;u.getDate()===h.getDate()&&u.getMonth()===h.getMonth()||(m=u.getTime()<h.getTime()?"+1d":"-1d"),l.datepicker({dateFormat:"yy/mm/dd",minDate:null,maxDate:m,defaultDate:h,beforeShow:function(){e(this).prop("disabled",!0)},onClose:function(){e(this).prop("disabled",!1)}}),l.datepicker("widget").addClass("stream-datepicker")}d.select2({allowClear:!0}),""!==r.val()&&c.show(),""!==s.val()&&o.show(),d.on({change:function(){var t=e(this).val(),a=d.find('[value="'+t+'"]'),i=a.data("to"),o=a.data("from");if("custom"===t)return n.show(),!1;n.hide(),l.datepicker("hide"),r.val(o).trigger("change",[!0]),s.val(i).trigger("change",[!0]),jQuery.datepicker&&l.datepicker("widget").is(":visible")&&l.datepicker("refresh").datepicker("hide")},"select2-removed":function(){d.val("").trigger("change")},check_options:function(){if(""!==s.val()&&""!==r.val()){var e=d.find("option").filter('[data-to="'+s.val()+'"]').filter('[data-from="'+r.val()+'"]');0!==e.length?d.val(e.attr("value")).trigger("change",[!0]):d.val("custom").trigger("change",[!0])}else""===s.val()&&""===r.val()?d.val("").trigger("change",[!0]):d.val("custom").trigger("change",[!0])}}),r.on("change",function(){if(""!==r.val()?(c.show(),s.datepicker("option","minDate",r.val())):c.hide(),!0===arguments[arguments.length-1])return!1;d.trigger("check_options")}),s.on("change",function(){if(""!==s.val()?(o.show(),r.datepicker("option","maxDate",s.val())):o.hide(),!0===arguments[arguments.length-1])return!1;d.trigger("check_options")}),d.trigger("change"),e("").add(c).add(o).on("click",function(){e(this).next("input").val("").trigger("change")})})},save_interval:function(t){var a=this.wrapper;t.click(function(){var t={key:a.find("select.field-predefined").find(":selected").val(),start:a.find(".date-inputs .field-from").val(),end:a.find(".date-inputs .field-to").val()};e(this).attr("href",e(this).attr("href")+"&"+e.param(t))})}};e(document).ready(function(){l.init(e(".date-interval")),e('select[name="context"] .level-1').each(function(){var t=!0;e(this).nextUntil(".level-1").each(function(){if(e(this).is(":not(:disabled)"))return t=!1,!1}),!0===t&&e(this).prop("disabled",!0)})})}),jQuery.extend({streamGetQueryVars:function(e){return(e||document.location.search).replace(/(^\?)/,"").split("&").map(function(e){return e=e.split("="),this[e[0]]=e[1],this}.bind({}))[0]}});