Version Description
April 23, 2018 =
New: Use minimized assets (#973)
New: Alert type Slack alerts! (#970 #962)
Fix: PHP 7.1 compatibility fix (#974)
Fix: Make reset nonce unique (#972)
Fix: Stripped settings and alerts inputs (#968)
Fix: Update Datetime extension (#966)
Fix: WP CLI Namespace collision (#944)
Tweak: Coding standards updates (#975)
Tweak: Show real client IP (if available) when in reverse-proxy mode (#969 #963)
Tweak: Performance improvement when listing roles (#964)
Props @DavidCramer, @lukecarbis, @frozzare, @fjarrett, @shadyvb, @valendesigns, @robbiet480, @cfoellmann
Download this release
Release Info
Developer | Desertsnowman |
Plugin | Stream |
Version | 3.2.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.2 to 3.2.3
- alerts/class-alert-trigger-action.php +24 -7
- alerts/class-alert-trigger-author.php +31 -11
- alerts/class-alert-trigger-context.php +63 -26
- alerts/class-alert-type-die.php +1 -0
- alerts/class-alert-type-email.php +56 -32
- alerts/class-alert-type-highlight.php +62 -26
- alerts/class-alert-type-ifttt.php +49 -29
- alerts/class-alert-type-menu-alert.php +46 -32
- alerts/class-alert-type-none.php +1 -1
- alerts/class-alert-type-slack.php +303 -0
- alerts/js/alert-type-highlight.js +55 -43
- classes/class-admin.php +142 -63
- classes/class-alert-type.php +4 -4
- classes/class-alert.php +22 -20
- classes/class-alerts-list.php +44 -22
- classes/class-alerts.php +129 -87
- classes/class-author.php +13 -13
- classes/class-cli.php +27 -14
- classes/class-connector.php +1 -1
- classes/class-connectors.php +5 -0
- classes/class-date-interval.php +18 -12
- classes/class-db-driver-wpdb.php +0 -0
- classes/class-db-driver.php +0 -0
- classes/class-db.php +7 -5
- classes/class-export.php +12 -17
- classes/class-exporter.php +1 -1
- classes/class-form-generator.php +24 -20
- classes/class-install.php +45 -15
- classes/class-list-table.php +124 -77
- classes/class-live-update.php +7 -2
- classes/class-log.php +78 -75
- classes/class-network.php +34 -11
- classes/class-plugin.php +10 -10
- classes/class-preview-list-table.php +13 -5
- classes/class-query.php +1 -1
- classes/class-record.php +11 -11
- classes/class-settings.php +209 -130
- classes/class-uninstall.php +2 -2
- connectors/class-connector-acf.php +15 -7
- connectors/class-connector-bbpress.php +8 -5
- connectors/class-connector-blogs.php +5 -0
- connectors/class-connector-buddypress.php +91 -39
- connectors/class-connector-comments.php +34 -14
- connectors/class-connector-edd.php +60 -12
- connectors/class-connector-editor.php +19 -21
- connectors/class-connector-gravityforms.php +28 -10
- connectors/class-connector-installer.php +22 -12
- connectors/class-connector-jetpack.php +40 -24
- connectors/class-connector-media.php +15 -6
- connectors/class-connector-menus.php +10 -1
- connectors/class-connector-posts.php +21 -5
- connectors/class-connector-settings.php +22 -13
- connectors/class-connector-taxonomies.php +9 -10
- connectors/class-connector-user-switching.php +8 -5
- connectors/class-connector-users.php +22 -6
- connectors/class-connector-widgets.php +50 -15
- connectors/class-connector-woocommerce.php +45 -21
- connectors/class-connector-wordpress-seo.php +83 -73
- includes/db-updates.php +14 -2
- includes/feeds/atom.php +20 -20
- includes/feeds/rss-2.0.php +18 -18
- includes/functions.php +15 -1
- includes/lib/Carbon.php +3 -2
- readme.txt +20 -4
- stream.php +1 -1
- ui/css/admin.css +10 -10
- ui/css/admin.min.css +1 -0
- ui/css/alerts-list.css +3 -3
- ui/css/alerts-list.min.css +1 -0
- ui/css/datepicker.css +6 -6
- ui/css/datepicker.min.css +1 -0
- ui/js/admin.js +508 -446
- ui/js/admin.min.js +1 -0
- ui/js/alerts-list.js +11 -7
- ui/js/alerts-list.min.js +1 -0
- ui/js/alerts.js +273 -235
- ui/js/alerts.min.js +1 -0
- ui/js/exclude.js +417 -353
- ui/js/exclude.min.js +1 -0
- ui/js/global.js +33 -25
- ui/js/global.min.js +1 -0
- ui/js/live-updates.js +119 -106
- ui/js/live-updates.min.js +1 -0
- ui/js/settings.js +67 -60
- ui/js/settings.min.js +1 -0
- ui/js/wpseo-admin.js +30 -24
- ui/js/wpseo-admin.min.js +1 -0
- ui/lib/select2/css/select2.css +0 -0
- ui/lib/select2/css/select2.min.css +0 -0
- ui/lib/select2/js/i18n/ar.js +0 -0
- ui/lib/select2/js/i18n/az.js +0 -0
- ui/lib/select2/js/i18n/bg.js +0 -0
- ui/lib/select2/js/i18n/ca.js +0 -0
- ui/lib/select2/js/i18n/cs.js +0 -0
- ui/lib/select2/js/i18n/da.js +0 -0
- ui/lib/select2/js/i18n/de.js +0 -0
- ui/lib/select2/js/i18n/el.js +0 -0
- ui/lib/select2/js/i18n/en.js +0 -0
- ui/lib/select2/js/i18n/es.js +0 -0
- ui/lib/select2/js/i18n/et.js +0 -0
- ui/lib/select2/js/i18n/eu.js +0 -0
- ui/lib/select2/js/i18n/fa.js +0 -0
- ui/lib/select2/js/i18n/fi.js +0 -0
- ui/lib/select2/js/i18n/fr.js +0 -0
- ui/lib/select2/js/i18n/gl.js +0 -0
- ui/lib/select2/js/i18n/he.js +0 -0
- ui/lib/select2/js/i18n/hi.js +0 -0
- ui/lib/select2/js/i18n/hr.js +0 -0
- ui/lib/select2/js/i18n/hu.js +0 -0
- ui/lib/select2/js/i18n/id.js +0 -0
- ui/lib/select2/js/i18n/is.js +0 -0
- ui/lib/select2/js/i18n/it.js +0 -0
- ui/lib/select2/js/i18n/ja.js +0 -0
- ui/lib/select2/js/i18n/km.js +0 -0
- ui/lib/select2/js/i18n/ko.js +0 -0
- ui/lib/select2/js/i18n/lt.js +0 -0
- ui/lib/select2/js/i18n/lv.js +0 -0
- ui/lib/select2/js/i18n/mk.js +0 -0
- ui/lib/select2/js/i18n/ms.js +0 -0
- ui/lib/select2/js/i18n/nb.js +0 -0
- ui/lib/select2/js/i18n/nl.js +0 -0
- ui/lib/select2/js/i18n/pl.js +0 -0
- ui/lib/select2/js/i18n/pt-BR.js +0 -0
- ui/lib/select2/js/i18n/pt.js +0 -0
- ui/lib/select2/js/i18n/ro.js +0 -0
- ui/lib/select2/js/i18n/ru.js +0 -0
- ui/lib/select2/js/i18n/sk.js +0 -0
- ui/lib/select2/js/i18n/sr-Cyrl.js +0 -0
- ui/lib/select2/js/i18n/sr.js +0 -0
- ui/lib/select2/js/i18n/sv.js +0 -0
- ui/lib/select2/js/i18n/th.js +0 -0
- ui/lib/select2/js/i18n/tr.js +0 -0
- ui/lib/select2/js/i18n/uk.js +0 -0
- ui/lib/select2/js/i18n/vi.js +0 -0
- ui/lib/select2/js/i18n/zh-CN.js +0 -0
- ui/lib/select2/js/i18n/zh-TW.js +0 -0
- ui/lib/select2/js/select2.full.js +0 -0
- ui/lib/select2/js/select2.full.min.js +0 -0
- ui/lib/select2/js/select2.js +0 -0
- ui/lib/select2/js/select2.min.js +0 -0
- ui/lib/timeago/jquery.timeago.js +0 -0
- ui/lib/timeago/locales/README.md +0 -0
- ui/lib/timeago/locales/jquery.timeago.ar.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.bg.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.bs.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.ca.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.cs.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.cy.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.da.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.de.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.el.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.en-short.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.en.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.es-short.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.es.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.et.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.fa.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.fi.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.fr-short.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.fr.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.gl.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.he.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.hr.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.hu.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.hy.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.id.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.is.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.it.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.ja.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.jv.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.ko.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.lt.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.mk.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.nl.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.no.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.pl.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.pt-br-short.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.pt-br.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.pt.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.ro.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.rs.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.ru.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.sk.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.sl.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.sv.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.th.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.tr.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.uk.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.uz.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.vi.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.zh-CN.js +0 -0
- ui/lib/timeago/locales/jquery.timeago.zh-TW.js +0 -0
- ui/stream-icons/font/stream.eot +0 -0
- ui/stream-icons/font/stream.svg +0 -0
- ui/stream-icons/font/stream.ttf +0 -0
- ui/stream-icons/font/stream.woff +0 -0
- ui/stream-icons/style.css +0 -0
alerts/class-alert-trigger-action.php
CHANGED
@@ -39,16 +39,19 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
39 |
Â
* Checks if a record matches the criteria from the trigger.
|
40 |
Â
*
|
41 |
Â
* @see Alert_Trigger::check_record().
|
Â
|
|
42 |
Â
* @param bool $success Status of previous checks.
|
43 |
Â
* @param int $record_id Record ID.
|
44 |
Â
* @param array $recordarr Record data.
|
45 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
46 |
Â
* @return bool False on failure, otherwise should return original value of $success.
|
47 |
Â
*/
|
48 |
Â
public function check_record( $success, $record_id, $recordarr, $alert ) {
|
49 |
Â
if ( ! empty( $alert->alert_meta['trigger_action'] ) && $recordarr['action'] !== $alert->alert_meta['trigger_action'] ) {
|
50 |
Â
return false;
|
51 |
Â
}
|
Â
|
|
52 |
Â
return $success;
|
53 |
Â
}
|
54 |
Â
|
@@ -56,8 +59,10 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
56 |
Â
* Adds fields to the trigger form.
|
57 |
Â
*
|
58 |
Â
* @see Alert_Trigger::add_fields().
|
Â
|
|
59 |
Â
* @param Form_Generator $form The Form Object to add to.
|
60 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
61 |
Â
* @return void
|
62 |
Â
*/
|
63 |
Â
public function add_fields( $form, $alert = array() ) {
|
@@ -67,11 +72,11 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
67 |
Â
}
|
68 |
Â
|
69 |
Â
$args = array(
|
70 |
-
'name'
|
71 |
-
'value'
|
72 |
-
'options'
|
73 |
-
'classes'
|
74 |
-
'data'
|
75 |
Â
'placeholder' => __( 'Any Action', 'stream' ),
|
76 |
Â
),
|
77 |
Â
);
|
@@ -82,7 +87,9 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
82 |
Â
* Validate and save Alert object
|
83 |
Â
*
|
84 |
Â
* @see Alert_Trigger::save_fields().
|
Â
|
|
85 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
86 |
Â
* @return void
|
87 |
Â
*/
|
88 |
Â
public function save_fields( $alert ) {
|
@@ -98,17 +105,22 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
98 |
Â
* Generate array of possible action values
|
99 |
Â
*
|
100 |
Â
* @param bool $flat If the array should be multidimensional.
|
Â
|
|
101 |
Â
* @return array
|
102 |
Â
*/
|
103 |
Â
public function get_values( $flat = false ) {
|
104 |
Â
$action_values = array();
|
105 |
Â
foreach ( $this->get_terms_labels( 'action' ) as $action_id => $action_data ) {
|
106 |
Â
if ( ! $flat ) {
|
107 |
-
$action_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
108 |
Â
} else {
|
109 |
Â
$action_values[ $action_id ] = $action_data;
|
110 |
Â
}
|
111 |
Â
}
|
Â
|
|
112 |
Â
return $action_values;
|
113 |
Â
}
|
114 |
Â
|
@@ -116,7 +128,9 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
116 |
Â
* Function will return all terms labels of given column
|
117 |
Â
*
|
118 |
Â
* @todo refactor Settings::get_terms_labels into general utility
|
Â
|
|
119 |
Â
* @param string $column string Name of the column.
|
Â
|
|
120 |
Â
* @return array
|
121 |
Â
*/
|
122 |
Â
public function get_terms_labels( $column ) {
|
@@ -141,6 +155,7 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
141 |
Â
|
142 |
Â
ksort( $return_labels );
|
143 |
Â
}
|
Â
|
|
144 |
Â
return $return_labels;
|
145 |
Â
}
|
146 |
Â
|
@@ -148,11 +163,13 @@ class Alert_Trigger_Action extends Alert_Trigger {
|
|
148 |
Â
* Returns the trigger's value for the given alert.
|
149 |
Â
*
|
150 |
Â
* @see Alert_Trigger::get_display_value().
|
Â
|
|
151 |
Â
* @param string $context The location this data will be displayed in.
|
152 |
Â
* @param Alert $alert Alert being processed.
|
Â
|
|
153 |
Â
* @return string
|
154 |
Â
*/
|
155 |
-
function get_display_value( $context = 'normal', $alert ) {
|
156 |
Â
$action = ( ! empty( $alert->alert_meta['trigger_action'] ) ) ? $alert->alert_meta['trigger_action'] : null;
|
157 |
Â
|
158 |
Â
if ( 'post_title' === $context ) {
|
39 |
Â
* Checks if a record matches the criteria from the trigger.
|
40 |
Â
*
|
41 |
Â
* @see Alert_Trigger::check_record().
|
42 |
+
*
|
43 |
Â
* @param bool $success Status of previous checks.
|
44 |
Â
* @param int $record_id Record ID.
|
45 |
Â
* @param array $recordarr Record data.
|
46 |
Â
* @param Alert $alert The Alert being worked on.
|
47 |
+
*
|
48 |
Â
* @return bool False on failure, otherwise should return original value of $success.
|
49 |
Â
*/
|
50 |
Â
public function check_record( $success, $record_id, $recordarr, $alert ) {
|
51 |
Â
if ( ! empty( $alert->alert_meta['trigger_action'] ) && $recordarr['action'] !== $alert->alert_meta['trigger_action'] ) {
|
52 |
Â
return false;
|
53 |
Â
}
|
54 |
+
|
55 |
Â
return $success;
|
56 |
Â
}
|
57 |
Â
|
59 |
Â
* Adds fields to the trigger form.
|
60 |
Â
*
|
61 |
Â
* @see Alert_Trigger::add_fields().
|
62 |
+
*
|
63 |
Â
* @param Form_Generator $form The Form Object to add to.
|
64 |
Â
* @param Alert $alert The Alert being worked on.
|
65 |
+
*
|
66 |
Â
* @return void
|
67 |
Â
*/
|
68 |
Â
public function add_fields( $form, $alert = array() ) {
|
72 |
Â
}
|
73 |
Â
|
74 |
Â
$args = array(
|
75 |
+
'name' => esc_attr( $this->field_key ),
|
76 |
+
'value' => esc_attr( $value ),
|
77 |
+
'options' => $this->get_values(),
|
78 |
+
'classes' => 'wp_stream_ajax_forward',
|
79 |
+
'data' => array(
|
80 |
Â
'placeholder' => __( 'Any Action', 'stream' ),
|
81 |
Â
),
|
82 |
Â
);
|
87 |
Â
* Validate and save Alert object
|
88 |
Â
*
|
89 |
Â
* @see Alert_Trigger::save_fields().
|
90 |
+
*
|
91 |
Â
* @param Alert $alert The Alert being worked on.
|
92 |
+
*
|
93 |
Â
* @return void
|
94 |
Â
*/
|
95 |
Â
public function save_fields( $alert ) {
|
105 |
Â
* Generate array of possible action values
|
106 |
Â
*
|
107 |
Â
* @param bool $flat If the array should be multidimensional.
|
108 |
+
*
|
109 |
Â
* @return array
|
110 |
Â
*/
|
111 |
Â
public function get_values( $flat = false ) {
|
112 |
Â
$action_values = array();
|
113 |
Â
foreach ( $this->get_terms_labels( 'action' ) as $action_id => $action_data ) {
|
114 |
Â
if ( ! $flat ) {
|
115 |
+
$action_values[] = array(
|
116 |
+
'id' => $action_id,
|
117 |
+
'text' => $action_data,
|
118 |
+
);
|
119 |
Â
} else {
|
120 |
Â
$action_values[ $action_id ] = $action_data;
|
121 |
Â
}
|
122 |
Â
}
|
123 |
+
|
124 |
Â
return $action_values;
|
125 |
Â
}
|
126 |
Â
|
128 |
Â
* Function will return all terms labels of given column
|
129 |
Â
*
|
130 |
Â
* @todo refactor Settings::get_terms_labels into general utility
|
131 |
+
*
|
132 |
Â
* @param string $column string Name of the column.
|
133 |
+
*
|
134 |
Â
* @return array
|
135 |
Â
*/
|
136 |
Â
public function get_terms_labels( $column ) {
|
155 |
Â
|
156 |
Â
ksort( $return_labels );
|
157 |
Â
}
|
158 |
+
|
159 |
Â
return $return_labels;
|
160 |
Â
}
|
161 |
Â
|
163 |
Â
* Returns the trigger's value for the given alert.
|
164 |
Â
*
|
165 |
Â
* @see Alert_Trigger::get_display_value().
|
166 |
+
*
|
167 |
Â
* @param string $context The location this data will be displayed in.
|
168 |
Â
* @param Alert $alert Alert being processed.
|
169 |
+
*
|
170 |
Â
* @return string
|
171 |
Â
*/
|
172 |
+
public function get_display_value( $context = 'normal', $alert ) {
|
173 |
Â
$action = ( ! empty( $alert->alert_meta['trigger_action'] ) ) ? $alert->alert_meta['trigger_action'] : null;
|
174 |
Â
|
175 |
Â
if ( 'post_title' === $context ) {
|
alerts/class-alert-trigger-author.php
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
Â
*
|
5 |
Â
* @package WP_Stream
|
6 |
Â
*/
|
Â
|
|
7 |
Â
namespace WP_Stream;
|
8 |
Â
|
9 |
Â
/**
|
@@ -31,16 +32,19 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
31 |
Â
* Checks if a record matches the criteria from the trigger.
|
32 |
Â
*
|
33 |
Â
* @see Alert_Trigger::check_record().
|
Â
|
|
34 |
Â
* @param bool $success Status of previous checks.
|
35 |
Â
* @param int $record_id Record ID.
|
36 |
Â
* @param array $recordarr Record data.
|
37 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
38 |
Â
* @return bool False on failure, otherwise should return original value of $success.
|
39 |
Â
*/
|
40 |
Â
public function check_record( $success, $record_id, $recordarr, $alert ) {
|
41 |
Â
if ( ! empty( $alert->alert_meta['trigger_author'] ) && intval( $alert->alert_meta['trigger_author'] ) !== intval( $recordarr['user_id'] ) ) {
|
42 |
Â
return false;
|
43 |
Â
}
|
Â
|
|
44 |
Â
return $success;
|
45 |
Â
}
|
46 |
Â
|
@@ -48,8 +52,10 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
48 |
Â
* Adds fields to the trigger form.
|
49 |
Â
*
|
50 |
Â
* @see Alert_Trigger::add_fields().
|
Â
|
|
51 |
Â
* @param Form_Generator $form The Form Object to add to.
|
52 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
53 |
Â
* @return void
|
54 |
Â
*/
|
55 |
Â
public function add_fields( $form, $alert = array() ) {
|
@@ -59,11 +65,11 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
59 |
Â
}
|
60 |
Â
|
61 |
Â
$args = array(
|
62 |
-
'name'
|
63 |
-
'value'
|
64 |
-
'options'
|
65 |
-
'classes'
|
66 |
-
'data'
|
67 |
Â
'placeholder' => __( 'Any Author', 'stream' ),
|
68 |
Â
),
|
69 |
Â
);
|
@@ -86,24 +92,32 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
86 |
Â
}
|
87 |
Â
|
88 |
Â
$users = array_map(
|
89 |
-
function( $user_id ) {
|
90 |
Â
return new Author( $user_id );
|
91 |
Â
},
|
92 |
-
get_users(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
93 |
Â
);
|
94 |
Â
|
95 |
Â
if ( is_multisite() && is_super_admin() ) {
|
96 |
Â
$super_admins = array_map(
|
97 |
-
function( $login ) {
|
98 |
Â
$user = get_user_by( 'login', $login );
|
Â
|
|
99 |
Â
return new Author( $user->ID );
|
100 |
Â
},
|
101 |
Â
get_super_admins()
|
102 |
Â
);
|
103 |
-
$users
|
104 |
Â
}
|
105 |
Â
|
106 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
107 |
Â
|
108 |
Â
foreach ( $users as $user ) {
|
109 |
Â
$all_records[] = array(
|
@@ -112,6 +126,7 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
112 |
Â
'text' => $user->get_display_name(),
|
113 |
Â
);
|
114 |
Â
}
|
Â
|
|
115 |
Â
return $all_records;
|
116 |
Â
}
|
117 |
Â
|
@@ -119,7 +134,9 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
119 |
Â
* Validate and save Alert object
|
120 |
Â
*
|
121 |
Â
* @see Alert_Trigger::save_fields().
|
Â
|
|
122 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
123 |
Â
* @return void
|
124 |
Â
*/
|
125 |
Â
public function save_fields( $alert ) {
|
@@ -135,11 +152,13 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
135 |
Â
* Returns the trigger's value for the given alert.
|
136 |
Â
*
|
137 |
Â
* @see Alert_Trigger::get_display_value().
|
Â
|
|
138 |
Â
* @param string $context The location this data will be displayed in.
|
139 |
Â
* @param Alert $alert Alert being processed.
|
Â
|
|
140 |
Â
* @return string
|
141 |
Â
*/
|
142 |
-
function get_display_value( $context = 'normal', $alert ) {
|
143 |
Â
$author = ( ! empty( $alert->alert_meta['trigger_author'] ) ) ? $alert->alert_meta['trigger_author'] : null;
|
144 |
Â
if ( empty( $author ) ) {
|
145 |
Â
$author = __( 'Any User', 'stream' );
|
@@ -151,6 +170,7 @@ class Alert_Trigger_Author extends Alert_Trigger {
|
|
151 |
Â
$author = __( 'Unknown User', 'stream' );
|
152 |
Â
}
|
153 |
Â
}
|
Â
|
|
154 |
Â
return ucfirst( $author );
|
155 |
Â
}
|
156 |
Â
}
|
4 |
Â
*
|
5 |
Â
* @package WP_Stream
|
6 |
Â
*/
|
7 |
+
|
8 |
Â
namespace WP_Stream;
|
9 |
Â
|
10 |
Â
/**
|
32 |
Â
* Checks if a record matches the criteria from the trigger.
|
33 |
Â
*
|
34 |
Â
* @see Alert_Trigger::check_record().
|
35 |
+
*
|
36 |
Â
* @param bool $success Status of previous checks.
|
37 |
Â
* @param int $record_id Record ID.
|
38 |
Â
* @param array $recordarr Record data.
|
39 |
Â
* @param Alert $alert The Alert being worked on.
|
40 |
+
*
|
41 |
Â
* @return bool False on failure, otherwise should return original value of $success.
|
42 |
Â
*/
|
43 |
Â
public function check_record( $success, $record_id, $recordarr, $alert ) {
|
44 |
Â
if ( ! empty( $alert->alert_meta['trigger_author'] ) && intval( $alert->alert_meta['trigger_author'] ) !== intval( $recordarr['user_id'] ) ) {
|
45 |
Â
return false;
|
46 |
Â
}
|
47 |
+
|
48 |
Â
return $success;
|
49 |
Â
}
|
50 |
Â
|
52 |
Â
* Adds fields to the trigger form.
|
53 |
Â
*
|
54 |
Â
* @see Alert_Trigger::add_fields().
|
55 |
+
*
|
56 |
Â
* @param Form_Generator $form The Form Object to add to.
|
57 |
Â
* @param Alert $alert The Alert being worked on.
|
58 |
+
*
|
59 |
Â
* @return void
|
60 |
Â
*/
|
61 |
Â
public function add_fields( $form, $alert = array() ) {
|
65 |
Â
}
|
66 |
Â
|
67 |
Â
$args = array(
|
68 |
+
'name' => esc_attr( $this->field_key ),
|
69 |
+
'value' => esc_attr( $value ),
|
70 |
+
'options' => $this->get_values(),
|
71 |
+
'classes' => 'wp_stream_ajax_forward',
|
72 |
+
'data' => array(
|
73 |
Â
'placeholder' => __( 'Any Author', 'stream' ),
|
74 |
Â
),
|
75 |
Â
);
|
92 |
Â
}
|
93 |
Â
|
94 |
Â
$users = array_map(
|
95 |
+
function ( $user_id ) {
|
96 |
Â
return new Author( $user_id );
|
97 |
Â
},
|
98 |
+
get_users(
|
99 |
+
array(
|
100 |
+
'fields' => 'ID',
|
101 |
+
)
|
102 |
+
)
|
103 |
Â
);
|
104 |
Â
|
105 |
Â
if ( is_multisite() && is_super_admin() ) {
|
106 |
Â
$super_admins = array_map(
|
107 |
+
function ( $login ) {
|
108 |
Â
$user = get_user_by( 'login', $login );
|
109 |
+
|
110 |
Â
return new Author( $user->ID );
|
111 |
Â
},
|
112 |
Â
get_super_admins()
|
113 |
Â
);
|
114 |
+
$users = array_unique( array_merge( $users, $super_admins ) );
|
115 |
Â
}
|
116 |
Â
|
117 |
+
$user_meta = array(
|
118 |
+
'is_wp_cli' => true,
|
119 |
+
);
|
120 |
+
$users[] = new Author( 0, $user_meta );
|
121 |
Â
|
122 |
Â
foreach ( $users as $user ) {
|
123 |
Â
$all_records[] = array(
|
126 |
Â
'text' => $user->get_display_name(),
|
127 |
Â
);
|
128 |
Â
}
|
129 |
+
|
130 |
Â
return $all_records;
|
131 |
Â
}
|
132 |
Â
|
134 |
Â
* Validate and save Alert object
|
135 |
Â
*
|
136 |
Â
* @see Alert_Trigger::save_fields().
|
137 |
+
*
|
138 |
Â
* @param Alert $alert The Alert being worked on.
|
139 |
+
*
|
140 |
Â
* @return void
|
141 |
Â
*/
|
142 |
Â
public function save_fields( $alert ) {
|
152 |
Â
* Returns the trigger's value for the given alert.
|
153 |
Â
*
|
154 |
Â
* @see Alert_Trigger::get_display_value().
|
155 |
+
*
|
156 |
Â
* @param string $context The location this data will be displayed in.
|
157 |
Â
* @param Alert $alert Alert being processed.
|
158 |
+
*
|
159 |
Â
* @return string
|
160 |
Â
*/
|
161 |
+
public function get_display_value( $context = 'normal', $alert ) {
|
162 |
Â
$author = ( ! empty( $alert->alert_meta['trigger_author'] ) ) ? $alert->alert_meta['trigger_author'] : null;
|
163 |
Â
if ( empty( $author ) ) {
|
164 |
Â
$author = __( 'Any User', 'stream' );
|
170 |
Â
$author = __( 'Unknown User', 'stream' );
|
171 |
Â
}
|
172 |
Â
}
|
173 |
+
|
174 |
Â
return ucfirst( $author );
|
175 |
Â
}
|
176 |
Â
}
|
alerts/class-alert-trigger-context.php
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
Â
*
|
5 |
Â
* @package WP_Stream
|
6 |
Â
*/
|
Â
|
|
7 |
Â
namespace WP_Stream;
|
8 |
Â
|
9 |
Â
/**
|
@@ -31,10 +32,12 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
31 |
Â
* Checks if a record matches the criteria from the trigger.
|
32 |
Â
*
|
33 |
Â
* @see Alert_Trigger::check_record().
|
Â
|
|
34 |
Â
* @param bool $success Status of previous checks.
|
35 |
Â
* @param int $record_id Record ID.
|
36 |
Â
* @param array $recordarr Record data.
|
37 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
38 |
Â
* @return bool False on failure, otherwise should return original value of $success.
|
39 |
Â
*/
|
40 |
Â
public function check_record( $success, $record_id, $recordarr, $alert ) {
|
@@ -44,6 +47,7 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
44 |
Â
if ( ! empty( $alert->alert_meta['trigger_context'] ) && $recordarr['context'] !== $alert->alert_meta['trigger_context'] ) {
|
45 |
Â
return false;
|
46 |
Â
}
|
Â
|
|
47 |
Â
return $success;
|
48 |
Â
}
|
49 |
Â
|
@@ -51,8 +55,10 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
51 |
Â
* Adds fields to the trigger form.
|
52 |
Â
*
|
53 |
Â
* @see Alert_Trigger::add_fields().
|
Â
|
|
54 |
Â
* @param Form_Generator $form The Form Object to add to.
|
55 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
56 |
Â
* @return void
|
57 |
Â
*/
|
58 |
Â
public function add_fields( $form, $alert = array() ) {
|
@@ -69,38 +75,46 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
69 |
Â
// Context dropdown menu.
|
70 |
Â
$context_values = array();
|
71 |
Â
|
72 |
-
$form->add_field(
|
73 |
-
'
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
'
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
'
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
92 |
Â
}
|
93 |
Â
|
94 |
Â
/**
|
95 |
Â
* Validate and save Alert object
|
96 |
Â
*
|
97 |
Â
* @see Alert_Trigger::save_fields().
|
Â
|
|
98 |
Â
* @param Alert $alert The Alert being worked on.
|
Â
|
|
99 |
Â
* @return void
|
100 |
Â
*/
|
101 |
Â
public function save_fields( $alert ) {
|
102 |
Â
$alert->alert_meta['trigger_connector'] = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_connector' );
|
103 |
-
$alert->alert_meta['trigger_context']
|
104 |
Â
}
|
105 |
Â
|
106 |
Â
/**
|
@@ -109,22 +123,39 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
109 |
Â
* @return array
|
110 |
Â
*/
|
111 |
Â
public function get_values() {
|
Â
|
|
Â
|
|
112 |
Â
foreach ( $this->get_terms_labels( 'context' ) as $context_id => $context_data ) {
|
113 |
Â
if ( is_array( $context_data ) ) {
|
114 |
Â
$child_values = array();
|
115 |
Â
if ( isset( $context_data['children'] ) ) {
|
116 |
Â
$child_values = array();
|
117 |
Â
foreach ( $context_data['children'] as $child_id => $child_value ) {
|
118 |
-
$child_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
119 |
Â
}
|
120 |
Â
}
|
121 |
Â
if ( isset( $context_data['label'] ) ) {
|
122 |
-
$context_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
123 |
Â
}
|
124 |
Â
} else {
|
125 |
-
$context_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
126 |
Â
}
|
127 |
Â
}
|
Â
|
|
128 |
Â
return $context_values;
|
129 |
Â
}
|
130 |
Â
|
@@ -132,7 +163,9 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
132 |
Â
* Function will return all terms labels of given column
|
133 |
Â
*
|
134 |
Â
* @todo refactor Settings::get_terms_labels into general utility
|
Â
|
|
135 |
Â
* @param string $column string Name of the column.
|
Â
|
|
136 |
Â
* @return array
|
137 |
Â
*/
|
138 |
Â
public function get_terms_labels( $column ) {
|
@@ -157,6 +190,7 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
157 |
Â
|
158 |
Â
ksort( $return_labels );
|
159 |
Â
}
|
Â
|
|
160 |
Â
return $return_labels;
|
161 |
Â
}
|
162 |
Â
|
@@ -164,12 +198,14 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
164 |
Â
* Returns the trigger's value for the given alert.
|
165 |
Â
*
|
166 |
Â
* @see Alert_Trigger::get_display_value().
|
Â
|
|
167 |
Â
* @param string $context The location this data will be displayed in.
|
168 |
Â
* @param Alert $alert Alert being processed.
|
Â
|
|
169 |
Â
* @return string
|
170 |
Â
*/
|
171 |
-
function get_display_value( $context = 'normal', $alert ) {
|
172 |
-
$context
|
173 |
Â
$connector = ( ! empty( $alert->alert_meta['trigger_connector'] ) ) ? $alert->alert_meta['trigger_connector'] : null;
|
174 |
Â
if ( empty( $context ) && empty( $connector ) ) {
|
175 |
Â
$context = __( 'Any Context', 'stream' );
|
@@ -183,6 +219,7 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
183 |
Â
}
|
184 |
Â
}
|
185 |
Â
}
|
Â
|
|
186 |
Â
return ucfirst( $context );
|
187 |
Â
}
|
188 |
Â
}
|
4 |
Â
*
|
5 |
Â
* @package WP_Stream
|
6 |
Â
*/
|
7 |
+
|
8 |
Â
namespace WP_Stream;
|
9 |
Â
|
10 |
Â
/**
|
32 |
Â
* Checks if a record matches the criteria from the trigger.
|
33 |
Â
*
|
34 |
Â
* @see Alert_Trigger::check_record().
|
35 |
+
*
|
36 |
Â
* @param bool $success Status of previous checks.
|
37 |
Â
* @param int $record_id Record ID.
|
38 |
Â
* @param array $recordarr Record data.
|
39 |
Â
* @param Alert $alert The Alert being worked on.
|
40 |
+
*
|
41 |
Â
* @return bool False on failure, otherwise should return original value of $success.
|
42 |
Â
*/
|
43 |
Â
public function check_record( $success, $record_id, $recordarr, $alert ) {
|
47 |
Â
if ( ! empty( $alert->alert_meta['trigger_context'] ) && $recordarr['context'] !== $alert->alert_meta['trigger_context'] ) {
|
48 |
Â
return false;
|
49 |
Â
}
|
50 |
+
|
51 |
Â
return $success;
|
52 |
Â
}
|
53 |
Â
|
55 |
Â
* Adds fields to the trigger form.
|
56 |
Â
*
|
57 |
Â
* @see Alert_Trigger::add_fields().
|
58 |
+
*
|
59 |
Â
* @param Form_Generator $form The Form Object to add to.
|
60 |
Â
* @param Alert $alert The Alert being worked on.
|
61 |
+
*
|
62 |
Â
* @return void
|
63 |
Â
*/
|
64 |
Â
public function add_fields( $form, $alert = array() ) {
|
75 |
Â
// Context dropdown menu.
|
76 |
Â
$context_values = array();
|
77 |
Â
|
78 |
+
$form->add_field(
|
79 |
+
'select2', array(
|
80 |
+
'name' => 'wp_stream_trigger_connector_or_context',
|
81 |
+
'options' => $this->get_values(),
|
82 |
+
'classes' => 'wp_stream_ajax_forward connector_or_context',
|
83 |
+
'data' => array(
|
84 |
+
'placeholder' => __( 'Any Context', 'stream' ),
|
85 |
+
),
|
86 |
+
)
|
87 |
+
);
|
88 |
+
|
89 |
+
$form->add_field(
|
90 |
+
'hidden', array(
|
91 |
+
'name' => 'wp_stream_trigger_connector',
|
92 |
+
'value' => $connector,
|
93 |
+
'classes' => 'connector wp_stream_ajax_forward',
|
94 |
+
)
|
95 |
+
);
|
96 |
+
|
97 |
+
$form->add_field(
|
98 |
+
'hidden', array(
|
99 |
+
'name' => 'wp_stream_trigger_context',
|
100 |
+
'value' => $context,
|
101 |
+
'classes' => 'context wp_stream_ajax_forward',
|
102 |
+
)
|
103 |
+
);
|
104 |
Â
}
|
105 |
Â
|
106 |
Â
/**
|
107 |
Â
* Validate and save Alert object
|
108 |
Â
*
|
109 |
Â
* @see Alert_Trigger::save_fields().
|
110 |
+
*
|
111 |
Â
* @param Alert $alert The Alert being worked on.
|
112 |
+
*
|
113 |
Â
* @return void
|
114 |
Â
*/
|
115 |
Â
public function save_fields( $alert ) {
|
116 |
Â
$alert->alert_meta['trigger_connector'] = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_connector' );
|
117 |
+
$alert->alert_meta['trigger_context'] = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_context' );
|
118 |
Â
}
|
119 |
Â
|
120 |
Â
/**
|
123 |
Â
* @return array
|
124 |
Â
*/
|
125 |
Â
public function get_values() {
|
126 |
+
$context_values = array();
|
127 |
+
|
128 |
Â
foreach ( $this->get_terms_labels( 'context' ) as $context_id => $context_data ) {
|
129 |
Â
if ( is_array( $context_data ) ) {
|
130 |
Â
$child_values = array();
|
131 |
Â
if ( isset( $context_data['children'] ) ) {
|
132 |
Â
$child_values = array();
|
133 |
Â
foreach ( $context_data['children'] as $child_id => $child_value ) {
|
134 |
+
$child_values[] = array(
|
135 |
+
'value' => $context_id . '-' . $child_id,
|
136 |
+
'id' => $context_id . '-' . $child_id,
|
137 |
+
'text' => $child_value,
|
138 |
+
'parent' => $context_id,
|
139 |
+
);
|
140 |
Â
}
|
141 |
Â
}
|
142 |
Â
if ( isset( $context_data['label'] ) ) {
|
143 |
+
$context_values[] = array(
|
144 |
+
'value' => $context_id,
|
145 |
+
'id' => $context_id,
|
146 |
+
'text' => $context_data['label'],
|
147 |
+
'children' => $child_values,
|
148 |
+
);
|
149 |
Â
}
|
150 |
Â
} else {
|
151 |
+
$context_values[] = array(
|
152 |
+
'value' => $context_id,
|
153 |
+
'id' => $context_id,
|
154 |
+
'text' => $context_data,
|
155 |
+
);
|
156 |
Â
}
|
157 |
Â
}
|
158 |
+
|
159 |
Â
return $context_values;
|
160 |
Â
}
|
161 |
Â
|
163 |
Â
* Function will return all terms labels of given column
|
164 |
Â
*
|
165 |
Â
* @todo refactor Settings::get_terms_labels into general utility
|
166 |
+
*
|
167 |
Â
* @param string $column string Name of the column.
|
168 |
+
*
|
169 |
Â
* @return array
|
170 |
Â
*/
|
171 |
Â
public function get_terms_labels( $column ) {
|
190 |
Â
|
191 |
Â
ksort( $return_labels );
|
192 |
Â
}
|
193 |
+
|
194 |
Â
return $return_labels;
|
195 |
Â
}
|
196 |
Â
|
198 |
Â
* Returns the trigger's value for the given alert.
|
199 |
Â
*
|
200 |
Â
* @see Alert_Trigger::get_display_value().
|
201 |
+
*
|
202 |
Â
* @param string $context The location this data will be displayed in.
|
203 |
Â
* @param Alert $alert Alert being processed.
|
204 |
+
*
|
205 |
Â
* @return string
|
206 |
Â
*/
|
207 |
+
public function get_display_value( $context = 'normal', $alert ) {
|
208 |
+
$context = ( ! empty( $alert->alert_meta['trigger_context'] ) ) ? $alert->alert_meta['trigger_context'] : null;
|
209 |
Â
$connector = ( ! empty( $alert->alert_meta['trigger_connector'] ) ) ? $alert->alert_meta['trigger_connector'] : null;
|
210 |
Â
if ( empty( $context ) && empty( $connector ) ) {
|
211 |
Â
$context = __( 'Any Context', 'stream' );
|
219 |
Â
}
|
220 |
Â
}
|
221 |
Â
}
|
222 |
+
|
223 |
Â
return ucfirst( $context );
|
224 |
Â
}
|
225 |
Â
}
|
alerts/class-alert-type-die.php
CHANGED
@@ -13,6 +13,7 @@ namespace WP_Stream;
|
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alert_Type_Die extends Alert_Type {
|
Â
|
|
16 |
Â
/**
|
17 |
Â
* Alert type name
|
18 |
Â
*
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alert_Type_Die extends Alert_Type {
|
16 |
+
|
17 |
Â
/**
|
18 |
Â
* Alert type name
|
19 |
Â
*
|
alerts/class-alert-type-email.php
CHANGED
@@ -42,7 +42,12 @@ class Alert_Type_Email extends Alert_Type {
|
|
42 |
Â
if ( ! is_admin() ) {
|
43 |
Â
return;
|
44 |
Â
}
|
45 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
46 |
Â
}
|
47 |
Â
|
48 |
Â
/**
|
@@ -54,37 +59,46 @@ class Alert_Type_Email extends Alert_Type {
|
|
54 |
Â
* @return void
|
55 |
Â
*/
|
56 |
Â
public function alert( $record_id, $recordarr, $alert ) {
|
57 |
-
$options = wp_parse_args(
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
Â
|
|
Â
|
|
64 |
Â
|
65 |
Â
if ( empty( $options['email_recipient'] ) && empty( $options['email_subject'] ) ) {
|
66 |
Â
return;
|
67 |
Â
}
|
68 |
Â
|
69 |
-
|
Â
|
|
70 |
Â
|
71 |
Â
$user_id = $recordarr['user_id'];
|
72 |
-
$user
|
Â
|
|
Â
|
|
73 |
Â
$message .= sprintf( __( "User:\t%s", 'stream' ), $user->user_login ) . "\n";
|
74 |
Â
|
75 |
Â
if ( ! empty( $alert->alert_meta['trigger_context'] ) ) {
|
76 |
-
$context
|
77 |
-
|
Â
|
|
Â
|
|
78 |
Â
}
|
79 |
Â
if ( ! empty( $alert->alert_meta['trigger_action'] ) ) {
|
80 |
-
$action
|
81 |
-
|
Â
|
|
Â
|
|
82 |
Â
}
|
83 |
Â
|
84 |
Â
$post = null;
|
85 |
Â
if ( isset( $recordarr['object_id'] ) ) {
|
86 |
Â
$post_id = $recordarr['object_id'];
|
87 |
-
$post
|
88 |
Â
}
|
89 |
Â
if ( is_object( $post ) && ! empty( $post ) ) {
|
90 |
Â
$post_type = get_post_type_object( $post->post_type );
|
@@ -92,13 +106,15 @@ class Alert_Type_Email extends Alert_Type {
|
|
92 |
Â
$message .= $post_type->labels->singular_name . ":\t" . $post->post_title . "\n\n";
|
93 |
Â
|
94 |
Â
$edit_post_link = get_edit_post_link( $post->ID, 'raw' );
|
Â
|
|
Â
|
|
95 |
Â
$message .= sprintf( __( 'Edit %s', 'stream' ), $post_type->labels->singular_name ) . "\n<$edit_post_link>\n";
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
$message .= "\n";
|
99 |
Â
|
100 |
Â
$edit_alert_link = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $alert->ID );
|
101 |
-
$message
|
102 |
Â
|
103 |
Â
wp_mail( $options['email_recipient'], $options['email_subject'], $message );
|
104 |
Â
}
|
@@ -114,29 +130,35 @@ class Alert_Type_Email extends Alert_Type {
|
|
114 |
Â
if ( is_object( $alert ) ) {
|
115 |
Â
$alert_meta = $alert->alert_meta;
|
116 |
Â
}
|
117 |
-
$options = wp_parse_args(
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
Â
|
|
Â
|
|
123 |
Â
echo '<span class="wp_stream_alert_type_description">' . esc_html__( 'Send a notification email to the recipient.', 'stream' ) . '</span>';
|
124 |
Â
echo '<label for="wp_stream_email_recipient"><span class="title">' . esc_html__( 'Recipient', 'stream' ) . '</span>';
|
125 |
Â
echo '<span class="input-text-wrap">';
|
126 |
-
echo $form->render_field(
|
127 |
-
'
|
128 |
-
|
129 |
-
|
130 |
-
|
Â
|
|
Â
|
|
131 |
Â
echo '</span></label>';
|
132 |
Â
|
133 |
Â
echo '<label for="wp_stream_email_subject"><span class="title">' . esc_html__( 'Subject', 'stream' ) . '</span>';
|
134 |
Â
echo '<span class="input-text-wrap">';
|
135 |
-
echo $form->render_field(
|
136 |
-
'
|
137 |
-
|
138 |
-
|
139 |
-
|
Â
|
|
Â
|
|
140 |
Â
echo '</span></label>';
|
141 |
Â
}
|
142 |
Â
|
@@ -157,6 +179,7 @@ class Alert_Type_Email extends Alert_Type {
|
|
157 |
Â
$alert->alert_meta['email_subject'] = sanitize_text_field( wp_unslash( $_POST['wp_stream_email_subject'] ) );
|
158 |
Â
}
|
159 |
Â
}
|
Â
|
|
160 |
Â
/**
|
161 |
Â
* Add alert meta if this is a highlight alert
|
162 |
Â
*
|
@@ -176,6 +199,7 @@ class Alert_Type_Email extends Alert_Type {
|
|
176 |
Â
$alert_meta['email_subject'] = $email_subject;
|
177 |
Â
}
|
178 |
Â
}
|
Â
|
|
179 |
Â
return $alert_meta;
|
180 |
Â
}
|
181 |
Â
}
|
42 |
Â
if ( ! is_admin() ) {
|
43 |
Â
return;
|
44 |
Â
}
|
45 |
+
add_filter(
|
46 |
+
'wp_stream_alerts_save_meta', array(
|
47 |
+
$this,
|
48 |
+
'add_alert_meta',
|
49 |
+
), 10, 2
|
50 |
+
);
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
/**
|
59 |
Â
* @return void
|
60 |
Â
*/
|
61 |
Â
public function alert( $record_id, $recordarr, $alert ) {
|
62 |
+
$options = wp_parse_args(
|
63 |
+
$alert->alert_meta, array(
|
64 |
+
'email_recipient' => '',
|
65 |
+
'email_subject' => '',
|
66 |
+
'trigger_action' => '',
|
67 |
+
'trigger_connector' => '',
|
68 |
+
'trigger_context' => '',
|
69 |
+
)
|
70 |
+
);
|
71 |
Â
|
72 |
Â
if ( empty( $options['email_recipient'] ) && empty( $options['email_subject'] ) ) {
|
73 |
Â
return;
|
74 |
Â
}
|
75 |
Â
|
76 |
+
// translators: Placeholder refers to the title of a site (e.g. "FooBar Website").
|
77 |
+
$message = sprintf( __( 'A Stream Alert was triggered on %s.', 'stream' ), get_bloginfo( 'name' ) ) . "\n\n";
|
78 |
Â
|
79 |
Â
$user_id = $recordarr['user_id'];
|
80 |
+
$user = get_user_by( 'id', $user_id );
|
81 |
+
|
82 |
+
// translators: Placeholder refers to a username (e.g. "administrator").
|
83 |
Â
$message .= sprintf( __( "User:\t%s", 'stream' ), $user->user_login ) . "\n";
|
84 |
Â
|
85 |
Â
if ( ! empty( $alert->alert_meta['trigger_context'] ) ) {
|
86 |
+
$context = $this->plugin->alerts->alert_triggers['context']->get_display_value( 'list_table', $alert );
|
87 |
+
|
88 |
+
// translators: Placeholder refers to the context of the record (e.g. "Plugins").
|
89 |
+
$message .= sprintf( __( "Context:\t%s", 'stream' ), $context ) . "\n";
|
90 |
Â
}
|
91 |
Â
if ( ! empty( $alert->alert_meta['trigger_action'] ) ) {
|
92 |
+
$action = $this->plugin->alerts->alert_triggers['action']->get_display_value( 'list_table', $alert );
|
93 |
+
|
94 |
+
// translators: Placeholder refers to the action of the record (e.g. "Installed").
|
95 |
+
$message .= sprintf( __( "Action:\t%s", 'stream' ), $action ) . "\n";
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
$post = null;
|
99 |
Â
if ( isset( $recordarr['object_id'] ) ) {
|
100 |
Â
$post_id = $recordarr['object_id'];
|
101 |
+
$post = get_post( $post_id );
|
102 |
Â
}
|
103 |
Â
if ( is_object( $post ) && ! empty( $post ) ) {
|
104 |
Â
$post_type = get_post_type_object( $post->post_type );
|
106 |
Â
$message .= $post_type->labels->singular_name . ":\t" . $post->post_title . "\n\n";
|
107 |
Â
|
108 |
Â
$edit_post_link = get_edit_post_link( $post->ID, 'raw' );
|
109 |
+
|
110 |
+
// translators: Placeholder refers to the post type singular name (e.g. "Post").
|
111 |
Â
$message .= sprintf( __( 'Edit %s', 'stream' ), $post_type->labels->singular_name ) . "\n<$edit_post_link>\n";
|
112 |
Â
}
|
113 |
Â
|
114 |
Â
$message .= "\n";
|
115 |
Â
|
116 |
Â
$edit_alert_link = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $alert->ID );
|
117 |
+
$message .= __( 'Edit Alert', 'stream' ) . "\n<$edit_alert_link>";
|
118 |
Â
|
119 |
Â
wp_mail( $options['email_recipient'], $options['email_subject'], $message );
|
120 |
Â
}
|
130 |
Â
if ( is_object( $alert ) ) {
|
131 |
Â
$alert_meta = $alert->alert_meta;
|
132 |
Â
}
|
133 |
+
$options = wp_parse_args(
|
134 |
+
$alert_meta, array(
|
135 |
+
'email_recipient' => '',
|
136 |
+
'email_subject' => '',
|
137 |
+
)
|
138 |
+
);
|
139 |
+
|
140 |
+
$form = new Form_Generator();
|
141 |
Â
echo '<span class="wp_stream_alert_type_description">' . esc_html__( 'Send a notification email to the recipient.', 'stream' ) . '</span>';
|
142 |
Â
echo '<label for="wp_stream_email_recipient"><span class="title">' . esc_html__( 'Recipient', 'stream' ) . '</span>';
|
143 |
Â
echo '<span class="input-text-wrap">';
|
144 |
+
echo $form->render_field(
|
145 |
+
'text', array(
|
146 |
+
'name' => 'wp_stream_email_recipient',
|
147 |
+
'title' => esc_attr( __( 'Email Recipient', 'stream' ) ),
|
148 |
+
'value' => $options['email_recipient'],
|
149 |
+
)
|
150 |
+
); // Xss ok.
|
151 |
Â
echo '</span></label>';
|
152 |
Â
|
153 |
Â
echo '<label for="wp_stream_email_subject"><span class="title">' . esc_html__( 'Subject', 'stream' ) . '</span>';
|
154 |
Â
echo '<span class="input-text-wrap">';
|
155 |
+
echo $form->render_field(
|
156 |
+
'text', array(
|
157 |
+
'name' => 'wp_stream_email_subject',
|
158 |
+
'title' => esc_attr( __( 'Email Subject', 'stream' ) ),
|
159 |
+
'value' => $options['email_subject'],
|
160 |
+
)
|
161 |
+
); // Xss ok.
|
162 |
Â
echo '</span></label>';
|
163 |
Â
}
|
164 |
Â
|
179 |
Â
$alert->alert_meta['email_subject'] = sanitize_text_field( wp_unslash( $_POST['wp_stream_email_subject'] ) );
|
180 |
Â
}
|
181 |
Â
}
|
182 |
+
|
183 |
Â
/**
|
184 |
Â
* Add alert meta if this is a highlight alert
|
185 |
Â
*
|
199 |
Â
$alert_meta['email_subject'] = $email_subject;
|
200 |
Â
}
|
201 |
Â
}
|
202 |
+
|
203 |
Â
return $alert_meta;
|
204 |
Â
}
|
205 |
Â
}
|
alerts/class-alert-type-highlight.php
CHANGED
@@ -13,6 +13,7 @@ namespace WP_Stream;
|
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alert_Type_Highlight extends Alert_Type {
|
Â
|
|
16 |
Â
/**
|
17 |
Â
* Main JS file script handle.
|
18 |
Â
*/
|
@@ -68,17 +69,42 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
68 |
Â
if ( ! is_admin() ) {
|
69 |
Â
return;
|
70 |
Â
}
|
71 |
-
add_filter(
|
72 |
-
|
73 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
74 |
Â
|
75 |
Â
if ( ! empty( $this->plugin->connectors->connectors ) && is_array( $this->plugin->connectors->connectors ) ) {
|
76 |
-
foreach (
|
77 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
78 |
Â
}
|
79 |
Â
}
|
80 |
Â
|
81 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
82 |
Â
}
|
83 |
Â
|
84 |
Â
/**
|
@@ -93,10 +119,13 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
93 |
Â
* @return void
|
94 |
Â
*/
|
95 |
Â
public function alert( $record_id, $recordarr, $alert ) {
|
96 |
-
$recordarr['ID']
|
97 |
Â
$this->single_alert_id = $alert->ID;
|
98 |
Â
if ( ! empty( $alert->alert_meta['color'] ) ) {
|
99 |
-
|
Â
|
|
Â
|
|
Â
|
|
100 |
Â
}
|
101 |
Â
}
|
102 |
Â
|
@@ -111,22 +140,27 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
111 |
Â
if ( is_object( $alert ) ) {
|
112 |
Â
$alert_meta = $alert->alert_meta;
|
113 |
Â
}
|
114 |
-
$options = wp_parse_args(
|
115 |
-
|
116 |
-
|
Â
|
|
Â
|
|
117 |
Â
|
118 |
-
$form = new Form_Generator;
|
119 |
Â
echo '<span class="wp_stream_alert_type_description">' . esc_html__( 'Highlight this alert on the Stream records page.', 'stream' ) . '</span>';
|
120 |
Â
echo '<label for="wp_stream_highlight_color"><span class="title">' . esc_html__( 'Color', 'stream' ) . '</span>';
|
121 |
Â
echo '<span class="input-text-wrap">';
|
122 |
-
echo $form->render_field(
|
123 |
-
'
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
Â
|
|
Â
|
|
128 |
Â
echo '</span></label>';
|
129 |
Â
}
|
Â
|
|
130 |
Â
/**
|
131 |
Â
* Lists available color options for alerts.
|
132 |
Â
*
|
@@ -154,7 +188,7 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
154 |
Â
$alert->alert_meta['color'] = 'yellow';
|
155 |
Â
}
|
156 |
Â
$input_color = sanitize_text_field( wp_unslash( $_POST['wp_stream_highlight_color'] ) );
|
157 |
-
if ( ! array_key_exists( $input_color
|
158 |
Â
$alert->alert_meta['color'] = 'yellow';
|
159 |
Â
} else {
|
160 |
Â
$alert->alert_meta['color'] = $input_color;
|
@@ -199,7 +233,7 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
199 |
Â
* @return mixed
|
200 |
Â
*/
|
201 |
Â
public function action_link_remove_highlight( $actions, $record ) {
|
202 |
-
$record
|
203 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
204 |
Â
if ( ! empty( $alerts_triggered[ $this->slug ] ) ) {
|
205 |
Â
$actions[ __( 'Remove Highlight', 'stream' ) ] = '#';
|
@@ -242,9 +276,9 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
242 |
Â
if ( ! is_numeric( $record_id ) ) {
|
243 |
Â
wp_send_json_error( $failure_message );
|
244 |
Â
}
|
245 |
-
$record_obj
|
246 |
-
$record_obj->ID
|
247 |
-
$record
|
248 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
249 |
Â
if ( isset( $alerts_triggered[ $this->slug ] ) ) {
|
250 |
Â
unset( $alerts_triggered[ $this->slug ] );
|
@@ -260,12 +294,13 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
260 |
Â
*/
|
261 |
Â
public function enqueue_scripts( $page ) {
|
262 |
Â
if ( 'toplevel_page_wp_stream' === $page ) {
|
263 |
-
|
Â
|
|
264 |
Â
|
265 |
Â
$exports = array(
|
266 |
-
'ajaxUrl'
|
267 |
Â
'removeAction' => self::REMOVE_ACTION,
|
268 |
-
'security'
|
269 |
Â
);
|
270 |
Â
|
271 |
Â
wp_scripts()->add_data(
|
@@ -296,6 +331,7 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
296 |
Â
$alert_meta['color'] = $color;
|
297 |
Â
}
|
298 |
Â
}
|
Â
|
|
299 |
Â
return $alert_meta;
|
300 |
Â
}
|
301 |
Â
}
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alert_Type_Highlight extends Alert_Type {
|
16 |
+
|
17 |
Â
/**
|
18 |
Â
* Main JS file script handle.
|
19 |
Â
*/
|
69 |
Â
if ( ! is_admin() ) {
|
70 |
Â
return;
|
71 |
Â
}
|
72 |
+
add_filter(
|
73 |
+
'wp_stream_record_classes', array(
|
74 |
+
$this,
|
75 |
+
'post_class',
|
76 |
+
), 10, 2
|
77 |
+
);
|
78 |
+
add_action(
|
79 |
+
'admin_enqueue_scripts', array(
|
80 |
+
$this,
|
81 |
+
'enqueue_scripts',
|
82 |
+
)
|
83 |
+
);
|
84 |
+
add_action(
|
85 |
+
'wp_ajax_' . self::REMOVE_ACTION, array(
|
86 |
+
$this,
|
87 |
+
'ajax_remove_highlight',
|
88 |
+
)
|
89 |
+
);
|
90 |
Â
|
91 |
Â
if ( ! empty( $this->plugin->connectors->connectors ) && is_array( $this->plugin->connectors->connectors ) ) {
|
92 |
+
foreach ( $this->plugin->connectors->connectors as $connector ) {
|
93 |
+
add_filter(
|
94 |
+
'wp_stream_action_links_' . $connector->name, array(
|
95 |
+
$this,
|
96 |
+
'action_link_remove_highlight',
|
97 |
+
), 10, 2
|
98 |
+
);
|
99 |
Â
}
|
100 |
Â
}
|
101 |
Â
|
102 |
+
add_filter(
|
103 |
+
'wp_stream_alerts_save_meta', array(
|
104 |
+
$this,
|
105 |
+
'add_alert_meta',
|
106 |
+
), 10, 2
|
107 |
+
);
|
108 |
Â
}
|
109 |
Â
|
110 |
Â
/**
|
119 |
Â
* @return void
|
120 |
Â
*/
|
121 |
Â
public function alert( $record_id, $recordarr, $alert ) {
|
122 |
+
$recordarr['ID'] = $record_id;
|
123 |
Â
$this->single_alert_id = $alert->ID;
|
124 |
Â
if ( ! empty( $alert->alert_meta['color'] ) ) {
|
125 |
+
$alert_meta = array(
|
126 |
+
'highlight_color' => $alert->alert_meta['color'],
|
127 |
+
);
|
128 |
+
Alert::update_record_triggered_alerts( (object) $recordarr, $this->slug, $alert_meta );
|
129 |
Â
}
|
130 |
Â
}
|
131 |
Â
|
140 |
Â
if ( is_object( $alert ) ) {
|
141 |
Â
$alert_meta = $alert->alert_meta;
|
142 |
Â
}
|
143 |
+
$options = wp_parse_args(
|
144 |
+
$alert_meta, array(
|
145 |
+
'color' => 'yellow',
|
146 |
+
)
|
147 |
+
);
|
148 |
Â
|
149 |
+
$form = new Form_Generator();
|
150 |
Â
echo '<span class="wp_stream_alert_type_description">' . esc_html__( 'Highlight this alert on the Stream records page.', 'stream' ) . '</span>';
|
151 |
Â
echo '<label for="wp_stream_highlight_color"><span class="title">' . esc_html__( 'Color', 'stream' ) . '</span>';
|
152 |
Â
echo '<span class="input-text-wrap">';
|
153 |
+
echo $form->render_field(
|
154 |
+
'select', array(
|
155 |
+
'name' => 'wp_stream_highlight_color',
|
156 |
+
'title' => esc_attr( __( 'Highlight Color', 'stream' ) ),
|
157 |
+
'options' => $this->get_highlight_options(),
|
158 |
+
'value' => $options['color'],
|
159 |
+
)
|
160 |
+
); // Xss ok.
|
161 |
Â
echo '</span></label>';
|
162 |
Â
}
|
163 |
+
|
164 |
Â
/**
|
165 |
Â
* Lists available color options for alerts.
|
166 |
Â
*
|
188 |
Â
$alert->alert_meta['color'] = 'yellow';
|
189 |
Â
}
|
190 |
Â
$input_color = sanitize_text_field( wp_unslash( $_POST['wp_stream_highlight_color'] ) );
|
191 |
+
if ( ! array_key_exists( $input_color, $this->get_highlight_options() ) ) {
|
192 |
Â
$alert->alert_meta['color'] = 'yellow';
|
193 |
Â
} else {
|
194 |
Â
$alert->alert_meta['color'] = $input_color;
|
233 |
Â
* @return mixed
|
234 |
Â
*/
|
235 |
Â
public function action_link_remove_highlight( $actions, $record ) {
|
236 |
+
$record = new Record( $record );
|
237 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
238 |
Â
if ( ! empty( $alerts_triggered[ $this->slug ] ) ) {
|
239 |
Â
$actions[ __( 'Remove Highlight', 'stream' ) ] = '#';
|
276 |
Â
if ( ! is_numeric( $record_id ) ) {
|
277 |
Â
wp_send_json_error( $failure_message );
|
278 |
Â
}
|
279 |
+
$record_obj = new \stdClass();
|
280 |
+
$record_obj->ID = $record_id;
|
281 |
+
$record = new Record( $record_obj );
|
282 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
283 |
Â
if ( isset( $alerts_triggered[ $this->slug ] ) ) {
|
284 |
Â
unset( $alerts_triggered[ $this->slug ] );
|
294 |
Â
*/
|
295 |
Â
public function enqueue_scripts( $page ) {
|
296 |
Â
if ( 'toplevel_page_wp_stream' === $page ) {
|
297 |
+
$min = wp_stream_min_suffix();
|
298 |
+
wp_register_script( self::SCRIPT_HANDLE, $this->plugin->locations['url'] . 'alerts/js/alert-type-highlight.' . $min . 'js', array( 'jquery' ) );
|
299 |
Â
|
300 |
Â
$exports = array(
|
301 |
+
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
302 |
Â
'removeAction' => self::REMOVE_ACTION,
|
303 |
+
'security' => wp_create_nonce( self::REMOVE_ACTION_NONCE ),
|
304 |
Â
);
|
305 |
Â
|
306 |
Â
wp_scripts()->add_data(
|
331 |
Â
$alert_meta['color'] = $color;
|
332 |
Â
}
|
333 |
Â
}
|
334 |
+
|
335 |
Â
return $alert_meta;
|
336 |
Â
}
|
337 |
Â
}
|
alerts/class-alert-type-ifttt.php
CHANGED
@@ -49,6 +49,7 @@ namespace WP_Stream;
|
|
49 |
Â
* @package WP_Stream
|
50 |
Â
*/
|
51 |
Â
class Alert_Type_IFTTT extends Alert_Type {
|
Â
|
|
52 |
Â
/**
|
53 |
Â
* Alert type name
|
54 |
Â
*
|
@@ -67,7 +68,6 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
67 |
Â
* Class Constructor
|
68 |
Â
*
|
69 |
Â
* @param Plugin $plugin Plugin object.
|
70 |
-
* @return void
|
71 |
Â
*/
|
72 |
Â
public function __construct( $plugin ) {
|
73 |
Â
parent::__construct( $plugin );
|
@@ -75,8 +75,14 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
75 |
Â
if ( ! is_admin() ) {
|
76 |
Â
return;
|
77 |
Â
}
|
78 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
79 |
Â
}
|
Â
|
|
80 |
Â
/**
|
81 |
Â
* Record that the Alert was triggered by a Record.
|
82 |
Â
*
|
@@ -104,12 +110,14 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
104 |
Â
if ( is_object( $alert ) ) {
|
105 |
Â
$alert_meta = $alert->alert_meta;
|
106 |
Â
}
|
107 |
-
$options = wp_parse_args(
|
108 |
-
|
109 |
-
|
110 |
-
|
Â
|
|
Â
|
|
111 |
Â
|
112 |
-
$form = new Form_Generator;
|
113 |
Â
|
114 |
Â
echo '<span class="wp_stream_alert_type_description">';
|
115 |
Â
echo esc_html__( 'Trigger an IFTTT Maker recipe.', 'stream' );
|
@@ -117,11 +125,13 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
117 |
Â
echo '</span>';
|
118 |
Â
echo '<label for="wp_stream_ifttt_maker_key"><span class="title">' . esc_html__( 'Maker Key', 'stream' ) . '</span>';
|
119 |
Â
echo '<span class="input-text-wrap">';
|
120 |
-
echo $form->render_field(
|
121 |
-
'
|
122 |
-
|
123 |
-
|
124 |
-
|
Â
|
|
Â
|
|
125 |
Â
echo '</span>';
|
126 |
Â
printf(
|
127 |
Â
'<span class="input-text-wrap"><a href="%1$s" target="_blank">%2$s %3$s</a></span>',
|
@@ -133,11 +143,13 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
133 |
Â
|
134 |
Â
echo '<label for="wp_stream_ifttt_event_name"><span class="title">' . esc_html__( 'Event Name', 'stream' ) . '</span>';
|
135 |
Â
echo '<span class="input-text-wrap">';
|
136 |
-
echo $form->render_field(
|
137 |
-
'
|
138 |
-
|
139 |
-
|
140 |
-
|
Â
|
|
Â
|
|
141 |
Â
echo '</span>';
|
142 |
Â
printf(
|
143 |
Â
'<span class="input-text-wrap"><a href="%1$s" target="_blank">%2$s %3$s</a></span>',
|
@@ -178,7 +190,7 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
178 |
Â
* array keys of data. (also documented below)
|
179 |
Â
*
|
180 |
Â
* @param object $alert The Alert object.
|
181 |
-
* @param array $recordarr
|
182 |
Â
*
|
183 |
Â
* @return bool
|
184 |
Â
*/
|
@@ -187,14 +199,18 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
187 |
Â
return false;
|
188 |
Â
}
|
189 |
Â
|
190 |
-
$record_data = wp_parse_args(
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
195 |
Â
|
196 |
Â
$user_id = $recordarr['user_id'];
|
197 |
-
$user
|
198 |
Â
|
199 |
Â
/**
|
200 |
Â
* Filter User data field
|
@@ -219,7 +235,7 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
219 |
Â
* @return string
|
220 |
Â
*/
|
221 |
Â
$date_format = apply_filters( 'wp_stream_alert_ifttt_date_format', 'Y-m-d H:i:s', $alert, $recordarr );
|
222 |
-
$date
|
223 |
Â
|
224 |
Â
$url = 'https://maker.ifttt.com/trigger/' . $alert->alert_meta['event_name'] . '/with/key/' . $alert->alert_meta['maker_key'];
|
225 |
Â
|
@@ -242,13 +258,13 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
242 |
Â
'headers' => array(
|
243 |
Â
'Content-Type' => 'application/json',
|
244 |
Â
),
|
245 |
-
'body'
|
246 |
Â
array(
|
247 |
Â
/**
|
248 |
Â
* Filter the first IFTTT alert value
|
249 |
Â
*
|
250 |
Â
* @param string $summary The Record's summary.
|
251 |
-
* @param object $alert
|
252 |
Â
* @param array $recordarr Array of Record data.
|
253 |
Â
* @return mixed
|
254 |
Â
*/
|
@@ -258,7 +274,7 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
258 |
Â
* Filter the second IFTTT alert value
|
259 |
Â
*
|
260 |
Â
* @param string $user_value The user meta value requested above.
|
261 |
-
* @param int $user_id
|
262 |
Â
* @param object $alert The Alert.
|
263 |
Â
* @param array $recordarr Array of Record data.
|
264 |
Â
* @return mixed
|
@@ -269,7 +285,7 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
269 |
Â
* Filter the third IFTTT alert value
|
270 |
Â
*
|
271 |
Â
* @param string $date The Record's date.
|
272 |
-
* @param object $alert
|
273 |
Â
* @param array $recordarr Array of Record data.
|
274 |
Â
* @return mixed
|
275 |
Â
*/
|
@@ -277,12 +293,15 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
277 |
Â
)
|
278 |
Â
),
|
279 |
Â
);
|
Â
|
|
280 |
Â
$response = wp_remote_post( $url, $args );
|
281 |
Â
if ( ! is_array( $response ) ) {
|
282 |
Â
return false;
|
283 |
Â
}
|
Â
|
|
284 |
Â
return true;
|
285 |
Â
}
|
Â
|
|
286 |
Â
/**
|
287 |
Â
* Add alert meta if this is a highlight alert
|
288 |
Â
*
|
@@ -302,6 +321,7 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
302 |
Â
$alert_meta['event_name'] = $event_name;
|
303 |
Â
}
|
304 |
Â
}
|
Â
|
|
305 |
Â
return $alert_meta;
|
306 |
Â
}
|
307 |
Â
}
|
49 |
Â
* @package WP_Stream
|
50 |
Â
*/
|
51 |
Â
class Alert_Type_IFTTT extends Alert_Type {
|
52 |
+
|
53 |
Â
/**
|
54 |
Â
* Alert type name
|
55 |
Â
*
|
68 |
Â
* Class Constructor
|
69 |
Â
*
|
70 |
Â
* @param Plugin $plugin Plugin object.
|
Â
|
|
71 |
Â
*/
|
72 |
Â
public function __construct( $plugin ) {
|
73 |
Â
parent::__construct( $plugin );
|
75 |
Â
if ( ! is_admin() ) {
|
76 |
Â
return;
|
77 |
Â
}
|
78 |
+
add_filter(
|
79 |
+
'wp_stream_alerts_save_meta', array(
|
80 |
+
$this,
|
81 |
+
'add_alert_meta',
|
82 |
+
), 10, 2
|
83 |
+
);
|
84 |
Â
}
|
85 |
+
|
86 |
Â
/**
|
87 |
Â
* Record that the Alert was triggered by a Record.
|
88 |
Â
*
|
110 |
Â
if ( is_object( $alert ) ) {
|
111 |
Â
$alert_meta = $alert->alert_meta;
|
112 |
Â
}
|
113 |
+
$options = wp_parse_args(
|
114 |
+
$alert_meta, array(
|
115 |
+
'maker_key' => '',
|
116 |
+
'event_name' => '',
|
117 |
+
)
|
118 |
+
);
|
119 |
Â
|
120 |
+
$form = new Form_Generator();
|
121 |
Â
|
122 |
Â
echo '<span class="wp_stream_alert_type_description">';
|
123 |
Â
echo esc_html__( 'Trigger an IFTTT Maker recipe.', 'stream' );
|
125 |
Â
echo '</span>';
|
126 |
Â
echo '<label for="wp_stream_ifttt_maker_key"><span class="title">' . esc_html__( 'Maker Key', 'stream' ) . '</span>';
|
127 |
Â
echo '<span class="input-text-wrap">';
|
128 |
+
echo $form->render_field(
|
129 |
+
'text', array(
|
130 |
+
'name' => 'wp_stream_ifttt_maker_key',
|
131 |
+
'title' => esc_attr( __( 'Maker Key', 'stream' ) ),
|
132 |
+
'value' => $options['maker_key'],
|
133 |
+
)
|
134 |
+
); // Xss ok.
|
135 |
Â
echo '</span>';
|
136 |
Â
printf(
|
137 |
Â
'<span class="input-text-wrap"><a href="%1$s" target="_blank">%2$s %3$s</a></span>',
|
143 |
Â
|
144 |
Â
echo '<label for="wp_stream_ifttt_event_name"><span class="title">' . esc_html__( 'Event Name', 'stream' ) . '</span>';
|
145 |
Â
echo '<span class="input-text-wrap">';
|
146 |
+
echo $form->render_field(
|
147 |
+
'text', array(
|
148 |
+
'name' => 'wp_stream_ifttt_event_name',
|
149 |
+
'title' => esc_attr( __( 'Event Name', 'stream' ) ),
|
150 |
+
'value' => $options['event_name'],
|
151 |
+
)
|
152 |
+
); // Xss ok.
|
153 |
Â
echo '</span>';
|
154 |
Â
printf(
|
155 |
Â
'<span class="input-text-wrap"><a href="%1$s" target="_blank">%2$s %3$s</a></span>',
|
190 |
Â
* array keys of data. (also documented below)
|
191 |
Â
*
|
192 |
Â
* @param object $alert The Alert object.
|
193 |
+
* @param array $recordarr Array of Record data.
|
194 |
Â
*
|
195 |
Â
* @return bool
|
196 |
Â
*/
|
199 |
Â
return false;
|
200 |
Â
}
|
201 |
Â
|
202 |
+
$record_data = wp_parse_args(
|
203 |
+
$recordarr, array(
|
204 |
+
// translators: Placeholder refers to the Event Name of the Alert (e.g. "Update a post")
|
205 |
+
'summary' => sprintf( __( 'The event %s was triggered' ), $alert->alert_meta['event_name'] ),
|
206 |
+
'user_id' => get_current_user_id(),
|
207 |
+
'created' => current_time( 'Y-m-d H:i:s' ),
|
208 |
+
// Blog's local time.
|
209 |
+
)
|
210 |
+
);
|
211 |
Â
|
212 |
Â
$user_id = $recordarr['user_id'];
|
213 |
+
$user = get_user_by( 'id', $user_id );
|
214 |
Â
|
215 |
Â
/**
|
216 |
Â
* Filter User data field
|
235 |
Â
* @return string
|
236 |
Â
*/
|
237 |
Â
$date_format = apply_filters( 'wp_stream_alert_ifttt_date_format', 'Y-m-d H:i:s', $alert, $recordarr );
|
238 |
+
$date = date( $date_format, strtotime( $created ) );
|
239 |
Â
|
240 |
Â
$url = 'https://maker.ifttt.com/trigger/' . $alert->alert_meta['event_name'] . '/with/key/' . $alert->alert_meta['maker_key'];
|
241 |
Â
|
258 |
Â
'headers' => array(
|
259 |
Â
'Content-Type' => 'application/json',
|
260 |
Â
),
|
261 |
+
'body' => wp_json_encode(
|
262 |
Â
array(
|
263 |
Â
/**
|
264 |
Â
* Filter the first IFTTT alert value
|
265 |
Â
*
|
266 |
Â
* @param string $summary The Record's summary.
|
267 |
+
* @param object $alert The Alert.
|
268 |
Â
* @param array $recordarr Array of Record data.
|
269 |
Â
* @return mixed
|
270 |
Â
*/
|
274 |
Â
* Filter the second IFTTT alert value
|
275 |
Â
*
|
276 |
Â
* @param string $user_value The user meta value requested above.
|
277 |
+
* @param int $user_id The user ID who fired the Alert.
|
278 |
Â
* @param object $alert The Alert.
|
279 |
Â
* @param array $recordarr Array of Record data.
|
280 |
Â
* @return mixed
|
285 |
Â
* Filter the third IFTTT alert value
|
286 |
Â
*
|
287 |
Â
* @param string $date The Record's date.
|
288 |
+
* @param object $alert The Alert.
|
289 |
Â
* @param array $recordarr Array of Record data.
|
290 |
Â
* @return mixed
|
291 |
Â
*/
|
293 |
Â
)
|
294 |
Â
),
|
295 |
Â
);
|
296 |
+
|
297 |
Â
$response = wp_remote_post( $url, $args );
|
298 |
Â
if ( ! is_array( $response ) ) {
|
299 |
Â
return false;
|
300 |
Â
}
|
301 |
+
|
302 |
Â
return true;
|
303 |
Â
}
|
304 |
+
|
305 |
Â
/**
|
306 |
Â
* Add alert meta if this is a highlight alert
|
307 |
Â
*
|
321 |
Â
$alert_meta['event_name'] = $event_name;
|
322 |
Â
}
|
323 |
Â
}
|
324 |
+
|
325 |
Â
return $alert_meta;
|
326 |
Â
}
|
327 |
Â
}
|
alerts/class-alert-type-menu-alert.php
CHANGED
@@ -13,6 +13,7 @@ namespace WP_Stream;
|
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alert_Type_Menu_Alert extends Alert_Type {
|
Â
|
|
16 |
Â
/**
|
17 |
Â
* Alert type name
|
18 |
Â
*
|
@@ -48,7 +49,6 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
48 |
Â
*/
|
49 |
Â
public function alert( $record_id, $recordarr, $options ) {
|
50 |
Â
$this->add_message( $recordarr['summary'] );
|
51 |
-
return;
|
52 |
Â
}
|
53 |
Â
|
54 |
Â
/**
|
@@ -62,19 +62,23 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
62 |
Â
if ( is_object( $alert ) ) {
|
63 |
Â
$alert_meta = $alert->alert_meta;
|
64 |
Â
}
|
65 |
-
$options = wp_parse_args(
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
78 |
Â
}
|
79 |
Â
|
80 |
Â
/**
|
@@ -101,25 +105,34 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
101 |
Â
return false;
|
102 |
Â
}
|
103 |
Â
|
104 |
-
$wp_admin_bar->add_node(
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
111 |
Â
|
112 |
Â
foreach ( $messages as $key => $message ) {
|
113 |
-
$wp_admin_bar->add_node(
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
120 |
Â
}
|
121 |
Â
|
122 |
Â
$this->clear_messages();
|
Â
|
|
123 |
Â
return true;
|
124 |
Â
}
|
125 |
Â
|
@@ -131,8 +144,9 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
131 |
Â
* @return array List of alert messages
|
132 |
Â
*/
|
133 |
Â
public function get_messages() {
|
134 |
-
$current_user
|
135 |
-
$messages
|
Â
|
|
136 |
Â
return $messages;
|
137 |
Â
}
|
138 |
Â
|
@@ -145,7 +159,7 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
145 |
Â
* @return void
|
146 |
Â
*/
|
147 |
Â
public function add_message( $message ) {
|
148 |
-
$current_user
|
149 |
Â
add_user_meta( $current_user->ID, $this->get_key(), $message, false );
|
150 |
Â
}
|
151 |
Â
|
@@ -158,7 +172,7 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
158 |
Â
* @return void
|
159 |
Â
*/
|
160 |
Â
public function clear_messages( $global = false ) {
|
161 |
-
$current_user
|
162 |
Â
delete_user_meta( $current_user->ID, $this->get_key(), $global );
|
163 |
Â
}
|
164 |
Â
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alert_Type_Menu_Alert extends Alert_Type {
|
16 |
+
|
17 |
Â
/**
|
18 |
Â
* Alert type name
|
19 |
Â
*
|
49 |
Â
*/
|
50 |
Â
public function alert( $record_id, $recordarr, $options ) {
|
51 |
Â
$this->add_message( $recordarr['summary'] );
|
Â
|
|
52 |
Â
}
|
53 |
Â
|
54 |
Â
/**
|
62 |
Â
if ( is_object( $alert ) ) {
|
63 |
Â
$alert_meta = $alert->alert_meta;
|
64 |
Â
}
|
65 |
+
$options = wp_parse_args(
|
66 |
+
$alert_meta, array(
|
67 |
+
'clear_immediate' => false,
|
68 |
+
)
|
69 |
+
);
|
70 |
+
|
71 |
+
$form = new Form_Generator();
|
72 |
+
$form->add_field(
|
73 |
+
'checkbox', array(
|
74 |
+
'name' => 'wp_stream_menu_alert_clear_immediate',
|
75 |
+
'text' => esc_attr( __( 'Clear alerts after seen.', 'stream' ) ),
|
76 |
+
'value' => $options['clear_immediate'],
|
77 |
+
'title' => __( 'Menu Bar', 'stream' ),
|
78 |
+
)
|
79 |
+
);
|
80 |
+
|
81 |
+
echo $form->render_fields(); // Xss ok.
|
82 |
Â
}
|
83 |
Â
|
84 |
Â
/**
|
105 |
Â
return false;
|
106 |
Â
}
|
107 |
Â
|
108 |
+
$wp_admin_bar->add_node(
|
109 |
+
array(
|
110 |
+
'id' => 'wp_stream_alert_notify',
|
111 |
+
'parent' => false,
|
112 |
+
'title' => __( 'New Stream Alert', 'stream' ),
|
113 |
+
'href' => '#',
|
114 |
+
'meta' => array(
|
115 |
+
'class' => 'opposite',
|
116 |
+
),
|
117 |
+
)
|
118 |
+
);
|
119 |
Â
|
120 |
Â
foreach ( $messages as $key => $message ) {
|
121 |
+
$wp_admin_bar->add_node(
|
122 |
+
array(
|
123 |
+
'id' => 'wp_stream_alert_notify_' . $key,
|
124 |
+
'parent' => 'wp_stream_alert_notify',
|
125 |
+
'title' => esc_html( $message ),
|
126 |
+
'href' => '#',
|
127 |
+
'meta' => array(
|
128 |
+
'class' => 'opposite',
|
129 |
+
),
|
130 |
+
)
|
131 |
+
);
|
132 |
Â
}
|
133 |
Â
|
134 |
Â
$this->clear_messages();
|
135 |
+
|
136 |
Â
return true;
|
137 |
Â
}
|
138 |
Â
|
144 |
Â
* @return array List of alert messages
|
145 |
Â
*/
|
146 |
Â
public function get_messages() {
|
147 |
+
$current_user = wp_get_current_user();
|
148 |
+
$messages = get_user_meta( $current_user->ID, $this->get_key(), false );
|
149 |
+
|
150 |
Â
return $messages;
|
151 |
Â
}
|
152 |
Â
|
159 |
Â
* @return void
|
160 |
Â
*/
|
161 |
Â
public function add_message( $message ) {
|
162 |
+
$current_user = wp_get_current_user();
|
163 |
Â
add_user_meta( $current_user->ID, $this->get_key(), $message, false );
|
164 |
Â
}
|
165 |
Â
|
172 |
Â
* @return void
|
173 |
Â
*/
|
174 |
Â
public function clear_messages( $global = false ) {
|
175 |
+
$current_user = wp_get_current_user();
|
176 |
Â
delete_user_meta( $current_user->ID, $this->get_key(), $global );
|
177 |
Â
}
|
178 |
Â
|
alerts/class-alert-type-none.php
CHANGED
@@ -36,6 +36,6 @@ class Alert_Type_None extends Alert_Type {
|
|
36 |
Â
* @return void
|
37 |
Â
*/
|
38 |
Â
public function alert( $record_id, $recordarr, $options ) {
|
39 |
-
|
40 |
Â
}
|
41 |
Â
}
|
36 |
Â
* @return void
|
37 |
Â
*/
|
38 |
Â
public function alert( $record_id, $recordarr, $options ) {
|
39 |
+
// Do nothing.
|
40 |
Â
}
|
41 |
Â
}
|
alerts/class-alert-type-slack.php
ADDED
@@ -0,0 +1,303 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Slack Alerts.
|
4 |
+
*
|
5 |
+
* @package WP_Stream
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace WP_Stream;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Alert_Type_Slack
|
12 |
+
*
|
13 |
+
* @package WP_Stream
|
14 |
+
*/
|
15 |
+
class Alert_Type_Slack extends Alert_Type {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Alert type name
|
19 |
+
*
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
public $name = 'Slack';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Alert type slug
|
26 |
+
*
|
27 |
+
* @var string
|
28 |
+
*/
|
29 |
+
public $slug = 'slack';
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Class Constructor
|
33 |
+
*
|
34 |
+
* @param Plugin $plugin Plugin object.
|
35 |
+
*/
|
36 |
+
public function __construct( $plugin ) {
|
37 |
+
parent::__construct( $plugin );
|
38 |
+
$this->plugin = $plugin;
|
39 |
+
if ( ! is_admin() ) {
|
40 |
+
return;
|
41 |
+
}
|
42 |
+
add_filter(
|
43 |
+
'wp_stream_alerts_save_meta', array(
|
44 |
+
$this,
|
45 |
+
'add_alert_meta',
|
46 |
+
), 10, 2
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Sends an message to the Slack channel.
|
52 |
+
*
|
53 |
+
* @param int $record_id Record that triggered notification.
|
54 |
+
* @param array $recordarr Record details.
|
55 |
+
* @param Alert $alert Alert options.
|
56 |
+
* @return void
|
57 |
+
*/
|
58 |
+
public function alert( $record_id, $recordarr, $alert ) {
|
59 |
+
$options = wp_parse_args(
|
60 |
+
$alert->alert_meta, array(
|
61 |
+
'webhook' => '',
|
62 |
+
'channel' => '',
|
63 |
+
'username' => '',
|
64 |
+
'icon' => '',
|
65 |
+
'trigger_action' => '',
|
66 |
+
'trigger_connector' => '',
|
67 |
+
'trigger_context' => '',
|
68 |
+
)
|
69 |
+
);
|
70 |
+
if ( empty( $options['webhook'] ) ) {
|
71 |
+
return;
|
72 |
+
}
|
73 |
+
$user_id = (int) $recordarr['user_id'];
|
74 |
+
$user = get_userdata( $user_id );
|
75 |
+
$logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
|
76 |
+
$context = $recordarr['context'];
|
77 |
+
$action = $recordarr['action'];
|
78 |
+
|
79 |
+
if ( ! empty( $alert->alert_meta['trigger_context'] ) ) {
|
80 |
+
$context = $this->plugin->alerts->alert_triggers['context']->get_display_value( 'list_table', $alert );
|
81 |
+
}
|
82 |
+
if ( ! empty( $alert->alert_meta['trigger_action'] ) ) {
|
83 |
+
$action = $this->plugin->alerts->alert_triggers['action']->get_display_value( 'list_table', $alert );
|
84 |
+
}
|
85 |
+
|
86 |
+
$fields = array(
|
87 |
+
array(
|
88 |
+
'title' => 'IP Address',
|
89 |
+
'value' => $recordarr['ip'],
|
90 |
+
'short' => true,
|
91 |
+
),
|
92 |
+
array(
|
93 |
+
'title' => 'Connector',
|
94 |
+
'value' => $recordarr['connector'],
|
95 |
+
'short' => true,
|
96 |
+
),
|
97 |
+
array(
|
98 |
+
'title' => 'Context',
|
99 |
+
'value' => $context,
|
100 |
+
'short' => true,
|
101 |
+
),
|
102 |
+
array(
|
103 |
+
'title' => 'Action',
|
104 |
+
'value' => $action,
|
105 |
+
'short' => true,
|
106 |
+
),
|
107 |
+
);
|
108 |
+
|
109 |
+
$post = null;
|
110 |
+
if ( isset( $recordarr['object_id'] ) ) {
|
111 |
+
$post_id = $recordarr['object_id'];
|
112 |
+
$post = get_post( $post_id );
|
113 |
+
}
|
114 |
+
if ( is_object( $post ) && ! empty( $post ) ) {
|
115 |
+
$post_type = get_post_type_object( $post->post_type );
|
116 |
+
$edit_post_link = get_edit_post_link( $post->ID, 'raw' );
|
117 |
+
array_push(
|
118 |
+
$fields, array(
|
119 |
+
'title' => 'Edit ' . $post_type->labels->singular_name,
|
120 |
+
'value' => "<$edit_post_link>",
|
121 |
+
'short' => false,
|
122 |
+
)
|
123 |
+
);
|
124 |
+
}
|
125 |
+
|
126 |
+
$edit_alert_link = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $alert->ID );
|
127 |
+
array_push(
|
128 |
+
$fields, array(
|
129 |
+
'title' => 'Edit Alert',
|
130 |
+
'value' => "<$edit_alert_link>",
|
131 |
+
'short' => false,
|
132 |
+
)
|
133 |
+
);
|
134 |
+
|
135 |
+
$attachment = array(
|
136 |
+
'author_icon' => get_avatar_url( $user_id, 16 ),
|
137 |
+
'author_link' => admin_url( "admin.php?page=wp_stream&user_id=$user_id" ),
|
138 |
+
'author_name' => trim( "$user->first_name $user->last_name" ),
|
139 |
+
'fallback' => html_entity_decode( $recordarr['summary'] ),
|
140 |
+
'fields' => $fields,
|
141 |
+
'footer' => get_bloginfo( 'name' ),
|
142 |
+
'footer_icon' => get_site_icon_url( 16, $logo[0], $recordarr['blog_id'] ),
|
143 |
+
'title' => html_entity_decode( $recordarr['summary'] ),
|
144 |
+
'ts' => strtotime( $recordarr['created'] ),
|
145 |
+
);
|
146 |
+
if ( array_key_exists( 'object_id', $recordarr ) ) {
|
147 |
+
$object_id = (int) $recordarr['object_id'];
|
148 |
+
$context = $recordarr['context'];
|
149 |
+
$attachment['title_link'] = admin_url( "admin.php?page=wp_stream&object_id=$object_id&context=$context" );
|
150 |
+
}
|
151 |
+
$data = array(
|
152 |
+
'attachments' => array( $attachment ),
|
153 |
+
);
|
154 |
+
if ( ! empty( $options['channel'] ) ) {
|
155 |
+
$data['channel'] = $options['channel'];
|
156 |
+
}
|
157 |
+
if ( ! empty( $options['username'] ) ) {
|
158 |
+
$data['username'] = $options['username'];
|
159 |
+
}
|
160 |
+
if ( ! empty( $options['icon'] ) ) {
|
161 |
+
if ( substr( $options['icon'], 0, 1 ) === ':' ) {
|
162 |
+
$data['icon_emoji'] = $options['icon'];
|
163 |
+
} elseif ( substr( $options['icon'], 0, 4 ) === 'http' ) {
|
164 |
+
$data['icon_url'] = $options['icon'];
|
165 |
+
}
|
166 |
+
}
|
167 |
+
wp_remote_post(
|
168 |
+
$options['webhook'], array(
|
169 |
+
'body' => wp_json_encode( $data ),
|
170 |
+
'headers' => array( 'Content-Type' => 'application/json' ),
|
171 |
+
)
|
172 |
+
);
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Displays a settings form for the alert type
|
177 |
+
*
|
178 |
+
* @param Alert $alert Alert object for the currently displayed alert.
|
179 |
+
* @return void
|
180 |
+
*/
|
181 |
+
public function display_fields( $alert ) {
|
182 |
+
$alert_meta = array();
|
183 |
+
if ( is_object( $alert ) ) {
|
184 |
+
$alert_meta = $alert->alert_meta;
|
185 |
+
}
|
186 |
+
$options = wp_parse_args(
|
187 |
+
$alert_meta, array(
|
188 |
+
'webhook' => '',
|
189 |
+
'channel' => '',
|
190 |
+
'username' => '',
|
191 |
+
'icon' => '',
|
192 |
+
)
|
193 |
+
);
|
194 |
+
$form = new Form_Generator();
|
195 |
+
echo '<span class="wp_stream_alert_type_description">' . esc_html__( 'Send a rich message notification to Slack.', 'stream' ) . '</span>';
|
196 |
+
echo '<label for="wp_stream_slack_webhook"><span class="title">' . esc_html__( 'Webhook URL', 'stream' ) . '</span>';
|
197 |
+
echo '<span class="input-text-wrap">';
|
198 |
+
echo $form->render_field(
|
199 |
+
'text', array(
|
200 |
+
'name' => 'wp_stream_slack_webhook',
|
201 |
+
'title' => esc_attr( __( 'Webhook URL', 'stream' ) ),
|
202 |
+
'value' => $options['webhook'],
|
203 |
+
)
|
204 |
+
); // Xss ok.
|
205 |
+
echo '</span>';
|
206 |
+
echo '<span class="input-text-wrap">' . esc_html__( 'The webhook URL', 'stream' ) . '</span>';
|
207 |
+
echo '</label>';
|
208 |
+
echo '<label for="wp_stream_slack_channel"><span class="title">' . esc_html__( 'Channel', 'stream' ) . '</span>';
|
209 |
+
echo '<span class="input-text-wrap">';
|
210 |
+
echo $form->render_field(
|
211 |
+
'text', array(
|
212 |
+
'name' => 'wp_stream_slack_channel',
|
213 |
+
'title' => esc_attr( __( 'Channel', 'stream' ) ),
|
214 |
+
'value' => $options['channel'],
|
215 |
+
)
|
216 |
+
); // Xss ok.
|
217 |
+
echo '</span>';
|
218 |
+
echo '<span class="input-text-wrap">' . esc_html__( 'The channel to send to (optional)', 'stream' ) . '</span>';
|
219 |
+
echo '</label>';
|
220 |
+
echo '<label for="wp_stream_slack_username"><span class="title">' . esc_html__( 'Username', 'stream' ) . '</span>';
|
221 |
+
echo '<span class="input-text-wrap">';
|
222 |
+
echo $form->render_field(
|
223 |
+
'text', array(
|
224 |
+
'name' => 'wp_stream_slack_username',
|
225 |
+
'title' => esc_attr( __( 'Username', 'stream' ) ),
|
226 |
+
'value' => $options['username'],
|
227 |
+
)
|
228 |
+
); // Xss ok.
|
229 |
+
echo '</span>';
|
230 |
+
echo '<span class="input-text-wrap">' . esc_html__( 'The username to send as (optional)', 'stream' ) . '</span>';
|
231 |
+
echo '</label>';
|
232 |
+
echo '<label for="wp_stream_slack_icon"><span class="title">' . esc_html__( 'Icon', 'stream' ) . '</span>';
|
233 |
+
echo '<span class="input-text-wrap">';
|
234 |
+
echo $form->render_field(
|
235 |
+
'text', array(
|
236 |
+
'name' => 'wp_stream_slack_icon',
|
237 |
+
'title' => esc_attr( __( 'Icon', 'stream' ) ),
|
238 |
+
'value' => $options['icon'],
|
239 |
+
)
|
240 |
+
); // Xss ok.
|
241 |
+
echo '</span>';
|
242 |
+
echo '<span class="input-text-wrap">' . esc_html__( 'The URL or emoji (with colons!) to use as the icon (optional)', 'stream' ) . '</span>';
|
243 |
+
echo '</label>';
|
244 |
+
}
|
245 |
+
|
246 |
+
/**
|
247 |
+
* Validates and saves form settings for later use.
|
248 |
+
*
|
249 |
+
* @param Alert $alert Alert object for the currently displayed alert.
|
250 |
+
* @return void
|
251 |
+
*/
|
252 |
+
public function save_fields( $alert ) {
|
253 |
+
check_admin_referer( 'save_alert', 'wp_stream_alerts_nonce' );
|
254 |
+
|
255 |
+
$webhook = wp_stream_filter_input( 'INPUT_POST', 'wp_stream_slack_webhook', 'FILTER_VALIDATE_URL' );
|
256 |
+
if ( ! empty( $webhook ) ) {
|
257 |
+
$alert->alert_meta['webhook'] = $webhook;
|
258 |
+
}
|
259 |
+
$channel = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_channel' );
|
260 |
+
if ( ! empty( $channel ) ) {
|
261 |
+
$alert->alert_meta['channel'] = $channel;
|
262 |
+
}
|
263 |
+
$username = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_username' );
|
264 |
+
if ( ! empty( $username ) ) {
|
265 |
+
$alert->alert_meta['username'] = $username;
|
266 |
+
}
|
267 |
+
$icon = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_icon' );
|
268 |
+
if ( ! empty( $icon ) ) {
|
269 |
+
$alert->alert_meta['icon'] = $icon;
|
270 |
+
}
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Add alert meta if this is a Slack alert
|
275 |
+
*
|
276 |
+
* @param array $alert_meta The metadata to be inserted for this alert.
|
277 |
+
* @param string $alert_type The type of alert being added or updated.
|
278 |
+
*
|
279 |
+
* @return mixed
|
280 |
+
*/
|
281 |
+
public function add_alert_meta( $alert_meta, $alert_type ) {
|
282 |
+
if ( $this->slug === $alert_type ) {
|
283 |
+
$webhook = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_webhook' );
|
284 |
+
if ( ! empty( $webhook ) ) {
|
285 |
+
$alert_meta['webhook'] = $webhook;
|
286 |
+
}
|
287 |
+
$channel = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_channel' );
|
288 |
+
if ( ! empty( $channel ) ) {
|
289 |
+
$alert_meta['channel'] = $channel;
|
290 |
+
}
|
291 |
+
$username = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_username' );
|
292 |
+
if ( ! empty( $username ) ) {
|
293 |
+
$alert_meta['username'] = $username;
|
294 |
+
}
|
295 |
+
$icon = wp_stream_filter_input( INPUT_POST, 'wp_stream_slack_icon' );
|
296 |
+
if ( ! empty( $icon ) ) {
|
297 |
+
$alert_meta['icon'] = $icon;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
|
301 |
+
return $alert_meta;
|
302 |
+
}
|
303 |
+
}
|
alerts/js/alert-type-highlight.js
CHANGED
@@ -17,59 +17,71 @@ var streamAlertTypeHighlight = ( function( $ ) {
|
|
17 |
Â
* @returns void.
|
18 |
Â
*/
|
19 |
Â
self.init = function() {
|
20 |
-
$( document ).ready(
|
Â
|
|
21 |
Â
|
22 |
-
|
23 |
Â
* Remove highlights on Record list screen.
|
24 |
Â
*
|
25 |
Â
* @returns void.
|
26 |
Â
*/
|
27 |
-
|
28 |
-
|
Â
|
|
29 |
Â
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
Â
|
|
40 |
Â
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
Â
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
Â
|
|
Â
|
|
52 |
Â
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
}
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
});
|
72 |
-
}); // End document.ready().
|
73 |
Â
};
|
74 |
Â
|
75 |
Â
return self;
|
17 |
Â
* @returns void.
|
18 |
Â
*/
|
19 |
Â
self.init = function() {
|
20 |
+
$( document ).ready(
|
21 |
+
function() {
|
22 |
Â
|
23 |
+
/**
|
24 |
Â
* Remove highlights on Record list screen.
|
25 |
Â
*
|
26 |
Â
* @returns void.
|
27 |
Â
*/
|
28 |
+
$( '.alert-highlight .action-link[href="#"]' ).each(
|
29 |
+
function() {
|
30 |
+
var actionLink = $( this );
|
31 |
Â
|
32 |
+
/**
|
33 |
+
* Ajax call to remove the highlight.
|
34 |
+
*
|
35 |
+
* @returns void.
|
36 |
+
*/
|
37 |
+
actionLink.click(
|
38 |
+
function( e ) {
|
39 |
+
var recordId, data;
|
40 |
+
e.preventDefault();
|
41 |
+
recordId = actionLink.parents( '.alert-highlight' ).attr( 'class' ).match( /record\-id\-[\w-]*\b/ );
|
42 |
+
recordId = recordId[0].replace( 'record-id-', '' );
|
43 |
Â
|
44 |
+
data = {
|
45 |
+
action: self.removeAction,
|
46 |
+
security: self.security,
|
47 |
+
recordId: recordId
|
48 |
+
};
|
49 |
Â
|
50 |
+
$.post(
|
51 |
+
self.ajaxUrl, data, function( response ) {
|
52 |
+
if ( true === response.success ) {
|
53 |
+
ajaxDone();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
);
|
57 |
Â
|
58 |
+
/**
|
59 |
+
* Fires when Ajax complete.
|
60 |
+
*/
|
61 |
+
function ajaxDone() {
|
62 |
+
var row = actionLink.parents( '.alert-highlight' ),
|
63 |
+
odd = $( '.striped > tbody > :nth-child( odd )' );
|
64 |
+
if ( row.is( odd ) ) {
|
65 |
+
row.animate(
|
66 |
+
{ backgroundColor: '#f9f9f9' }, 300, function() {
|
67 |
+
row.removeClass( 'alert-highlight' );
|
68 |
+
}
|
69 |
+
);
|
70 |
+
} else {
|
71 |
+
row.animate(
|
72 |
+
{ backgroundColor: '' }, 300, function() {
|
73 |
+
row.removeClass( 'alert-highlight' );
|
74 |
+
}
|
75 |
+
);
|
76 |
+
}
|
77 |
+
actionLink.remove();
|
78 |
+
}
|
79 |
+
}
|
80 |
+
);
|
81 |
Â
}
|
82 |
+
);
|
83 |
+
}
|
84 |
+
); // End document.ready().
|
Â
|
|
Â
|
|
85 |
Â
};
|
86 |
Â
|
87 |
Â
return self;
|
classes/class-admin.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
use DateTime;
|
@@ -8,6 +9,7 @@ use \WP_CLI;
|
|
8 |
Â
use \WP_Roles;
|
9 |
Â
|
10 |
Â
class Admin {
|
Â
|
|
11 |
Â
/**
|
12 |
Â
* Hold Plugin class
|
13 |
Â
*
|
@@ -125,7 +127,7 @@ class Admin {
|
|
125 |
Â
|
126 |
Â
// Ensure function used in various methods is pre-loaded.
|
127 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
128 |
-
require_once
|
129 |
Â
}
|
130 |
Â
|
131 |
Â
// User and role caps.
|
@@ -152,24 +154,49 @@ class Admin {
|
|
152 |
Â
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
153 |
Â
|
154 |
Â
// Plugin action links.
|
155 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
156 |
Â
|
157 |
Â
// Load admin scripts and styles.
|
158 |
-
add_action(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
159 |
Â
add_action( 'admin_enqueue_scripts', array( $this, 'admin_menu_css' ) );
|
160 |
Â
|
161 |
Â
// Reset Streams database.
|
162 |
-
add_action(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
163 |
Â
|
164 |
Â
// Uninstall Streams and Deactivate plugin.
|
165 |
Â
$uninstall = $this->plugin->db->driver->purge_storage( $this->plugin );
|
166 |
Â
|
167 |
Â
// Auto purge setup.
|
168 |
Â
add_action( 'wp_loaded', array( $this, 'purge_schedule_setup' ) );
|
169 |
-
add_action(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
170 |
Â
|
171 |
Â
// Ajax users list.
|
172 |
-
add_action(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
173 |
Â
}
|
174 |
Â
|
175 |
Â
/**
|
@@ -331,7 +358,12 @@ class Admin {
|
|
331 |
Â
do_action( 'wp_stream_admin_menu_screens' );
|
332 |
Â
|
333 |
Â
// Register the list table early, so it associates the column headers with 'Screen settings'.
|
334 |
-
add_action(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
335 |
Â
}
|
336 |
Â
}
|
337 |
Â
|
@@ -358,7 +390,8 @@ class Admin {
|
|
358 |
Â
wp_register_script( 'wp-stream-timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, 'en' ), array( 'wp-stream-timeago' ), '1' );
|
359 |
Â
}
|
360 |
Â
|
361 |
-
|
Â
|
|
362 |
Â
|
363 |
Â
$script_screens = array( 'plugins.php' );
|
364 |
Â
|
@@ -369,9 +402,24 @@ class Admin {
|
|
369 |
Â
wp_enqueue_script( 'wp-stream-timeago' );
|
370 |
Â
wp_enqueue_script( 'wp-stream-timeago-locale' );
|
371 |
Â
|
372 |
-
wp_enqueue_script(
|
373 |
-
|
374 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
375 |
Â
|
376 |
Â
wp_localize_script(
|
377 |
Â
'wp-stream-admin',
|
@@ -392,10 +440,14 @@ class Admin {
|
|
392 |
Â
'wp_stream_live_updates',
|
393 |
Â
array(
|
394 |
Â
'current_screen' => $hook,
|
395 |
-
'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', //
|
396 |
-
|
397 |
-
'
|
398 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
399 |
Â
)
|
400 |
Â
);
|
401 |
Â
}
|
@@ -414,13 +466,14 @@ class Admin {
|
|
414 |
Â
*/
|
415 |
Â
$bulk_actions_threshold = apply_filters( 'wp_stream_bulk_actions_threshold', 100 );
|
416 |
Â
|
417 |
-
wp_enqueue_script( 'wp-stream-global', $this->plugin->locations['url'] . 'ui/js/global.js', array( 'jquery' ), $this->plugin->get_version() );
|
418 |
Â
wp_localize_script(
|
419 |
Â
'wp-stream-global',
|
420 |
Â
'wp_stream_global',
|
421 |
Â
array(
|
422 |
-
'bulk_actions'
|
423 |
-
'i18n'
|
Â
|
|
424 |
Â
'confirm_action' => sprintf( esc_html__( 'Are you sure you want to perform bulk actions on over %s items? This process could take a while to complete.', 'stream' ), number_format( absint( $bulk_actions_threshold ) ) ),
|
425 |
Â
),
|
426 |
Â
'threshold' => absint( $bulk_actions_threshold ),
|
@@ -463,8 +516,8 @@ class Admin {
|
|
463 |
Â
if ( $this->is_stream_screen() ) {
|
464 |
Â
$stream_classes[] = $this->admin_body_class;
|
465 |
Â
|
466 |
-
if ( isset( $_GET['page'] ) ) {
|
467 |
-
$stream_classes[] = sanitize_key( $_GET['page'] ); // input var okay
|
468 |
Â
}
|
469 |
Â
}
|
470 |
Â
|
@@ -487,14 +540,15 @@ class Admin {
|
|
487 |
Â
* @action admin_enqueue_scripts
|
488 |
Â
*/
|
489 |
Â
public function admin_menu_css() {
|
490 |
-
|
Â
|
|
491 |
Â
wp_register_style( 'wp-stream-icons', $this->plugin->locations['url'] . 'ui/stream-icons/style.css', array(), $this->plugin->get_version() );
|
492 |
Â
|
493 |
Â
// Make sure we're working off a clean version
|
494 |
Â
if ( ! file_exists( ABSPATH . WPINC . '/version.php' ) ) {
|
495 |
Â
return;
|
496 |
Â
}
|
497 |
-
include
|
498 |
Â
|
499 |
Â
if ( ! isset( $wp_version ) ) {
|
500 |
Â
return;
|
@@ -555,8 +609,13 @@ class Admin {
|
|
555 |
Â
\wp_add_inline_style( 'wp-admin', $css );
|
556 |
Â
}
|
557 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
558 |
Â
public function wp_ajax_reset() {
|
559 |
-
check_ajax_referer( '
|
560 |
Â
|
561 |
Â
if ( ! current_user_can( $this->settings_cap ) ) {
|
562 |
Â
wp_die(
|
@@ -631,8 +690,9 @@ class Admin {
|
|
631 |
Â
return;
|
632 |
Â
}
|
633 |
Â
|
634 |
-
$days
|
635 |
-
$
|
Â
|
|
636 |
Â
|
637 |
Â
$date->sub( DateInterval::createFromDateString( "$days days" ) );
|
638 |
Â
|
@@ -653,7 +713,7 @@ class Admin {
|
|
653 |
Â
}
|
654 |
Â
|
655 |
Â
/**
|
656 |
-
* @param array
|
657 |
Â
* @param string $file
|
658 |
Â
*
|
659 |
Â
* @filter plugin_action_links
|
@@ -671,9 +731,17 @@ class Admin {
|
|
671 |
Â
}
|
672 |
Â
|
673 |
Â
if ( is_network_admin() ) {
|
674 |
-
$admin_page_url = add_query_arg(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
675 |
Â
} else {
|
676 |
-
$admin_page_url = add_query_arg(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
677 |
Â
}
|
678 |
Â
|
679 |
Â
$links[] = sprintf( '<a href="%s">%s</a>', esc_url( $admin_page_url ), esc_html__( 'Settings', 'default' ) );
|
@@ -701,7 +769,7 @@ class Admin {
|
|
701 |
Â
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
702 |
Â
<?php $this->list_table->display(); ?>
|
703 |
Â
</div>
|
704 |
-
|
705 |
Â
}
|
706 |
Â
|
707 |
Â
/**
|
@@ -715,8 +783,8 @@ class Admin {
|
|
715 |
Â
|
716 |
Â
$sections = $this->plugin->settings->get_fields();
|
717 |
Â
$active_tab = wp_stream_filter_input( INPUT_GET, 'tab' );
|
718 |
-
|
719 |
-
wp_enqueue_script( 'wp-stream-settings', $this->plugin->locations['url'] . 'ui/js/settings.js', array( 'jquery' ), $this->plugin->get_version(), true );
|
720 |
Â
?>
|
721 |
Â
<div class="wrap">
|
722 |
Â
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
@@ -729,11 +797,11 @@ class Admin {
|
|
729 |
Â
|
730 |
Â
<?php if ( count( $sections ) > 1 ) : ?>
|
731 |
Â
<h2 class="nav-tab-wrapper">
|
732 |
-
<?php $i = 0 ?>
|
733 |
Â
<?php foreach ( $sections as $section => $data ) : ?>
|
734 |
-
<?php $i
|
735 |
Â
<?php $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section ); ?>
|
736 |
-
<a href="<?php echo esc_url( add_query_arg( 'tab', $section ) ); ?>" class="nav-tab<?php
|
737 |
Â
<?php echo esc_html( $data['title'] ); ?>
|
738 |
Â
</a>
|
739 |
Â
<?php endforeach; ?>
|
@@ -743,32 +811,36 @@ class Admin {
|
|
743 |
Â
<div class="nav-tab-content" id="tab-content-settings">
|
744 |
Â
<form method="post" action="<?php echo esc_attr( $form_action ); ?>" enctype="multipart/form-data">
|
745 |
Â
<div class="settings-sections">
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
Â
|
751 |
-
|
752 |
Â
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
Â
</div>
|
760 |
Â
<?php submit_button(); ?>
|
761 |
Â
</form>
|
762 |
Â
</div>
|
763 |
Â
</div>
|
764 |
-
|
765 |
Â
}
|
766 |
Â
|
767 |
Â
/**
|
768 |
Â
* Instantiate the list table
|
769 |
Â
*/
|
770 |
Â
public function register_list_table() {
|
771 |
-
$this->list_table = new List_Table(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
772 |
Â
}
|
773 |
Â
|
774 |
Â
/**
|
@@ -868,7 +940,11 @@ class Admin {
|
|
868 |
Â
switch ( wp_stream_filter_input( INPUT_GET, 'filter' ) ) {
|
869 |
Â
case 'user_id':
|
870 |
Â
$users = array_merge(
|
871 |
-
array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
872 |
Â
get_users()
|
873 |
Â
);
|
874 |
Â
|
@@ -877,7 +953,7 @@ class Admin {
|
|
877 |
Â
// `search` arg for get_users() is not enough
|
878 |
Â
$users = array_filter(
|
879 |
Â
$users,
|
880 |
-
function( $user ) use ( $search ) {
|
881 |
Â
return false !== mb_strpos( mb_strtolower( $user->display_name ), mb_strtolower( $search ) );
|
882 |
Â
}
|
883 |
Â
);
|
@@ -907,11 +983,11 @@ class Admin {
|
|
907 |
Â
$author = new Author( $args->ID );
|
908 |
Â
|
909 |
Â
$authors_records[ $user_id ] = array(
|
910 |
-
'text'
|
911 |
-
'id'
|
912 |
-
'label'
|
913 |
-
'icon'
|
914 |
-
'title'
|
915 |
Â
);
|
916 |
Â
}
|
917 |
Â
|
@@ -921,49 +997,52 @@ class Admin {
|
|
921 |
Â
/**
|
922 |
Â
* Get user meta in a way that is also safe for VIP
|
923 |
Â
*
|
924 |
-
* @param int
|
925 |
Â
* @param string $meta_key
|
926 |
-
* @param bool
|
927 |
Â
*
|
928 |
Â
* @return mixed
|
929 |
Â
*/
|
930 |
-
function get_user_meta( $user_id, $meta_key, $single = true ) {
|
931 |
Â
if ( wp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) {
|
932 |
Â
return get_user_attribute( $user_id, $meta_key );
|
933 |
Â
}
|
Â
|
|
934 |
Â
return get_user_meta( $user_id, $meta_key, $single );
|
935 |
Â
}
|
936 |
Â
|
937 |
Â
/**
|
938 |
Â
* Update user meta in a way that is also safe for VIP
|
939 |
Â
*
|
940 |
-
* @param int
|
941 |
Â
* @param string $meta_key
|
942 |
Â
* @param mixed $meta_value
|
943 |
-
* @param mixed
|
944 |
Â
*
|
945 |
Â
* @return int|bool
|
946 |
Â
*/
|
947 |
-
function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
|
948 |
Â
if ( wp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) {
|
949 |
Â
return update_user_attribute( $user_id, $meta_key, $meta_value );
|
950 |
Â
}
|
Â
|
|
951 |
Â
return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
|
952 |
Â
}
|
953 |
Â
|
954 |
Â
/**
|
955 |
Â
* Delete user meta in a way that is also safe for VIP
|
956 |
Â
*
|
957 |
-
* @param int
|
958 |
Â
* @param string $meta_key
|
959 |
-
* @param mixed
|
960 |
Â
*
|
961 |
Â
* @return bool
|
962 |
Â
*/
|
963 |
-
function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
|
964 |
Â
if ( wp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) {
|
965 |
Â
return delete_user_attribute( $user_id, $meta_key, $meta_value );
|
966 |
Â
}
|
Â
|
|
967 |
Â
return delete_user_meta( $user_id, $meta_key, $meta_value );
|
968 |
Â
}
|
969 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
use DateTime;
|
9 |
Â
use \WP_Roles;
|
10 |
Â
|
11 |
Â
class Admin {
|
12 |
+
|
13 |
Â
/**
|
14 |
Â
* Hold Plugin class
|
15 |
Â
*
|
127 |
Â
|
128 |
Â
// Ensure function used in various methods is pre-loaded.
|
129 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
130 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
131 |
Â
}
|
132 |
Â
|
133 |
Â
// User and role caps.
|
154 |
Â
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
155 |
Â
|
156 |
Â
// Plugin action links.
|
157 |
+
add_filter(
|
158 |
+
'plugin_action_links', array(
|
159 |
+
$this,
|
160 |
+
'plugin_action_links',
|
161 |
+
), 10, 2
|
162 |
+
);
|
163 |
Â
|
164 |
Â
// Load admin scripts and styles.
|
165 |
+
add_action(
|
166 |
+
'admin_enqueue_scripts', array(
|
167 |
+
$this,
|
168 |
+
'admin_enqueue_scripts',
|
169 |
+
)
|
170 |
+
);
|
171 |
Â
add_action( 'admin_enqueue_scripts', array( $this, 'admin_menu_css' ) );
|
172 |
Â
|
173 |
Â
// Reset Streams database.
|
174 |
+
add_action(
|
175 |
+
'wp_ajax_wp_stream_reset', array(
|
176 |
+
$this,
|
177 |
+
'wp_ajax_reset',
|
178 |
+
)
|
179 |
+
);
|
180 |
Â
|
181 |
Â
// Uninstall Streams and Deactivate plugin.
|
182 |
Â
$uninstall = $this->plugin->db->driver->purge_storage( $this->plugin );
|
183 |
Â
|
184 |
Â
// Auto purge setup.
|
185 |
Â
add_action( 'wp_loaded', array( $this, 'purge_schedule_setup' ) );
|
186 |
+
add_action(
|
187 |
+
'wp_stream_auto_purge', array(
|
188 |
+
$this,
|
189 |
+
'purge_scheduled_action',
|
190 |
+
)
|
191 |
+
);
|
192 |
Â
|
193 |
Â
// Ajax users list.
|
194 |
+
add_action(
|
195 |
+
'wp_ajax_wp_stream_filters', array(
|
196 |
+
$this,
|
197 |
+
'ajax_filters',
|
198 |
+
)
|
199 |
+
);
|
200 |
Â
}
|
201 |
Â
|
202 |
Â
/**
|
358 |
Â
do_action( 'wp_stream_admin_menu_screens' );
|
359 |
Â
|
360 |
Â
// Register the list table early, so it associates the column headers with 'Screen settings'.
|
361 |
+
add_action(
|
362 |
+
'load-' . $this->screen_id['main'], array(
|
363 |
+
$this,
|
364 |
+
'register_list_table',
|
365 |
+
)
|
366 |
+
);
|
367 |
Â
}
|
368 |
Â
}
|
369 |
Â
|
390 |
Â
wp_register_script( 'wp-stream-timeago-locale', $this->plugin->locations['url'] . sprintf( $file_tmpl, 'en' ), array( 'wp-stream-timeago' ), '1' );
|
391 |
Â
}
|
392 |
Â
|
393 |
+
$min = wp_stream_min_suffix();
|
394 |
+
wp_enqueue_style( 'wp-stream-admin', $this->plugin->locations['url'] . 'ui/css/admin.' . $min . 'css', array(), $this->plugin->get_version() );
|
395 |
Â
|
396 |
Â
$script_screens = array( 'plugins.php' );
|
397 |
Â
|
402 |
Â
wp_enqueue_script( 'wp-stream-timeago' );
|
403 |
Â
wp_enqueue_script( 'wp-stream-timeago-locale' );
|
404 |
Â
|
405 |
+
wp_enqueue_script(
|
406 |
+
'wp-stream-admin', $this->plugin->locations['url'] . 'ui/js/admin.' . $min . 'js', array(
|
407 |
+
'jquery',
|
408 |
+
'wp-stream-select2',
|
409 |
+
), $this->plugin->get_version()
|
410 |
+
);
|
411 |
+
wp_enqueue_script(
|
412 |
+
'wp-stream-admin-exclude', $this->plugin->locations['url'] . 'ui/js/exclude.' . $min . 'js', array(
|
413 |
+
'jquery',
|
414 |
+
'wp-stream-select2',
|
415 |
+
), $this->plugin->get_version()
|
416 |
+
);
|
417 |
+
wp_enqueue_script(
|
418 |
+
'wp-stream-live-updates', $this->plugin->locations['url'] . 'ui/js/live-updates.' . $min . 'js', array(
|
419 |
+
'jquery',
|
420 |
+
'heartbeat',
|
421 |
+
), $this->plugin->get_version()
|
422 |
+
);
|
423 |
Â
|
424 |
Â
wp_localize_script(
|
425 |
Â
'wp-stream-admin',
|
440 |
Â
'wp_stream_live_updates',
|
441 |
Â
array(
|
442 |
Â
'current_screen' => $hook,
|
443 |
+
'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // WPCS: CSRF ok.
|
444 |
+
// input var okay, CSRF okay
|
445 |
+
'current_order' => isset( $_GET['order'] ) ? esc_js( $_GET['order'] ) : 'desc', // WPCS: CSRF ok.
|
446 |
+
// input var okay, CSRF okay
|
447 |
+
'current_query' => wp_stream_json_encode( $_GET ), // WPCS: CSRF ok.
|
448 |
+
// input var okay, CSRF okay
|
449 |
+
'current_query_count' => count( $_GET ), // WPCS: CSRF ok.
|
450 |
+
// input var okay, CSRF okay
|
451 |
Â
)
|
452 |
Â
);
|
453 |
Â
}
|
466 |
Â
*/
|
467 |
Â
$bulk_actions_threshold = apply_filters( 'wp_stream_bulk_actions_threshold', 100 );
|
468 |
Â
|
469 |
+
wp_enqueue_script( 'wp-stream-global', $this->plugin->locations['url'] . 'ui/js/global.' . $min . 'js', array( 'jquery' ), $this->plugin->get_version() );
|
470 |
Â
wp_localize_script(
|
471 |
Â
'wp-stream-global',
|
472 |
Â
'wp_stream_global',
|
473 |
Â
array(
|
474 |
+
'bulk_actions' => array(
|
475 |
+
'i18n' => array(
|
476 |
+
// translators: Placeholder refers to a number of items (e.g. "1,742")
|
477 |
Â
'confirm_action' => sprintf( esc_html__( 'Are you sure you want to perform bulk actions on over %s items? This process could take a while to complete.', 'stream' ), number_format( absint( $bulk_actions_threshold ) ) ),
|
478 |
Â
),
|
479 |
Â
'threshold' => absint( $bulk_actions_threshold ),
|
516 |
Â
if ( $this->is_stream_screen() ) {
|
517 |
Â
$stream_classes[] = $this->admin_body_class;
|
518 |
Â
|
519 |
+
if ( isset( $_GET['page'] ) ) { // CSRF okay
|
520 |
+
$stream_classes[] = sanitize_key( $_GET['page'] ); // input var okay, CSRF okay
|
521 |
Â
}
|
522 |
Â
}
|
523 |
Â
|
540 |
Â
* @action admin_enqueue_scripts
|
541 |
Â
*/
|
542 |
Â
public function admin_menu_css() {
|
543 |
+
$min = wp_stream_min_suffix();
|
544 |
+
wp_register_style( 'wp-stream-datepicker', $this->plugin->locations['url'] . 'ui/css/datepicker.' . $min . 'css', array(), $this->plugin->get_version() );
|
545 |
Â
wp_register_style( 'wp-stream-icons', $this->plugin->locations['url'] . 'ui/stream-icons/style.css', array(), $this->plugin->get_version() );
|
546 |
Â
|
547 |
Â
// Make sure we're working off a clean version
|
548 |
Â
if ( ! file_exists( ABSPATH . WPINC . '/version.php' ) ) {
|
549 |
Â
return;
|
550 |
Â
}
|
551 |
+
include ABSPATH . WPINC . '/version.php';
|
552 |
Â
|
553 |
Â
if ( ! isset( $wp_version ) ) {
|
554 |
Â
return;
|
609 |
Â
\wp_add_inline_style( 'wp-admin', $css );
|
610 |
Â
}
|
611 |
Â
|
612 |
+
/**
|
613 |
+
* Handle the reset AJAX request to reset logs.
|
614 |
+
*
|
615 |
+
* @return bool
|
616 |
+
*/
|
617 |
Â
public function wp_ajax_reset() {
|
618 |
+
check_ajax_referer( 'stream_nonce_reset', 'wp_stream_nonce_reset' );
|
619 |
Â
|
620 |
Â
if ( ! current_user_can( $this->settings_cap ) ) {
|
621 |
Â
wp_die(
|
690 |
Â
return;
|
691 |
Â
}
|
692 |
Â
|
693 |
+
$days = $options['general_records_ttl'];
|
694 |
+
$timezone = new DateTimeZone( 'UTC' );
|
695 |
+
$date = new DateTime( 'now', $timezone );
|
696 |
Â
|
697 |
Â
$date->sub( DateInterval::createFromDateString( "$days days" ) );
|
698 |
Â
|
713 |
Â
}
|
714 |
Â
|
715 |
Â
/**
|
716 |
+
* @param array $links
|
717 |
Â
* @param string $file
|
718 |
Â
*
|
719 |
Â
* @filter plugin_action_links
|
731 |
Â
}
|
732 |
Â
|
733 |
Â
if ( is_network_admin() ) {
|
734 |
+
$admin_page_url = add_query_arg(
|
735 |
+
array(
|
736 |
+
'page' => $this->network->network_settings_page_slug,
|
737 |
+
), network_admin_url( $this->admin_parent_page )
|
738 |
+
);
|
739 |
Â
} else {
|
740 |
+
$admin_page_url = add_query_arg(
|
741 |
+
array(
|
742 |
+
'page' => $this->settings_page_slug,
|
743 |
+
), admin_url( $this->admin_parent_page )
|
744 |
+
);
|
745 |
Â
}
|
746 |
Â
|
747 |
Â
$links[] = sprintf( '<a href="%s">%s</a>', esc_url( $admin_page_url ), esc_html__( 'Settings', 'default' ) );
|
769 |
Â
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
770 |
Â
<?php $this->list_table->display(); ?>
|
771 |
Â
</div>
|
772 |
+
<?php
|
773 |
Â
}
|
774 |
Â
|
775 |
Â
/**
|
783 |
Â
|
784 |
Â
$sections = $this->plugin->settings->get_fields();
|
785 |
Â
$active_tab = wp_stream_filter_input( INPUT_GET, 'tab' );
|
786 |
+
$min = wp_stream_min_suffix();
|
787 |
+
wp_enqueue_script( 'wp-stream-settings', $this->plugin->locations['url'] . 'ui/js/settings.' . $min . 'js', array( 'jquery' ), $this->plugin->get_version(), true );
|
788 |
Â
?>
|
789 |
Â
<div class="wrap">
|
790 |
Â
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
797 |
Â
|
798 |
Â
<?php if ( count( $sections ) > 1 ) : ?>
|
799 |
Â
<h2 class="nav-tab-wrapper">
|
800 |
+
<?php $i = 0; ?>
|
801 |
Â
<?php foreach ( $sections as $section => $data ) : ?>
|
802 |
+
<?php $i++; ?>
|
803 |
Â
<?php $is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section ); ?>
|
804 |
+
<a href="<?php echo esc_url( add_query_arg( 'tab', $section ) ); ?>" class="nav-tab <?php echo $is_active ? esc_attr( ' nav-tab-active' ) : ''; ?>">
|
805 |
Â
<?php echo esc_html( $data['title'] ); ?>
|
806 |
Â
</a>
|
807 |
Â
<?php endforeach; ?>
|
811 |
Â
<div class="nav-tab-content" id="tab-content-settings">
|
812 |
Â
<form method="post" action="<?php echo esc_attr( $form_action ); ?>" enctype="multipart/form-data">
|
813 |
Â
<div class="settings-sections">
|
814 |
+
<?php
|
815 |
+
$i = 0;
|
816 |
+
foreach ( $sections as $section => $data ) {
|
817 |
+
$i++;
|
818 |
Â
|
819 |
+
$is_active = ( ( 1 === $i && ! $active_tab ) || $active_tab === $section );
|
820 |
Â
|
821 |
+
if ( $is_active ) {
|
822 |
+
settings_fields( $option_key );
|
823 |
+
do_settings_sections( $option_key );
|
824 |
+
}
|
825 |
+
}
|
826 |
+
?>
|
827 |
Â
</div>
|
828 |
Â
<?php submit_button(); ?>
|
829 |
Â
</form>
|
830 |
Â
</div>
|
831 |
Â
</div>
|
832 |
+
<?php
|
833 |
Â
}
|
834 |
Â
|
835 |
Â
/**
|
836 |
Â
* Instantiate the list table
|
837 |
Â
*/
|
838 |
Â
public function register_list_table() {
|
839 |
+
$this->list_table = new List_Table(
|
840 |
+
$this->plugin, array(
|
841 |
+
'screen' => $this->screen_id['main'],
|
842 |
+
)
|
843 |
+
);
|
844 |
Â
}
|
845 |
Â
|
846 |
Â
/**
|
940 |
Â
switch ( wp_stream_filter_input( INPUT_GET, 'filter' ) ) {
|
941 |
Â
case 'user_id':
|
942 |
Â
$users = array_merge(
|
943 |
+
array(
|
944 |
+
0 => (object) array(
|
945 |
+
'display_name' => 'WP-CLI',
|
946 |
+
),
|
947 |
+
),
|
948 |
Â
get_users()
|
949 |
Â
);
|
950 |
Â
|
953 |
Â
// `search` arg for get_users() is not enough
|
954 |
Â
$users = array_filter(
|
955 |
Â
$users,
|
956 |
+
function ( $user ) use ( $search ) {
|
957 |
Â
return false !== mb_strpos( mb_strtolower( $user->display_name ), mb_strtolower( $search ) );
|
958 |
Â
}
|
959 |
Â
);
|
983 |
Â
$author = new Author( $args->ID );
|
984 |
Â
|
985 |
Â
$authors_records[ $user_id ] = array(
|
986 |
+
'text' => $author->get_display_name(),
|
987 |
+
'id' => $author->id,
|
988 |
+
'label' => $author->get_display_name(),
|
989 |
+
'icon' => $author->get_avatar_src( 32 ),
|
990 |
+
'title' => '',
|
991 |
Â
);
|
992 |
Â
}
|
993 |
Â
|
997 |
Â
/**
|
998 |
Â
* Get user meta in a way that is also safe for VIP
|
999 |
Â
*
|
1000 |
+
* @param int $user_id
|
1001 |
Â
* @param string $meta_key
|
1002 |
+
* @param bool $single (optional)
|
1003 |
Â
*
|
1004 |
Â
* @return mixed
|
1005 |
Â
*/
|
1006 |
+
public function get_user_meta( $user_id, $meta_key, $single = true ) {
|
1007 |
Â
if ( wp_stream_is_vip() && function_exists( 'get_user_attribute' ) ) {
|
1008 |
Â
return get_user_attribute( $user_id, $meta_key );
|
1009 |
Â
}
|
1010 |
+
|
1011 |
Â
return get_user_meta( $user_id, $meta_key, $single );
|
1012 |
Â
}
|
1013 |
Â
|
1014 |
Â
/**
|
1015 |
Â
* Update user meta in a way that is also safe for VIP
|
1016 |
Â
*
|
1017 |
+
* @param int $user_id
|
1018 |
Â
* @param string $meta_key
|
1019 |
Â
* @param mixed $meta_value
|
1020 |
+
* @param mixed $prev_value (optional)
|
1021 |
Â
*
|
1022 |
Â
* @return int|bool
|
1023 |
Â
*/
|
1024 |
+
public function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) {
|
1025 |
Â
if ( wp_stream_is_vip() && function_exists( 'update_user_attribute' ) ) {
|
1026 |
Â
return update_user_attribute( $user_id, $meta_key, $meta_value );
|
1027 |
Â
}
|
1028 |
+
|
1029 |
Â
return update_user_meta( $user_id, $meta_key, $meta_value, $prev_value );
|
1030 |
Â
}
|
1031 |
Â
|
1032 |
Â
/**
|
1033 |
Â
* Delete user meta in a way that is also safe for VIP
|
1034 |
Â
*
|
1035 |
+
* @param int $user_id
|
1036 |
Â
* @param string $meta_key
|
1037 |
+
* @param mixed $meta_value (optional)
|
1038 |
Â
*
|
1039 |
Â
* @return bool
|
1040 |
Â
*/
|
1041 |
+
public function delete_user_meta( $user_id, $meta_key, $meta_value = '' ) {
|
1042 |
Â
if ( wp_stream_is_vip() && function_exists( 'delete_user_attribute' ) ) {
|
1043 |
Â
return delete_user_attribute( $user_id, $meta_key, $meta_value );
|
1044 |
Â
}
|
1045 |
+
|
1046 |
Â
return delete_user_meta( $user_id, $meta_key, $meta_value );
|
1047 |
Â
}
|
1048 |
Â
}
|
classes/class-alert-type.php
CHANGED
@@ -34,14 +34,13 @@ abstract class Alert_Type {
|
|
34 |
Â
* Class constructor.
|
35 |
Â
*
|
36 |
Â
* @param Plugin $plugin Plugin object.
|
37 |
-
* @return void
|
38 |
Â
*/
|
39 |
Â
public function __construct( $plugin ) {
|
40 |
Â
$this->plugin = $plugin;
|
41 |
Â
}
|
42 |
Â
|
43 |
Â
/**
|
44 |
-
*
|
45 |
Â
*
|
46 |
Â
* @param int $record_id Record ID.
|
47 |
Â
* @param array $recordarr Record details.
|
@@ -55,7 +54,7 @@ abstract class Alert_Type {
|
|
55 |
Â
* @param Alert $alert Alert currently being worked on.
|
56 |
Â
*/
|
57 |
Â
public function display_fields( $alert ) {
|
58 |
-
|
59 |
Â
}
|
60 |
Â
|
61 |
Â
/**
|
@@ -64,7 +63,7 @@ abstract class Alert_Type {
|
|
64 |
Â
* @param Alert $alert Alert currently being worked on.
|
65 |
Â
*/
|
66 |
Â
public function save_fields( $alert ) {
|
67 |
-
|
68 |
Â
}
|
69 |
Â
|
70 |
Â
/**
|
@@ -73,6 +72,7 @@ abstract class Alert_Type {
|
|
73 |
Â
* @return bool
|
74 |
Â
*/
|
75 |
Â
public function is_dependency_satisfied() {
|
Â
|
|
76 |
Â
return true;
|
77 |
Â
}
|
78 |
Â
}
|
34 |
Â
* Class constructor.
|
35 |
Â
*
|
36 |
Â
* @param Plugin $plugin Plugin object.
|
Â
|
|
37 |
Â
*/
|
38 |
Â
public function __construct( $plugin ) {
|
39 |
Â
$this->plugin = $plugin;
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
+
* Alert recipients about the new record
|
44 |
Â
*
|
45 |
Â
* @param int $record_id Record ID.
|
46 |
Â
* @param array $recordarr Record details.
|
54 |
Â
* @param Alert $alert Alert currently being worked on.
|
55 |
Â
*/
|
56 |
Â
public function display_fields( $alert ) {
|
57 |
+
// Implementation optional, but recommended
|
58 |
Â
}
|
59 |
Â
|
60 |
Â
/**
|
63 |
Â
* @param Alert $alert Alert currently being worked on.
|
64 |
Â
*/
|
65 |
Â
public function save_fields( $alert ) {
|
66 |
+
// Implementation optional, but recommended
|
67 |
Â
}
|
68 |
Â
|
69 |
Â
/**
|
72 |
Â
* @return bool
|
73 |
Â
*/
|
74 |
Â
public function is_dependency_satisfied() {
|
75 |
+
// Implementation optional, but recommended
|
76 |
Â
return true;
|
77 |
Â
}
|
78 |
Â
}
|
classes/class-alert.php
CHANGED
@@ -71,12 +71,12 @@ class Alert {
|
|
71 |
Â
* @return void
|
72 |
Â
*/
|
73 |
Â
public function __construct( $item, $plugin ) {
|
74 |
-
$this->plugin
|
75 |
Â
|
76 |
-
$this->ID
|
77 |
-
$this->status
|
78 |
-
$this->date
|
79 |
-
$this->author
|
80 |
Â
|
81 |
Â
$this->alert_type = isset( $item->alert_type ) ? $item->alert_type : null;
|
82 |
Â
$this->alert_meta = isset( $item->alert_meta ) ? $item->alert_meta : array();
|
@@ -109,8 +109,8 @@ class Alert {
|
|
109 |
Â
}
|
110 |
Â
|
111 |
Â
$meta = array(
|
112 |
-
'alert_type'
|
113 |
-
'alert_meta'
|
114 |
Â
);
|
115 |
Â
|
116 |
Â
foreach ( $meta as $key => $value ) {
|
@@ -129,11 +129,11 @@ class Alert {
|
|
129 |
Â
public function process_settings_form( $data ) {
|
130 |
Â
|
131 |
Â
$args = array(
|
132 |
-
'post_date'
|
133 |
-
'post_status'
|
134 |
-
'post_title'
|
135 |
-
'post_author'
|
136 |
-
'post_type'
|
137 |
Â
);
|
138 |
Â
|
139 |
Â
foreach ( $args as $key => $value ) {
|
@@ -141,8 +141,8 @@ class Alert {
|
|
141 |
Â
}
|
142 |
Â
|
143 |
Â
$meta_input = array(
|
144 |
-
'alert_type'
|
145 |
-
'alert_meta'
|
146 |
Â
);
|
147 |
Â
|
148 |
Â
foreach ( $meta_input as $key => $value ) {
|
@@ -156,7 +156,7 @@ class Alert {
|
|
156 |
Â
* Query record meta
|
157 |
Â
*
|
158 |
Â
* @param string $meta_key Meta key to retrieve (optional). Otherwise will
|
159 |
-
*
|
160 |
Â
* @param bool $single Whether to only retrieve the first value (optional).
|
161 |
Â
*
|
162 |
Â
* @return mixed Single value if $single is true, array if false.
|
@@ -183,7 +183,7 @@ class Alert {
|
|
183 |
Â
* @todo enhance human readibility
|
184 |
Â
* @return string The title of the alert
|
185 |
Â
*/
|
186 |
-
function get_title() {
|
187 |
Â
|
188 |
Â
$alert_type = $this->get_alert_type_obj()->name;
|
189 |
Â
|
@@ -193,7 +193,7 @@ class Alert {
|
|
193 |
Â
}
|
194 |
Â
$title = '';
|
195 |
Â
foreach ( $this->plugin->alerts->alert_triggers as $trigger_type => $trigger_obj ) {
|
196 |
-
$value
|
197 |
Â
$title .= $value . ' > ';
|
198 |
Â
}
|
199 |
Â
$title = rtrim( $title, ' > ' );
|
@@ -267,11 +267,13 @@ class Alert {
|
|
267 |
Â
if ( empty( $record->ID ) ) {
|
268 |
Â
return false;
|
269 |
Â
}
|
270 |
-
$record
|
271 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
272 |
Â
|
273 |
Â
if ( empty( $alerts_triggered ) || ! is_array( $alerts_triggered ) ) {
|
274 |
-
$alerts_triggered = array(
|
Â
|
|
Â
|
|
275 |
Â
} elseif ( ! array_key_exists( $alert_slug, $alerts_triggered ) || ! is_array( $alerts_triggered[ $alert_slug ] ) ) {
|
276 |
Â
$alerts_triggered[ $alert_slug ] = $alert_meta;
|
277 |
Â
}
|
@@ -304,7 +306,7 @@ class Alert {
|
|
304 |
Â
if ( ! is_object( $record ) || ! is_string( $alert_slug ) || ! is_string( $setting ) ) {
|
305 |
Â
return false;
|
306 |
Â
}
|
307 |
-
$record
|
308 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
309 |
Â
|
310 |
Â
// Ensure we have a meta array and that this record has triggered a highlight alert.
|
71 |
Â
* @return void
|
72 |
Â
*/
|
73 |
Â
public function __construct( $item, $plugin ) {
|
74 |
+
$this->plugin = $plugin;
|
75 |
Â
|
76 |
+
$this->ID = isset( $item->ID ) ? $item->ID : null;
|
77 |
+
$this->status = isset( $item->status ) ? $item->status : 'wp_stream_disabled';
|
78 |
+
$this->date = isset( $item->date ) ? $item->date : null;
|
79 |
+
$this->author = isset( $item->author ) ? $item->author : null;
|
80 |
Â
|
81 |
Â
$this->alert_type = isset( $item->alert_type ) ? $item->alert_type : null;
|
82 |
Â
$this->alert_meta = isset( $item->alert_meta ) ? $item->alert_meta : array();
|
109 |
Â
}
|
110 |
Â
|
111 |
Â
$meta = array(
|
112 |
+
'alert_type' => $this->alert_type,
|
113 |
+
'alert_meta' => $this->alert_meta,
|
114 |
Â
);
|
115 |
Â
|
116 |
Â
foreach ( $meta as $key => $value ) {
|
129 |
Â
public function process_settings_form( $data ) {
|
130 |
Â
|
131 |
Â
$args = array(
|
132 |
+
'post_date' => $this->date,
|
133 |
+
'post_status' => $this->status,
|
134 |
+
'post_title' => $this->get_title(),
|
135 |
+
'post_author' => $this->author,
|
136 |
+
'post_type' => Alerts::POST_TYPE,
|
137 |
Â
);
|
138 |
Â
|
139 |
Â
foreach ( $args as $key => $value ) {
|
141 |
Â
}
|
142 |
Â
|
143 |
Â
$meta_input = array(
|
144 |
+
'alert_type' => $this->alert_type,
|
145 |
+
'alert_meta' => $this->alert_meta,
|
146 |
Â
);
|
147 |
Â
|
148 |
Â
foreach ( $meta_input as $key => $value ) {
|
156 |
Â
* Query record meta
|
157 |
Â
*
|
158 |
Â
* @param string $meta_key Meta key to retrieve (optional). Otherwise will
|
159 |
+
* grab all meta data for the ID.
|
160 |
Â
* @param bool $single Whether to only retrieve the first value (optional).
|
161 |
Â
*
|
162 |
Â
* @return mixed Single value if $single is true, array if false.
|
183 |
Â
* @todo enhance human readibility
|
184 |
Â
* @return string The title of the alert
|
185 |
Â
*/
|
186 |
+
public function get_title() {
|
187 |
Â
|
188 |
Â
$alert_type = $this->get_alert_type_obj()->name;
|
189 |
Â
|
193 |
Â
}
|
194 |
Â
$title = '';
|
195 |
Â
foreach ( $this->plugin->alerts->alert_triggers as $trigger_type => $trigger_obj ) {
|
196 |
+
$value = $trigger_obj->get_display_value( 'list_table', $this );
|
197 |
Â
$title .= $value . ' > ';
|
198 |
Â
}
|
199 |
Â
$title = rtrim( $title, ' > ' );
|
267 |
Â
if ( empty( $record->ID ) ) {
|
268 |
Â
return false;
|
269 |
Â
}
|
270 |
+
$record = new Record( $record );
|
271 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
272 |
Â
|
273 |
Â
if ( empty( $alerts_triggered ) || ! is_array( $alerts_triggered ) ) {
|
274 |
+
$alerts_triggered = array(
|
275 |
+
$alert_slug => $alert_meta,
|
276 |
+
);
|
277 |
Â
} elseif ( ! array_key_exists( $alert_slug, $alerts_triggered ) || ! is_array( $alerts_triggered[ $alert_slug ] ) ) {
|
278 |
Â
$alerts_triggered[ $alert_slug ] = $alert_meta;
|
279 |
Â
}
|
306 |
Â
if ( ! is_object( $record ) || ! is_string( $alert_slug ) || ! is_string( $setting ) ) {
|
307 |
Â
return false;
|
308 |
Â
}
|
309 |
+
$record = new Record( $record );
|
310 |
Â
$alerts_triggered = $record->get_meta( Alerts::ALERTS_TRIGGERED_META_KEY, true );
|
311 |
Â
|
312 |
Â
// Ensure we have a meta array and that this record has triggered a highlight alert.
|
classes/class-alerts-list.php
CHANGED
@@ -55,7 +55,7 @@ class Alerts_List {
|
|
55 |
Â
* @param array $query_vars Arguments for query to populate table.
|
56 |
Â
* @return array
|
57 |
Â
*/
|
58 |
-
function parse_request( $query_vars ) {
|
59 |
Â
$screen = get_current_screen();
|
60 |
Â
if ( 'edit-wp_stream_alerts' === $screen->id && Alerts::POST_TYPE === $query_vars['post_type'] && empty( $query_vars['post_status'] ) ) {
|
61 |
Â
$query_vars['post_status'] = array( 'wp_stream_enabled', 'wp_stream_disabled' );
|
@@ -71,7 +71,7 @@ class Alerts_List {
|
|
71 |
Â
* @param array $views View links HTML.
|
72 |
Â
* @return array
|
73 |
Â
*/
|
74 |
-
function manage_views( $views ) {
|
75 |
Â
|
76 |
Â
if ( array_key_exists( 'trash', $views ) ) {
|
77 |
Â
$trash = $views['trash'];
|
@@ -90,7 +90,7 @@ class Alerts_List {
|
|
90 |
Â
* @param array $columns Column id -> title array.
|
91 |
Â
* @return array
|
92 |
Â
*/
|
93 |
-
function manage_columns( $columns ) {
|
94 |
Â
$columns = array(
|
95 |
Â
'cb' => $columns['cb'],
|
96 |
Â
'alert_trigger' => __( 'Trigger', 'stream' ),
|
@@ -109,7 +109,7 @@ class Alerts_List {
|
|
109 |
Â
* @param int $post_id The post being processed.
|
110 |
Â
* @return mixed
|
111 |
Â
*/
|
112 |
-
function column_data( $column_name, $post_id ) {
|
113 |
Â
|
114 |
Â
$alert = $this->plugin->alerts->get_alert( $post_id );
|
115 |
Â
if ( ! $alert ) {
|
@@ -117,10 +117,10 @@ class Alerts_List {
|
|
117 |
Â
}
|
118 |
Â
|
119 |
Â
switch ( $column_name ) {
|
120 |
-
case 'alert_trigger'
|
121 |
Â
$values = array();
|
122 |
Â
foreach ( $this->plugin->alerts->alert_triggers as $trigger_type => $trigger_obj ) {
|
123 |
-
$value
|
124 |
Â
$values[] = '<span class="alert_trigger_value alert_trigger_' . esc_attr( $trigger_type ) . '">' . esc_html( $value ) . '</span>';
|
125 |
Â
}
|
126 |
Â
?>
|
@@ -152,7 +152,7 @@ class Alerts_List {
|
|
152 |
Â
<?php
|
153 |
Â
echo wp_kses_post( $this->custom_column_actions( $post_id ) );
|
154 |
Â
break;
|
155 |
-
case 'alert_type'
|
156 |
Â
$alert_type = $alert->alert_type;
|
157 |
Â
if ( ! empty( $this->plugin->alerts->alert_types[ $alert_type ]->name ) ) {
|
158 |
Â
$alert_name = $this->plugin->alerts->alert_types[ $alert_type ]->name;
|
@@ -188,8 +188,28 @@ class Alerts_List {
|
|
188 |
Â
<input type="hidden" name="wp_stream_ifttt_maker_key" value="<?php echo esc_attr( $alert->alert_meta['maker_key'] ); ?>" />
|
189 |
Â
<?php
|
190 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
191 |
Â
break;
|
192 |
-
case 'alert_status'
|
193 |
Â
$post_status_object = get_post_status_object( get_post_status( $post_id ) );
|
194 |
Â
if ( ! empty( $post_status_object ) ) {
|
195 |
Â
echo esc_html( $post_status_object->label );
|
@@ -222,7 +242,7 @@ class Alerts_List {
|
|
222 |
Â
* @param array $actions List of inline edit actions available.
|
223 |
Â
* @return array
|
224 |
Â
*/
|
225 |
-
function suppress_quick_edit( $actions ) {
|
226 |
Â
if ( Alerts::POST_TYPE !== get_post_type() ) {
|
227 |
Â
return $actions;
|
228 |
Â
}
|
@@ -295,11 +315,12 @@ class Alerts_List {
|
|
295 |
Â
?>
|
296 |
Â
<legend class="inline-edit-legend"><?php esc_html_e( 'Edit', 'stream' ); ?></legend>
|
297 |
Â
<?php
|
298 |
-
foreach ( $box_type as $type ) : // @todo remove inline styles.
|
Â
|
|
299 |
Â
<fieldset class="inline-edit-col inline-edit-<?php echo esc_attr( Alerts::POST_TYPE ); ?>">
|
300 |
Â
<?php
|
301 |
Â
$function_name = 'display_' . $type . '_box';
|
302 |
-
$the_post
|
303 |
Â
call_user_func( array( $this->plugin->alerts, $function_name ), $the_post );
|
304 |
Â
?>
|
305 |
Â
</fieldset>
|
@@ -318,9 +339,10 @@ class Alerts_List {
|
|
318 |
Â
if ( 'edit-wp_stream_alerts' !== $screen->id ) {
|
319 |
Â
return;
|
320 |
Â
}
|
321 |
-
|
Â
|
|
322 |
Â
wp_enqueue_script( 'wp-stream-alerts-list-js' );
|
323 |
-
wp_register_style( 'wp-stream-alerts-list-css', $this->plugin->locations['url'] . 'ui/css/alerts-list.css' );
|
324 |
Â
wp_enqueue_style( 'wp-stream-alerts-list-css' );
|
325 |
Â
wp_enqueue_style( 'wp-stream-select2' );
|
326 |
Â
}
|
@@ -333,12 +355,12 @@ class Alerts_List {
|
|
333 |
Â
*
|
334 |
Â
* @return array
|
335 |
Â
*/
|
336 |
-
function save_alert_inline_edit( $data, $postarr ) {
|
337 |
Â
if ( did_action( 'customize_preview_init' ) || empty( $postarr['ID'] ) ) {
|
338 |
Â
return $data;
|
339 |
Â
}
|
340 |
Â
|
341 |
-
$post_id
|
342 |
Â
$post_type = wp_stream_filter_input( INPUT_POST, 'post_type' );
|
343 |
Â
if ( Alerts::POST_TYPE !== $post_type ) {
|
344 |
Â
return $data;
|
@@ -352,15 +374,15 @@ class Alerts_List {
|
|
352 |
Â
return $data;
|
353 |
Â
}
|
354 |
Â
|
355 |
-
$trigger_author
|
356 |
-
$trigger_connector_and_context
|
357 |
Â
$trigger_connector_and_context_split = explode( '-', $trigger_connector_and_context );
|
358 |
-
$trigger_connector
|
359 |
-
$trigger_context
|
360 |
Â
|
361 |
-
$trigger_action
|
362 |
-
$alert_type
|
363 |
-
$alert_status
|
364 |
Â
$data['post_status'] = $alert_status;
|
365 |
Â
|
366 |
Â
update_post_meta( $post_id, 'alert_type', $alert_type );
|
55 |
Â
* @param array $query_vars Arguments for query to populate table.
|
56 |
Â
* @return array
|
57 |
Â
*/
|
58 |
+
public function parse_request( $query_vars ) {
|
59 |
Â
$screen = get_current_screen();
|
60 |
Â
if ( 'edit-wp_stream_alerts' === $screen->id && Alerts::POST_TYPE === $query_vars['post_type'] && empty( $query_vars['post_status'] ) ) {
|
61 |
Â
$query_vars['post_status'] = array( 'wp_stream_enabled', 'wp_stream_disabled' );
|
71 |
Â
* @param array $views View links HTML.
|
72 |
Â
* @return array
|
73 |
Â
*/
|
74 |
+
public function manage_views( $views ) {
|
75 |
Â
|
76 |
Â
if ( array_key_exists( 'trash', $views ) ) {
|
77 |
Â
$trash = $views['trash'];
|
90 |
Â
* @param array $columns Column id -> title array.
|
91 |
Â
* @return array
|
92 |
Â
*/
|
93 |
+
public function manage_columns( $columns ) {
|
94 |
Â
$columns = array(
|
95 |
Â
'cb' => $columns['cb'],
|
96 |
Â
'alert_trigger' => __( 'Trigger', 'stream' ),
|
109 |
Â
* @param int $post_id The post being processed.
|
110 |
Â
* @return mixed
|
111 |
Â
*/
|
112 |
+
public function column_data( $column_name, $post_id ) {
|
113 |
Â
|
114 |
Â
$alert = $this->plugin->alerts->get_alert( $post_id );
|
115 |
Â
if ( ! $alert ) {
|
117 |
Â
}
|
118 |
Â
|
119 |
Â
switch ( $column_name ) {
|
120 |
+
case 'alert_trigger':
|
121 |
Â
$values = array();
|
122 |
Â
foreach ( $this->plugin->alerts->alert_triggers as $trigger_type => $trigger_obj ) {
|
123 |
+
$value = $trigger_obj->get_display_value( 'list_table', $alert );
|
124 |
Â
$values[] = '<span class="alert_trigger_value alert_trigger_' . esc_attr( $trigger_type ) . '">' . esc_html( $value ) . '</span>';
|
125 |
Â
}
|
126 |
Â
?>
|
152 |
Â
<?php
|
153 |
Â
echo wp_kses_post( $this->custom_column_actions( $post_id ) );
|
154 |
Â
break;
|
155 |
+
case 'alert_type':
|
156 |
Â
$alert_type = $alert->alert_type;
|
157 |
Â
if ( ! empty( $this->plugin->alerts->alert_types[ $alert_type ]->name ) ) {
|
158 |
Â
$alert_name = $this->plugin->alerts->alert_types[ $alert_type ]->name;
|
188 |
Â
<input type="hidden" name="wp_stream_ifttt_maker_key" value="<?php echo esc_attr( $alert->alert_meta['maker_key'] ); ?>" />
|
189 |
Â
<?php
|
190 |
Â
}
|
191 |
+
if ( ! empty( $alert->alert_meta['slack_webhook'] ) ) {
|
192 |
+
?>
|
193 |
+
<input type="hidden" name="wp_stream_slack_webhook" value="<?php echo esc_attr( $alert->alert_meta['slack_webhook'] ); ?>" />
|
194 |
+
<?php
|
195 |
+
}
|
196 |
+
if ( ! empty( $alert->alert_meta['slack_channel'] ) ) {
|
197 |
+
?>
|
198 |
+
<input type="hidden" name="wp_stream_slack_channel" value="<?php echo esc_attr( $alert->alert_meta['slack_channel'] ); ?>" />
|
199 |
+
<?php
|
200 |
+
}
|
201 |
+
if ( ! empty( $alert->alert_meta['slack_username'] ) ) {
|
202 |
+
?>
|
203 |
+
<input type="hidden" name="wp_stream_slack_username" value="<?php echo esc_attr( $alert->alert_meta['slack_username'] ); ?>" />
|
204 |
+
<?php
|
205 |
+
}
|
206 |
+
if ( ! empty( $alert->alert_meta['slack_icon'] ) ) {
|
207 |
+
?>
|
208 |
+
<input type="hidden" name="wp_stream_slack_icon" value="<?php echo esc_attr( $alert->alert_meta['slack_icon'] ); ?>" />
|
209 |
+
<?php
|
210 |
+
}
|
211 |
Â
break;
|
212 |
+
case 'alert_status':
|
213 |
Â
$post_status_object = get_post_status_object( get_post_status( $post_id ) );
|
214 |
Â
if ( ! empty( $post_status_object ) ) {
|
215 |
Â
echo esc_html( $post_status_object->label );
|
242 |
Â
* @param array $actions List of inline edit actions available.
|
243 |
Â
* @return array
|
244 |
Â
*/
|
245 |
+
public function suppress_quick_edit( $actions ) {
|
246 |
Â
if ( Alerts::POST_TYPE !== get_post_type() ) {
|
247 |
Â
return $actions;
|
248 |
Â
}
|
315 |
Â
?>
|
316 |
Â
<legend class="inline-edit-legend"><?php esc_html_e( 'Edit', 'stream' ); ?></legend>
|
317 |
Â
<?php
|
318 |
+
foreach ( $box_type as $type ) : // @todo remove inline styles.
|
319 |
+
?>
|
320 |
Â
<fieldset class="inline-edit-col inline-edit-<?php echo esc_attr( Alerts::POST_TYPE ); ?>">
|
321 |
Â
<?php
|
322 |
Â
$function_name = 'display_' . $type . '_box';
|
323 |
+
$the_post = get_post();
|
324 |
Â
call_user_func( array( $this->plugin->alerts, $function_name ), $the_post );
|
325 |
Â
?>
|
326 |
Â
</fieldset>
|
339 |
Â
if ( 'edit-wp_stream_alerts' !== $screen->id ) {
|
340 |
Â
return;
|
341 |
Â
}
|
342 |
+
$min = wp_stream_min_suffix();
|
343 |
+
wp_register_script( 'wp-stream-alerts-list-js', $this->plugin->locations['url'] . 'ui/js/alerts-list.' . $min . 'js', array( 'wp-stream-alerts', 'jquery' ) );
|
344 |
Â
wp_enqueue_script( 'wp-stream-alerts-list-js' );
|
345 |
+
wp_register_style( 'wp-stream-alerts-list-css', $this->plugin->locations['url'] . 'ui/css/alerts-list.' . $min . 'css' );
|
346 |
Â
wp_enqueue_style( 'wp-stream-alerts-list-css' );
|
347 |
Â
wp_enqueue_style( 'wp-stream-select2' );
|
348 |
Â
}
|
355 |
Â
*
|
356 |
Â
* @return array
|
357 |
Â
*/
|
358 |
+
public function save_alert_inline_edit( $data, $postarr ) {
|
359 |
Â
if ( did_action( 'customize_preview_init' ) || empty( $postarr['ID'] ) ) {
|
360 |
Â
return $data;
|
361 |
Â
}
|
362 |
Â
|
363 |
+
$post_id = $postarr['ID'];
|
364 |
Â
$post_type = wp_stream_filter_input( INPUT_POST, 'post_type' );
|
365 |
Â
if ( Alerts::POST_TYPE !== $post_type ) {
|
366 |
Â
return $data;
|
374 |
Â
return $data;
|
375 |
Â
}
|
376 |
Â
|
377 |
+
$trigger_author = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_author' );
|
378 |
+
$trigger_connector_and_context = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_connector_or_context' );
|
379 |
Â
$trigger_connector_and_context_split = explode( '-', $trigger_connector_and_context );
|
380 |
+
$trigger_connector = $trigger_connector_and_context_split[0];
|
381 |
+
$trigger_context = $trigger_connector_and_context_split[1];
|
382 |
Â
|
383 |
+
$trigger_action = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_action' );
|
384 |
+
$alert_type = wp_stream_filter_input( INPUT_POST, 'wp_stream_alert_type' );
|
385 |
+
$alert_status = wp_stream_filter_input( INPUT_POST, 'wp_stream_alert_status' );
|
386 |
Â
$data['post_status'] = $alert_status;
|
387 |
Â
|
388 |
Â
update_post_meta( $post_id, 'alert_type', $alert_type );
|
classes/class-alerts.php
CHANGED
@@ -13,6 +13,7 @@ namespace WP_Stream;
|
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alerts {
|
Â
|
|
16 |
Â
/**
|
17 |
Â
* Alerts post type slug
|
18 |
Â
*/
|
@@ -66,24 +67,44 @@ class Alerts {
|
|
66 |
Â
add_action( 'wp_stream_admin_menu', array( $this, 'register_menu' ) );
|
67 |
Â
|
68 |
Â
// Add scripts to post screens.
|
69 |
-
add_action( 'admin_enqueue_scripts', array(
|
Â
|
|
Â
|
|
Â
|
|
70 |
Â
|
71 |
-
add_action( 'network_admin_menu', array(
|
Â
|
|
Â
|
|
Â
|
|
72 |
Â
|
73 |
-
add_filter( 'wp_stream_record_inserted', array(
|
Â
|
|
Â
|
|
Â
|
|
74 |
Â
|
75 |
-
add_action( 'wp_ajax_load_alerts_settings', array(
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
add_action( 'wp_ajax_get_actions', array( $this, 'get_actions' ) );
|
77 |
-
add_action( 'wp_ajax_save_new_alert', array(
|
78 |
-
add_action( 'wp_ajax_get_new_alert_triggers_notifications', array(
|
79 |
Â
$this,
|
80 |
-
'
|
81 |
Â
) );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
82 |
Â
|
83 |
Â
$this->load_alert_types();
|
84 |
Â
$this->load_alert_triggers();
|
85 |
Â
|
86 |
-
add_filter( 'wp_stream_action_links_posts', array(
|
Â
|
|
Â
|
|
Â
|
|
87 |
Â
|
88 |
Â
}
|
89 |
Â
|
@@ -92,12 +113,13 @@ class Alerts {
|
|
92 |
Â
*
|
93 |
Â
* @return void
|
94 |
Â
*/
|
95 |
-
function load_alert_types() {
|
96 |
Â
$alert_types = array(
|
97 |
Â
'none',
|
98 |
Â
'highlight',
|
99 |
Â
'email',
|
100 |
Â
'ifttt',
|
Â
|
|
101 |
Â
);
|
102 |
Â
|
103 |
Â
$classes = array();
|
@@ -128,12 +150,6 @@ class Alerts {
|
|
128 |
Â
foreach ( $this->alert_types as $key => $alert_type ) {
|
129 |
Â
if ( ! $this->is_valid_alert_type( $alert_type ) ) {
|
130 |
Â
unset( $this->alert_types[ $key ] );
|
131 |
-
trigger_error(
|
132 |
-
sprintf(
|
133 |
-
esc_html__( 'Registered alert_type %s does not extend WP_Stream\Alert_Type.', 'stream' ),
|
134 |
-
esc_html( get_class( $alert_type ) )
|
135 |
-
)
|
136 |
-
);
|
137 |
Â
}
|
138 |
Â
}
|
139 |
Â
}
|
@@ -143,7 +159,7 @@ class Alerts {
|
|
143 |
Â
*
|
144 |
Â
* @return void
|
145 |
Â
*/
|
146 |
-
function load_alert_triggers() {
|
147 |
Â
$alert_triggers = array(
|
148 |
Â
'author',
|
149 |
Â
'context',
|
@@ -178,12 +194,6 @@ class Alerts {
|
|
178 |
Â
foreach ( $this->alert_triggers as $key => $alert_trigger ) {
|
179 |
Â
if ( ! $this->is_valid_alert_trigger( $alert_trigger ) ) {
|
180 |
Â
unset( $this->alert_triggers[ $key ] );
|
181 |
-
trigger_error(
|
182 |
-
sprintf(
|
183 |
-
esc_html__( 'Registered alert_trigger %s does not extend WP_Stream\Alert_Trigger.', 'stream' ),
|
184 |
-
esc_html( get_class( $alert_trigger ) )
|
185 |
-
)
|
186 |
-
);
|
187 |
Â
}
|
188 |
Â
}
|
189 |
Â
}
|
@@ -236,7 +246,7 @@ class Alerts {
|
|
236 |
Â
*
|
237 |
Â
* @return array
|
238 |
Â
*/
|
239 |
-
function check_records( $record_id, $recordarr ) {
|
240 |
Â
$args = array(
|
241 |
Â
'post_type' => self::POST_TYPE,
|
242 |
Â
'post_status' => 'wp_stream_enabled',
|
@@ -263,15 +273,19 @@ class Alerts {
|
|
263 |
Â
*
|
264 |
Â
* @return void
|
265 |
Â
*/
|
266 |
-
function register_scripts() {
|
267 |
Â
$screen = get_current_screen();
|
268 |
Â
if ( 'edit-wp_stream_alerts' === $screen->id ) {
|
269 |
-
|
Â
|
|
Â
|
|
270 |
Â
'wp-stream-select2',
|
271 |
Â
'jquery',
|
272 |
Â
'inline-edit-post',
|
273 |
Â
) );
|
274 |
-
|
Â
|
|
Â
|
|
275 |
Â
array(
|
276 |
Â
'any' => __( 'Any', 'stream' ),
|
277 |
Â
'anyContext' => __( 'Any Context', 'stream' ),
|
@@ -335,6 +349,7 @@ class Alerts {
|
|
335 |
Â
'public' => false,
|
336 |
Â
'show_in_admin_all_list' => true,
|
337 |
Â
'show_in_admin_status_list' => true,
|
Â
|
|
338 |
Â
'label_count' => _n_noop( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', 'stream' ),
|
339 |
Â
);
|
340 |
Â
|
@@ -346,6 +361,7 @@ class Alerts {
|
|
346 |
Â
'internal' => false,
|
347 |
Â
'show_in_admin_all_list' => true,
|
348 |
Â
'show_in_admin_status_list' => true,
|
Â
|
|
349 |
Â
'label_count' => _n_noop( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', 'stream' ),
|
350 |
Â
);
|
351 |
Â
|
@@ -362,21 +378,22 @@ class Alerts {
|
|
362 |
Â
public function get_alert( $post_id = '' ) {
|
363 |
Â
if ( ! $post_id ) {
|
364 |
Â
$obj = new Alert( null, $this->plugin );
|
Â
|
|
365 |
Â
return $obj;
|
366 |
Â
}
|
367 |
Â
|
368 |
Â
$post = get_post( $post_id );
|
369 |
Â
|
370 |
-
$alert_type
|
371 |
-
$alert_meta
|
372 |
Â
|
373 |
Â
$obj = (object) array(
|
374 |
-
'ID'
|
375 |
-
'status'
|
376 |
-
'date'
|
377 |
-
'author'
|
378 |
-
'alert_type'
|
379 |
-
'alert_meta'
|
380 |
Â
);
|
381 |
Â
|
382 |
Â
return new Alert( $obj, $this->plugin );
|
@@ -390,7 +407,7 @@ class Alerts {
|
|
390 |
Â
*
|
391 |
Â
* @return void
|
392 |
Â
*/
|
393 |
-
function register_menu() {
|
394 |
Â
add_submenu_page(
|
395 |
Â
$this->plugin->admin->records_page_slug,
|
396 |
Â
__( 'Alerts', 'stream' ),
|
@@ -413,7 +430,7 @@ class Alerts {
|
|
413 |
Â
* @action network_admin_menu
|
414 |
Â
* @return bool
|
415 |
Â
*/
|
416 |
-
function change_menu_link_url() {
|
417 |
Â
global $submenu;
|
418 |
Â
|
419 |
Â
$parent = 'wp_stream';
|
@@ -441,10 +458,10 @@ class Alerts {
|
|
441 |
Â
$new_url = get_admin_url( $site_id, $page );
|
442 |
Â
|
443 |
Â
foreach ( $submenu[ $parent ] as $key => $value ) {
|
444 |
-
|
445 |
Â
// Set correct URL for the menu item.
|
446 |
Â
if ( $page === $value[2] ) {
|
447 |
-
|
Â
|
|
448 |
Â
break;
|
449 |
Â
}
|
450 |
Â
}
|
@@ -459,22 +476,24 @@ class Alerts {
|
|
459 |
Â
*
|
460 |
Â
* @return void
|
461 |
Â
*/
|
462 |
-
function display_notification_box( $post = array() ) {
|
463 |
Â
$alert_type = 'none';
|
464 |
Â
if ( is_object( $post ) ) {
|
465 |
Â
$alert = $this->get_alert( $post->ID );
|
466 |
Â
$alert_type = $alert->alert_type;
|
467 |
Â
}
|
468 |
-
$form = new Form_Generator;
|
469 |
-
|
470 |
-
$field_html = $form->render_field(
|
471 |
-
'
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
Â
|
|
Â
|
|
478 |
Â
|
479 |
Â
echo '<label>' . esc_html__( 'Alert me by', 'stream' ) . '</label>';
|
480 |
Â
echo $field_html; // Xss ok.
|
@@ -496,15 +515,17 @@ class Alerts {
|
|
496 |
Â
*
|
497 |
Â
* @return void
|
498 |
Â
*/
|
499 |
-
function load_alerts_settings() {
|
500 |
-
$alert
|
501 |
Â
$post_id = wp_stream_filter_input( INPUT_POST, 'post_id' );
|
502 |
Â
if ( ! empty( $post_id ) ) {
|
503 |
Â
$alert = $this->get_alert( $post_id );
|
504 |
Â
if ( ! $alert ) {
|
505 |
-
wp_send_json_error(
|
506 |
-
|
507 |
-
|
Â
|
|
Â
|
|
508 |
Â
}
|
509 |
Â
}
|
510 |
Â
|
@@ -513,9 +534,11 @@ class Alerts {
|
|
513 |
Â
$alert_type = 'none';
|
514 |
Â
}
|
515 |
Â
if ( ! array_key_exists( $alert_type, $this->alert_types ) ) {
|
516 |
-
wp_send_json_error(
|
517 |
-
|
518 |
-
|
Â
|
|
Â
|
|
519 |
Â
}
|
520 |
Â
|
521 |
Â
ob_start();
|
@@ -523,7 +546,9 @@ class Alerts {
|
|
523 |
Â
$output = ob_get_contents();
|
524 |
Â
ob_end_clean();
|
525 |
Â
|
526 |
-
$data = array(
|
Â
|
|
Â
|
|
527 |
Â
wp_send_json_success( $data );
|
528 |
Â
}
|
529 |
Â
|
@@ -534,13 +559,13 @@ class Alerts {
|
|
534 |
Â
*
|
535 |
Â
* @return void
|
536 |
Â
*/
|
537 |
-
function display_triggers_box( $post = array() ) {
|
538 |
Â
if ( is_object( $post ) ) {
|
539 |
Â
$alert = $this->get_alert( $post->ID );
|
540 |
Â
} else {
|
541 |
Â
$alert = array();
|
542 |
Â
}
|
543 |
-
$form = new Form_Generator;
|
544 |
Â
do_action( 'wp_stream_alert_trigger_form_display', $form, $alert );
|
545 |
Â
// @TODO use human readable text.
|
546 |
Â
echo '<label>' . esc_html__( 'Alert me when', 'stream' ) . '</label>';
|
@@ -555,7 +580,7 @@ class Alerts {
|
|
555 |
Â
*
|
556 |
Â
* @return void
|
557 |
Â
*/
|
558 |
-
function display_submit_box( $post ) {
|
559 |
Â
if ( empty( $post ) ) {
|
560 |
Â
return;
|
561 |
Â
}
|
@@ -572,9 +597,9 @@ class Alerts {
|
|
572 |
Â
<label for="wp_stream_alert_status"><?php esc_html_e( 'Status', 'stream' ); ?></label>
|
573 |
Â
<select name='wp_stream_alert_status' id='wp_stream_alert_status'>
|
574 |
Â
<option<?php selected( $post_status, 'wp_stream_enabled' ); ?>
|
575 |
-
|
576 |
Â
<option<?php selected( $post_status, 'wp_stream_disabled' ); ?>
|
577 |
-
|
578 |
Â
</select>
|
579 |
Â
</div>
|
580 |
Â
</div>
|
@@ -591,9 +616,12 @@ class Alerts {
|
|
591 |
Â
$delete_text = __( 'Move to Trash', 'stream' );
|
592 |
Â
}
|
593 |
Â
?>
|
594 |
-
<a class="submitdelete deletion"
|
595 |
-
|
596 |
-
|
Â
|
|
Â
|
|
Â
|
|
597 |
Â
</div>
|
598 |
Â
<div id="publishing-action">
|
599 |
Â
<span class="spinner"></span>
|
@@ -610,7 +638,7 @@ class Alerts {
|
|
610 |
Â
*
|
611 |
Â
* @return void
|
612 |
Â
*/
|
613 |
-
function display_status_box() {
|
614 |
Â
?>
|
615 |
Â
<div id="minor-publishing">
|
616 |
Â
<div id="misc-publishing-actions">
|
@@ -636,7 +664,7 @@ class Alerts {
|
|
636 |
Â
*
|
637 |
Â
* @return array
|
638 |
Â
*/
|
639 |
-
function get_notification_values() {
|
640 |
Â
$result = array();
|
641 |
Â
$names = wp_list_pluck( $this->alert_types, 'name', 'slug' );
|
642 |
Â
foreach ( $names as $slug => $name ) {
|
@@ -649,7 +677,7 @@ class Alerts {
|
|
649 |
Â
/**
|
650 |
Â
* Update actions dropdown options based on the connector selected.
|
651 |
Â
*/
|
652 |
-
function get_actions() {
|
653 |
Â
$connector_name = wp_stream_filter_input( INPUT_POST, 'connector' );
|
654 |
Â
$stream_connectors = wp_stream_get_instance()->connectors;
|
655 |
Â
if ( ! empty( $connector_name ) ) {
|
@@ -669,7 +697,7 @@ class Alerts {
|
|
669 |
Â
/**
|
670 |
Â
* Save a new alert
|
671 |
Â
*/
|
672 |
-
function save_new_alert() {
|
673 |
Â
check_ajax_referer( 'save_alert', 'wp_stream_alerts_nonce' );
|
674 |
Â
$trigger_author = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_author' );
|
675 |
Â
$trigger_connector_and_context = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_context' );
|
@@ -695,9 +723,9 @@ class Alerts {
|
|
695 |
Â
$alert_status = wp_stream_filter_input( INPUT_POST, 'wp_stream_alert_status' );
|
696 |
Â
|
697 |
Â
// Insert the post into the database
|
698 |
-
$item
|
699 |
-
'alert_type'
|
700 |
-
'alert_meta'
|
701 |
Â
'trigger_author' => $trigger_author,
|
702 |
Â
'trigger_connector' => $trigger_connector,
|
703 |
Â
'trigger_action' => $trigger_action,
|
@@ -705,13 +733,15 @@ class Alerts {
|
|
705 |
Â
),
|
706 |
Â
'alert_status' => $alert_status,
|
707 |
Â
);
|
708 |
-
$alert
|
709 |
-
$title
|
710 |
-
$post_id = wp_insert_post(
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
Â
|
|
Â
|
|
715 |
Â
if ( empty( $post_id ) ) {
|
716 |
Â
wp_send_json_error();
|
717 |
Â
}
|
@@ -725,13 +755,17 @@ class Alerts {
|
|
725 |
Â
);
|
726 |
Â
$alert_meta = apply_filters( 'wp_stream_alerts_save_meta', $alert_meta, $alert_type );
|
727 |
Â
add_post_meta( $post_id, 'alert_meta', $alert_meta );
|
728 |
-
wp_send_json_success(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
729 |
Â
}
|
730 |
Â
|
731 |
Â
/**
|
732 |
Â
*
|
733 |
Â
*/
|
734 |
-
function get_new_alert_triggers_notifications() {
|
735 |
Â
ob_start();
|
736 |
Â
?>
|
737 |
Â
<fieldset class="inline-edit-col inline-edit-wp_stream_alerts inline-edit-add-new-triggers">
|
@@ -746,30 +780,38 @@ class Alerts {
|
|
746 |
Â
</fieldset>
|
747 |
Â
<?php
|
748 |
Â
$html = ob_get_clean();
|
749 |
-
wp_send_json_success(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
750 |
Â
}
|
Â
|
|
751 |
Â
/**
|
752 |
Â
* Add action links to Stream drop row in admin list screen
|
753 |
Â
*
|
754 |
Â
* @filter wp_stream_action_links_{connector}
|
755 |
Â
*
|
756 |
-
* @param array
|
757 |
Â
* @param Record $record Stream record
|
758 |
Â
*
|
759 |
Â
* @return array Action links
|
760 |
Â
*/
|
761 |
-
function change_alert_action_links( $links, $record ) {
|
762 |
Â
$post = get_post( $record->object_id );
|
763 |
Â
|
764 |
Â
if ( $post && self::POST_TYPE === $post->post_type && $post->post_status === $record->get_meta( 'new_status', true ) ) {
|
765 |
Â
if ( 'trash' !== $post->post_status ) {
|
766 |
-
$connector_posts = new \WP_Stream\Connector_Posts;
|
767 |
-
$post_type_name
|
768 |
Â
|
Â
|
|
769 |
Â
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $post->ID );
|
770 |
Â
unset( $links[ esc_html__( 'View', 'stream' ) ] );
|
771 |
Â
}
|
772 |
Â
}
|
Â
|
|
773 |
Â
return $links;
|
774 |
Â
}
|
775 |
Â
}
|
13 |
Â
* @package WP_Stream
|
14 |
Â
*/
|
15 |
Â
class Alerts {
|
16 |
+
|
17 |
Â
/**
|
18 |
Â
* Alerts post type slug
|
19 |
Â
*/
|
67 |
Â
add_action( 'wp_stream_admin_menu', array( $this, 'register_menu' ) );
|
68 |
Â
|
69 |
Â
// Add scripts to post screens.
|
70 |
+
add_action( 'admin_enqueue_scripts', array(
|
71 |
+
$this,
|
72 |
+
'register_scripts',
|
73 |
+
) );
|
74 |
Â
|
75 |
+
add_action( 'network_admin_menu', array(
|
76 |
+
$this,
|
77 |
+
'change_menu_link_url',
|
78 |
+
), 99 );
|
79 |
Â
|
80 |
+
add_filter( 'wp_stream_record_inserted', array(
|
81 |
+
$this,
|
82 |
+
'check_records',
|
83 |
+
), 10, 2 );
|
84 |
Â
|
85 |
+
add_action( 'wp_ajax_load_alerts_settings', array(
|
86 |
+
$this,
|
87 |
+
'load_alerts_settings',
|
88 |
+
) );
|
89 |
Â
add_action( 'wp_ajax_get_actions', array( $this, 'get_actions' ) );
|
90 |
+
add_action( 'wp_ajax_save_new_alert', array(
|
Â
|
|
91 |
Â
$this,
|
92 |
+
'save_new_alert',
|
93 |
Â
) );
|
94 |
+
add_action(
|
95 |
+
'wp_ajax_get_new_alert_triggers_notifications', array(
|
96 |
+
$this,
|
97 |
+
'get_new_alert_triggers_notifications',
|
98 |
+
)
|
99 |
+
);
|
100 |
Â
|
101 |
Â
$this->load_alert_types();
|
102 |
Â
$this->load_alert_triggers();
|
103 |
Â
|
104 |
+
add_filter( 'wp_stream_action_links_posts', array(
|
105 |
+
$this,
|
106 |
+
'change_alert_action_links',
|
107 |
+
), 11, 2 );
|
108 |
Â
|
109 |
Â
}
|
110 |
Â
|
113 |
Â
*
|
114 |
Â
* @return void
|
115 |
Â
*/
|
116 |
+
public function load_alert_types() {
|
117 |
Â
$alert_types = array(
|
118 |
Â
'none',
|
119 |
Â
'highlight',
|
120 |
Â
'email',
|
121 |
Â
'ifttt',
|
122 |
+
'slack',
|
123 |
Â
);
|
124 |
Â
|
125 |
Â
$classes = array();
|
150 |
Â
foreach ( $this->alert_types as $key => $alert_type ) {
|
151 |
Â
if ( ! $this->is_valid_alert_type( $alert_type ) ) {
|
152 |
Â
unset( $this->alert_types[ $key ] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
153 |
Â
}
|
154 |
Â
}
|
155 |
Â
}
|
159 |
Â
*
|
160 |
Â
* @return void
|
161 |
Â
*/
|
162 |
+
public function load_alert_triggers() {
|
163 |
Â
$alert_triggers = array(
|
164 |
Â
'author',
|
165 |
Â
'context',
|
194 |
Â
foreach ( $this->alert_triggers as $key => $alert_trigger ) {
|
195 |
Â
if ( ! $this->is_valid_alert_trigger( $alert_trigger ) ) {
|
196 |
Â
unset( $this->alert_triggers[ $key ] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
197 |
Â
}
|
198 |
Â
}
|
199 |
Â
}
|
246 |
Â
*
|
247 |
Â
* @return array
|
248 |
Â
*/
|
249 |
+
public function check_records( $record_id, $recordarr ) {
|
250 |
Â
$args = array(
|
251 |
Â
'post_type' => self::POST_TYPE,
|
252 |
Â
'post_status' => 'wp_stream_enabled',
|
273 |
Â
*
|
274 |
Â
* @return void
|
275 |
Â
*/
|
276 |
+
public function register_scripts() {
|
277 |
Â
$screen = get_current_screen();
|
278 |
Â
if ( 'edit-wp_stream_alerts' === $screen->id ) {
|
279 |
+
|
280 |
+
$min = wp_stream_min_suffix();
|
281 |
+
wp_register_script( 'wp-stream-alerts', $this->plugin->locations['url'] . 'ui/js/alerts.' . $min . 'js', array(
|
282 |
Â
'wp-stream-select2',
|
283 |
Â
'jquery',
|
284 |
Â
'inline-edit-post',
|
285 |
Â
) );
|
286 |
+
|
287 |
+
wp_localize_script(
|
288 |
+
'wp-stream-alerts', 'streamAlerts',
|
289 |
Â
array(
|
290 |
Â
'any' => __( 'Any', 'stream' ),
|
291 |
Â
'anyContext' => __( 'Any Context', 'stream' ),
|
349 |
Â
'public' => false,
|
350 |
Â
'show_in_admin_all_list' => true,
|
351 |
Â
'show_in_admin_status_list' => true,
|
352 |
+
// translators: Placeholder refers to a number of items (e.g. "42")
|
353 |
Â
'label_count' => _n_noop( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', 'stream' ),
|
354 |
Â
);
|
355 |
Â
|
361 |
Â
'internal' => false,
|
362 |
Â
'show_in_admin_all_list' => true,
|
363 |
Â
'show_in_admin_status_list' => true,
|
364 |
+
// translators: Placeholder refers to a number of items (e.g. "42")
|
365 |
Â
'label_count' => _n_noop( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', 'stream' ),
|
366 |
Â
);
|
367 |
Â
|
378 |
Â
public function get_alert( $post_id = '' ) {
|
379 |
Â
if ( ! $post_id ) {
|
380 |
Â
$obj = new Alert( null, $this->plugin );
|
381 |
+
|
382 |
Â
return $obj;
|
383 |
Â
}
|
384 |
Â
|
385 |
Â
$post = get_post( $post_id );
|
386 |
Â
|
387 |
+
$alert_type = get_post_meta( $post_id, 'alert_type', true );
|
388 |
+
$alert_meta = get_post_meta( $post_id, 'alert_meta', true );
|
389 |
Â
|
390 |
Â
$obj = (object) array(
|
391 |
+
'ID' => $post->ID,
|
392 |
+
'status' => $post->post_status,
|
393 |
+
'date' => $post->post_date,
|
394 |
+
'author' => $post->post_author,
|
395 |
+
'alert_type' => $alert_type,
|
396 |
+
'alert_meta' => $alert_meta,
|
397 |
Â
);
|
398 |
Â
|
399 |
Â
return new Alert( $obj, $this->plugin );
|
407 |
Â
*
|
408 |
Â
* @return void
|
409 |
Â
*/
|
410 |
+
public function register_menu() {
|
411 |
Â
add_submenu_page(
|
412 |
Â
$this->plugin->admin->records_page_slug,
|
413 |
Â
__( 'Alerts', 'stream' ),
|
430 |
Â
* @action network_admin_menu
|
431 |
Â
* @return bool
|
432 |
Â
*/
|
433 |
+
public function change_menu_link_url() {
|
434 |
Â
global $submenu;
|
435 |
Â
|
436 |
Â
$parent = 'wp_stream';
|
458 |
Â
$new_url = get_admin_url( $site_id, $page );
|
459 |
Â
|
460 |
Â
foreach ( $submenu[ $parent ] as $key => $value ) {
|
Â
|
|
461 |
Â
// Set correct URL for the menu item.
|
462 |
Â
if ( $page === $value[2] ) {
|
463 |
+
// This hack is not kosher, see the docblock for an explanation.
|
464 |
+
$submenu[ $parent ][ $key ][2] = $new_url; // override okay
|
465 |
Â
break;
|
466 |
Â
}
|
467 |
Â
}
|
476 |
Â
*
|
477 |
Â
* @return void
|
478 |
Â
*/
|
479 |
+
public function display_notification_box( $post = array() ) {
|
480 |
Â
$alert_type = 'none';
|
481 |
Â
if ( is_object( $post ) ) {
|
482 |
Â
$alert = $this->get_alert( $post->ID );
|
483 |
Â
$alert_type = $alert->alert_type;
|
484 |
Â
}
|
485 |
+
$form = new Form_Generator();
|
486 |
+
|
487 |
+
$field_html = $form->render_field(
|
488 |
+
'select', array(
|
489 |
+
'id' => 'wp_stream_alert_type',
|
490 |
+
'name' => 'wp_stream_alert_type',
|
491 |
+
'value' => $alert_type,
|
492 |
+
'options' => $this->get_notification_values(),
|
493 |
+
'placeholder' => __( 'No Alert', 'stream' ),
|
494 |
+
'title' => 'Alert Type:',
|
495 |
+
)
|
496 |
+
);
|
497 |
Â
|
498 |
Â
echo '<label>' . esc_html__( 'Alert me by', 'stream' ) . '</label>';
|
499 |
Â
echo $field_html; // Xss ok.
|
515 |
Â
*
|
516 |
Â
* @return void
|
517 |
Â
*/
|
518 |
+
public function load_alerts_settings() {
|
519 |
+
$alert = array();
|
520 |
Â
$post_id = wp_stream_filter_input( INPUT_POST, 'post_id' );
|
521 |
Â
if ( ! empty( $post_id ) ) {
|
522 |
Â
$alert = $this->get_alert( $post_id );
|
523 |
Â
if ( ! $alert ) {
|
524 |
+
wp_send_json_error(
|
525 |
+
array(
|
526 |
+
'message' => 'Could not find alert.',
|
527 |
+
)
|
528 |
+
);
|
529 |
Â
}
|
530 |
Â
}
|
531 |
Â
|
534 |
Â
$alert_type = 'none';
|
535 |
Â
}
|
536 |
Â
if ( ! array_key_exists( $alert_type, $this->alert_types ) ) {
|
537 |
+
wp_send_json_error(
|
538 |
+
array(
|
539 |
+
'message' => 'Could not find alert type.',
|
540 |
+
)
|
541 |
+
);
|
542 |
Â
}
|
543 |
Â
|
544 |
Â
ob_start();
|
546 |
Â
$output = ob_get_contents();
|
547 |
Â
ob_end_clean();
|
548 |
Â
|
549 |
+
$data = array(
|
550 |
+
'html' => $output,
|
551 |
+
);
|
552 |
Â
wp_send_json_success( $data );
|
553 |
Â
}
|
554 |
Â
|
559 |
Â
*
|
560 |
Â
* @return void
|
561 |
Â
*/
|
562 |
+
public function display_triggers_box( $post = array() ) {
|
563 |
Â
if ( is_object( $post ) ) {
|
564 |
Â
$alert = $this->get_alert( $post->ID );
|
565 |
Â
} else {
|
566 |
Â
$alert = array();
|
567 |
Â
}
|
568 |
+
$form = new Form_Generator();
|
569 |
Â
do_action( 'wp_stream_alert_trigger_form_display', $form, $alert );
|
570 |
Â
// @TODO use human readable text.
|
571 |
Â
echo '<label>' . esc_html__( 'Alert me when', 'stream' ) . '</label>';
|
580 |
Â
*
|
581 |
Â
* @return void
|
582 |
Â
*/
|
583 |
+
public function display_submit_box( $post ) {
|
584 |
Â
if ( empty( $post ) ) {
|
585 |
Â
return;
|
586 |
Â
}
|
597 |
Â
<label for="wp_stream_alert_status"><?php esc_html_e( 'Status', 'stream' ); ?></label>
|
598 |
Â
<select name='wp_stream_alert_status' id='wp_stream_alert_status'>
|
599 |
Â
<option<?php selected( $post_status, 'wp_stream_enabled' ); ?>
|
600 |
+
value='wp_stream_enabled'><?php esc_html_e( 'Enabled', 'stream' ); ?></option>
|
601 |
Â
<option<?php selected( $post_status, 'wp_stream_disabled' ); ?>
|
602 |
+
value='wp_stream_disabled'><?php esc_html_e( 'Disabled', 'stream' ); ?></option>
|
603 |
Â
</select>
|
604 |
Â
</div>
|
605 |
Â
</div>
|
616 |
Â
$delete_text = __( 'Move to Trash', 'stream' );
|
617 |
Â
}
|
618 |
Â
?>
|
619 |
+
<a class="submitdelete deletion" href="<?php echo get_delete_post_link( $post->ID ); ?>">
|
620 |
+
<?php esc_html( $delete_text ); ?>
|
621 |
+
</a>
|
622 |
+
<?php
|
623 |
+
}
|
624 |
+
?>
|
625 |
Â
</div>
|
626 |
Â
<div id="publishing-action">
|
627 |
Â
<span class="spinner"></span>
|
638 |
Â
*
|
639 |
Â
* @return void
|
640 |
Â
*/
|
641 |
+
public function display_status_box() {
|
642 |
Â
?>
|
643 |
Â
<div id="minor-publishing">
|
644 |
Â
<div id="misc-publishing-actions">
|
664 |
Â
*
|
665 |
Â
* @return array
|
666 |
Â
*/
|
667 |
+
public function get_notification_values() {
|
668 |
Â
$result = array();
|
669 |
Â
$names = wp_list_pluck( $this->alert_types, 'name', 'slug' );
|
670 |
Â
foreach ( $names as $slug => $name ) {
|
677 |
Â
/**
|
678 |
Â
* Update actions dropdown options based on the connector selected.
|
679 |
Â
*/
|
680 |
+
public function get_actions() {
|
681 |
Â
$connector_name = wp_stream_filter_input( INPUT_POST, 'connector' );
|
682 |
Â
$stream_connectors = wp_stream_get_instance()->connectors;
|
683 |
Â
if ( ! empty( $connector_name ) ) {
|
697 |
Â
/**
|
698 |
Â
* Save a new alert
|
699 |
Â
*/
|
700 |
+
public function save_new_alert() {
|
701 |
Â
check_ajax_referer( 'save_alert', 'wp_stream_alerts_nonce' );
|
702 |
Â
$trigger_author = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_author' );
|
703 |
Â
$trigger_connector_and_context = wp_stream_filter_input( INPUT_POST, 'wp_stream_trigger_context' );
|
723 |
Â
$alert_status = wp_stream_filter_input( INPUT_POST, 'wp_stream_alert_status' );
|
724 |
Â
|
725 |
Â
// Insert the post into the database
|
726 |
+
$item = (object) array(
|
727 |
+
'alert_type' => $alert_type,
|
728 |
+
'alert_meta' => array(
|
729 |
Â
'trigger_author' => $trigger_author,
|
730 |
Â
'trigger_connector' => $trigger_connector,
|
731 |
Â
'trigger_action' => $trigger_action,
|
733 |
Â
),
|
734 |
Â
'alert_status' => $alert_status,
|
735 |
Â
);
|
736 |
+
$alert = new Alert( $item, $this->plugin );
|
737 |
+
$title = $alert->get_title();
|
738 |
+
$post_id = wp_insert_post(
|
739 |
+
array(
|
740 |
+
'post_status' => $alert_status,
|
741 |
+
'post_type' => 'wp_stream_alerts',
|
742 |
+
'post_title' => $title,
|
743 |
+
)
|
744 |
+
);
|
745 |
Â
if ( empty( $post_id ) ) {
|
746 |
Â
wp_send_json_error();
|
747 |
Â
}
|
755 |
Â
);
|
756 |
Â
$alert_meta = apply_filters( 'wp_stream_alerts_save_meta', $alert_meta, $alert_type );
|
757 |
Â
add_post_meta( $post_id, 'alert_meta', $alert_meta );
|
758 |
+
wp_send_json_success(
|
759 |
+
array(
|
760 |
+
'success' => true,
|
761 |
+
)
|
762 |
+
);
|
763 |
Â
}
|
764 |
Â
|
765 |
Â
/**
|
766 |
Â
*
|
767 |
Â
*/
|
768 |
+
public function get_new_alert_triggers_notifications() {
|
769 |
Â
ob_start();
|
770 |
Â
?>
|
771 |
Â
<fieldset class="inline-edit-col inline-edit-wp_stream_alerts inline-edit-add-new-triggers">
|
780 |
Â
</fieldset>
|
781 |
Â
<?php
|
782 |
Â
$html = ob_get_clean();
|
783 |
+
wp_send_json_success(
|
784 |
+
array(
|
785 |
+
'success' => true,
|
786 |
+
'html' => $html,
|
787 |
+
)
|
788 |
+
);
|
789 |
Â
}
|
790 |
+
|
791 |
Â
/**
|
792 |
Â
* Add action links to Stream drop row in admin list screen
|
793 |
Â
*
|
794 |
Â
* @filter wp_stream_action_links_{connector}
|
795 |
Â
*
|
796 |
+
* @param array $links Previous links registered
|
797 |
Â
* @param Record $record Stream record
|
798 |
Â
*
|
799 |
Â
* @return array Action links
|
800 |
Â
*/
|
801 |
+
public function change_alert_action_links( $links, $record ) {
|
802 |
Â
$post = get_post( $record->object_id );
|
803 |
Â
|
804 |
Â
if ( $post && self::POST_TYPE === $post->post_type && $post->post_status === $record->get_meta( 'new_status', true ) ) {
|
805 |
Â
if ( 'trash' !== $post->post_status ) {
|
806 |
+
$connector_posts = new \WP_Stream\Connector_Posts();
|
807 |
+
$post_type_name = $connector_posts->get_post_type_name( get_post_type( $post->ID ) );
|
808 |
Â
|
809 |
+
// translators: Placeholder refers to the post type singular name (e.g. "Post")
|
810 |
Â
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $post->ID );
|
811 |
Â
unset( $links[ esc_html__( 'View', 'stream' ) ] );
|
812 |
Â
}
|
813 |
Â
}
|
814 |
+
|
815 |
Â
return $links;
|
816 |
Â
}
|
817 |
Â
}
|
classes/class-author.php
CHANGED
@@ -23,7 +23,7 @@ class Author {
|
|
23 |
Â
* @param int $user_id The user ID.
|
24 |
Â
* @param array $user_meta The user meta array.
|
25 |
Â
*/
|
26 |
-
function __construct( $user_id, $user_meta = array() ) {
|
27 |
Â
$this->id = absint( $user_id );
|
28 |
Â
$this->meta = $user_meta;
|
29 |
Â
|
@@ -41,7 +41,7 @@ class Author {
|
|
41 |
Â
*
|
42 |
Â
* @return string
|
43 |
Â
*/
|
44 |
-
function __get( $name ) {
|
45 |
Â
if ( 'display_name' === $name ) {
|
46 |
Â
return $this->get_display_name();
|
47 |
Â
} elseif ( 'avatar_img' === $name ) {
|
@@ -62,7 +62,7 @@ class Author {
|
|
62 |
Â
/**
|
63 |
Â
* @return string
|
64 |
Â
*/
|
65 |
-
function __toString() {
|
66 |
Â
return $this->get_display_name();
|
67 |
Â
}
|
68 |
Â
|
@@ -71,7 +71,7 @@ class Author {
|
|
71 |
Â
*
|
72 |
Â
* @return string
|
73 |
Â
*/
|
74 |
-
function get_display_name() {
|
75 |
Â
if ( 0 === $this->id ) {
|
76 |
Â
if ( isset( $this->meta['system_user_name'] ) ) {
|
77 |
Â
return esc_html( $this->meta['system_user_name'] );
|
@@ -101,7 +101,7 @@ class Author {
|
|
101 |
Â
*
|
102 |
Â
* @return string
|
103 |
Â
*/
|
104 |
-
function get_agent() {
|
105 |
Â
$agent = '';
|
106 |
Â
|
107 |
Â
if ( ! empty( $this->meta['agent'] ) ) {
|
@@ -122,7 +122,7 @@ class Author {
|
|
122 |
Â
*
|
123 |
Â
* @return string|bool An img HTML element, or false if avatars are disabled
|
124 |
Â
*/
|
125 |
-
function get_avatar_img( $size = 80 ) {
|
126 |
Â
if ( ! get_option( 'show_avatars' ) ) {
|
127 |
Â
return false;
|
128 |
Â
}
|
@@ -150,7 +150,7 @@ class Author {
|
|
150 |
Â
*
|
151 |
Â
* @return string|bool Gravatar image URL, or false on failure
|
152 |
Â
*/
|
153 |
-
function get_avatar_src( $size = 80 ) {
|
154 |
Â
$img = $this->get_avatar_img( $size );
|
155 |
Â
|
156 |
Â
if ( ! $img ) {
|
@@ -177,7 +177,7 @@ class Author {
|
|
177 |
Â
*
|
178 |
Â
* @return string
|
179 |
Â
*/
|
180 |
-
function get_role() {
|
181 |
Â
global $wp_roles;
|
182 |
Â
|
183 |
Â
$user_role = '';
|
@@ -200,7 +200,7 @@ class Author {
|
|
200 |
Â
*
|
201 |
Â
* @return bool
|
202 |
Â
*/
|
203 |
-
function is_deleted() {
|
204 |
Â
return ( 0 !== $this->id && 0 === $this->user->ID );
|
205 |
Â
}
|
206 |
Â
|
@@ -209,7 +209,7 @@ class Author {
|
|
209 |
Â
*
|
210 |
Â
* @return bool
|
211 |
Â
*/
|
212 |
-
function is_wp_cli() {
|
213 |
Â
return ( 'wp_cli' === $this->get_agent() );
|
214 |
Â
}
|
215 |
Â
|
@@ -222,7 +222,7 @@ class Author {
|
|
222 |
Â
*
|
223 |
Â
* @return bool
|
224 |
Â
*/
|
225 |
-
function is_doing_wp_cron() {
|
226 |
Â
return (
|
227 |
Â
wp_stream_is_cron_enabled()
|
228 |
Â
&&
|
@@ -237,7 +237,7 @@ class Author {
|
|
237 |
Â
*
|
238 |
Â
* @return string
|
239 |
Â
*/
|
240 |
-
function get_current_agent() {
|
241 |
Â
$agent = '';
|
242 |
Â
|
243 |
Â
if ( defined( '\WP_CLI' ) && \WP_CLI ) {
|
@@ -263,7 +263,7 @@ class Author {
|
|
263 |
Â
*
|
264 |
Â
* @return string
|
265 |
Â
*/
|
266 |
-
function get_agent_label( $agent ) {
|
267 |
Â
if ( 'wp_cli' === $agent ) {
|
268 |
Â
$label = esc_html__( 'via WP-CLI', 'stream' );
|
269 |
Â
} elseif ( 'wp_cron' === $agent ) {
|
23 |
Â
* @param int $user_id The user ID.
|
24 |
Â
* @param array $user_meta The user meta array.
|
25 |
Â
*/
|
26 |
+
public function __construct( $user_id, $user_meta = array() ) {
|
27 |
Â
$this->id = absint( $user_id );
|
28 |
Â
$this->meta = $user_meta;
|
29 |
Â
|
41 |
Â
*
|
42 |
Â
* @return string
|
43 |
Â
*/
|
44 |
+
public function __get( $name ) {
|
45 |
Â
if ( 'display_name' === $name ) {
|
46 |
Â
return $this->get_display_name();
|
47 |
Â
} elseif ( 'avatar_img' === $name ) {
|
62 |
Â
/**
|
63 |
Â
* @return string
|
64 |
Â
*/
|
65 |
+
public function __toString() {
|
66 |
Â
return $this->get_display_name();
|
67 |
Â
}
|
68 |
Â
|
71 |
Â
*
|
72 |
Â
* @return string
|
73 |
Â
*/
|
74 |
+
public function get_display_name() {
|
75 |
Â
if ( 0 === $this->id ) {
|
76 |
Â
if ( isset( $this->meta['system_user_name'] ) ) {
|
77 |
Â
return esc_html( $this->meta['system_user_name'] );
|
101 |
Â
*
|
102 |
Â
* @return string
|
103 |
Â
*/
|
104 |
+
public function get_agent() {
|
105 |
Â
$agent = '';
|
106 |
Â
|
107 |
Â
if ( ! empty( $this->meta['agent'] ) ) {
|
122 |
Â
*
|
123 |
Â
* @return string|bool An img HTML element, or false if avatars are disabled
|
124 |
Â
*/
|
125 |
+
public function get_avatar_img( $size = 80 ) {
|
126 |
Â
if ( ! get_option( 'show_avatars' ) ) {
|
127 |
Â
return false;
|
128 |
Â
}
|
150 |
Â
*
|
151 |
Â
* @return string|bool Gravatar image URL, or false on failure
|
152 |
Â
*/
|
153 |
+
public function get_avatar_src( $size = 80 ) {
|
154 |
Â
$img = $this->get_avatar_img( $size );
|
155 |
Â
|
156 |
Â
if ( ! $img ) {
|
177 |
Â
*
|
178 |
Â
* @return string
|
179 |
Â
*/
|
180 |
+
public function get_role() {
|
181 |
Â
global $wp_roles;
|
182 |
Â
|
183 |
Â
$user_role = '';
|
200 |
Â
*
|
201 |
Â
* @return bool
|
202 |
Â
*/
|
203 |
+
public function is_deleted() {
|
204 |
Â
return ( 0 !== $this->id && 0 === $this->user->ID );
|
205 |
Â
}
|
206 |
Â
|
209 |
Â
*
|
210 |
Â
* @return bool
|
211 |
Â
*/
|
212 |
+
public function is_wp_cli() {
|
213 |
Â
return ( 'wp_cli' === $this->get_agent() );
|
214 |
Â
}
|
215 |
Â
|
222 |
Â
*
|
223 |
Â
* @return bool
|
224 |
Â
*/
|
225 |
+
public function is_doing_wp_cron() {
|
226 |
Â
return (
|
227 |
Â
wp_stream_is_cron_enabled()
|
228 |
Â
&&
|
237 |
Â
*
|
238 |
Â
* @return string
|
239 |
Â
*/
|
240 |
+
public function get_current_agent() {
|
241 |
Â
$agent = '';
|
242 |
Â
|
243 |
Â
if ( defined( '\WP_CLI' ) && \WP_CLI ) {
|
263 |
Â
*
|
264 |
Â
* @return string
|
265 |
Â
*/
|
266 |
+
public function get_agent_label( $agent ) {
|
267 |
Â
if ( 'wp_cli' === $agent ) {
|
268 |
Â
$label = esc_html__( 'via WP-CLI', 'stream' );
|
269 |
Â
} elseif ( 'wp_cron' === $agent ) {
|
classes/class-cli.php
CHANGED
@@ -4,9 +4,11 @@
|
|
4 |
Â
*
|
5 |
Â
* @see https://github.com/wp-cli/wp-cli
|
6 |
Â
*/
|
Â
|
|
7 |
Â
namespace WP_Stream;
|
8 |
Â
|
9 |
Â
class CLI extends \WP_CLI_Command {
|
Â
|
|
10 |
Â
/**
|
11 |
Â
* Query a set of Stream records.
|
12 |
Â
*
|
@@ -96,7 +98,13 @@ class CLI extends \WP_CLI_Command {
|
|
96 |
Â
$this->connection();
|
97 |
Â
|
98 |
Â
if ( empty( $assoc_args['fields'] ) ) {
|
99 |
-
$fields = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
100 |
Â
} else {
|
101 |
Â
$fields = explode( ',', $assoc_args['fields'] );
|
102 |
Â
}
|
@@ -135,23 +143,23 @@ class CLI extends \WP_CLI_Command {
|
|
135 |
Â
|
136 |
Â
if ( isset( $assoc_args['format'] ) && 'table' !== $assoc_args['format'] ) {
|
137 |
Â
if ( 'count' === $assoc_args['format'] ) {
|
138 |
-
WP_CLI::line( count( $records ) );
|
139 |
Â
}
|
140 |
Â
|
141 |
Â
if ( 'json' === $assoc_args['format'] ) {
|
142 |
-
WP_CLI::line( wp_stream_json_encode( $formatted_records ) );
|
143 |
Â
}
|
144 |
Â
|
145 |
Â
if ( 'json_pretty' === $assoc_args['format'] ) {
|
146 |
Â
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
|
147 |
-
WP_CLI::line( wp_stream_json_encode( $formatted_records ) ); // xss ok
|
148 |
Â
} else {
|
149 |
-
WP_CLI::line( wp_stream_json_encode( $formatted_records, JSON_PRETTY_PRINT ) ); // xss ok
|
150 |
Â
}
|
151 |
Â
}
|
152 |
Â
|
153 |
Â
if ( 'csv' === $assoc_args['format'] ) {
|
154 |
-
WP_CLI::line( $this->csv_format( $formatted_records ) );
|
155 |
Â
}
|
156 |
Â
|
157 |
Â
return;
|
@@ -168,8 +176,8 @@ class CLI extends \WP_CLI_Command {
|
|
168 |
Â
/**
|
169 |
Â
* Convert any field to a flat array.
|
170 |
Â
*
|
171 |
-
* @param string $name
|
172 |
-
* @param mixed $object
|
173 |
Â
*
|
174 |
Â
* @return array The flat array
|
175 |
Â
*/
|
@@ -192,18 +200,18 @@ class CLI extends \WP_CLI_Command {
|
|
192 |
Â
/**
|
193 |
Â
* Convert an array of flat records to CSV
|
194 |
Â
*
|
195 |
-
* @param array $array
|
196 |
Â
*
|
197 |
Â
* @return string The CSV output
|
198 |
Â
*/
|
199 |
Â
private function csv_format( $array ) {
|
200 |
-
$output = fopen( 'php://output', 'w' );
|
201 |
Â
|
202 |
Â
foreach ( $array as $line ) {
|
203 |
-
fputcsv( $output, $line );
|
204 |
Â
}
|
205 |
Â
|
206 |
-
fclose( $output );
|
207 |
Â
}
|
208 |
Â
|
209 |
Â
/**
|
@@ -212,10 +220,15 @@ class CLI extends \WP_CLI_Command {
|
|
212 |
Â
* @return void
|
213 |
Â
*/
|
214 |
Â
private function connection() {
|
215 |
-
$query = wp_stream_get_instance()->db->query(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
216 |
Â
|
217 |
Â
if ( ! $query ) {
|
218 |
-
WP_CLI::error( esc_html__( 'SITE IS DISCONNECTED', 'stream' ) );
|
219 |
Â
}
|
220 |
Â
}
|
221 |
Â
}
|
4 |
Â
*
|
5 |
Â
* @see https://github.com/wp-cli/wp-cli
|
6 |
Â
*/
|
7 |
+
|
8 |
Â
namespace WP_Stream;
|
9 |
Â
|
10 |
Â
class CLI extends \WP_CLI_Command {
|
11 |
+
|
12 |
Â
/**
|
13 |
Â
* Query a set of Stream records.
|
14 |
Â
*
|
98 |
Â
$this->connection();
|
99 |
Â
|
100 |
Â
if ( empty( $assoc_args['fields'] ) ) {
|
101 |
+
$fields = array(
|
102 |
+
'created',
|
103 |
+
'ip',
|
104 |
+
'user_id',
|
105 |
+
'user_role',
|
106 |
+
'summary',
|
107 |
+
);
|
108 |
Â
} else {
|
109 |
Â
$fields = explode( ',', $assoc_args['fields'] );
|
110 |
Â
}
|
143 |
Â
|
144 |
Â
if ( isset( $assoc_args['format'] ) && 'table' !== $assoc_args['format'] ) {
|
145 |
Â
if ( 'count' === $assoc_args['format'] ) {
|
146 |
+
\WP_CLI::line( count( $records ) );
|
147 |
Â
}
|
148 |
Â
|
149 |
Â
if ( 'json' === $assoc_args['format'] ) {
|
150 |
+
\WP_CLI::line( wp_stream_json_encode( $formatted_records ) );
|
151 |
Â
}
|
152 |
Â
|
153 |
Â
if ( 'json_pretty' === $assoc_args['format'] ) {
|
154 |
Â
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
|
155 |
+
\WP_CLI::line( wp_stream_json_encode( $formatted_records ) ); // xss ok
|
156 |
Â
} else {
|
157 |
+
\WP_CLI::line( wp_stream_json_encode( $formatted_records, JSON_PRETTY_PRINT ) ); // xss ok
|
158 |
Â
}
|
159 |
Â
}
|
160 |
Â
|
161 |
Â
if ( 'csv' === $assoc_args['format'] ) {
|
162 |
+
\WP_CLI::line( $this->csv_format( $formatted_records ) );
|
163 |
Â
}
|
164 |
Â
|
165 |
Â
return;
|
176 |
Â
/**
|
177 |
Â
* Convert any field to a flat array.
|
178 |
Â
*
|
179 |
+
* @param string $name The output array element name
|
180 |
+
* @param mixed $object Any value to be converted to an array
|
181 |
Â
*
|
182 |
Â
* @return array The flat array
|
183 |
Â
*/
|
200 |
Â
/**
|
201 |
Â
* Convert an array of flat records to CSV
|
202 |
Â
*
|
203 |
+
* @param array $array The input array of records
|
204 |
Â
*
|
205 |
Â
* @return string The CSV output
|
206 |
Â
*/
|
207 |
Â
private function csv_format( $array ) {
|
208 |
+
$output = fopen( 'php://output', 'w' ); // @codingStandardsIgnoreLine Clever output for WP CLI using php://output
|
209 |
Â
|
210 |
Â
foreach ( $array as $line ) {
|
211 |
+
fputcsv( $output, $line ); // @codingStandardsIgnoreLine
|
212 |
Â
}
|
213 |
Â
|
214 |
+
fclose( $output ); // @codingStandardsIgnoreLine
|
215 |
Â
}
|
216 |
Â
|
217 |
Â
/**
|
220 |
Â
* @return void
|
221 |
Â
*/
|
222 |
Â
private function connection() {
|
223 |
+
$query = wp_stream_get_instance()->db->query(
|
224 |
+
array(
|
225 |
+
'records_per_page' => 1,
|
226 |
+
'fields' => 'created',
|
227 |
+
)
|
228 |
+
);
|
229 |
Â
|
230 |
Â
if ( ! $query ) {
|
231 |
+
\WP_CLI::error( esc_html__( 'SITE IS DISCONNECTED', 'stream' ) );
|
232 |
Â
}
|
233 |
Â
}
|
234 |
Â
}
|
classes/class-connector.php
CHANGED
@@ -229,7 +229,7 @@ abstract class Connector {
|
|
229 |
Â
$inner[ $parent . '::' . $child ] = $change;
|
230 |
Â
}
|
231 |
Â
$result[ $key ] = 0; // Changed parent which has a changed children
|
232 |
-
$result
|
233 |
Â
}
|
234 |
Â
}
|
235 |
Â
}
|
229 |
Â
$inner[ $parent . '::' . $child ] = $change;
|
230 |
Â
}
|
231 |
Â
$result[ $key ] = 0; // Changed parent which has a changed children
|
232 |
+
$result = array_merge( $result, $inner );
|
233 |
Â
}
|
234 |
Â
}
|
235 |
Â
}
|
classes/class-connectors.php
CHANGED
@@ -133,24 +133,29 @@ class Connectors {
|
|
133 |
Â
|
134 |
Â
foreach ( $this->connectors as $connector ) {
|
135 |
Â
if ( ! method_exists( $connector, 'get_label' ) ) {
|
Â
|
|
136 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_label method.', 'stream' ), $connector->name, 'Connector' ), true );
|
137 |
Â
continue;
|
138 |
Â
}
|
139 |
Â
if ( ! method_exists( $connector, 'register' ) ) {
|
Â
|
|
140 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the register method.', 'stream' ), $connector->name, 'Connector' ), true );
|
141 |
Â
continue;
|
142 |
Â
}
|
143 |
Â
if ( ! method_exists( $connector, 'get_context_labels' ) ) {
|
Â
|
|
144 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_context_labels method.', 'stream' ), $connector->name, 'Connector' ), true );
|
145 |
Â
continue;
|
146 |
Â
}
|
147 |
Â
if ( ! method_exists( $connector, 'get_action_labels' ) ) {
|
Â
|
|
148 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_action_labels method.', 'stream' ), $connector->name, 'Connector' ), true );
|
149 |
Â
continue;
|
150 |
Â
}
|
151 |
Â
|
152 |
Â
// Check if the connectors extends the Connector class, if not skip it.
|
153 |
Â
if ( ! is_subclass_of( $connector, '\WP_Stream\Connector' ) ) {
|
Â
|
|
154 |
Â
$this->plugin->admin->notice( sprintf( __( '%1$s class wasn\'t loaded because it doesn\'t extends the %2$s class.', 'stream' ), $connector->name, 'Connector' ), true );
|
155 |
Â
continue;
|
156 |
Â
}
|
133 |
Â
|
134 |
Â
foreach ( $this->connectors as $connector ) {
|
135 |
Â
if ( ! method_exists( $connector, 'get_label' ) ) {
|
136 |
+
// translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
|
137 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_label method.', 'stream' ), $connector->name, 'Connector' ), true );
|
138 |
Â
continue;
|
139 |
Â
}
|
140 |
Â
if ( ! method_exists( $connector, 'register' ) ) {
|
141 |
+
// translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
|
142 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the register method.', 'stream' ), $connector->name, 'Connector' ), true );
|
143 |
Â
continue;
|
144 |
Â
}
|
145 |
Â
if ( ! method_exists( $connector, 'get_context_labels' ) ) {
|
146 |
+
// translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
|
147 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_context_labels method.', 'stream' ), $connector->name, 'Connector' ), true );
|
148 |
Â
continue;
|
149 |
Â
}
|
150 |
Â
if ( ! method_exists( $connector, 'get_action_labels' ) ) {
|
151 |
+
// translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
|
152 |
Â
$this->plugin->admin->notice( sprintf( __( '%s class wasn\'t loaded because it doesn\'t implement the get_action_labels method.', 'stream' ), $connector->name, 'Connector' ), true );
|
153 |
Â
continue;
|
154 |
Â
}
|
155 |
Â
|
156 |
Â
// Check if the connectors extends the Connector class, if not skip it.
|
157 |
Â
if ( ! is_subclass_of( $connector, '\WP_Stream\Connector' ) ) {
|
158 |
+
// translators: Placeholder refers to a Connector class name, intended to provide help to developers (e.g. "Connector_BuddyPress")
|
159 |
Â
$this->plugin->admin->notice( sprintf( __( '%1$s class wasn\'t loaded because it doesn\'t extends the %2$s class.', 'stream' ), $connector->name, 'Connector' ), true );
|
160 |
Â
continue;
|
161 |
Â
}
|
classes/class-date-interval.php
CHANGED
@@ -25,7 +25,7 @@ class Date_Interval {
|
|
25 |
Â
}
|
26 |
Â
|
27 |
Â
/**
|
28 |
-
* @return mixed
|
29 |
Â
*/
|
30 |
Â
public function get_predefined_intervals() {
|
31 |
Â
$timezone = get_option( 'timezone_string' );
|
@@ -44,62 +44,68 @@ class Date_Interval {
|
|
44 |
Â
return apply_filters(
|
45 |
Â
'wp_stream_predefined_date_intervals',
|
46 |
Â
array(
|
47 |
-
'today'
|
48 |
Â
'label' => esc_html__( 'Today', 'stream' ),
|
49 |
Â
'start' => Carbon::today( $timezone )->startOfDay(),
|
50 |
Â
'end' => Carbon::today( $timezone )->endOfDay(),
|
51 |
Â
),
|
52 |
-
'yesterday'
|
53 |
Â
'label' => esc_html__( 'Yesterday', 'stream' ),
|
54 |
Â
'start' => Carbon::today( $timezone )->startOfDay()->subDay(),
|
55 |
Â
'end' => Carbon::today( $timezone )->startOfDay()->subSecond(),
|
56 |
Â
),
|
57 |
-
'last-7-days'
|
Â
|
|
58 |
Â
'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 7 ),
|
59 |
Â
'start' => Carbon::today( $timezone )->subDays( 7 ),
|
60 |
Â
'end' => Carbon::today( $timezone ),
|
61 |
Â
),
|
62 |
-
'last-14-days'
|
Â
|
|
63 |
Â
'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 14 ),
|
64 |
Â
'start' => Carbon::today( $timezone )->subDays( 14 ),
|
65 |
Â
'end' => Carbon::today( $timezone ),
|
66 |
Â
),
|
67 |
-
'last-30-days'
|
Â
|
|
68 |
Â
'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 30 ),
|
69 |
Â
'start' => Carbon::today( $timezone )->subDays( 30 ),
|
70 |
Â
'end' => Carbon::today( $timezone ),
|
71 |
Â
),
|
72 |
-
'this-month'
|
73 |
Â
'label' => esc_html__( 'This Month', 'stream' ),
|
74 |
Â
'start' => Carbon::today( $timezone )->startOfMonth(),
|
75 |
Â
'end' => Carbon::today( $timezone )->endOfMonth(),
|
76 |
Â
),
|
77 |
-
'last-month'
|
78 |
Â
'label' => esc_html__( 'Last Month', 'stream' ),
|
79 |
Â
'start' => Carbon::today( $timezone )->startOfMonth()->subMonth(),
|
80 |
Â
'end' => Carbon::today( $timezone )->startOfMonth()->subSecond(),
|
81 |
Â
),
|
82 |
-
'last-3-months'
|
Â
|
|
83 |
Â
'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 3 ),
|
84 |
Â
'start' => Carbon::today( $timezone )->subMonths( 3 ),
|
85 |
Â
'end' => Carbon::today( $timezone ),
|
86 |
Â
),
|
87 |
-
'last-6-months'
|
Â
|
|
88 |
Â
'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 6 ),
|
89 |
Â
'start' => Carbon::today( $timezone )->subMonths( 6 ),
|
90 |
Â
'end' => Carbon::today( $timezone ),
|
91 |
Â
),
|
92 |
Â
'last-12-months' => array(
|
Â
|
|
93 |
Â
'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 12 ),
|
94 |
Â
'start' => Carbon::today( $timezone )->subMonths( 12 ),
|
95 |
Â
'end' => Carbon::today( $timezone ),
|
96 |
Â
),
|
97 |
-
'this-year'
|
98 |
Â
'label' => esc_html__( 'This Year', 'stream' ),
|
99 |
Â
'start' => Carbon::today( $timezone )->startOfYear(),
|
100 |
Â
'end' => Carbon::today( $timezone )->endOfYear(),
|
101 |
Â
),
|
102 |
-
'last-year'
|
103 |
Â
'label' => esc_html__( 'Last Year', 'stream' ),
|
104 |
Â
'start' => Carbon::today( $timezone )->startOfYear()->subYear(),
|
105 |
Â
'end' => Carbon::today( $timezone )->startOfYear()->subSecond(),
|
25 |
Â
}
|
26 |
Â
|
27 |
Â
/**
|
28 |
+
* @return mixed
|
29 |
Â
*/
|
30 |
Â
public function get_predefined_intervals() {
|
31 |
Â
$timezone = get_option( 'timezone_string' );
|
44 |
Â
return apply_filters(
|
45 |
Â
'wp_stream_predefined_date_intervals',
|
46 |
Â
array(
|
47 |
+
'today' => array(
|
48 |
Â
'label' => esc_html__( 'Today', 'stream' ),
|
49 |
Â
'start' => Carbon::today( $timezone )->startOfDay(),
|
50 |
Â
'end' => Carbon::today( $timezone )->endOfDay(),
|
51 |
Â
),
|
52 |
+
'yesterday' => array(
|
53 |
Â
'label' => esc_html__( 'Yesterday', 'stream' ),
|
54 |
Â
'start' => Carbon::today( $timezone )->startOfDay()->subDay(),
|
55 |
Â
'end' => Carbon::today( $timezone )->startOfDay()->subSecond(),
|
56 |
Â
),
|
57 |
+
'last-7-days' => array(
|
58 |
+
// translators: Placeholder refers to a number of days (e.g. "7")
|
59 |
Â
'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 7 ),
|
60 |
Â
'start' => Carbon::today( $timezone )->subDays( 7 ),
|
61 |
Â
'end' => Carbon::today( $timezone ),
|
62 |
Â
),
|
63 |
+
'last-14-days' => array(
|
64 |
+
// translators: Placeholder refers to a number of days (e.g. "7")
|
65 |
Â
'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 14 ),
|
66 |
Â
'start' => Carbon::today( $timezone )->subDays( 14 ),
|
67 |
Â
'end' => Carbon::today( $timezone ),
|
68 |
Â
),
|
69 |
+
'last-30-days' => array(
|
70 |
+
// translators: Placeholder refers to a number of days (e.g. "7")
|
71 |
Â
'label' => sprintf( esc_html__( 'Last %d Days', 'stream' ), 30 ),
|
72 |
Â
'start' => Carbon::today( $timezone )->subDays( 30 ),
|
73 |
Â
'end' => Carbon::today( $timezone ),
|
74 |
Â
),
|
75 |
+
'this-month' => array(
|
76 |
Â
'label' => esc_html__( 'This Month', 'stream' ),
|
77 |
Â
'start' => Carbon::today( $timezone )->startOfMonth(),
|
78 |
Â
'end' => Carbon::today( $timezone )->endOfMonth(),
|
79 |
Â
),
|
80 |
+
'last-month' => array(
|
81 |
Â
'label' => esc_html__( 'Last Month', 'stream' ),
|
82 |
Â
'start' => Carbon::today( $timezone )->startOfMonth()->subMonth(),
|
83 |
Â
'end' => Carbon::today( $timezone )->startOfMonth()->subSecond(),
|
84 |
Â
),
|
85 |
+
'last-3-months' => array(
|
86 |
+
// translators: Placeholder refers to a number of months (e.g. "3")
|
87 |
Â
'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 3 ),
|
88 |
Â
'start' => Carbon::today( $timezone )->subMonths( 3 ),
|
89 |
Â
'end' => Carbon::today( $timezone ),
|
90 |
Â
),
|
91 |
+
'last-6-months' => array(
|
92 |
+
// translators: Placeholder refers to a number of months (e.g. "3")
|
93 |
Â
'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 6 ),
|
94 |
Â
'start' => Carbon::today( $timezone )->subMonths( 6 ),
|
95 |
Â
'end' => Carbon::today( $timezone ),
|
96 |
Â
),
|
97 |
Â
'last-12-months' => array(
|
98 |
+
// translators: Placeholder refers to a number of months (e.g. "3")
|
99 |
Â
'label' => sprintf( esc_html__( 'Last %d Months', 'stream' ), 12 ),
|
100 |
Â
'start' => Carbon::today( $timezone )->subMonths( 12 ),
|
101 |
Â
'end' => Carbon::today( $timezone ),
|
102 |
Â
),
|
103 |
+
'this-year' => array(
|
104 |
Â
'label' => esc_html__( 'This Year', 'stream' ),
|
105 |
Â
'start' => Carbon::today( $timezone )->startOfYear(),
|
106 |
Â
'end' => Carbon::today( $timezone )->endOfYear(),
|
107 |
Â
),
|
108 |
+
'last-year' => array(
|
109 |
Â
'label' => esc_html__( 'Last Year', 'stream' ),
|
110 |
Â
'start' => Carbon::today( $timezone )->startOfYear()->subYear(),
|
111 |
Â
'end' => Carbon::today( $timezone )->startOfYear()->subSecond(),
|
classes/class-db-driver-wpdb.php
CHANGED
File without changes
|
classes/class-db-driver.php
CHANGED
File without changes
|
classes/class-db.php
CHANGED
@@ -46,11 +46,13 @@ class DB {
|
|
46 |
Â
*/
|
47 |
Â
$record = apply_filters( 'wp_stream_record_array', $record );
|
48 |
Â
|
49 |
-
array_walk(
|
50 |
-
|
51 |
-
|
Â
|
|
Â
|
|
52 |
Â
}
|
53 |
-
|
54 |
Â
|
55 |
Â
if ( empty( $record ) ) {
|
56 |
Â
return false;
|
@@ -197,7 +199,7 @@ class DB {
|
|
197 |
Â
*/
|
198 |
Â
$args = apply_filters( 'wp_stream_query_args', $args );
|
199 |
Â
|
200 |
-
$result
|
201 |
Â
$this->found_records_count = isset( $result['count'] ) ? $result['count'] : 0;
|
202 |
Â
|
203 |
Â
return empty( $result['items'] ) ? array() : $result['items'];
|
46 |
Â
*/
|
47 |
Â
$record = apply_filters( 'wp_stream_record_array', $record );
|
48 |
Â
|
49 |
+
array_walk(
|
50 |
+
$record, function( &$value, &$key ) {
|
51 |
+
if ( ! is_array( $value ) ) {
|
52 |
+
$value = strip_tags( $value );
|
53 |
+
}
|
54 |
Â
}
|
55 |
+
);
|
56 |
Â
|
57 |
Â
if ( empty( $record ) ) {
|
58 |
Â
return false;
|
199 |
Â
*/
|
200 |
Â
$args = apply_filters( 'wp_stream_query_args', $args );
|
201 |
Â
|
202 |
+
$result = (array) $this->driver->get_records( $args );
|
203 |
Â
$this->found_records_count = isset( $result['count'] ) ? $result['count'] : 0;
|
204 |
Â
|
205 |
Â
return empty( $result['items'] ) ? array() : $result['items'];
|
classes/class-export.php
CHANGED
@@ -60,15 +60,14 @@ class Export {
|
|
60 |
Â
|
61 |
Â
$records = $list_table->get_records();
|
62 |
Â
$columns = $list_table->get_columns();
|
63 |
-
$output
|
64 |
Â
foreach ( $records as $item ) {
|
65 |
Â
$output[] = $this->build_record( $item, $columns );
|
66 |
Â
}
|
67 |
Â
|
68 |
Â
$exporters = $this->get_exporters();
|
69 |
-
$exporter
|
70 |
Â
$exporter->output_file( $output, $columns );
|
71 |
-
return;
|
72 |
Â
}
|
73 |
Â
|
74 |
Â
/**
|
@@ -76,9 +75,10 @@ class Export {
|
|
76 |
Â
*
|
77 |
Â
* @return array
|
78 |
Â
*/
|
79 |
-
function actions_menu_export_items( $action_menu_items ) {
|
80 |
Â
foreach ( $this->get_exporters() as $exporter ) {
|
81 |
Â
$action = 'export-' . $exporter->slug;
|
Â
|
|
82 |
Â
$action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'stream' ), $exporter->name );
|
83 |
Â
}
|
84 |
Â
|
@@ -92,23 +92,23 @@ class Export {
|
|
92 |
Â
* @param array $columns Columns being extracted.
|
93 |
Â
* @return array Numerically-indexed array with extracted data.
|
94 |
Â
*/
|
95 |
-
function build_record( $item, $columns ) {
|
96 |
Â
$record = new Record( $item );
|
97 |
Â
|
98 |
Â
$row_out = array();
|
99 |
Â
foreach ( array_keys( $columns ) as $column_name ) {
|
100 |
Â
switch ( $column_name ) {
|
101 |
-
case 'date'
|
102 |
-
$created
|
103 |
Â
$row_out[ $column_name ] = get_date_from_gmt( $created, 'Y/m/d h:i:s A' );
|
104 |
Â
break;
|
105 |
Â
|
106 |
-
case 'summary'
|
107 |
Â
$row_out[ $column_name ] = $record->summary;
|
108 |
Â
break;
|
109 |
Â
|
110 |
-
case 'user_id'
|
111 |
-
$user
|
112 |
Â
$row_out[ $column_name ] = $user->get_display_name();
|
113 |
Â
break;
|
114 |
Â
|
@@ -128,7 +128,7 @@ class Export {
|
|
128 |
Â
$row_out[ $column_name ] = $record->blog_id;
|
129 |
Â
break;
|
130 |
Â
|
131 |
-
case 'ip'
|
132 |
Â
$row_out[ $column_name ] = $record->{$column_name};
|
133 |
Â
break;
|
134 |
Â
}
|
@@ -141,6 +141,7 @@ class Export {
|
|
141 |
Â
* Increase pagination limit for CSV Output
|
142 |
Â
*
|
143 |
Â
* @param int $records_per_page Old limit for records_per_page.
|
Â
|
|
144 |
Â
*/
|
145 |
Â
public function disable_paginate( $records_per_page ) {
|
146 |
Â
return 10000;
|
@@ -206,12 +207,6 @@ class Export {
|
|
206 |
Â
foreach ( $this->exporters as $key => $exporter ) {
|
207 |
Â
if ( ! $this->is_valid_exporter( $exporter ) ) {
|
208 |
Â
unset( $this->exporters[ $key ] );
|
209 |
-
trigger_error(
|
210 |
-
sprintf(
|
211 |
-
esc_html__( 'Registered exporter %s does not extend WP_Stream\Exporter.', 'stream' ),
|
212 |
-
esc_html( get_class( $exporter ) )
|
213 |
-
)
|
214 |
-
);
|
215 |
Â
}
|
216 |
Â
}
|
217 |
Â
}
|
60 |
Â
|
61 |
Â
$records = $list_table->get_records();
|
62 |
Â
$columns = $list_table->get_columns();
|
63 |
+
$output = array();
|
64 |
Â
foreach ( $records as $item ) {
|
65 |
Â
$output[] = $this->build_record( $item, $columns );
|
66 |
Â
}
|
67 |
Â
|
68 |
Â
$exporters = $this->get_exporters();
|
69 |
+
$exporter = $exporters[ $output_type ];
|
70 |
Â
$exporter->output_file( $output, $columns );
|
Â
|
|
71 |
Â
}
|
72 |
Â
|
73 |
Â
/**
|
75 |
Â
*
|
76 |
Â
* @return array
|
77 |
Â
*/
|
78 |
+
public function actions_menu_export_items( $action_menu_items ) {
|
79 |
Â
foreach ( $this->get_exporters() as $exporter ) {
|
80 |
Â
$action = 'export-' . $exporter->slug;
|
81 |
+
// translators: Placeholder refers to an export format (e.g. "CSV")
|
82 |
Â
$action_menu_items[ $action ] = sprintf( __( 'Export as %s', 'stream' ), $exporter->name );
|
83 |
Â
}
|
84 |
Â
|
92 |
Â
* @param array $columns Columns being extracted.
|
93 |
Â
* @return array Numerically-indexed array with extracted data.
|
94 |
Â
*/
|
95 |
+
public function build_record( $item, $columns ) {
|
96 |
Â
$record = new Record( $item );
|
97 |
Â
|
98 |
Â
$row_out = array();
|
99 |
Â
foreach ( array_keys( $columns ) as $column_name ) {
|
100 |
Â
switch ( $column_name ) {
|
101 |
+
case 'date':
|
102 |
+
$created = date( 'Y-m-d H:i:s', strtotime( $record->created ) );
|
103 |
Â
$row_out[ $column_name ] = get_date_from_gmt( $created, 'Y/m/d h:i:s A' );
|
104 |
Â
break;
|
105 |
Â
|
106 |
+
case 'summary':
|
107 |
Â
$row_out[ $column_name ] = $record->summary;
|
108 |
Â
break;
|
109 |
Â
|
110 |
+
case 'user_id':
|
111 |
+
$user = new Author( (int) $record->user_id, (array) $record->user_meta );
|
112 |
Â
$row_out[ $column_name ] = $user->get_display_name();
|
113 |
Â
break;
|
114 |
Â
|
128 |
Â
$row_out[ $column_name ] = $record->blog_id;
|
129 |
Â
break;
|
130 |
Â
|
131 |
+
case 'ip':
|
132 |
Â
$row_out[ $column_name ] = $record->{$column_name};
|
133 |
Â
break;
|
134 |
Â
}
|
141 |
Â
* Increase pagination limit for CSV Output
|
142 |
Â
*
|
143 |
Â
* @param int $records_per_page Old limit for records_per_page.
|
144 |
+
* @return int
|
145 |
Â
*/
|
146 |
Â
public function disable_paginate( $records_per_page ) {
|
147 |
Â
return 10000;
|
207 |
Â
foreach ( $this->exporters as $key => $exporter ) {
|
208 |
Â
if ( ! $this->is_valid_exporter( $exporter ) ) {
|
209 |
Â
unset( $this->exporters[ $key ] );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
210 |
Â
}
|
211 |
Â
}
|
212 |
Â
}
|
classes/class-exporter.php
CHANGED
@@ -23,7 +23,7 @@ abstract class Exporter {
|
|
23 |
Â
* @param array $columns Column names included in data set.
|
24 |
Â
* @return void
|
25 |
Â
*/
|
26 |
-
public
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* Allow connectors to determine if their dependencies is satisfied or not
|
23 |
Â
* @param array $columns Column names included in data set.
|
24 |
Â
* @return void
|
25 |
Â
*/
|
26 |
+
abstract public function output_file( $data, $columns );
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* Allow connectors to determine if their dependencies is satisfied or not
|
classes/class-form-generator.php
CHANGED
@@ -64,15 +64,17 @@ class Form_Generator {
|
|
64 |
Â
* @return string
|
65 |
Â
*/
|
66 |
Â
public function render_field( $field_type, $args ) {
|
67 |
-
$args = wp_parse_args(
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
Â
|
|
Â
|
|
76 |
Â
|
77 |
Â
$output = '';
|
78 |
Â
switch ( $field_type ) {
|
@@ -95,7 +97,7 @@ class Form_Generator {
|
|
95 |
Â
case 'select':
|
96 |
Â
$current_value = $args['value'];
|
97 |
Â
|
98 |
-
$output
|
99 |
Â
'<select name="%1$s" class="%2$s" id="%1$s">',
|
100 |
Â
esc_attr( $args['name'] ),
|
101 |
Â
esc_attr( $args['classes'] )
|
@@ -115,7 +117,7 @@ class Form_Generator {
|
|
115 |
Â
$values = array();
|
116 |
Â
|
117 |
Â
$multiple = ( $args['multiple'] ) ? 'multiple ' : '';
|
118 |
-
$output
|
119 |
Â
'<select name="%1$s" id="%1$s" class="select2-select %2$s" %3$s%4$s>',
|
120 |
Â
esc_attr( $args['name'] ),
|
121 |
Â
esc_attr( $args['classes'] ),
|
@@ -128,11 +130,13 @@ class Form_Generator {
|
|
128 |
Â
}
|
129 |
Â
|
130 |
Â
foreach ( $args['options'] as $parent ) {
|
131 |
-
$parent = wp_parse_args(
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
Â
|
|
Â
|
|
136 |
Â
if ( empty( $parent['value'] ) ) {
|
137 |
Â
continue;
|
138 |
Â
}
|
@@ -141,7 +145,7 @@ class Form_Generator {
|
|
141 |
Â
} else {
|
142 |
Â
$selected = selected( $args['value'], $parent['value'], false );
|
143 |
Â
}
|
144 |
-
$output
|
145 |
Â
'<option class="parent" value="%1$s" %3$s>%2$s</option>',
|
146 |
Â
$parent['value'],
|
147 |
Â
$parent['text'],
|
@@ -150,7 +154,7 @@ class Form_Generator {
|
|
150 |
Â
$values[] = $parent['value'];
|
151 |
Â
if ( ! empty( $parent['children'] ) ) {
|
152 |
Â
foreach ( $parent['children'] as $child ) {
|
153 |
-
$output
|
154 |
Â
'<option class="child" value="%1$s" %3$s>%2$s</option>',
|
155 |
Â
$child['value'],
|
156 |
Â
$child['text'],
|
@@ -188,7 +192,7 @@ class Form_Generator {
|
|
188 |
Â
break;
|
189 |
Â
}
|
190 |
Â
|
191 |
-
$output .= ! empty( $args['description'] ) ?
|
192 |
Â
|
193 |
Â
return $output;
|
194 |
Â
}
|
@@ -202,7 +206,7 @@ class Form_Generator {
|
|
202 |
Â
public function prepare_data_attributes_string( $data ) {
|
203 |
Â
$output = '';
|
204 |
Â
foreach ( $data as $key => $value ) {
|
205 |
-
$key
|
206 |
Â
$output .= $key . '="' . esc_attr( $value ) . '" ';
|
207 |
Â
}
|
208 |
Â
return $output;
|
64 |
Â
* @return string
|
65 |
Â
*/
|
66 |
Â
public function render_field( $field_type, $args ) {
|
67 |
+
$args = wp_parse_args(
|
68 |
+
$args, array(
|
69 |
+
'name' => '',
|
70 |
+
'value' => '',
|
71 |
+
'options' => array(),
|
72 |
+
'description' => '',
|
73 |
+
'classes' => '',
|
74 |
+
'data' => array(),
|
75 |
+
'multiple' => false,
|
76 |
+
)
|
77 |
+
);
|
78 |
Â
|
79 |
Â
$output = '';
|
80 |
Â
switch ( $field_type ) {
|
97 |
Â
case 'select':
|
98 |
Â
$current_value = $args['value'];
|
99 |
Â
|
100 |
+
$output = sprintf(
|
101 |
Â
'<select name="%1$s" class="%2$s" id="%1$s">',
|
102 |
Â
esc_attr( $args['name'] ),
|
103 |
Â
esc_attr( $args['classes'] )
|
117 |
Â
$values = array();
|
118 |
Â
|
119 |
Â
$multiple = ( $args['multiple'] ) ? 'multiple ' : '';
|
120 |
+
$output = sprintf(
|
121 |
Â
'<select name="%1$s" id="%1$s" class="select2-select %2$s" %3$s%4$s>',
|
122 |
Â
esc_attr( $args['name'] ),
|
123 |
Â
esc_attr( $args['classes'] ),
|
130 |
Â
}
|
131 |
Â
|
132 |
Â
foreach ( $args['options'] as $parent ) {
|
133 |
+
$parent = wp_parse_args(
|
134 |
+
$parent, array(
|
135 |
+
'value' => '',
|
136 |
+
'text' => '',
|
137 |
+
'children' => array(),
|
138 |
+
)
|
139 |
+
);
|
140 |
Â
if ( empty( $parent['value'] ) ) {
|
141 |
Â
continue;
|
142 |
Â
}
|
145 |
Â
} else {
|
146 |
Â
$selected = selected( $args['value'], $parent['value'], false );
|
147 |
Â
}
|
148 |
+
$output .= sprintf(
|
149 |
Â
'<option class="parent" value="%1$s" %3$s>%2$s</option>',
|
150 |
Â
$parent['value'],
|
151 |
Â
$parent['text'],
|
154 |
Â
$values[] = $parent['value'];
|
155 |
Â
if ( ! empty( $parent['children'] ) ) {
|
156 |
Â
foreach ( $parent['children'] as $child ) {
|
157 |
+
$output .= sprintf(
|
158 |
Â
'<option class="child" value="%1$s" %3$s>%2$s</option>',
|
159 |
Â
$child['value'],
|
160 |
Â
$child['text'],
|
192 |
Â
break;
|
193 |
Â
}
|
194 |
Â
|
195 |
+
$output .= ! empty( $args['description'] ) ? sprintf( '<p class="description">%s</p>', $args['description'] ) : null;
|
196 |
Â
|
197 |
Â
return $output;
|
198 |
Â
}
|
206 |
Â
public function prepare_data_attributes_string( $data ) {
|
207 |
Â
$output = '';
|
208 |
Â
foreach ( $data as $key => $value ) {
|
209 |
+
$key = 'data-' . esc_attr( $key );
|
210 |
Â
$output .= $key . '="' . esc_attr( $value ) . '" ';
|
211 |
Â
}
|
212 |
Â
return $output;
|
classes/class-install.php
CHANGED
@@ -82,7 +82,6 @@ class Install {
|
|
82 |
Â
|
83 |
Â
if ( empty( $this->db_version ) ) {
|
84 |
Â
$this->install( $this->plugin->get_version() );
|
85 |
-
|
86 |
Â
return;
|
87 |
Â
}
|
88 |
Â
|
@@ -90,15 +89,26 @@ class Install {
|
|
90 |
Â
return;
|
91 |
Â
}
|
92 |
Â
|
93 |
-
$update =
|
Â
|
|
Â
|
|
Â
|
|
94 |
Â
|
95 |
Â
if ( ! $update ) {
|
96 |
Â
$this->update_required = true;
|
97 |
-
$this->success_db = $this->update(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
98 |
Â
}
|
99 |
Â
|
100 |
Â
if ( 'update_and_continue' === $update ) {
|
101 |
-
$this->success_db = $this->update(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
102 |
Â
}
|
103 |
Â
|
104 |
Â
$versions = $this->db_update_versions();
|
@@ -129,7 +139,7 @@ class Install {
|
|
129 |
Â
}
|
130 |
Â
|
131 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
132 |
-
require_once
|
133 |
Â
}
|
134 |
Â
|
135 |
Â
/**
|
@@ -168,9 +178,19 @@ class Install {
|
|
168 |
Â
}
|
169 |
Â
|
170 |
Â
if ( is_plugin_active_for_network( $this->plugin->locations['plugin'] ) && current_user_can( 'manage_network_plugins' ) ) {
|
171 |
-
$uninstall_message = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
172 |
Â
} elseif ( current_user_can( 'activate_plugins' ) ) {
|
173 |
-
$uninstall_message = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
174 |
Â
}
|
175 |
Â
|
176 |
Â
if ( ! empty( $database_message ) ) {
|
@@ -220,8 +240,6 @@ class Install {
|
|
220 |
Â
} else {
|
221 |
Â
update_option( $this->option_key . '_registered_connectors', $current_versions );
|
222 |
Â
}
|
223 |
-
|
224 |
-
return;
|
225 |
Â
}
|
226 |
Â
|
227 |
Â
/**
|
@@ -265,7 +283,10 @@ class Install {
|
|
265 |
Â
return;
|
266 |
Â
}
|
267 |
Â
|
268 |
-
$update =
|
Â
|
|
Â
|
|
Â
|
|
269 |
Â
|
270 |
Â
if ( ! $update ) {
|
271 |
Â
$this->prompt_update();
|
@@ -315,7 +336,16 @@ class Install {
|
|
315 |
Â
<div class="updated">
|
316 |
Â
<form method="post" action="<?php echo esc_url( remove_query_arg( 'wp_stream_update' ) ); ?>" style="display:inline;">
|
317 |
Â
<p><strong><?php esc_html_e( 'Update Complete', 'stream' ); ?></strong></p>
|
318 |
-
<p
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
319 |
Â
<?php submit_button( esc_html__( 'Continue', 'stream' ), 'secondary', false ); ?>
|
320 |
Â
</form>
|
321 |
Â
</div>
|
@@ -334,9 +364,9 @@ class Install {
|
|
334 |
Â
*/
|
335 |
Â
public function db_update_versions() {
|
336 |
Â
$db_update_versions = array(
|
337 |
-
'3.0.0' /* @version 3.0.0 Drop the stream_context table, changes to stream table
|
338 |
-
'3.0.2' /* @version 3.0.2 Fix uppercase values in stream table, connector column
|
339 |
-
'3.0.8' /* @version 3.0.8 Increase size of user role IDs, user_roll column
|
340 |
Â
);
|
341 |
Â
|
342 |
Â
/**
|
@@ -360,7 +390,7 @@ class Install {
|
|
360 |
Â
*/
|
361 |
Â
public function update( $db_version, $current_version, $update_args ) {
|
362 |
Â
$versions = $this->db_update_versions();
|
363 |
-
include_once
|
364 |
Â
|
365 |
Â
foreach ( $versions as $version ) {
|
366 |
Â
if ( ! isset( $update_args['type'] ) ) {
|
82 |
Â
|
83 |
Â
if ( empty( $this->db_version ) ) {
|
84 |
Â
$this->install( $this->plugin->get_version() );
|
Â
|
|
85 |
Â
return;
|
86 |
Â
}
|
87 |
Â
|
89 |
Â
return;
|
90 |
Â
}
|
91 |
Â
|
92 |
+
$update = null;
|
93 |
+
if ( isset( $_REQUEST['wp_stream_update'] ) && wp_verify_nonce( 'wp_stream_update_db' ) ) {
|
94 |
+
$update = esc_attr( $_REQUEST['wp_stream_update'] );
|
95 |
+
}
|
96 |
Â
|
97 |
Â
if ( ! $update ) {
|
98 |
Â
$this->update_required = true;
|
99 |
+
$this->success_db = $this->update(
|
100 |
+
$this->db_version, $this->plugin->get_version(), array(
|
101 |
+
'type' => 'auto',
|
102 |
+
)
|
103 |
+
);
|
104 |
Â
}
|
105 |
Â
|
106 |
Â
if ( 'update_and_continue' === $update ) {
|
107 |
+
$this->success_db = $this->update(
|
108 |
+
$this->db_version, $this->plugin->get_version(), array(
|
109 |
+
'type' => 'user',
|
110 |
+
)
|
111 |
+
);
|
112 |
Â
}
|
113 |
Â
|
114 |
Â
$versions = $this->db_update_versions();
|
139 |
Â
}
|
140 |
Â
|
141 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
142 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
143 |
Â
}
|
144 |
Â
|
145 |
Â
/**
|
178 |
Â
}
|
179 |
Â
|
180 |
Â
if ( is_plugin_active_for_network( $this->plugin->locations['plugin'] ) && current_user_can( 'manage_network_plugins' ) ) {
|
181 |
+
$uninstall_message = sprintf(
|
182 |
+
// translators: Placeholders refer to HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">")
|
183 |
+
__( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
|
184 |
+
'<a href="' . network_admin_url( 'plugins.php#stream' ) . '">',
|
185 |
+
'</a>'
|
186 |
+
);
|
187 |
Â
} elseif ( current_user_can( 'activate_plugins' ) ) {
|
188 |
+
$uninstall_message = sprintf(
|
189 |
+
// translators: Placeholders refer to HTML Link tags (e.g. "<a href="https://foo.com/wp-admin/">")
|
190 |
+
__( 'Please %1$suninstall%2$s the Stream plugin and activate it again.', 'stream' ),
|
191 |
+
'<a href="' . admin_url( 'plugins.php#stream' ) . '">',
|
192 |
+
'</a>'
|
193 |
+
);
|
194 |
Â
}
|
195 |
Â
|
196 |
Â
if ( ! empty( $database_message ) ) {
|
240 |
Â
} else {
|
241 |
Â
update_option( $this->option_key . '_registered_connectors', $current_versions );
|
242 |
Â
}
|
Â
|
|
Â
|
|
243 |
Â
}
|
244 |
Â
|
245 |
Â
/**
|
283 |
Â
return;
|
284 |
Â
}
|
285 |
Â
|
286 |
+
$update = null;
|
287 |
+
if ( isset( $_REQUEST['wp_stream_update'] ) && wp_verify_nonce( 'wp_stream_update_db' ) ) {
|
288 |
+
$update = esc_attr( $_REQUEST['wp_stream_update'] );
|
289 |
+
}
|
290 |
Â
|
291 |
Â
if ( ! $update ) {
|
292 |
Â
$this->prompt_update();
|
336 |
Â
<div class="updated">
|
337 |
Â
<form method="post" action="<?php echo esc_url( remove_query_arg( 'wp_stream_update' ) ); ?>" style="display:inline;">
|
338 |
Â
<p><strong><?php esc_html_e( 'Update Complete', 'stream' ); ?></strong></p>
|
339 |
+
<p>
|
340 |
+
<?php
|
341 |
+
printf(
|
342 |
+
// translators: Placeholders refer to version numbers (e.g. "4.2")
|
343 |
+
esc_html__( 'Your Stream database has been successfully updated from %1$s to %2$s!', 'stream' ),
|
344 |
+
esc_html( $this->db_version ),
|
345 |
+
esc_html( $this->plugin->get_version() )
|
346 |
+
);
|
347 |
+
?>
|
348 |
+
</p>
|
349 |
Â
<?php submit_button( esc_html__( 'Continue', 'stream' ), 'secondary', false ); ?>
|
350 |
Â
</form>
|
351 |
Â
</div>
|
364 |
Â
*/
|
365 |
Â
public function db_update_versions() {
|
366 |
Â
$db_update_versions = array(
|
367 |
+
'3.0.0', /* @version 3.0.0 Drop the stream_context table, changes to stream table */
|
368 |
+
'3.0.2', /* @version 3.0.2 Fix uppercase values in stream table, connector column */
|
369 |
+
'3.0.8', /* @version 3.0.8 Increase size of user role IDs, user_roll column */
|
370 |
Â
);
|
371 |
Â
|
372 |
Â
/**
|
390 |
Â
*/
|
391 |
Â
public function update( $db_version, $current_version, $update_args ) {
|
392 |
Â
$versions = $this->db_update_versions();
|
393 |
+
include_once $this->plugin->locations['inc_dir'] . 'db-updates.php';
|
394 |
Â
|
395 |
Â
foreach ( $versions as $version ) {
|
396 |
Â
if ( ! isset( $update_args['type'] ) ) {
|
classes/class-list-table.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
class List_Table extends \WP_List_Table {
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Hold Plugin class
|
7 |
Â
*
|
@@ -15,7 +17,7 @@ class List_Table extends \WP_List_Table {
|
|
15 |
Â
* @param Plugin $plugin The main Plugin class.
|
16 |
Â
* @param array $args
|
17 |
Â
*/
|
18 |
-
function __construct( $plugin, $args = array() ) {
|
19 |
Â
$this->plugin = $plugin;
|
20 |
Â
|
21 |
Â
$screen_id = isset( $args['screen'] ) ? $args['screen'] : null;
|
@@ -47,19 +49,25 @@ class List_Table extends \WP_List_Table {
|
|
47 |
Â
// Check for default hidden columns
|
48 |
Â
$this->get_hidden_columns();
|
49 |
Â
|
50 |
-
add_filter( 'screen_settings', array(
|
51 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
52 |
Â
|
53 |
Â
set_screen_options();
|
54 |
Â
}
|
55 |
Â
|
56 |
-
function extra_tablenav( $which ) {
|
57 |
Â
if ( 'top' === $which ) {
|
58 |
Â
echo $this->filters_form(); // xss ok
|
59 |
Â
}
|
60 |
Â
}
|
61 |
Â
|
62 |
-
function no_items() {
|
63 |
Â
?>
|
64 |
Â
<div class="stream-list-table-no-items">
|
65 |
Â
<p><?php esc_html_e( 'Sorry, no activity records were found.', 'stream' ); ?></p>
|
@@ -67,7 +75,7 @@ class List_Table extends \WP_List_Table {
|
|
67 |
Â
<?php
|
68 |
Â
}
|
69 |
Â
|
70 |
-
function get_columns() {
|
71 |
Â
/**
|
72 |
Â
* Allows devs to add new columns to table
|
73 |
Â
*
|
@@ -86,14 +94,15 @@ class List_Table extends \WP_List_Table {
|
|
86 |
Â
);
|
87 |
Â
}
|
88 |
Â
|
89 |
-
function get_sortable_columns() {
|
90 |
Â
return array(
|
91 |
Â
'date' => array( 'date', false ),
|
92 |
Â
);
|
93 |
Â
}
|
94 |
Â
|
95 |
-
function get_hidden_columns() {
|
96 |
-
|
Â
|
|
97 |
Â
return array();
|
98 |
Â
}
|
99 |
Â
|
@@ -109,13 +118,18 @@ class List_Table extends \WP_List_Table {
|
|
109 |
Â
return $hidden;
|
110 |
Â
}
|
111 |
Â
|
112 |
-
function prepare_items() {
|
113 |
Â
$columns = $this->get_columns();
|
114 |
Â
$sortable = $this->get_sortable_columns();
|
115 |
Â
$hidden = $this->get_hidden_columns();
|
116 |
Â
$primary = $columns['summary'];
|
117 |
Â
|
118 |
-
$this->_column_headers = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
119 |
Â
|
120 |
Â
$this->items = $this->get_records();
|
121 |
Â
|
@@ -129,15 +143,17 @@ class List_Table extends \WP_List_Table {
|
|
129 |
Â
);
|
130 |
Â
}
|
131 |
Â
|
132 |
-
function get_records() {
|
133 |
Â
$args = array();
|
134 |
Â
|
135 |
Â
// Parse sorting params
|
136 |
-
|
Â
|
|
137 |
Â
$args['order'] = $order;
|
138 |
Â
}
|
139 |
Â
|
140 |
-
|
Â
|
|
141 |
Â
$args['orderby'] = $orderby;
|
142 |
Â
}
|
143 |
Â
|
@@ -207,6 +223,7 @@ class List_Table extends \WP_List_Table {
|
|
207 |
Â
$args['records_per_page'] = apply_filters( 'stream_records_per_page', $args['records_per_page'] );
|
208 |
Â
|
209 |
Â
$items = $this->plugin->db->get_records( $args );
|
Â
|
|
210 |
Â
return $items;
|
211 |
Â
}
|
212 |
Â
|
@@ -219,26 +236,27 @@ class List_Table extends \WP_List_Table {
|
|
219 |
Â
return $this->plugin->db->get_found_records_count();
|
220 |
Â
}
|
221 |
Â
|
222 |
-
function column_default( $item, $column_name ) {
|
223 |
-
$out
|
224 |
Â
$record = new Record( $item );
|
225 |
Â
|
226 |
Â
switch ( $column_name ) {
|
227 |
-
case 'date'
|
228 |
Â
$created = date( 'Y-m-d H:i:s', strtotime( $record->created ) );
|
229 |
Â
$date_string = sprintf(
|
230 |
Â
'<time datetime="%s" class="relative-time record-created">%s</time>',
|
231 |
Â
wp_stream_get_iso_8601_extended_date( strtotime( $record->created ) ),
|
232 |
Â
get_date_from_gmt( $created, 'Y/m/d' )
|
233 |
Â
);
|
234 |
-
$out
|
235 |
-
$out
|
236 |
-
$out
|
237 |
Â
break;
|
238 |
Â
|
239 |
-
case 'summary'
|
240 |
-
$out
|
241 |
-
$object_title
|
Â
|
|
242 |
Â
$view_all_text = $object_title ? sprintf( esc_html__( 'View all activity for "%s"', 'stream' ), esc_attr( $object_title ) ) : esc_html__( 'View all activity for this object', 'stream' );
|
243 |
Â
|
244 |
Â
if ( $record->object_id ) {
|
@@ -255,7 +273,7 @@ class List_Table extends \WP_List_Table {
|
|
255 |
Â
$out .= $this->get_action_links( $record );
|
256 |
Â
break;
|
257 |
Â
|
258 |
-
case 'user_id'
|
259 |
Â
$user = new Author( (int) $record->user_id, (array) $record->user_meta );
|
260 |
Â
|
261 |
Â
$filtered_records_url = add_query_arg(
|
@@ -301,18 +319,19 @@ class List_Table extends \WP_List_Table {
|
|
301 |
Â
$out = $this->column_link( $blog->blogname, 'blog_id', $blog->blog_id );
|
302 |
Â
break;
|
303 |
Â
|
304 |
-
case 'ip'
|
305 |
Â
$out = $this->column_link( $record->{$column_name}, 'ip', $record->{$column_name} );
|
306 |
Â
break;
|
307 |
Â
|
308 |
-
default
|
309 |
Â
/**
|
310 |
Â
* Registers new Columns to be inserted into the table. The cell contents of this column is set
|
311 |
Â
* below with 'wp_stream_insert_column_default_'
|
312 |
Â
*
|
313 |
Â
* @return array
|
314 |
Â
*/
|
315 |
-
$
|
Â
|
|
316 |
Â
|
317 |
Â
if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
|
318 |
Â
foreach ( $inserted_columns as $column_title ) {
|
@@ -328,7 +347,7 @@ class List_Table extends \WP_List_Table {
|
|
328 |
Â
/**
|
329 |
Â
* Allows for the addition of content under a specified column.
|
330 |
Â
*
|
331 |
-
* @param object $record
|
332 |
Â
*
|
333 |
Â
* @return string
|
334 |
Â
*/
|
@@ -342,8 +361,11 @@ class List_Table extends \WP_List_Table {
|
|
342 |
Â
}
|
343 |
Â
}
|
344 |
Â
|
345 |
-
$allowed_tags
|
346 |
-
$allowed_tags['time']
|
Â
|
|
Â
|
|
Â
|
|
347 |
Â
$allowed_tags['img']['srcset'] = true;
|
348 |
Â
|
349 |
Â
echo wp_kses( $out, $allowed_tags );
|
@@ -402,7 +424,7 @@ class List_Table extends \WP_List_Table {
|
|
402 |
Â
return $out;
|
403 |
Â
}
|
404 |
Â
|
405 |
-
function column_link( $display, $key, $value = null, $title = null ) {
|
406 |
Â
$url = add_query_arg(
|
407 |
Â
array(
|
408 |
Â
'page' => $this->plugin->admin->records_page_slug,
|
@@ -410,7 +432,9 @@ class List_Table extends \WP_List_Table {
|
|
410 |
Â
self_admin_url( $this->plugin->admin->admin_parent_page )
|
411 |
Â
);
|
412 |
Â
|
413 |
-
$args = ! is_array( $key ) ? array(
|
Â
|
|
Â
|
|
414 |
Â
|
415 |
Â
foreach ( $args as $k => $v ) {
|
416 |
Â
$url = add_query_arg( $k, $v, $url );
|
@@ -425,11 +449,11 @@ class List_Table extends \WP_List_Table {
|
|
425 |
Â
}
|
426 |
Â
|
427 |
Â
public function get_term_title( $term, $type ) {
|
428 |
-
if ( ! isset( $this->plugin->connectors->term_labels[
|
429 |
Â
return $term;
|
430 |
Â
}
|
431 |
Â
|
432 |
-
return $this->plugin->connectors->term_labels[
|
433 |
Â
}
|
434 |
Â
|
435 |
Â
/**
|
@@ -443,7 +467,7 @@ class List_Table extends \WP_List_Table {
|
|
443 |
Â
*
|
444 |
Â
* @return array Options to be displayed in search filters
|
445 |
Â
*/
|
446 |
-
function assemble_records( $column ) {
|
447 |
Â
// @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object
|
448 |
Â
if ( 'user_id' === $column ) {
|
449 |
Â
$all_records = array();
|
@@ -456,31 +480,43 @@ class List_Table extends \WP_List_Table {
|
|
456 |
Â
$selected_user = wp_stream_filter_input( INPUT_GET, 'user_id' );
|
457 |
Â
if ( $selected_user ) {
|
458 |
Â
$user = new Author( $selected_user );
|
459 |
-
|
Â
|
|
Â
|
|
Â
|
|
460 |
Â
} else {
|
461 |
Â
return array();
|
462 |
Â
}
|
463 |
Â
}
|
464 |
Â
|
465 |
Â
$users = array_map(
|
466 |
-
function( $user_id ) {
|
467 |
Â
return new Author( $user_id );
|
468 |
Â
},
|
469 |
-
get_users(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
470 |
Â
);
|
471 |
Â
|
472 |
Â
if ( is_multisite() && is_super_admin() ) {
|
473 |
Â
$super_admins = array_map(
|
474 |
-
function( $login ) {
|
475 |
Â
$user = get_user_by( 'login', $login );
|
Â
|
|
476 |
Â
return new Author( $user->ID );
|
477 |
Â
},
|
478 |
Â
get_super_admins()
|
479 |
Â
);
|
480 |
-
$users
|
481 |
Â
}
|
482 |
Â
|
483 |
-
$users[] = new Author(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
484 |
Â
|
485 |
Â
foreach ( $users as $user ) {
|
486 |
Â
$all_records[ $user->id ] = $user->get_display_name();
|
@@ -496,9 +532,15 @@ class List_Table extends \WP_List_Table {
|
|
496 |
Â
|
497 |
Â
foreach ( $all_records as $record => $label ) {
|
498 |
Â
if ( array_key_exists( $record, $existing_records ) ) {
|
499 |
-
$active_records[ $record ] = array(
|
Â
|
|
Â
|
|
Â
|
|
500 |
Â
} else {
|
501 |
-
$disabled_records[ $record ] = array(
|
Â
|
|
Â
|
|
Â
|
|
502 |
Â
}
|
503 |
Â
}
|
504 |
Â
|
@@ -507,7 +549,7 @@ class List_Table extends \WP_List_Table {
|
|
507 |
Â
unset( $disabled_records[0] );
|
508 |
Â
}
|
509 |
Â
|
510 |
-
$sort = function( $a, $b ) use ( $column ) {
|
511 |
Â
$label_a = (string) $a['label'];
|
512 |
Â
$label_b = (string) $b['label'];
|
513 |
Â
|
@@ -515,7 +557,7 @@ class List_Table extends \WP_List_Table {
|
|
515 |
Â
return 0;
|
516 |
Â
}
|
517 |
Â
|
518 |
-
return ( strtolower( $label_a ) < strtolower( $label_b ) ) ? -1 : 1;
|
519 |
Â
};
|
520 |
Â
|
521 |
Â
uasort( $active_records, $sort );
|
@@ -567,7 +609,7 @@ class List_Table extends \WP_List_Table {
|
|
567 |
Â
return apply_filters( 'wp_stream_list_table_filters', $filters );
|
568 |
Â
}
|
569 |
Â
|
570 |
-
function filters_form() {
|
571 |
Â
$filters = $this->get_filters();
|
572 |
Â
|
573 |
Â
$filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
|
@@ -575,11 +617,13 @@ class List_Table extends \WP_List_Table {
|
|
575 |
Â
|
576 |
Â
foreach ( $filters as $name => $data ) {
|
577 |
Â
|
578 |
-
$data = wp_parse_args(
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
Â
|
|
Â
|
|
583 |
Â
|
584 |
Â
if ( 'date' === $name ) {
|
585 |
Â
$filters_string .= $this->filter_date( $data['items'] );
|
@@ -661,7 +705,7 @@ class List_Table extends \WP_List_Table {
|
|
661 |
Â
return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok
|
662 |
Â
}
|
663 |
Â
|
664 |
-
function filter_select( $name, $title, $items, $ajax = false ) {
|
665 |
Â
if ( $ajax ) {
|
666 |
Â
$out = sprintf(
|
667 |
Â
'<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />',
|
@@ -685,11 +729,11 @@ class List_Table extends \WP_List_Table {
|
|
685 |
Â
'class' => isset( $item['children'] ) ? 'level-1' : null,
|
686 |
Â
'label' => isset( $item['label'] ) ? $item['label'] : null,
|
687 |
Â
);
|
688 |
-
$options[]
|
689 |
Â
|
690 |
Â
if ( isset( $item['children'] ) ) {
|
691 |
Â
foreach ( $item['children'] as $child_value => $child_item ) {
|
692 |
-
$option_args
|
693 |
Â
'value' => $child_value,
|
694 |
Â
'selected' => selected( $child_value, $selected, false ),
|
695 |
Â
'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
|
@@ -699,13 +743,14 @@ class List_Table extends \WP_List_Table {
|
|
699 |
Â
'class' => 'level-2',
|
700 |
Â
'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
|
701 |
Â
);
|
702 |
-
$options[]
|
703 |
Â
}
|
704 |
Â
}
|
705 |
Â
}
|
706 |
Â
$out = sprintf(
|
707 |
Â
'<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
|
708 |
Â
esc_attr( $name ),
|
Â
|
|
709 |
Â
sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ),
|
710 |
Â
implode( '', $options )
|
711 |
Â
);
|
@@ -714,7 +759,7 @@ class List_Table extends \WP_List_Table {
|
|
714 |
Â
return $out;
|
715 |
Â
}
|
716 |
Â
|
717 |
-
function filter_option( $args ) {
|
718 |
Â
$defaults = array(
|
719 |
Â
'value' => null,
|
720 |
Â
'selected' => null,
|
@@ -740,11 +785,10 @@ class List_Table extends \WP_List_Table {
|
|
740 |
Â
);
|
741 |
Â
}
|
742 |
Â
|
743 |
-
function filter_search() {
|
744 |
Â
$search = null;
|
745 |
-
if ( isset( $_GET['search'] ) ) {
|
746 |
-
//
|
747 |
-
$search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay
|
748 |
Â
}
|
749 |
Â
$out = sprintf(
|
750 |
Â
'<p class="search-box">
|
@@ -759,7 +803,7 @@ class List_Table extends \WP_List_Table {
|
|
759 |
Â
return $out;
|
760 |
Â
}
|
761 |
Â
|
762 |
-
function filter_date( $items ) {
|
763 |
Â
wp_enqueue_style( 'jquery-ui' );
|
764 |
Â
wp_enqueue_style( 'wp-stream-datepicker' );
|
765 |
Â
wp_enqueue_script( 'jquery-ui-datepicker' );
|
@@ -794,13 +838,13 @@ class List_Table extends \WP_List_Table {
|
|
794 |
Â
<div class="date-inputs">
|
795 |
Â
<div class="box">
|
796 |
Â
<i class="date-remove dashicons"></i>
|
797 |
-
<input type="text" name="date_from" class="date-picker field-from" placeholder="<?php esc_attr_e( 'Start Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_from ); ?>"
|
798 |
Â
</div>
|
799 |
Â
<span class="connector dashicons"></span>
|
800 |
Â
|
801 |
Â
<div class="box">
|
802 |
Â
<i class="date-remove dashicons"></i>
|
803 |
-
<input type="text" name="date_to" class="date-picker field-to" placeholder="<?php esc_attr_e( 'End Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_to ); ?>"
|
804 |
Â
</div>
|
805 |
Â
</div>
|
806 |
Â
|
@@ -815,7 +859,7 @@ class List_Table extends \WP_List_Table {
|
|
815 |
Â
*
|
816 |
Â
* @return string
|
817 |
Â
*/
|
818 |
-
function record_actions_form() {
|
819 |
Â
/**
|
820 |
Â
* Filter the records screen actions dropdown menu
|
821 |
Â
*
|
@@ -855,7 +899,7 @@ class List_Table extends \WP_List_Table {
|
|
855 |
Â
return ob_get_clean();
|
856 |
Â
}
|
857 |
Â
|
858 |
-
function display() {
|
859 |
Â
$url = self_admin_url( $this->plugin->admin->admin_parent_page );
|
860 |
Â
|
861 |
Â
echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">';
|
@@ -868,7 +912,7 @@ class List_Table extends \WP_List_Table {
|
|
868 |
Â
echo '</form>';
|
869 |
Â
}
|
870 |
Â
|
871 |
-
function single_row( $item ) {
|
872 |
Â
$classes = apply_filters( 'wp_stream_record_classes', array(), $item );
|
873 |
Â
$class_string = '';
|
874 |
Â
if ( ! empty( $classes ) ) {
|
@@ -880,15 +924,16 @@ class List_Table extends \WP_List_Table {
|
|
880 |
Â
echo '</tr>';
|
881 |
Â
}
|
882 |
Â
|
883 |
-
function display_tablenav( $which ) {
|
884 |
-
if ( 'top' === $which ) :
|
Â
|
|
885 |
Â
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
886 |
Â
<?php
|
887 |
Â
$this->pagination( $which );
|
888 |
Â
$this->extra_tablenav( $which );
|
889 |
Â
?>
|
890 |
Â
|
891 |
-
<br class="clear"
|
892 |
Â
</div>
|
893 |
Â
<?php else : ?>
|
894 |
Â
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
@@ -901,13 +946,13 @@ class List_Table extends \WP_List_Table {
|
|
901 |
Â
$this->extra_tablenav( $which );
|
902 |
Â
?>
|
903 |
Â
|
904 |
-
<br class="clear"
|
905 |
Â
</div>
|
906 |
-
|
907 |
Â
endif;
|
908 |
Â
}
|
909 |
Â
|
910 |
-
function set_screen_option( $dummy, $option, $value ) {
|
911 |
Â
if ( 'edit_stream_per_page' === $option ) {
|
912 |
Â
return $value;
|
913 |
Â
} else {
|
@@ -915,7 +960,7 @@ class List_Table extends \WP_List_Table {
|
|
915 |
Â
}
|
916 |
Â
}
|
917 |
Â
|
918 |
-
function set_live_update_option( $dummy, $option, $value ) {
|
919 |
Â
unset( $value );
|
920 |
Â
|
921 |
Â
// @codingStandardsIgnoreStart
|
@@ -928,6 +973,7 @@ class List_Table extends \WP_List_Table {
|
|
928 |
Â
|
929 |
Â
return $value;
|
930 |
Â
}
|
Â
|
|
931 |
Â
// @codingStandardsIgnoreEnd
|
932 |
Â
|
933 |
Â
return $dummy;
|
@@ -955,15 +1001,16 @@ class List_Table extends \WP_List_Table {
|
|
955 |
Â
<h5><?php esc_html_e( 'Live updates', 'stream' ); ?></h5>
|
956 |
Â
|
957 |
Â
<div>
|
958 |
-
<input type="hidden" name="stream_live_update_nonce" id="stream_live_update_nonce" value="<?php echo esc_attr( $nonce ); ?>"
|
959 |
Â
</div>
|
960 |
Â
<div>
|
961 |
-
<input type="hidden" name="enable_live_update_user" id="enable_live_update_user" value="<?php echo absint( $user_id ); ?>"
|
962 |
Â
</div>
|
963 |
Â
<div class="metabox-prefs stream-live-update-checkbox">
|
964 |
Â
<label for="enable_live_update">
|
965 |
Â
<input type="checkbox" value="on" name="enable_live_update" id="enable_live_update" data-heartbeat="<?php echo esc_attr( $heartbeat ); ?>" <?php checked( $option, 'on' ); ?> />
|
966 |
-
<?php esc_html_e( 'Enabled', 'stream' );
|
Â
|
|
967 |
Â
</label>
|
968 |
Â
</div>
|
969 |
Â
</fieldset>
|
@@ -978,7 +1025,7 @@ class List_Table extends \WP_List_Table {
|
|
978 |
Â
*
|
979 |
Â
* @return string setting name for that column
|
980 |
Â
*/
|
981 |
-
function get_column_excluded_setting_key( $column ) {
|
982 |
Â
switch ( $column ) {
|
983 |
Â
case 'connector':
|
984 |
Â
$output = 'connectors';
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
class List_Table extends \WP_List_Table {
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Hold Plugin class
|
9 |
Â
*
|
17 |
Â
* @param Plugin $plugin The main Plugin class.
|
18 |
Â
* @param array $args
|
19 |
Â
*/
|
20 |
+
public function __construct( $plugin, $args = array() ) {
|
21 |
Â
$this->plugin = $plugin;
|
22 |
Â
|
23 |
Â
$screen_id = isset( $args['screen'] ) ? $args['screen'] : null;
|
49 |
Â
// Check for default hidden columns
|
50 |
Â
$this->get_hidden_columns();
|
51 |
Â
|
52 |
+
add_filter( 'screen_settings', array(
|
53 |
+
$this,
|
54 |
+
'screen_controls',
|
55 |
+
), 10, 2 );
|
56 |
+
add_filter( 'set-screen-option', array(
|
57 |
+
$this,
|
58 |
+
'set_screen_option',
|
59 |
+
), 10, 3 );
|
60 |
Â
|
61 |
Â
set_screen_options();
|
62 |
Â
}
|
63 |
Â
|
64 |
+
public function extra_tablenav( $which ) {
|
65 |
Â
if ( 'top' === $which ) {
|
66 |
Â
echo $this->filters_form(); // xss ok
|
67 |
Â
}
|
68 |
Â
}
|
69 |
Â
|
70 |
+
public function no_items() {
|
71 |
Â
?>
|
72 |
Â
<div class="stream-list-table-no-items">
|
73 |
Â
<p><?php esc_html_e( 'Sorry, no activity records were found.', 'stream' ); ?></p>
|
75 |
Â
<?php
|
76 |
Â
}
|
77 |
Â
|
78 |
+
public function get_columns() {
|
79 |
Â
/**
|
80 |
Â
* Allows devs to add new columns to table
|
81 |
Â
*
|
94 |
Â
);
|
95 |
Â
}
|
96 |
Â
|
97 |
+
public function get_sortable_columns() {
|
98 |
Â
return array(
|
99 |
Â
'date' => array( 'date', false ),
|
100 |
Â
);
|
101 |
Â
}
|
102 |
Â
|
103 |
+
public function get_hidden_columns() {
|
104 |
+
$user = wp_get_current_user();
|
105 |
+
if ( ! $user ) {
|
106 |
Â
return array();
|
107 |
Â
}
|
108 |
Â
|
118 |
Â
return $hidden;
|
119 |
Â
}
|
120 |
Â
|
121 |
+
public function prepare_items() {
|
122 |
Â
$columns = $this->get_columns();
|
123 |
Â
$sortable = $this->get_sortable_columns();
|
124 |
Â
$hidden = $this->get_hidden_columns();
|
125 |
Â
$primary = $columns['summary'];
|
126 |
Â
|
127 |
+
$this->_column_headers = array(
|
128 |
+
$columns,
|
129 |
+
$hidden,
|
130 |
+
$sortable,
|
131 |
+
$primary,
|
132 |
+
);
|
133 |
Â
|
134 |
Â
$this->items = $this->get_records();
|
135 |
Â
|
143 |
Â
);
|
144 |
Â
}
|
145 |
Â
|
146 |
+
public function get_records() {
|
147 |
Â
$args = array();
|
148 |
Â
|
149 |
Â
// Parse sorting params
|
150 |
+
$order = wp_stream_filter_input( INPUT_GET, 'order' );
|
151 |
+
if ( $order ) {
|
152 |
Â
$args['order'] = $order;
|
153 |
Â
}
|
154 |
Â
|
155 |
+
$orderby = wp_stream_filter_input( INPUT_GET, 'orderby' );
|
156 |
+
if ( $orderby ) {
|
157 |
Â
$args['orderby'] = $orderby;
|
158 |
Â
}
|
159 |
Â
|
223 |
Â
$args['records_per_page'] = apply_filters( 'stream_records_per_page', $args['records_per_page'] );
|
224 |
Â
|
225 |
Â
$items = $this->plugin->db->get_records( $args );
|
226 |
+
|
227 |
Â
return $items;
|
228 |
Â
}
|
229 |
Â
|
236 |
Â
return $this->plugin->db->get_found_records_count();
|
237 |
Â
}
|
238 |
Â
|
239 |
+
public function column_default( $item, $column_name ) {
|
240 |
+
$out = '';
|
241 |
Â
$record = new Record( $item );
|
242 |
Â
|
243 |
Â
switch ( $column_name ) {
|
244 |
+
case 'date':
|
245 |
Â
$created = date( 'Y-m-d H:i:s', strtotime( $record->created ) );
|
246 |
Â
$date_string = sprintf(
|
247 |
Â
'<time datetime="%s" class="relative-time record-created">%s</time>',
|
248 |
Â
wp_stream_get_iso_8601_extended_date( strtotime( $record->created ) ),
|
249 |
Â
get_date_from_gmt( $created, 'Y/m/d' )
|
250 |
Â
);
|
251 |
+
$out = $this->column_link( $date_string, 'date', get_date_from_gmt( $created, 'Y/m/d' ) );
|
252 |
+
$out .= '<br />';
|
253 |
+
$out .= get_date_from_gmt( $created, 'h:i:s A' );
|
254 |
Â
break;
|
255 |
Â
|
256 |
+
case 'summary':
|
257 |
+
$out = $record->summary;
|
258 |
+
$object_title = $record->get_object_title();
|
259 |
+
// translators: Placeholder refers to the title of any object, like a Post (e.g. "Hello World")
|
260 |
Â
$view_all_text = $object_title ? sprintf( esc_html__( 'View all activity for "%s"', 'stream' ), esc_attr( $object_title ) ) : esc_html__( 'View all activity for this object', 'stream' );
|
261 |
Â
|
262 |
Â
if ( $record->object_id ) {
|
273 |
Â
$out .= $this->get_action_links( $record );
|
274 |
Â
break;
|
275 |
Â
|
276 |
+
case 'user_id':
|
277 |
Â
$user = new Author( (int) $record->user_id, (array) $record->user_meta );
|
278 |
Â
|
279 |
Â
$filtered_records_url = add_query_arg(
|
319 |
Â
$out = $this->column_link( $blog->blogname, 'blog_id', $blog->blog_id );
|
320 |
Â
break;
|
321 |
Â
|
322 |
+
case 'ip':
|
323 |
Â
$out = $this->column_link( $record->{$column_name}, 'ip', $record->{$column_name} );
|
324 |
Â
break;
|
325 |
Â
|
326 |
+
default:
|
327 |
Â
/**
|
328 |
Â
* Registers new Columns to be inserted into the table. The cell contents of this column is set
|
329 |
Â
* below with 'wp_stream_insert_column_default_'
|
330 |
Â
*
|
331 |
Â
* @return array
|
332 |
Â
*/
|
333 |
+
$new_columns = array();
|
334 |
+
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns );
|
335 |
Â
|
336 |
Â
if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
|
337 |
Â
foreach ( $inserted_columns as $column_title ) {
|
347 |
Â
/**
|
348 |
Â
* Allows for the addition of content under a specified column.
|
349 |
Â
*
|
350 |
+
* @param object $record Contents of the row
|
351 |
Â
*
|
352 |
Â
* @return string
|
353 |
Â
*/
|
361 |
Â
}
|
362 |
Â
}
|
363 |
Â
|
364 |
+
$allowed_tags = wp_kses_allowed_html( 'post' );
|
365 |
+
$allowed_tags['time'] = array(
|
366 |
+
'datetime' => true,
|
367 |
+
'class' => true,
|
368 |
+
);
|
369 |
Â
$allowed_tags['img']['srcset'] = true;
|
370 |
Â
|
371 |
Â
echo wp_kses( $out, $allowed_tags );
|
424 |
Â
return $out;
|
425 |
Â
}
|
426 |
Â
|
427 |
+
public function column_link( $display, $key, $value = null, $title = null ) {
|
428 |
Â
$url = add_query_arg(
|
429 |
Â
array(
|
430 |
Â
'page' => $this->plugin->admin->records_page_slug,
|
432 |
Â
self_admin_url( $this->plugin->admin->admin_parent_page )
|
433 |
Â
);
|
434 |
Â
|
435 |
+
$args = ! is_array( $key ) ? array(
|
436 |
+
$key => $value,
|
437 |
+
) : $key;
|
438 |
Â
|
439 |
Â
foreach ( $args as $k => $v ) {
|
440 |
Â
$url = add_query_arg( $k, $v, $url );
|
449 |
Â
}
|
450 |
Â
|
451 |
Â
public function get_term_title( $term, $type ) {
|
452 |
+
if ( ! isset( $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ] ) ) {
|
453 |
Â
return $term;
|
454 |
Â
}
|
455 |
Â
|
456 |
+
return $this->plugin->connectors->term_labels[ 'stream_' . $type ][ $term ];
|
457 |
Â
}
|
458 |
Â
|
459 |
Â
/**
|
467 |
Â
*
|
468 |
Â
* @return array Options to be displayed in search filters
|
469 |
Â
*/
|
470 |
+
public function assemble_records( $column ) {
|
471 |
Â
// @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object
|
472 |
Â
if ( 'user_id' === $column ) {
|
473 |
Â
$all_records = array();
|
480 |
Â
$selected_user = wp_stream_filter_input( INPUT_GET, 'user_id' );
|
481 |
Â
if ( $selected_user ) {
|
482 |
Â
$user = new Author( $selected_user );
|
483 |
+
|
484 |
+
return array(
|
485 |
+
$selected_user => $user->get_display_name(),
|
486 |
+
);
|
487 |
Â
} else {
|
488 |
Â
return array();
|
489 |
Â
}
|
490 |
Â
}
|
491 |
Â
|
492 |
Â
$users = array_map(
|
493 |
+
function ( $user_id ) {
|
494 |
Â
return new Author( $user_id );
|
495 |
Â
},
|
496 |
+
get_users(
|
497 |
+
array(
|
498 |
+
'fields' => 'ID',
|
499 |
+
)
|
500 |
+
)
|
501 |
Â
);
|
502 |
Â
|
503 |
Â
if ( is_multisite() && is_super_admin() ) {
|
504 |
Â
$super_admins = array_map(
|
505 |
+
function ( $login ) {
|
506 |
Â
$user = get_user_by( 'login', $login );
|
507 |
+
|
508 |
Â
return new Author( $user->ID );
|
509 |
Â
},
|
510 |
Â
get_super_admins()
|
511 |
Â
);
|
512 |
+
$users = array_unique( array_merge( $users, $super_admins ) );
|
513 |
Â
}
|
514 |
Â
|
515 |
+
$users[] = new Author(
|
516 |
+
0, array(
|
517 |
+
'is_wp_cli' => true,
|
518 |
+
)
|
519 |
+
);
|
520 |
Â
|
521 |
Â
foreach ( $users as $user ) {
|
522 |
Â
$all_records[ $user->id ] = $user->get_display_name();
|
532 |
Â
|
533 |
Â
foreach ( $all_records as $record => $label ) {
|
534 |
Â
if ( array_key_exists( $record, $existing_records ) ) {
|
535 |
+
$active_records[ $record ] = array(
|
536 |
+
'label' => $label,
|
537 |
+
'disabled' => '',
|
538 |
+
);
|
539 |
Â
} else {
|
540 |
+
$disabled_records[ $record ] = array(
|
541 |
+
'label' => $label,
|
542 |
+
'disabled' => 'disabled="disabled"',
|
543 |
+
);
|
544 |
Â
}
|
545 |
Â
}
|
546 |
Â
|
549 |
Â
unset( $disabled_records[0] );
|
550 |
Â
}
|
551 |
Â
|
552 |
+
$sort = function ( $a, $b ) use ( $column ) {
|
553 |
Â
$label_a = (string) $a['label'];
|
554 |
Â
$label_b = (string) $b['label'];
|
555 |
Â
|
557 |
Â
return 0;
|
558 |
Â
}
|
559 |
Â
|
560 |
+
return ( strtolower( $label_a ) < strtolower( $label_b ) ) ? - 1 : 1;
|
561 |
Â
};
|
562 |
Â
|
563 |
Â
uasort( $active_records, $sort );
|
609 |
Â
return apply_filters( 'wp_stream_list_table_filters', $filters );
|
610 |
Â
}
|
611 |
Â
|
612 |
+
public function filters_form() {
|
613 |
Â
$filters = $this->get_filters();
|
614 |
Â
|
615 |
Â
$filters_string = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
|
617 |
Â
|
618 |
Â
foreach ( $filters as $name => $data ) {
|
619 |
Â
|
620 |
+
$data = wp_parse_args(
|
621 |
+
$data, array(
|
622 |
+
'title' => '',
|
623 |
+
'items' => array(),
|
624 |
+
'ajax' => false,
|
625 |
+
)
|
626 |
+
);
|
627 |
Â
|
628 |
Â
if ( 'date' === $name ) {
|
629 |
Â
$filters_string .= $this->filter_date( $data['items'] );
|
705 |
Â
return sprintf( '<div class="alignleft actions">%s</div>', $filters_string ); // xss ok
|
706 |
Â
}
|
707 |
Â
|
708 |
+
public function filter_select( $name, $title, $items, $ajax = false ) {
|
709 |
Â
if ( $ajax ) {
|
710 |
Â
$out = sprintf(
|
711 |
Â
'<input type="hidden" name="%s" class="chosen-select" value="%s" data-placeholder="%s" />',
|
729 |
Â
'class' => isset( $item['children'] ) ? 'level-1' : null,
|
730 |
Â
'label' => isset( $item['label'] ) ? $item['label'] : null,
|
731 |
Â
);
|
732 |
+
$options[] = $this->filter_option( $option_args );
|
733 |
Â
|
734 |
Â
if ( isset( $item['children'] ) ) {
|
735 |
Â
foreach ( $item['children'] as $child_value => $child_item ) {
|
736 |
+
$option_args = array(
|
737 |
Â
'value' => $child_value,
|
738 |
Â
'selected' => selected( $child_value, $selected, false ),
|
739 |
Â
'disabled' => isset( $child_item['disabled'] ) ? $child_item['disabled'] : null,
|
743 |
Â
'class' => 'level-2',
|
744 |
Â
'label' => isset( $child_item['label'] ) ? '- ' . $child_item['label'] : null,
|
745 |
Â
);
|
746 |
+
$options[] = $this->filter_option( $option_args );
|
747 |
Â
}
|
748 |
Â
}
|
749 |
Â
}
|
750 |
Â
$out = sprintf(
|
751 |
Â
'<select name="%s" class="chosen-select" data-placeholder="%s">%s</select>',
|
752 |
Â
esc_attr( $name ),
|
753 |
+
// translators: Placeholder refers to the title of the dropdown menu (e.g. "users")
|
754 |
Â
sprintf( esc_attr__( 'Show all %s', 'stream' ), $title ),
|
755 |
Â
implode( '', $options )
|
756 |
Â
);
|
759 |
Â
return $out;
|
760 |
Â
}
|
761 |
Â
|
762 |
+
public function filter_option( $args ) {
|
763 |
Â
$defaults = array(
|
764 |
Â
'value' => null,
|
765 |
Â
'selected' => null,
|
785 |
Â
);
|
786 |
Â
}
|
787 |
Â
|
788 |
+
public function filter_search() {
|
789 |
Â
$search = null;
|
790 |
+
if ( isset( $_GET['search'] ) ) { // CSRF okay
|
791 |
+
$search = esc_attr( wp_unslash( $_GET['search'] ) ); // input var okay, CSRF okay
|
Â
|
|
792 |
Â
}
|
793 |
Â
$out = sprintf(
|
794 |
Â
'<p class="search-box">
|
803 |
Â
return $out;
|
804 |
Â
}
|
805 |
Â
|
806 |
+
public function filter_date( $items ) {
|
807 |
Â
wp_enqueue_style( 'jquery-ui' );
|
808 |
Â
wp_enqueue_style( 'wp-stream-datepicker' );
|
809 |
Â
wp_enqueue_script( 'jquery-ui-datepicker' );
|
838 |
Â
<div class="date-inputs">
|
839 |
Â
<div class="box">
|
840 |
Â
<i class="date-remove dashicons"></i>
|
841 |
+
<input type="text" name="date_from" class="date-picker field-from" placeholder="<?php esc_attr_e( 'Start Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_from ); ?>"/>
|
842 |
Â
</div>
|
843 |
Â
<span class="connector dashicons"></span>
|
844 |
Â
|
845 |
Â
<div class="box">
|
846 |
Â
<i class="date-remove dashicons"></i>
|
847 |
+
<input type="text" name="date_to" class="date-picker field-to" placeholder="<?php esc_attr_e( 'End Date', 'stream' ); ?>" value="<?php echo esc_attr( $date_to ); ?>"/>
|
848 |
Â
</div>
|
849 |
Â
</div>
|
850 |
Â
|
859 |
Â
*
|
860 |
Â
* @return string
|
861 |
Â
*/
|
862 |
+
public function record_actions_form() {
|
863 |
Â
/**
|
864 |
Â
* Filter the records screen actions dropdown menu
|
865 |
Â
*
|
899 |
Â
return ob_get_clean();
|
900 |
Â
}
|
901 |
Â
|
902 |
+
public function display() {
|
903 |
Â
$url = self_admin_url( $this->plugin->admin->admin_parent_page );
|
904 |
Â
|
905 |
Â
echo '<form method="get" action="' . esc_url( $url ) . '" id="record-filter-form">';
|
912 |
Â
echo '</form>';
|
913 |
Â
}
|
914 |
Â
|
915 |
+
public function single_row( $item ) {
|
916 |
Â
$classes = apply_filters( 'wp_stream_record_classes', array(), $item );
|
917 |
Â
$class_string = '';
|
918 |
Â
if ( ! empty( $classes ) ) {
|
924 |
Â
echo '</tr>';
|
925 |
Â
}
|
926 |
Â
|
927 |
+
public function display_tablenav( $which ) {
|
928 |
+
if ( 'top' === $which ) :
|
929 |
+
?>
|
930 |
Â
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
931 |
Â
<?php
|
932 |
Â
$this->pagination( $which );
|
933 |
Â
$this->extra_tablenav( $which );
|
934 |
Â
?>
|
935 |
Â
|
936 |
+
<br class="clear"/>
|
937 |
Â
</div>
|
938 |
Â
<?php else : ?>
|
939 |
Â
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
946 |
Â
$this->extra_tablenav( $which );
|
947 |
Â
?>
|
948 |
Â
|
949 |
+
<br class="clear"/>
|
950 |
Â
</div>
|
951 |
+
<?php
|
952 |
Â
endif;
|
953 |
Â
}
|
954 |
Â
|
955 |
+
public function set_screen_option( $dummy, $option, $value ) {
|
956 |
Â
if ( 'edit_stream_per_page' === $option ) {
|
957 |
Â
return $value;
|
958 |
Â
} else {
|
960 |
Â
}
|
961 |
Â
}
|
962 |
Â
|
963 |
+
public function set_live_update_option( $dummy, $option, $value ) {
|
964 |
Â
unset( $value );
|
965 |
Â
|
966 |
Â
// @codingStandardsIgnoreStart
|
973 |
Â
|
974 |
Â
return $value;
|
975 |
Â
}
|
976 |
+
|
977 |
Â
// @codingStandardsIgnoreEnd
|
978 |
Â
|
979 |
Â
return $dummy;
|
1001 |
Â
<h5><?php esc_html_e( 'Live updates', 'stream' ); ?></h5>
|
1002 |
Â
|
1003 |
Â
<div>
|
1004 |
+
<input type="hidden" name="stream_live_update_nonce" id="stream_live_update_nonce" value="<?php echo esc_attr( $nonce ); ?>"/>
|
1005 |
Â
</div>
|
1006 |
Â
<div>
|
1007 |
+
<input type="hidden" name="enable_live_update_user" id="enable_live_update_user" value="<?php echo absint( $user_id ); ?>"/>
|
1008 |
Â
</div>
|
1009 |
Â
<div class="metabox-prefs stream-live-update-checkbox">
|
1010 |
Â
<label for="enable_live_update">
|
1011 |
Â
<input type="checkbox" value="on" name="enable_live_update" id="enable_live_update" data-heartbeat="<?php echo esc_attr( $heartbeat ); ?>" <?php checked( $option, 'on' ); ?> />
|
1012 |
+
<?php esc_html_e( 'Enabled', 'stream' ); ?>
|
1013 |
+
<span class="spinner"></span>
|
1014 |
Â
</label>
|
1015 |
Â
</div>
|
1016 |
Â
</fieldset>
|
1025 |
Â
*
|
1026 |
Â
* @return string setting name for that column
|
1027 |
Â
*/
|
1028 |
+
public function get_column_excluded_setting_key( $column ) {
|
1029 |
Â
switch ( $column ) {
|
1030 |
Â
case 'connector':
|
1031 |
Â
$output = 'connectors';
|
classes/class-live-update.php
CHANGED
@@ -176,14 +176,19 @@ class Live_Update {
|
|
176 |
Â
$enable_stream_update = ( 'off' !== $this->plugin->admin->get_user_meta( get_current_user_id(), $this->user_meta_key ) );
|
177 |
Â
|
178 |
Â
// Register list table
|
179 |
-
$this->list_table = new List_Table(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
180 |
Â
$this->list_table->prepare_items();
|
181 |
Â
|
182 |
Â
$total_items = isset( $this->list_table->_pagination_args['total_items'] ) ? $this->list_table->_pagination_args['total_items'] : null;
|
183 |
Â
$total_pages = isset( $this->list_table->_pagination_args['total_pages'] ) ? $this->list_table->_pagination_args['total_pages'] : null;
|
184 |
Â
|
185 |
Â
if ( isset( $data['wp-stream-heartbeat'] ) && isset( $total_items ) ) {
|
186 |
-
$response['total_items']
|
Â
|
|
187 |
Â
$response['total_items_i18n'] = sprintf( _n( '%d item', '%d items', $total_items ), number_format_i18n( $total_items ) );
|
188 |
Â
}
|
189 |
Â
|
176 |
Â
$enable_stream_update = ( 'off' !== $this->plugin->admin->get_user_meta( get_current_user_id(), $this->user_meta_key ) );
|
177 |
Â
|
178 |
Â
// Register list table
|
179 |
+
$this->list_table = new List_Table(
|
180 |
+
$this->plugin, array(
|
181 |
+
'screen' => 'toplevel_page_' . $this->plugin->admin->records_page_slug,
|
182 |
+
)
|
183 |
+
);
|
184 |
Â
$this->list_table->prepare_items();
|
185 |
Â
|
186 |
Â
$total_items = isset( $this->list_table->_pagination_args['total_items'] ) ? $this->list_table->_pagination_args['total_items'] : null;
|
187 |
Â
$total_pages = isset( $this->list_table->_pagination_args['total_pages'] ) ? $this->list_table->_pagination_args['total_pages'] : null;
|
188 |
Â
|
189 |
Â
if ( isset( $data['wp-stream-heartbeat'] ) && isset( $total_items ) ) {
|
190 |
+
$response['total_items'] = $total_items;
|
191 |
+
// translators: Placeholder refers to a number of items (e.g. "42")
|
192 |
Â
$response['total_items_i18n'] = sprintf( _n( '%d item', '%d items', $total_items ), number_format_i18n( $total_items ) );
|
193 |
Â
}
|
194 |
Â
|
classes/class-log.php
CHANGED
@@ -1,13 +1,24 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
class Log {
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Hold Plugin class
|
Â
|
|
7 |
Â
* @var Plugin
|
8 |
Â
*/
|
9 |
Â
public $plugin;
|
10 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
11 |
Â
/**
|
12 |
Â
* Previous Stream record ID, used for chaining same-session records
|
13 |
Â
*
|
@@ -23,22 +34,28 @@ class Log {
|
|
23 |
Â
public function __construct( $plugin ) {
|
24 |
Â
$this->plugin = $plugin;
|
25 |
Â
|
26 |
-
//
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
28 |
-
require_once
|
29 |
Â
}
|
30 |
Â
}
|
31 |
Â
|
32 |
Â
/**
|
33 |
Â
* Log handler
|
34 |
Â
*
|
35 |
-
* @param Connector $connector Connector responsible for logging the event
|
36 |
-
* @param string
|
37 |
-
* @param array
|
38 |
-
* @param int
|
39 |
-
* @param string
|
40 |
-
* @param string
|
41 |
-
* @param int
|
42 |
Â
*
|
43 |
Â
* @return mixed True if updated, otherwise false|WP_Error
|
44 |
Â
*/
|
@@ -57,7 +74,7 @@ class Log {
|
|
57 |
Â
$author = new Author( $user_id );
|
58 |
Â
$agent = $author->get_current_agent();
|
59 |
Â
|
60 |
-
// WP Cron tracking requires opt-in and WP Cron to be enabled
|
61 |
Â
if ( ! $wp_cron_tracking && 'wp_cron' === $agent ) {
|
62 |
Â
return false;
|
63 |
Â
}
|
@@ -84,18 +101,18 @@ class Log {
|
|
84 |
Â
$user_meta['system_user_name'] = (string) $user_info['name'];
|
85 |
Â
}
|
86 |
Â
|
87 |
-
// Prevent any meta with null values from being logged
|
88 |
Â
$stream_meta = array_filter(
|
89 |
Â
$args,
|
90 |
-
function( $var ) {
|
91 |
Â
return ! is_null( $var );
|
92 |
Â
}
|
93 |
Â
);
|
94 |
Â
|
95 |
-
// Add user meta to Stream meta
|
96 |
Â
$stream_meta['user_meta'] = $user_meta;
|
97 |
Â
|
98 |
-
// Get the current time in milliseconds
|
99 |
Â
$iso_8601_extended_date = wp_stream_get_iso_8601_extended_date();
|
100 |
Â
|
101 |
Â
if ( ! empty( $user->roles ) ) {
|
@@ -108,18 +125,18 @@ class Log {
|
|
108 |
Â
}
|
109 |
Â
|
110 |
Â
$recordarr = array(
|
111 |
-
'object_id'
|
112 |
-
'site_id'
|
113 |
-
'blog_id'
|
114 |
-
'user_id'
|
115 |
-
'user_role'
|
116 |
-
'created'
|
117 |
-
'summary'
|
118 |
-
'connector'
|
119 |
-
'context'
|
120 |
-
'action'
|
121 |
-
'ip'
|
122 |
-
'meta'
|
123 |
Â
);
|
124 |
Â
|
125 |
Â
if ( 0 === $recordarr['object_id'] ) {
|
@@ -128,19 +145,20 @@ class Log {
|
|
128 |
Â
|
129 |
Â
$result = $this->plugin->db->insert( $recordarr );
|
130 |
Â
|
131 |
-
|
Â
|
|
132 |
Â
|
133 |
Â
return $result;
|
134 |
Â
}
|
135 |
Â
|
136 |
Â
/**
|
137 |
-
* This function is use to check whether or not a record should be excluded from the log
|
138 |
Â
*
|
139 |
-
* @param string
|
140 |
-
* @param string
|
141 |
-
* @param string
|
142 |
-
* @param \WP_User $user
|
143 |
-
* @param string
|
144 |
Â
*
|
145 |
Â
* @return bool
|
146 |
Â
*/
|
@@ -150,14 +168,14 @@ class Log {
|
|
150 |
Â
}
|
151 |
Â
|
152 |
Â
if ( is_null( $ip ) ) {
|
153 |
-
$ip =
|
154 |
Â
} else {
|
155 |
Â
$ip = wp_stream_filter_var( $ip, FILTER_VALIDATE_IP );
|
156 |
Â
}
|
157 |
Â
|
158 |
Â
if ( ! empty( $user->roles ) ) {
|
159 |
Â
$roles = array_values( $user->roles );
|
160 |
-
$role
|
161 |
Â
} else {
|
162 |
Â
$role = '';
|
163 |
Â
}
|
@@ -173,7 +191,7 @@ class Log {
|
|
173 |
Â
$exclude_settings = isset( $this->plugin->settings->options['exclude_rules'] ) ? $this->plugin->settings->options['exclude_rules'] : array();
|
174 |
Â
|
175 |
Â
if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) && ! is_network_admin() ) {
|
176 |
-
$multisite_options
|
177 |
Â
$multisite_exclude_settings = isset( $multisite_options['exclude_rules'] ) ? $multisite_options['exclude_rules'] : array();
|
178 |
Â
|
179 |
Â
if ( ! empty( $multisite_exclude_settings ) ) {
|
@@ -192,7 +210,7 @@ class Log {
|
|
192 |
Â
|
193 |
Â
if ( isset( $exclude_settings['exclude_row'] ) && ! empty( $exclude_settings['exclude_row'] ) ) {
|
194 |
Â
foreach ( $exclude_settings['exclude_row'] as $key => $value ) {
|
195 |
-
// Prepare values
|
196 |
Â
$author_or_role = isset( $exclude_settings['author_or_role'][ $key ] ) ? $exclude_settings['author_or_role'][ $key ] : '';
|
197 |
Â
$connector = isset( $exclude_settings['connector'][ $key ] ) ? $exclude_settings['connector'][ $key ] : '';
|
198 |
Â
$context = isset( $exclude_settings['context'][ $key ] ) ? $exclude_settings['context'][ $key ] : '';
|
@@ -233,13 +251,14 @@ class Log {
|
|
233 |
Â
}
|
234 |
Â
}
|
235 |
Â
}
|
Â
|
|
236 |
Â
/**
|
237 |
-
* Filters whether or not a record should be excluded from the log
|
238 |
Â
*
|
239 |
Â
* If true, the record is not logged.
|
240 |
Â
*
|
241 |
-
* @param array $exclude_record Whether the record should excluded
|
242 |
-
* @param array $recordarr The record to log
|
243 |
Â
*
|
244 |
Â
* @return bool
|
245 |
Â
*/
|
@@ -247,68 +266,52 @@ class Log {
|
|
247 |
Â
}
|
248 |
Â
|
249 |
Â
/**
|
250 |
-
*
|
251 |
Â
*
|
252 |
-
* @param array $recordarr
|
253 |
Â
*
|
254 |
-
* @return
|
255 |
Â
*/
|
256 |
Â
public function debug_backtrace( $recordarr ) {
|
257 |
-
/**
|
258 |
-
* Enable debug backtrace on records.
|
259 |
-
*
|
260 |
-
* This filter is for developer use only. When enabled, Stream will send
|
261 |
-
* a full debug backtrace of PHP calls for each record. Optionally, you may
|
262 |
-
* use the available $recordarr parameter to specify what types of records to
|
263 |
-
* create backtrace logs for.
|
264 |
-
*
|
265 |
-
* @param array $recordarr
|
266 |
-
*
|
267 |
-
* @return bool Set to FALSE by default (backtrace disabled)
|
268 |
-
*/
|
269 |
-
$enabled = apply_filters( 'wp_stream_debug_backtrace', false, $recordarr );
|
270 |
-
|
271 |
-
if ( ! $enabled ) {
|
272 |
-
return;
|
273 |
-
}
|
274 |
-
|
275 |
Â
if ( version_compare( PHP_VERSION, '5.3.6', '<' ) ) {
|
276 |
-
|
277 |
-
return;
|
278 |
Â
}
|
279 |
Â
|
280 |
-
// Record details
|
281 |
Â
$summary = isset( $recordarr['summary'] ) ? $recordarr['summary'] : null;
|
282 |
Â
$author = isset( $recordarr['author'] ) ? $recordarr['author'] : null;
|
283 |
Â
$connector = isset( $recordarr['connector'] ) ? $recordarr['connector'] : null;
|
284 |
Â
$context = isset( $recordarr['context'] ) ? $recordarr['context'] : null;
|
285 |
Â
$action = isset( $recordarr['action'] ) ? $recordarr['action'] : null;
|
286 |
Â
|
287 |
-
// Stream meta
|
288 |
Â
$stream_meta = isset( $recordarr['meta'] ) ? $recordarr['meta'] : null;
|
289 |
Â
|
290 |
Â
unset( $stream_meta['user_meta'] );
|
291 |
Â
|
292 |
Â
if ( $stream_meta ) {
|
293 |
-
array_walk(
|
294 |
-
$
|
295 |
-
|
296 |
-
|
Â
|
|
297 |
Â
$stream_meta = implode( ', ', $stream_meta );
|
298 |
Â
}
|
299 |
Â
|
300 |
-
// User meta
|
301 |
Â
$user_meta = isset( $recordarr['meta']['user_meta'] ) ? $recordarr['meta']['user_meta'] : null;
|
302 |
Â
|
303 |
Â
if ( $user_meta ) {
|
304 |
-
array_walk(
|
305 |
-
$
|
306 |
-
|
Â
|
|
Â
|
|
307 |
Â
|
308 |
Â
$user_meta = implode( ', ', $user_meta );
|
309 |
Â
}
|
310 |
Â
|
311 |
-
// Debug backtrace
|
312 |
Â
ob_start();
|
313 |
Â
|
314 |
Â
// @codingStandardsIgnoreStart
|
@@ -330,6 +333,6 @@ class Log {
|
|
330 |
Â
implode( "\n", $backtrace )
|
331 |
Â
);
|
332 |
Â
|
333 |
-
|
334 |
Â
}
|
335 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
class Log {
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Hold Plugin class
|
9 |
+
*
|
10 |
Â
* @var Plugin
|
11 |
Â
*/
|
12 |
Â
public $plugin;
|
13 |
Â
|
14 |
+
/**
|
15 |
+
* Hold Current visitors IP Address.
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
private $ip_address;
|
20 |
+
|
21 |
+
|
22 |
Â
/**
|
23 |
Â
* Previous Stream record ID, used for chaining same-session records
|
24 |
Â
*
|
34 |
Â
public function __construct( $plugin ) {
|
35 |
Â
$this->plugin = $plugin;
|
36 |
Â
|
37 |
+
// Support proxy mode by checking the `X-Forwarded-For` header first.
|
38 |
+
$ip_address = wp_stream_filter_input( INPUT_SERVER, 'HTTP_X_FORWARDED_FOR', FILTER_VALIDATE_IP );
|
39 |
+
$ip_address = $ip_address ? $ip_address : wp_stream_filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP );
|
40 |
+
|
41 |
+
$this->ip_address = $ip_address;
|
42 |
+
|
43 |
+
// Ensure function used in various methods is pre-loaded.
|
44 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
45 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
46 |
Â
}
|
47 |
Â
}
|
48 |
Â
|
49 |
Â
/**
|
50 |
Â
* Log handler
|
51 |
Â
*
|
52 |
+
* @param Connector $connector Connector responsible for logging the event.
|
53 |
+
* @param string $message sprintf-ready error message string.
|
54 |
+
* @param array $args sprintf (and extra) arguments to use.
|
55 |
+
* @param int $object_id Target object id.
|
56 |
+
* @param string $context Context of the event.
|
57 |
+
* @param string $action Action of the event.
|
58 |
+
* @param int $user_id User responsible for the event.
|
59 |
Â
*
|
60 |
Â
* @return mixed True if updated, otherwise false|WP_Error
|
61 |
Â
*/
|
74 |
Â
$author = new Author( $user_id );
|
75 |
Â
$agent = $author->get_current_agent();
|
76 |
Â
|
77 |
+
// WP Cron tracking requires opt-in and WP Cron to be enabled.
|
78 |
Â
if ( ! $wp_cron_tracking && 'wp_cron' === $agent ) {
|
79 |
Â
return false;
|
80 |
Â
}
|
101 |
Â
$user_meta['system_user_name'] = (string) $user_info['name'];
|
102 |
Â
}
|
103 |
Â
|
104 |
+
// Prevent any meta with null values from being logged.
|
105 |
Â
$stream_meta = array_filter(
|
106 |
Â
$args,
|
107 |
+
function ( $var ) {
|
108 |
Â
return ! is_null( $var );
|
109 |
Â
}
|
110 |
Â
);
|
111 |
Â
|
112 |
+
// Add user meta to Stream meta.
|
113 |
Â
$stream_meta['user_meta'] = $user_meta;
|
114 |
Â
|
115 |
+
// Get the current time in milliseconds.
|
116 |
Â
$iso_8601_extended_date = wp_stream_get_iso_8601_extended_date();
|
117 |
Â
|
118 |
Â
if ( ! empty( $user->roles ) ) {
|
125 |
Â
}
|
126 |
Â
|
127 |
Â
$recordarr = array(
|
128 |
+
'object_id' => (int) $object_id,
|
129 |
+
'site_id' => (int) is_multisite() ? get_current_site()->id : 1,
|
130 |
+
'blog_id' => (int) apply_filters( 'wp_stream_blog_id_logged', get_current_blog_id() ),
|
131 |
+
'user_id' => (int) $user_id,
|
132 |
+
'user_role' => (string) $role,
|
133 |
+
'created' => (string) $iso_8601_extended_date,
|
134 |
+
'summary' => (string) vsprintf( $message, $args ),
|
135 |
+
'connector' => (string) $connector,
|
136 |
+
'context' => (string) $context,
|
137 |
+
'action' => (string) $action,
|
138 |
+
'ip' => (string) $this->ip_address,
|
139 |
+
'meta' => (array) $stream_meta,
|
140 |
Â
);
|
141 |
Â
|
142 |
Â
if ( 0 === $recordarr['object_id'] ) {
|
145 |
Â
|
146 |
Â
$result = $this->plugin->db->insert( $recordarr );
|
147 |
Â
|
148 |
+
// This is helpful in development environments:
|
149 |
+
// error_log( $this->debug_backtrace( $recordarr ) );
|
150 |
Â
|
151 |
Â
return $result;
|
152 |
Â
}
|
153 |
Â
|
154 |
Â
/**
|
155 |
+
* This function is use to check whether or not a record should be excluded from the log.
|
156 |
Â
*
|
157 |
+
* @param string $connector Name of the connector being logged.
|
158 |
+
* @param string $context Name of the context being logged.
|
159 |
+
* @param string $action Name of the action being logged.
|
160 |
+
* @param \WP_User $user The user being logged.
|
161 |
+
* @param string $ip IP address being logged.
|
162 |
Â
*
|
163 |
Â
* @return bool
|
164 |
Â
*/
|
168 |
Â
}
|
169 |
Â
|
170 |
Â
if ( is_null( $ip ) ) {
|
171 |
+
$ip = $this->ip_address;
|
172 |
Â
} else {
|
173 |
Â
$ip = wp_stream_filter_var( $ip, FILTER_VALIDATE_IP );
|
174 |
Â
}
|
175 |
Â
|
176 |
Â
if ( ! empty( $user->roles ) ) {
|
177 |
Â
$roles = array_values( $user->roles );
|
178 |
+
$role = $roles[0];
|
179 |
Â
} else {
|
180 |
Â
$role = '';
|
181 |
Â
}
|
191 |
Â
$exclude_settings = isset( $this->plugin->settings->options['exclude_rules'] ) ? $this->plugin->settings->options['exclude_rules'] : array();
|
192 |
Â
|
193 |
Â
if ( is_multisite() && is_plugin_active_for_network( $this->plugin->locations['plugin'] ) && ! is_network_admin() ) {
|
194 |
+
$multisite_options = (array) get_site_option( 'wp_stream_network', array() );
|
195 |
Â
$multisite_exclude_settings = isset( $multisite_options['exclude_rules'] ) ? $multisite_options['exclude_rules'] : array();
|
196 |
Â
|
197 |
Â
if ( ! empty( $multisite_exclude_settings ) ) {
|
210 |
Â
|
211 |
Â
if ( isset( $exclude_settings['exclude_row'] ) && ! empty( $exclude_settings['exclude_row'] ) ) {
|
212 |
Â
foreach ( $exclude_settings['exclude_row'] as $key => $value ) {
|
213 |
+
// Prepare values.
|
214 |
Â
$author_or_role = isset( $exclude_settings['author_or_role'][ $key ] ) ? $exclude_settings['author_or_role'][ $key ] : '';
|
215 |
Â
$connector = isset( $exclude_settings['connector'][ $key ] ) ? $exclude_settings['connector'][ $key ] : '';
|
216 |
Â
$context = isset( $exclude_settings['context'][ $key ] ) ? $exclude_settings['context'][ $key ] : '';
|
251 |
Â
}
|
252 |
Â
}
|
253 |
Â
}
|
254 |
+
|
255 |
Â
/**
|
256 |
+
* Filters whether or not a record should be excluded from the log.
|
257 |
Â
*
|
258 |
Â
* If true, the record is not logged.
|
259 |
Â
*
|
260 |
+
* @param array $exclude_record Whether the record should excluded.
|
261 |
+
* @param array $recordarr The record to log.
|
262 |
Â
*
|
263 |
Â
* @return bool
|
264 |
Â
*/
|
266 |
Â
}
|
267 |
Â
|
268 |
Â
/**
|
269 |
+
* Helper function to send a full backtrace of calls to the PHP error log for debugging
|
270 |
Â
*
|
271 |
+
* @param array $recordarr Record argument array.
|
272 |
Â
*
|
273 |
+
* @return string
|
274 |
Â
*/
|
275 |
Â
public function debug_backtrace( $recordarr ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
276 |
Â
if ( version_compare( PHP_VERSION, '5.3.6', '<' ) ) {
|
277 |
+
return __( 'Debug backtrace requires at least PHP 5.3.6', 'wp_stream' );
|
Â
|
|
278 |
Â
}
|
279 |
Â
|
280 |
+
// Record details.
|
281 |
Â
$summary = isset( $recordarr['summary'] ) ? $recordarr['summary'] : null;
|
282 |
Â
$author = isset( $recordarr['author'] ) ? $recordarr['author'] : null;
|
283 |
Â
$connector = isset( $recordarr['connector'] ) ? $recordarr['connector'] : null;
|
284 |
Â
$context = isset( $recordarr['context'] ) ? $recordarr['context'] : null;
|
285 |
Â
$action = isset( $recordarr['action'] ) ? $recordarr['action'] : null;
|
286 |
Â
|
287 |
+
// Stream meta.
|
288 |
Â
$stream_meta = isset( $recordarr['meta'] ) ? $recordarr['meta'] : null;
|
289 |
Â
|
290 |
Â
unset( $stream_meta['user_meta'] );
|
291 |
Â
|
292 |
Â
if ( $stream_meta ) {
|
293 |
+
array_walk(
|
294 |
+
$stream_meta, function ( &$value, $key ) {
|
295 |
+
$value = sprintf( '%s: %s', $key, ( '' === $value ) ? 'null' : $value );
|
296 |
+
}
|
297 |
+
);
|
298 |
Â
$stream_meta = implode( ', ', $stream_meta );
|
299 |
Â
}
|
300 |
Â
|
301 |
+
// User meta.
|
302 |
Â
$user_meta = isset( $recordarr['meta']['user_meta'] ) ? $recordarr['meta']['user_meta'] : null;
|
303 |
Â
|
304 |
Â
if ( $user_meta ) {
|
305 |
+
array_walk(
|
306 |
+
$user_meta, function ( &$value, $key ) {
|
307 |
+
$value = sprintf( '%s: %s', $key, ( '' === $value ) ? 'null' : $value );
|
308 |
+
}
|
309 |
+
);
|
310 |
Â
|
311 |
Â
$user_meta = implode( ', ', $user_meta );
|
312 |
Â
}
|
313 |
Â
|
314 |
+
// Debug backtrace.
|
315 |
Â
ob_start();
|
316 |
Â
|
317 |
Â
// @codingStandardsIgnoreStart
|
333 |
Â
implode( "\n", $backtrace )
|
334 |
Â
);
|
335 |
Â
|
336 |
+
return $output;
|
337 |
Â
}
|
338 |
Â
}
|
classes/class-network.php
CHANGED
@@ -12,7 +12,7 @@ class Network {
|
|
12 |
Â
|
13 |
Â
public $default_settings_page_slug = 'wp_stream_default_settings';
|
14 |
Â
|
15 |
-
function __construct( $plugin ) {
|
16 |
Â
$this->plugin = $plugin;
|
17 |
Â
|
18 |
Â
// Always add default site_id/blog_id params when multisite
|
@@ -78,7 +78,7 @@ class Network {
|
|
78 |
Â
* @return object
|
79 |
Â
*/
|
80 |
Â
public function get_network_blog() {
|
81 |
-
$blog = new \stdClass;
|
82 |
Â
$blog->blog_id = 0;
|
83 |
Â
$blog->blogname = esc_html__( 'Network Admin', 'stream' );
|
84 |
Â
|
@@ -92,12 +92,32 @@ class Network {
|
|
92 |
Â
*/
|
93 |
Â
public function is_network_activated() {
|
94 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
95 |
-
require_once
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
return is_plugin_active_for_network( $this->plugin->locations['plugin'] );
|
99 |
Â
}
|
100 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
101 |
Â
/**
|
102 |
Â
* Adds Stream to the admin bar under the "My Sites > Network Admin" menu
|
103 |
Â
* if Stream has been network-activated.
|
@@ -178,7 +198,11 @@ class Network {
|
|
178 |
Â
public function settings_form_action( $action ) {
|
179 |
Â
if ( is_network_admin() ) {
|
180 |
Â
$current_page = wp_stream_filter_input( INPUT_GET, 'page' );
|
181 |
-
$action = add_query_arg(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
182 |
Â
}
|
183 |
Â
|
184 |
Â
return $action;
|
@@ -199,10 +223,10 @@ class Network {
|
|
199 |
Â
$current_page = wp_stream_filter_input( INPUT_GET, 'page' );
|
200 |
Â
|
201 |
Â
switch ( $current_page ) {
|
202 |
-
case $this->network_settings_page_slug
|
203 |
Â
$description = __( 'These settings apply to all sites on the network.', 'stream' );
|
204 |
Â
break;
|
205 |
-
case $this->default_settings_page_slug
|
206 |
Â
$description = __( 'These default settings will apply to new sites created on the network. These settings do not alter existing sites.', 'stream' );
|
207 |
Â
break;
|
208 |
Â
}
|
@@ -225,7 +249,7 @@ class Network {
|
|
225 |
Â
$stream_hidden_options = apply_filters(
|
226 |
Â
'wp_stream_hidden_option_fields',
|
227 |
Â
array(
|
228 |
-
'general'
|
229 |
Â
'records_ttl',
|
230 |
Â
),
|
231 |
Â
'advanced' => array(
|
@@ -327,13 +351,11 @@ class Network {
|
|
327 |
Â
$this->default_settings_page_slug,
|
328 |
Â
);
|
329 |
Â
|
330 |
-
if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers, true ) ) {
|
331 |
Â
return;
|
332 |
Â
}
|
333 |
Â
|
334 |
-
//
|
335 |
-
$options = isset( $_POST['option_page'] ) ? explode( ',', stripslashes( $_POST['option_page'] ) ) : null;
|
336 |
-
// @codingStandardsIgnoreEnd
|
337 |
Â
|
338 |
Â
if ( $options ) {
|
339 |
Â
|
@@ -487,6 +509,7 @@ class Network {
|
|
487 |
Â
*/
|
488 |
Â
public function network_admin_page_title( $page_title ) {
|
489 |
Â
if ( is_network_admin() ) {
|
Â
|
|
490 |
Â
$site_count = sprintf( _n( '%d site', '%d sites', get_blog_count(), 'stream' ), number_format( get_blog_count() ) );
|
491 |
Â
$page_title = sprintf( '%s (%s)', $page_title, $site_count );
|
492 |
Â
}
|
12 |
Â
|
13 |
Â
public $default_settings_page_slug = 'wp_stream_default_settings';
|
14 |
Â
|
15 |
+
public function __construct( $plugin ) {
|
16 |
Â
$this->plugin = $plugin;
|
17 |
Â
|
18 |
Â
// Always add default site_id/blog_id params when multisite
|
78 |
Â
* @return object
|
79 |
Â
*/
|
80 |
Â
public function get_network_blog() {
|
81 |
+
$blog = new \stdClass();
|
82 |
Â
$blog->blog_id = 0;
|
83 |
Â
$blog->blogname = esc_html__( 'Network Admin', 'stream' );
|
84 |
Â
|
92 |
Â
*/
|
93 |
Â
public function is_network_activated() {
|
94 |
Â
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
|
95 |
+
require_once ABSPATH . '/wp-admin/includes/plugin.php';
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( $this->is_mustuse() ) {
|
99 |
+
return true;
|
100 |
Â
}
|
101 |
Â
|
102 |
Â
return is_plugin_active_for_network( $this->plugin->locations['plugin'] );
|
103 |
Â
}
|
104 |
Â
|
105 |
+
/**
|
106 |
+
* Returns true if Stream is a must-use plugin, otherwise false
|
107 |
+
*
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
public function is_mustuse() {
|
111 |
+
|
112 |
+
$stream_php = trailingslashit( WPMU_PLUGIN_DIR ) . $this->plugin->locations['plugin'];
|
113 |
+
|
114 |
+
if ( file_exists( $stream_php ) && class_exists( 'WP_Stream\Plugin' ) ) {
|
115 |
+
return true;
|
116 |
+
}
|
117 |
+
|
118 |
+
return false;
|
119 |
+
}
|
120 |
+
|
121 |
Â
/**
|
122 |
Â
* Adds Stream to the admin bar under the "My Sites > Network Admin" menu
|
123 |
Â
* if Stream has been network-activated.
|
198 |
Â
public function settings_form_action( $action ) {
|
199 |
Â
if ( is_network_admin() ) {
|
200 |
Â
$current_page = wp_stream_filter_input( INPUT_GET, 'page' );
|
201 |
+
$action = add_query_arg(
|
202 |
+
array(
|
203 |
+
'action' => $current_page,
|
204 |
+
), 'edit.php'
|
205 |
+
);
|
206 |
Â
}
|
207 |
Â
|
208 |
Â
return $action;
|
223 |
Â
$current_page = wp_stream_filter_input( INPUT_GET, 'page' );
|
224 |
Â
|
225 |
Â
switch ( $current_page ) {
|
226 |
+
case $this->network_settings_page_slug:
|
227 |
Â
$description = __( 'These settings apply to all sites on the network.', 'stream' );
|
228 |
Â
break;
|
229 |
+
case $this->default_settings_page_slug:
|
230 |
Â
$description = __( 'These default settings will apply to new sites created on the network. These settings do not alter existing sites.', 'stream' );
|
231 |
Â
break;
|
232 |
Â
}
|
249 |
Â
$stream_hidden_options = apply_filters(
|
250 |
Â
'wp_stream_hidden_option_fields',
|
251 |
Â
array(
|
252 |
+
'general' => array(
|
253 |
Â
'records_ttl',
|
254 |
Â
),
|
255 |
Â
'advanced' => array(
|
351 |
Â
$this->default_settings_page_slug,
|
352 |
Â
);
|
353 |
Â
|
354 |
+
if ( ! isset( $_GET['action'] ) || ! in_array( $_GET['action'], $allowed_referers, true ) ) { // CSRF okay
|
355 |
Â
return;
|
356 |
Â
}
|
357 |
Â
|
358 |
+
$options = isset( $_POST['option_page'] ) ? explode( ',', stripslashes( $_POST['option_page'] ) ) : null; // CSRF okay
|
Â
|
|
Â
|
|
359 |
Â
|
360 |
Â
if ( $options ) {
|
361 |
Â
|
509 |
Â
*/
|
510 |
Â
public function network_admin_page_title( $page_title ) {
|
511 |
Â
if ( is_network_admin() ) {
|
512 |
+
// translators: Placeholder refers to a number of sites on the network (e.g. "42")
|
513 |
Â
$site_count = sprintf( _n( '%d site', '%d sites', get_blog_count(), 'stream' ), number_format( get_blog_count() ) );
|
514 |
Â
$page_title = sprintf( '%s (%s)', $page_title, $site_count );
|
515 |
Â
}
|
classes/class-plugin.php
CHANGED
@@ -7,7 +7,7 @@ class Plugin {
|
|
7 |
Â
*
|
8 |
Â
* @const string
|
9 |
Â
*/
|
10 |
-
const VERSION = '3.2.
|
11 |
Â
|
12 |
Â
/**
|
13 |
Â
* WP-CLI command
|
@@ -139,7 +139,7 @@ class Plugin {
|
|
139 |
Â
*
|
140 |
Â
* @param string $class
|
141 |
Â
*/
|
142 |
-
function autoload( $class ) {
|
143 |
Â
if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class, $matches ) ) {
|
144 |
Â
return;
|
145 |
Â
}
|
@@ -178,10 +178,10 @@ class Plugin {
|
|
178 |
Â
* @action init
|
179 |
Â
*/
|
180 |
Â
public function init() {
|
181 |
-
$this->settings
|
182 |
-
$this->connectors
|
183 |
-
$this->alerts
|
184 |
-
$this->alerts_list
|
185 |
Â
|
186 |
Â
}
|
187 |
Â
|
@@ -218,10 +218,10 @@ class Plugin {
|
|
218 |
Â
* @return array
|
219 |
Â
*/
|
220 |
Â
private function locate_plugin() {
|
221 |
-
$dir_url
|
222 |
-
$dir_path
|
223 |
-
$dir_basename
|
224 |
-
$plugin_basename
|
225 |
Â
|
226 |
Â
return compact( 'dir_url', 'dir_path', 'dir_basename', 'plugin_basename' );
|
227 |
Â
}
|
7 |
Â
*
|
8 |
Â
* @const string
|
9 |
Â
*/
|
10 |
+
const VERSION = '3.2.3';
|
11 |
Â
|
12 |
Â
/**
|
13 |
Â
* WP-CLI command
|
139 |
Â
*
|
140 |
Â
* @param string $class
|
141 |
Â
*/
|
142 |
+
public function autoload( $class ) {
|
143 |
Â
if ( ! preg_match( '/^(?P<namespace>.+)\\\\(?P<autoload>[^\\\\]+)$/', $class, $matches ) ) {
|
144 |
Â
return;
|
145 |
Â
}
|
178 |
Â
* @action init
|
179 |
Â
*/
|
180 |
Â
public function init() {
|
181 |
+
$this->settings = new Settings( $this );
|
182 |
+
$this->connectors = new Connectors( $this );
|
183 |
+
$this->alerts = new Alerts( $this );
|
184 |
+
$this->alerts_list = new Alerts_List( $this );
|
185 |
Â
|
186 |
Â
}
|
187 |
Â
|
218 |
Â
* @return array
|
219 |
Â
*/
|
220 |
Â
private function locate_plugin() {
|
221 |
+
$dir_url = trailingslashit( plugins_url( '', dirname( __FILE__ ) ) );
|
222 |
+
$dir_path = plugin_dir_path( dirname( __FILE__ ) );
|
223 |
+
$dir_basename = basename( $dir_path );
|
224 |
+
$plugin_basename = trailingslashit( $dir_basename ) . $dir_basename . '.php';
|
225 |
Â
|
226 |
Â
return compact( 'dir_url', 'dir_path', 'dir_basename', 'plugin_basename' );
|
227 |
Â
}
|
classes/class-preview-list-table.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
class Preview_List_Table extends List_Table {
|
@@ -7,6 +8,7 @@ class Preview_List_Table extends List_Table {
|
|
7 |
Â
* Class constructor.
|
8 |
Â
*
|
9 |
Â
* @param Plugin $plugin Plugin object.
|
Â
|
|
10 |
Â
* @return void
|
11 |
Â
*/
|
12 |
Â
public function __construct( $plugin ) {
|
@@ -18,15 +20,21 @@ class Preview_List_Table extends List_Table {
|
|
18 |
Â
* Sets up the records for display.
|
19 |
Â
*
|
20 |
Â
* @param array $items List of items for display.
|
Â
|
|
21 |
Â
* @return void
|
22 |
Â
*/
|
23 |
-
function set_records( $items ) {
|
24 |
-
$columns
|
25 |
Â
$sortable = $this->get_sortable_columns();
|
26 |
Â
$hidden = $this->get_hidden_columns();
|
27 |
-
$primary
|
28 |
Â
|
29 |
-
$this->_column_headers = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
|
31 |
Â
$this->items = $items;
|
32 |
Â
}
|
@@ -47,7 +55,7 @@ class Preview_List_Table extends List_Table {
|
|
47 |
Â
</thead>
|
48 |
Â
|
49 |
Â
<tbody id="the-list">
|
50 |
-
|
51 |
Â
</tbody>
|
52 |
Â
|
53 |
Â
<tfoot>
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
class Preview_List_Table extends List_Table {
|
8 |
Â
* Class constructor.
|
9 |
Â
*
|
10 |
Â
* @param Plugin $plugin Plugin object.
|
11 |
+
*
|
12 |
Â
* @return void
|
13 |
Â
*/
|
14 |
Â
public function __construct( $plugin ) {
|
20 |
Â
* Sets up the records for display.
|
21 |
Â
*
|
22 |
Â
* @param array $items List of items for display.
|
23 |
+
*
|
24 |
Â
* @return void
|
25 |
Â
*/
|
26 |
+
public function set_records( $items ) {
|
27 |
+
$columns = $this->get_columns();
|
28 |
Â
$sortable = $this->get_sortable_columns();
|
29 |
Â
$hidden = $this->get_hidden_columns();
|
30 |
+
$primary = $columns['summary'];
|
31 |
Â
|
32 |
+
$this->_column_headers = array(
|
33 |
+
$columns,
|
34 |
+
$hidden,
|
35 |
+
$sortable,
|
36 |
+
$primary,
|
37 |
+
);
|
38 |
Â
|
39 |
Â
$this->items = $items;
|
40 |
Â
}
|
55 |
Â
</thead>
|
56 |
Â
|
57 |
Â
<tbody id="the-list">
|
58 |
+
<?php $this->display_rows_or_placeholder(); ?>
|
59 |
Â
</tbody>
|
60 |
Â
|
61 |
Â
<tfoot>
|
classes/class-query.php
CHANGED
@@ -46,7 +46,7 @@ class Query {
|
|
46 |
Â
}
|
47 |
Â
|
48 |
Â
if ( ! empty( $args['search'] ) ) {
|
49 |
-
$field
|
50 |
Â
|
51 |
Â
// Sanitize field
|
52 |
Â
$allowed_fields = array( 'ID', 'site_id', 'blog_id', 'object_id', 'user_id', 'user_role', 'created', 'summary', 'connector', 'context', 'action', 'ip' );
|
46 |
Â
}
|
47 |
Â
|
48 |
Â
if ( ! empty( $args['search'] ) ) {
|
49 |
+
$field = ! empty( $args['search_field'] ) ? $args['search_field'] : 'summary';
|
50 |
Â
|
51 |
Â
// Sanitize field
|
52 |
Â
$allowed_fields = array( 'ID', 'site_id', 'blog_id', 'object_id', 'user_id', 'user_role', 'created', 'summary', 'connector', 'context', 'action', 'ip' );
|
classes/class-record.php
CHANGED
@@ -18,20 +18,20 @@ class Record {
|
|
18 |
Â
public $meta;
|
19 |
Â
|
20 |
Â
public function __construct( $item ) {
|
21 |
-
$this->ID
|
22 |
-
$this->created
|
23 |
-
$this->site_id
|
24 |
-
$this->blog_id
|
25 |
Â
$this->object_id = isset( $item->object_id ) ? $item->object_id : null;
|
26 |
-
$this->user_id
|
27 |
Â
$this->user_role = isset( $item->user_role ) ? $item->user_role : null;
|
28 |
Â
$this->user_meta = isset( $item->meta['user_meta'] ) ? $item->meta['user_meta'] : null;
|
29 |
-
$this->summary
|
30 |
Â
$this->connector = isset( $item->connector ) ? $item->connector : null;
|
31 |
-
$this->context
|
32 |
-
$this->action
|
33 |
-
$this->ip
|
34 |
-
$this->meta
|
35 |
Â
|
36 |
Â
if ( isset( $this->meta['user_meta'] ) ) {
|
37 |
Â
unset( $this->meta['user_meta'] );
|
@@ -89,7 +89,7 @@ class Record {
|
|
89 |
Â
* @param object Record object
|
90 |
Â
* @return mixed The title of the object as a string, otherwise false
|
91 |
Â
*/
|
92 |
-
function get_object_title() {
|
93 |
Â
if ( ! isset( $this->object_id ) || empty( $this->object_id ) ) {
|
94 |
Â
return false;
|
95 |
Â
}
|
18 |
Â
public $meta;
|
19 |
Â
|
20 |
Â
public function __construct( $item ) {
|
21 |
+
$this->ID = isset( $item->ID ) ? $item->ID : null;
|
22 |
+
$this->created = isset( $item->created ) ? $item->created : null;
|
23 |
+
$this->site_id = isset( $item->site_id ) ? $item->site_id : null;
|
24 |
+
$this->blog_id = isset( $item->blog_id ) ? $item->blog_id : null;
|
25 |
Â
$this->object_id = isset( $item->object_id ) ? $item->object_id : null;
|
26 |
+
$this->user_id = isset( $item->user_id ) ? $item->user_id : null;
|
27 |
Â
$this->user_role = isset( $item->user_role ) ? $item->user_role : null;
|
28 |
Â
$this->user_meta = isset( $item->meta['user_meta'] ) ? $item->meta['user_meta'] : null;
|
29 |
+
$this->summary = isset( $item->summary ) ? $item->summary : null;
|
30 |
Â
$this->connector = isset( $item->connector ) ? $item->connector : null;
|
31 |
+
$this->context = isset( $item->context ) ? $item->context : null;
|
32 |
+
$this->action = isset( $item->action ) ? $item->action : null;
|
33 |
+
$this->ip = isset( $item->ip ) ? $item->ip : null;
|
34 |
+
$this->meta = isset( $item->meta ) ? $item->meta : null;
|
35 |
Â
|
36 |
Â
if ( isset( $this->meta['user_meta'] ) ) {
|
37 |
Â
unset( $this->meta['user_meta'] );
|
89 |
Â
* @param object Record object
|
90 |
Â
* @return mixed The title of the object as a string, otherwise false
|
91 |
Â
*/
|
92 |
+
public function get_object_title() {
|
93 |
Â
if ( ! isset( $this->object_id ) || empty( $this->object_id ) ) {
|
94 |
Â
return false;
|
95 |
Â
}
|
classes/class-settings.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
use \WP_Roles;
|
@@ -6,6 +7,7 @@ use \WP_User;
|
|
6 |
Â
use \WP_User_Query;
|
7 |
Â
|
8 |
Â
class Settings {
|
Â
|
|
9 |
Â
/**
|
10 |
Â
* Hold Plugin class
|
11 |
Â
* @var Plugin
|
@@ -55,10 +57,20 @@ class Settings {
|
|
55 |
Â
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
56 |
Â
|
57 |
Â
// Remove records when records TTL is shortened
|
58 |
-
add_action(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
59 |
Â
|
60 |
Â
// Apply label translations for settings
|
61 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
62 |
Â
|
63 |
Â
// Ajax callback function to search users
|
64 |
Â
add_action( 'wp_ajax_stream_get_users', array( $this, 'get_users' ) );
|
@@ -95,23 +107,33 @@ class Settings {
|
|
95 |
Â
'find' => $search,
|
96 |
Â
);
|
97 |
Â
|
98 |
-
add_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
99 |
Â
|
100 |
Â
$users = new WP_User_Query(
|
101 |
Â
array(
|
102 |
-
'search'
|
103 |
Â
'search_columns' => array(
|
104 |
Â
'user_login',
|
105 |
Â
'user_nicename',
|
106 |
Â
'user_email',
|
107 |
Â
'user_url',
|
108 |
Â
),
|
109 |
-
'orderby'
|
110 |
-
'number'
|
111 |
Â
)
|
112 |
Â
);
|
113 |
Â
|
114 |
-
remove_filter(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
115 |
Â
|
116 |
Â
if ( 0 === $users->get_total() ) {
|
117 |
Â
wp_send_json_error( $response );
|
@@ -121,15 +143,15 @@ class Settings {
|
|
121 |
Â
if ( is_multisite() && is_super_admin() ) {
|
122 |
Â
$super_admins = get_super_admins();
|
123 |
Â
foreach ( $super_admins as $admin ) {
|
124 |
-
$user
|
125 |
Â
$users_array[] = $user;
|
126 |
Â
}
|
127 |
Â
}
|
128 |
Â
|
129 |
-
$response->status
|
130 |
-
$response->message
|
131 |
-
$response->roles
|
132 |
-
$response->users
|
133 |
Â
$users_added_to_response = array();
|
134 |
Â
|
135 |
Â
foreach ( $users_array as $key => $user ) {
|
@@ -149,6 +171,7 @@ class Settings {
|
|
149 |
Â
|
150 |
Â
$args['tooltip'] = esc_attr(
|
151 |
Â
sprintf(
|
Â
|
|
152 |
Â
__( 'ID: %1$d\nUser: %2$s\nEmail: %3$s\nRole: %4$s', 'stream' ),
|
153 |
Â
$author->id,
|
154 |
Â
$author->user_login,
|
@@ -164,13 +187,13 @@ class Settings {
|
|
164 |
Â
|
165 |
Â
usort(
|
166 |
Â
$response->users,
|
167 |
-
function( $a, $b ) {
|
168 |
Â
return strcmp( $a['text'], $b['text'] );
|
169 |
Â
}
|
170 |
Â
);
|
171 |
Â
|
172 |
Â
if ( empty( $search ) || preg_match( '/wp|cli|system|unknown/i', $search ) ) {
|
173 |
-
$author
|
174 |
Â
$response->users[] = array(
|
175 |
Â
'id' => '0',
|
176 |
Â
'text' => $author->get_display_name(),
|
@@ -183,8 +206,8 @@ class Settings {
|
|
183 |
Â
}
|
184 |
Â
|
185 |
Â
/**
|
186 |
-
|
187 |
-
|
188 |
Â
public function get_ips() {
|
189 |
Â
if ( ! defined( 'DOING_AJAX' ) || ! current_user_can( $this->plugin->admin->settings_cap ) ) {
|
190 |
Â
return;
|
@@ -196,9 +219,12 @@ class Settings {
|
|
196 |
Â
$find = wp_stream_filter_input( INPUT_POST, 'find' );
|
197 |
Â
|
198 |
Â
if ( isset( $find['term'] ) && '' !== $find['term'] ) {
|
199 |
-
$ips = array_filter(
|
200 |
-
|
201 |
-
|
Â
|
|
Â
|
|
Â
|
|
202 |
Â
}
|
203 |
Â
|
204 |
Â
if ( $ips ) {
|
@@ -211,9 +237,9 @@ class Settings {
|
|
211 |
Â
/**
|
212 |
Â
* Filter the columns to search in a WP_User_Query search.
|
213 |
Â
*
|
214 |
-
* @param array
|
215 |
-
* @param string
|
216 |
-
* @param \WP_User_Query $query
|
217 |
Â
*
|
218 |
Â
* @return array
|
219 |
Â
*/
|
@@ -254,16 +280,16 @@ class Settings {
|
|
254 |
Â
*/
|
255 |
Â
public function get_fields() {
|
256 |
Â
$fields = array(
|
257 |
-
'general'
|
258 |
Â
'title' => esc_html__( 'General', 'stream' ),
|
259 |
Â
'fields' => array(
|
260 |
Â
array(
|
261 |
-
'name'
|
262 |
-
'title'
|
263 |
-
'type'
|
264 |
-
'desc'
|
265 |
-
'choices'
|
266 |
-
'default'
|
267 |
Â
),
|
268 |
Â
array(
|
269 |
Â
'name' => 'records_ttl',
|
@@ -287,16 +313,16 @@ class Settings {
|
|
287 |
Â
),
|
288 |
Â
),
|
289 |
Â
),
|
290 |
-
'exclude'
|
291 |
Â
'title' => esc_html__( 'Exclude', 'stream' ),
|
292 |
Â
'fields' => array(
|
293 |
Â
array(
|
294 |
-
'name'
|
295 |
-
'title'
|
296 |
-
'type'
|
297 |
-
'desc'
|
298 |
-
'default'
|
299 |
-
'nonce'
|
300 |
Â
),
|
301 |
Â
),
|
302 |
Â
),
|
@@ -312,20 +338,20 @@ class Settings {
|
|
312 |
Â
'default' => 0,
|
313 |
Â
),
|
314 |
Â
array(
|
315 |
-
'name'
|
316 |
-
'title'
|
317 |
-
'type'
|
318 |
-
'href'
|
319 |
Â
array(
|
320 |
-
'action'
|
321 |
-
'
|
322 |
Â
),
|
323 |
Â
admin_url( 'admin-ajax.php' )
|
324 |
Â
),
|
325 |
-
'class'
|
326 |
-
'desc'
|
327 |
-
'default'
|
328 |
-
'sticky'
|
329 |
Â
),
|
330 |
Â
),
|
331 |
Â
),
|
@@ -438,7 +464,12 @@ class Settings {
|
|
438 |
Â
public function register_settings() {
|
439 |
Â
$sections = $this->get_fields();
|
440 |
Â
|
441 |
-
register_setting(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
442 |
Â
|
443 |
Â
foreach ( $sections as $section_name => $section ) {
|
444 |
Â
add_settings_section(
|
@@ -456,12 +487,16 @@ class Settings {
|
|
456 |
Â
add_settings_field(
|
457 |
Â
$field['name'],
|
458 |
Â
$field['title'],
|
459 |
-
( isset( $field['callback'] ) ? $field['callback'] : array(
|
Â
|
|
Â
|
|
Â
|
|
460 |
Â
$this->option_key,
|
461 |
Â
$section_name,
|
462 |
Â
$field + array(
|
463 |
Â
'section' => $section_name,
|
464 |
-
'label_for' => sprintf( '%s_%s_%s', $this->option_key, $section_name, $field['name'] ),
|
Â
|
|
465 |
Â
)
|
466 |
Â
);
|
467 |
Â
}
|
@@ -492,7 +527,7 @@ class Settings {
|
|
492 |
Â
continue;
|
493 |
Â
}
|
494 |
Â
|
495 |
-
// Sanitize depending on the type of field
|
496 |
Â
switch ( $type ) {
|
497 |
Â
case 'number':
|
498 |
Â
$output[ $name ] = is_numeric( $input[ $name ] ) ? intval( trim( $input[ $name ] ) ) : '';
|
@@ -504,10 +539,12 @@ class Settings {
|
|
504 |
Â
if ( is_array( $input[ $name ] ) ) {
|
505 |
Â
$output[ $name ] = $input[ $name ];
|
506 |
Â
|
507 |
-
// Support all values in multidimentional arrays too
|
508 |
-
array_walk_recursive(
|
509 |
-
$
|
510 |
-
|
Â
|
|
Â
|
|
511 |
Â
} else {
|
512 |
Â
$output[ $name ] = trim( $input[ $name ] );
|
513 |
Â
}
|
@@ -564,9 +601,7 @@ class Settings {
|
|
564 |
Â
return '';
|
565 |
Â
}
|
566 |
Â
|
567 |
-
if ( 'multi_checkbox' === $type
|
568 |
-
&& ( empty( $field['choices'] ) || ! is_array( $field['choices'] ) )
|
569 |
-
) {
|
570 |
Â
return '';
|
571 |
Â
}
|
572 |
Â
|
@@ -627,15 +662,15 @@ class Settings {
|
|
627 |
Â
esc_attr( $section ),
|
628 |
Â
esc_attr( $name )
|
629 |
Â
);
|
630 |
-
// Fallback if nothing is selected
|
631 |
-
$output
|
632 |
Â
'<input type="hidden" name="%1$s[%2$s_%3$s][]" value="__placeholder__" />',
|
633 |
Â
esc_attr( $option_key ),
|
634 |
Â
esc_attr( $section ),
|
635 |
Â
esc_attr( $name )
|
636 |
Â
);
|
637 |
Â
$current_value = (array) $current_value;
|
638 |
-
$choices
|
639 |
Â
if ( is_callable( $choices ) ) {
|
640 |
Â
$choices = call_user_func( $choices );
|
641 |
Â
}
|
@@ -702,7 +737,7 @@ class Settings {
|
|
702 |
Â
esc_attr( $title )
|
703 |
Â
);
|
704 |
Â
break;
|
705 |
-
case 'select2'
|
706 |
Â
if ( ! isset( $current_value ) ) {
|
707 |
Â
$current_value = '';
|
708 |
Â
}
|
@@ -721,14 +756,24 @@ class Settings {
|
|
721 |
Â
if ( isset( $value['children'] ) ) {
|
722 |
Â
$child_values = array();
|
723 |
Â
foreach ( $value['children'] as $child_key => $child_value ) {
|
724 |
-
$child_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
725 |
Â
}
|
726 |
Â
}
|
727 |
Â
if ( isset( $value['label'] ) ) {
|
728 |
-
$data_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
729 |
Â
}
|
730 |
Â
} else {
|
731 |
-
$data_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
732 |
Â
}
|
733 |
Â
}
|
734 |
Â
$class .= ' with-source';
|
@@ -742,6 +787,7 @@ class Settings {
|
|
742 |
Â
esc_attr( wp_stream_json_encode( $data_values ) ),
|
743 |
Â
esc_attr( $current_value ),
|
744 |
Â
esc_attr( $class ),
|
Â
|
|
745 |
Â
sprintf( esc_html__( 'Any %s', 'stream' ), $title )
|
746 |
Â
);
|
747 |
Â
|
@@ -754,12 +800,13 @@ class Settings {
|
|
754 |
Â
);
|
755 |
Â
|
756 |
Â
break;
|
757 |
-
case 'rule_list'
|
758 |
-
$
|
Â
|
|
759 |
Â
$output = '<p class="description">' . esc_html( $description ) . '</p>';
|
760 |
Â
|
761 |
-
$actions_top = sprintf( '<input type="button" class="button" id="%1$s_new_rule" value="+ %2$s" />', esc_attr( $section . '_' . $name ),
|
762 |
-
$actions_bottom = sprintf( '<input type="button" class="button" id="%1$s_remove_rules" value="%2$s" />', esc_attr( $section . '_' . $name ),
|
763 |
Â
|
764 |
Â
$output .= sprintf( '<div class="tablenav top">%1$s</div>', $actions_top );
|
765 |
Â
$output .= '<table class="wp-list-table widefat fixed stream-exclude-list">';
|
@@ -785,11 +832,11 @@ class Settings {
|
|
785 |
Â
|
786 |
Â
$exclude_rows = array();
|
787 |
Â
|
788 |
-
// Prepend an empty row
|
789 |
Â
$current_value['exclude_row'] = array( 'helper' => '' ) + ( isset( $current_value['exclude_row'] ) ? $current_value['exclude_row'] : array() );
|
790 |
Â
|
791 |
Â
foreach ( $current_value['exclude_row'] as $key => $value ) {
|
792 |
-
// Prepare values
|
793 |
Â
$author_or_role = isset( $current_value['author_or_role'][ $key ] ) ? $current_value['author_or_role'][ $key ] : '';
|
794 |
Â
$connector = isset( $current_value['connector'][ $key ] ) ? $current_value['connector'][ $key ] : '';
|
795 |
Â
$context = isset( $current_value['context'][ $key ] ) ? $current_value['context'][ $key ] : '';
|
@@ -801,11 +848,14 @@ class Settings {
|
|
801 |
Â
$author_or_role_selected = array();
|
802 |
Â
|
803 |
Â
foreach ( $this->get_roles() as $role_id => $role ) {
|
804 |
-
$args = array(
|
805 |
-
|
Â
|
|
Â
|
|
806 |
Â
$count = isset( $users['avail_roles'][ $role_id ] ) ? $users['avail_roles'][ $role_id ] : 0;
|
807 |
Â
|
808 |
Â
if ( ! empty( $count ) ) {
|
Â
|
|
809 |
Â
$args['user_count'] = sprintf( _n( '%d user', '%d users', absint( $count ), 'stream' ), absint( $count ) );
|
810 |
Â
}
|
811 |
Â
|
@@ -820,21 +870,26 @@ class Settings {
|
|
820 |
Â
if ( empty( $author_or_role_selected ) && is_numeric( $author_or_role ) ) {
|
821 |
Â
$user = new WP_User( $author_or_role );
|
822 |
Â
$display_name = ( 0 === $user->ID ) ? esc_html__( 'N/A', 'stream' ) : $user->display_name;
|
823 |
-
$author_or_role_selected = array(
|
Â
|
|
Â
|
|
Â
|
|
824 |
Â
$author_or_role_values[] = $author_or_role_selected;
|
825 |
Â
}
|
826 |
Â
|
827 |
-
$author_or_role_input = $form->render_field(
|
828 |
-
'
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
'
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
Â
|
|
Â
|
|
838 |
Â
|
839 |
Â
// Context dropdown menu
|
840 |
Â
$context_values = array();
|
@@ -845,67 +900,91 @@ class Settings {
|
|
845 |
Â
if ( isset( $context_data['children'] ) ) {
|
846 |
Â
$child_values = array();
|
847 |
Â
foreach ( $context_data['children'] as $child_id => $child_value ) {
|
848 |
-
$child_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
849 |
Â
}
|
850 |
Â
}
|
851 |
Â
if ( isset( $context_data['label'] ) ) {
|
852 |
-
$context_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
853 |
Â
}
|
854 |
Â
} else {
|
855 |
-
$context_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
856 |
Â
}
|
857 |
Â
}
|
858 |
Â
|
859 |
-
$connector_or_context_input = $form->render_field(
|
860 |
-
'
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
'
|
865 |
-
|
866 |
-
|
867 |
-
|
Â
|
|
Â
|
|
868 |
Â
|
869 |
-
$connector_input = $form->render_field(
|
870 |
-
'
|
871 |
-
|
872 |
-
|
873 |
-
|
Â
|
|
Â
|
|
874 |
Â
|
875 |
-
$context_input = $form->render_field(
|
876 |
-
'
|
877 |
-
|
878 |
-
|
879 |
-
|
Â
|
|
Â
|
|
880 |
Â
|
881 |
Â
// Action dropdown menu
|
882 |
Â
$action_values = array();
|
883 |
Â
|
884 |
Â
foreach ( $this->get_terms_labels( 'action' ) as $action_id => $action_data ) {
|
885 |
-
$action_values[] = array(
|
Â
|
|
Â
|
|
Â
|
|
886 |
Â
}
|
887 |
Â
|
888 |
-
$action_input = $form->render_field(
|
889 |
-
'
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
'
|
895 |
-
|
896 |
-
|
Â
|
|
Â
|
|
897 |
Â
|
898 |
Â
// IP Address input
|
899 |
-
$ip_address_input = $form->render_field(
|
900 |
-
'
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
'
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
Â
|
|
Â
|
|
909 |
Â
|
910 |
Â
// Hidden helper input
|
911 |
Â
$helper_input = sprintf(
|
@@ -925,8 +1004,8 @@ class Settings {
|
|
925 |
Â
<td>%10$s</td>
|
926 |
Â
<th scope="row" class="actions-column">%11$s</th>
|
927 |
Â
</tr>',
|
928 |
-
( 0 !== $key % 2 ) ? 'alternate' : '',
|
929 |
-
( 'helper' === $key ) ? 'hidden helper' : '',
|
930 |
Â
'<input class="cb-select" type="checkbox" />',
|
931 |
Â
$helper_input,
|
932 |
Â
$author_or_role_input,
|
@@ -1036,8 +1115,8 @@ class Settings {
|
|
1036 |
Â
* @param array $new_value
|
1037 |
Â
*/
|
1038 |
Â
public function updated_option_ttl_remove_records( $old_value, $new_value ) {
|
1039 |
-
$ttl_before = isset( $old_value['general_records_ttl'] ) ? (int) $old_value['general_records_ttl'] : -1;
|
1040 |
-
$ttl_after = isset( $new_value['general_records_ttl'] ) ? (int) $new_value['general_records_ttl'] : -1;
|
1041 |
Â
|
1042 |
Â
if ( $ttl_after < $ttl_before ) {
|
1043 |
Â
/**
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
use \WP_Roles;
|
7 |
Â
use \WP_User_Query;
|
8 |
Â
|
9 |
Â
class Settings {
|
10 |
+
|
11 |
Â
/**
|
12 |
Â
* Hold Plugin class
|
13 |
Â
* @var Plugin
|
57 |
Â
add_action( 'admin_init', array( $this, 'register_settings' ) );
|
58 |
Â
|
59 |
Â
// Remove records when records TTL is shortened
|
60 |
+
add_action(
|
61 |
+
'update_option_' . $this->option_key, array(
|
62 |
+
$this,
|
63 |
+
'updated_option_ttl_remove_records',
|
64 |
+
), 10, 2
|
65 |
+
);
|
66 |
Â
|
67 |
Â
// Apply label translations for settings
|
68 |
+
add_filter(
|
69 |
+
'wp_stream_serialized_labels', array(
|
70 |
+
$this,
|
71 |
+
'get_settings_translations',
|
72 |
+
)
|
73 |
+
);
|
74 |
Â
|
75 |
Â
// Ajax callback function to search users
|
76 |
Â
add_action( 'wp_ajax_stream_get_users', array( $this, 'get_users' ) );
|
107 |
Â
'find' => $search,
|
108 |
Â
);
|
109 |
Â
|
110 |
+
add_filter(
|
111 |
+
'user_search_columns', array(
|
112 |
+
$this,
|
113 |
+
'add_display_name_search_columns',
|
114 |
+
), 10, 3
|
115 |
+
);
|
116 |
Â
|
117 |
Â
$users = new WP_User_Query(
|
118 |
Â
array(
|
119 |
+
'search' => "*{$request->find}*",
|
120 |
Â
'search_columns' => array(
|
121 |
Â
'user_login',
|
122 |
Â
'user_nicename',
|
123 |
Â
'user_email',
|
124 |
Â
'user_url',
|
125 |
Â
),
|
126 |
+
'orderby' => 'display_name',
|
127 |
+
'number' => $this->plugin->admin->preload_users_max,
|
128 |
Â
)
|
129 |
Â
);
|
130 |
Â
|
131 |
+
remove_filter(
|
132 |
+
'user_search_columns', array(
|
133 |
+
$this,
|
134 |
+
'add_display_name_search_columns',
|
135 |
+
), 10
|
136 |
+
);
|
137 |
Â
|
138 |
Â
if ( 0 === $users->get_total() ) {
|
139 |
Â
wp_send_json_error( $response );
|
143 |
Â
if ( is_multisite() && is_super_admin() ) {
|
144 |
Â
$super_admins = get_super_admins();
|
145 |
Â
foreach ( $super_admins as $admin ) {
|
146 |
+
$user = get_user_by( 'login', $admin );
|
147 |
Â
$users_array[] = $user;
|
148 |
Â
}
|
149 |
Â
}
|
150 |
Â
|
151 |
+
$response->status = true;
|
152 |
+
$response->message = '';
|
153 |
+
$response->roles = $this->get_roles();
|
154 |
+
$response->users = array();
|
155 |
Â
$users_added_to_response = array();
|
156 |
Â
|
157 |
Â
foreach ( $users_array as $key => $user ) {
|
171 |
Â
|
172 |
Â
$args['tooltip'] = esc_attr(
|
173 |
Â
sprintf(
|
174 |
+
// translators: Placeholders refers to a user ID, a username, an email address, and a user role (e.g. "42", "administrator", "foo@bar.com", "subscriber").
|
175 |
Â
__( 'ID: %1$d\nUser: %2$s\nEmail: %3$s\nRole: %4$s', 'stream' ),
|
176 |
Â
$author->id,
|
177 |
Â
$author->user_login,
|
187 |
Â
|
188 |
Â
usort(
|
189 |
Â
$response->users,
|
190 |
+
function ( $a, $b ) {
|
191 |
Â
return strcmp( $a['text'], $b['text'] );
|
192 |
Â
}
|
193 |
Â
);
|
194 |
Â
|
195 |
Â
if ( empty( $search ) || preg_match( '/wp|cli|system|unknown/i', $search ) ) {
|
196 |
+
$author = new Author( 0 );
|
197 |
Â
$response->users[] = array(
|
198 |
Â
'id' => '0',
|
199 |
Â
'text' => $author->get_display_name(),
|
206 |
Â
}
|
207 |
Â
|
208 |
Â
/**
|
209 |
+
* Ajax callback function to search IP addresses, used on exclude setting page
|
210 |
+
*/
|
211 |
Â
public function get_ips() {
|
212 |
Â
if ( ! defined( 'DOING_AJAX' ) || ! current_user_can( $this->plugin->admin->settings_cap ) ) {
|
213 |
Â
return;
|
219 |
Â
$find = wp_stream_filter_input( INPUT_POST, 'find' );
|
220 |
Â
|
221 |
Â
if ( isset( $find['term'] ) && '' !== $find['term'] ) {
|
222 |
+
$ips = array_filter(
|
223 |
+
$ips,
|
224 |
+
function ( $ip ) use ( $find ) {
|
225 |
+
return 0 === strpos( $ip, $find['term'] );
|
226 |
+
}
|
227 |
+
);
|
228 |
Â
}
|
229 |
Â
|
230 |
Â
if ( $ips ) {
|
237 |
Â
/**
|
238 |
Â
* Filter the columns to search in a WP_User_Query search.
|
239 |
Â
*
|
240 |
+
* @param array $search_columns Array of column names to be searched.
|
241 |
+
* @param string $search Text being searched.
|
242 |
+
* @param \WP_User_Query $query current WP_User_Query instance.
|
243 |
Â
*
|
244 |
Â
* @return array
|
245 |
Â
*/
|
280 |
Â
*/
|
281 |
Â
public function get_fields() {
|
282 |
Â
$fields = array(
|
283 |
+
'general' => array(
|
284 |
Â
'title' => esc_html__( 'General', 'stream' ),
|
285 |
Â
'fields' => array(
|
286 |
Â
array(
|
287 |
+
'name' => 'role_access',
|
288 |
+
'title' => esc_html__( 'Role Access', 'stream' ),
|
289 |
+
'type' => 'multi_checkbox',
|
290 |
+
'desc' => esc_html__( 'Users from the selected roles above will have permission to view Stream Records. However, only site Administrators can access Stream Settings.', 'stream' ),
|
291 |
+
'choices' => $this->get_roles(),
|
292 |
+
'default' => array( 'administrator' ),
|
293 |
Â
),
|
294 |
Â
array(
|
295 |
Â
'name' => 'records_ttl',
|
313 |
Â
),
|
314 |
Â
),
|
315 |
Â
),
|
316 |
+
'exclude' => array(
|
317 |
Â
'title' => esc_html__( 'Exclude', 'stream' ),
|
318 |
Â
'fields' => array(
|
319 |
Â
array(
|
320 |
+
'name' => 'rules',
|
321 |
+
'title' => esc_html__( 'Exclude Rules', 'stream' ),
|
322 |
+
'type' => 'rule_list',
|
323 |
+
'desc' => esc_html__( 'Create rules to exclude certain kinds of activity from being recorded by Stream.', 'stream' ),
|
324 |
+
'default' => array(),
|
325 |
+
'nonce' => 'stream_get_ips',
|
326 |
Â
),
|
327 |
Â
),
|
328 |
Â
),
|
338 |
Â
'default' => 0,
|
339 |
Â
),
|
340 |
Â
array(
|
341 |
+
'name' => 'delete_all_records',
|
342 |
+
'title' => esc_html__( 'Reset Stream Database', 'stream' ),
|
343 |
+
'type' => 'link',
|
344 |
+
'href' => add_query_arg(
|
345 |
Â
array(
|
346 |
+
'action' => 'wp_stream_reset',
|
347 |
+
'wp_stream_nonce_reset' => wp_create_nonce( 'stream_nonce_reset' ),
|
348 |
Â
),
|
349 |
Â
admin_url( 'admin-ajax.php' )
|
350 |
Â
),
|
351 |
+
'class' => 'warning',
|
352 |
+
'desc' => esc_html__( 'Warning: This will delete all activity records from the database.', 'stream' ),
|
353 |
+
'default' => 0,
|
354 |
+
'sticky' => 'bottom',
|
355 |
Â
),
|
356 |
Â
),
|
357 |
Â
),
|
464 |
Â
public function register_settings() {
|
465 |
Â
$sections = $this->get_fields();
|
466 |
Â
|
467 |
+
register_setting(
|
468 |
+
$this->option_key, $this->option_key, array(
|
469 |
+
$this,
|
470 |
+
'sanitize_settings',
|
471 |
+
)
|
472 |
+
);
|
473 |
Â
|
474 |
Â
foreach ( $sections as $section_name => $section ) {
|
475 |
Â
add_settings_section(
|
487 |
Â
add_settings_field(
|
488 |
Â
$field['name'],
|
489 |
Â
$field['title'],
|
490 |
+
( isset( $field['callback'] ) ? $field['callback'] : array(
|
491 |
+
$this,
|
492 |
+
'output_field',
|
493 |
+
) ),
|
494 |
Â
$this->option_key,
|
495 |
Â
$section_name,
|
496 |
Â
$field + array(
|
497 |
Â
'section' => $section_name,
|
498 |
+
'label_for' => sprintf( '%s_%s_%s', $this->option_key, $section_name, $field['name'] ),
|
499 |
+
// xss ok
|
500 |
Â
)
|
501 |
Â
);
|
502 |
Â
}
|
527 |
Â
continue;
|
528 |
Â
}
|
529 |
Â
|
530 |
+
// Sanitize depending on the type of field.
|
531 |
Â
switch ( $type ) {
|
532 |
Â
case 'number':
|
533 |
Â
$output[ $name ] = is_numeric( $input[ $name ] ) ? intval( trim( $input[ $name ] ) ) : '';
|
539 |
Â
if ( is_array( $input[ $name ] ) ) {
|
540 |
Â
$output[ $name ] = $input[ $name ];
|
541 |
Â
|
542 |
+
// Support all values in multidimentional arrays too.
|
543 |
+
array_walk_recursive(
|
544 |
+
$output[ $name ], function ( &$v, $k ) {
|
545 |
+
$v = trim( $v );
|
546 |
+
}
|
547 |
+
);
|
548 |
Â
} else {
|
549 |
Â
$output[ $name ] = trim( $input[ $name ] );
|
550 |
Â
}
|
601 |
Â
return '';
|
602 |
Â
}
|
603 |
Â
|
604 |
+
if ( 'multi_checkbox' === $type && ( empty( $field['choices'] ) || ! is_array( $field['choices'] ) ) ) {
|
Â
|
|
Â
|
|
605 |
Â
return '';
|
606 |
Â
}
|
607 |
Â
|
662 |
Â
esc_attr( $section ),
|
663 |
Â
esc_attr( $name )
|
664 |
Â
);
|
665 |
+
// Fallback if nothing is selected.
|
666 |
+
$output .= sprintf(
|
667 |
Â
'<input type="hidden" name="%1$s[%2$s_%3$s][]" value="__placeholder__" />',
|
668 |
Â
esc_attr( $option_key ),
|
669 |
Â
esc_attr( $section ),
|
670 |
Â
esc_attr( $name )
|
671 |
Â
);
|
672 |
Â
$current_value = (array) $current_value;
|
673 |
+
$choices = $field['choices'];
|
674 |
Â
if ( is_callable( $choices ) ) {
|
675 |
Â
$choices = call_user_func( $choices );
|
676 |
Â
}
|
737 |
Â
esc_attr( $title )
|
738 |
Â
);
|
739 |
Â
break;
|
740 |
+
case 'select2':
|
741 |
Â
if ( ! isset( $current_value ) ) {
|
742 |
Â
$current_value = '';
|
743 |
Â
}
|
756 |
Â
if ( isset( $value['children'] ) ) {
|
757 |
Â
$child_values = array();
|
758 |
Â
foreach ( $value['children'] as $child_key => $child_value ) {
|
759 |
+
$child_values[] = array(
|
760 |
+
'id' => $child_key,
|
761 |
+
'text' => $child_value,
|
762 |
+
);
|
763 |
Â
}
|
764 |
Â
}
|
765 |
Â
if ( isset( $value['label'] ) ) {
|
766 |
+
$data_values[] = array(
|
767 |
+
'id' => $key,
|
768 |
+
'text' => $value['label'],
|
769 |
+
'children' => $child_values,
|
770 |
+
);
|
771 |
Â
}
|
772 |
Â
} else {
|
773 |
+
$data_values[] = array(
|
774 |
+
'id' => $key,
|
775 |
+
'text' => $value,
|
776 |
+
);
|
777 |
Â
}
|
778 |
Â
}
|
779 |
Â
$class .= ' with-source';
|
787 |
Â
esc_attr( wp_stream_json_encode( $data_values ) ),
|
788 |
Â
esc_attr( $current_value ),
|
789 |
Â
esc_attr( $class ),
|
790 |
+
// translators: Placeholder refers to the title of the dropdown menu (e.g. "users")
|
791 |
Â
sprintf( esc_html__( 'Any %s', 'stream' ), $title )
|
792 |
Â
);
|
793 |
Â
|
800 |
Â
);
|
801 |
Â
|
802 |
Â
break;
|
803 |
+
case 'rule_list':
|
804 |
+
$users = count_users();
|
805 |
+
$form = new Form_Generator();
|
806 |
Â
$output = '<p class="description">' . esc_html( $description ) . '</p>';
|
807 |
Â
|
808 |
+
$actions_top = sprintf( '<input type="button" class="button" id="%1$s_new_rule" value="+ %2$s" />', esc_attr( $section . '_' . $name ), esc_html__( 'Add New Rule', 'stream' ) );
|
809 |
+
$actions_bottom = sprintf( '<input type="button" class="button" id="%1$s_remove_rules" value="%2$s" />', esc_attr( $section . '_' . $name ), esc_html__( 'Delete Selected Rules', 'stream' ) );
|
810 |
Â
|
811 |
Â
$output .= sprintf( '<div class="tablenav top">%1$s</div>', $actions_top );
|
812 |
Â
$output .= '<table class="wp-list-table widefat fixed stream-exclude-list">';
|
832 |
Â
|
833 |
Â
$exclude_rows = array();
|
834 |
Â
|
835 |
+
// Prepend an empty row.
|
836 |
Â
$current_value['exclude_row'] = array( 'helper' => '' ) + ( isset( $current_value['exclude_row'] ) ? $current_value['exclude_row'] : array() );
|
837 |
Â
|
838 |
Â
foreach ( $current_value['exclude_row'] as $key => $value ) {
|
839 |
+
// Prepare values.
|
840 |
Â
$author_or_role = isset( $current_value['author_or_role'][ $key ] ) ? $current_value['author_or_role'][ $key ] : '';
|
841 |
Â
$connector = isset( $current_value['connector'][ $key ] ) ? $current_value['connector'][ $key ] : '';
|
842 |
Â
$context = isset( $current_value['context'][ $key ] ) ? $current_value['context'][ $key ] : '';
|
848 |
Â
$author_or_role_selected = array();
|
849 |
Â
|
850 |
Â
foreach ( $this->get_roles() as $role_id => $role ) {
|
851 |
+
$args = array(
|
852 |
+
'value' => $role_id,
|
853 |
+
'text' => $role,
|
854 |
+
);
|
855 |
Â
$count = isset( $users['avail_roles'][ $role_id ] ) ? $users['avail_roles'][ $role_id ] : 0;
|
856 |
Â
|
857 |
Â
if ( ! empty( $count ) ) {
|
858 |
+
// translators: Placeholder refers to a number of users (e.g. "42")
|
859 |
Â
$args['user_count'] = sprintf( _n( '%d user', '%d users', absint( $count ), 'stream' ), absint( $count ) );
|
860 |
Â
}
|
861 |
Â
|
870 |
Â
if ( empty( $author_or_role_selected ) && is_numeric( $author_or_role ) ) {
|
871 |
Â
$user = new WP_User( $author_or_role );
|
872 |
Â
$display_name = ( 0 === $user->ID ) ? esc_html__( 'N/A', 'stream' ) : $user->display_name;
|
873 |
+
$author_or_role_selected = array(
|
874 |
+
'value' => $user->ID,
|
875 |
+
'text' => $display_name,
|
876 |
+
);
|
877 |
Â
$author_or_role_values[] = $author_or_role_selected;
|
878 |
Â
}
|
879 |
Â
|
880 |
+
$author_or_role_input = $form->render_field(
|
881 |
+
'select2', array(
|
882 |
+
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'author_or_role' ) ),
|
883 |
+
'options' => $author_or_role_values,
|
884 |
+
'classes' => 'author_or_role',
|
885 |
+
'data' => array(
|
886 |
+
'placeholder' => esc_html__( 'Any Author or Role', 'stream' ),
|
887 |
+
'nonce' => esc_attr( wp_create_nonce( 'stream_get_users' ) ),
|
888 |
+
'selected-id' => isset( $author_or_role_selected['value'] ) ? esc_attr( $author_or_role_selected['value'] ) : '',
|
889 |
+
'selected-text' => isset( $author_or_role_selected['text'] ) ? esc_attr( $author_or_role_selected['text'] ) : '',
|
890 |
+
),
|
891 |
+
)
|
892 |
+
);
|
893 |
Â
|
894 |
Â
// Context dropdown menu
|
895 |
Â
$context_values = array();
|
900 |
Â
if ( isset( $context_data['children'] ) ) {
|
901 |
Â
$child_values = array();
|
902 |
Â
foreach ( $context_data['children'] as $child_id => $child_value ) {
|
903 |
+
$child_values[] = array(
|
904 |
+
'value' => $context_id . '-' . $child_id,
|
905 |
+
'text' => $child_value,
|
906 |
+
'parent' => $context_id,
|
907 |
+
);
|
908 |
Â
}
|
909 |
Â
}
|
910 |
Â
if ( isset( $context_data['label'] ) ) {
|
911 |
+
$context_values[] = array(
|
912 |
+
'value' => $context_id,
|
913 |
+
'text' => $context_data['label'],
|
914 |
+
'children' => $child_values,
|
915 |
+
);
|
916 |
Â
}
|
917 |
Â
} else {
|
918 |
+
$context_values[] = array(
|
919 |
+
'value' => $context_id,
|
920 |
+
'text' => $context_data,
|
921 |
+
);
|
922 |
Â
}
|
923 |
Â
}
|
924 |
Â
|
925 |
+
$connector_or_context_input = $form->render_field(
|
926 |
+
'select2', array(
|
927 |
+
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector_or_context' ) ),
|
928 |
+
'options' => $context_values,
|
929 |
+
'classes' => 'connector_or_context',
|
930 |
+
'data' => array(
|
931 |
+
'group' => 'connector',
|
932 |
+
'placeholder' => __( 'Any Context', 'stream' ),
|
933 |
+
),
|
934 |
+
)
|
935 |
+
);
|
936 |
Â
|
937 |
+
$connector_input = $form->render_field(
|
938 |
+
'hidden', array(
|
939 |
+
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector' ) ),
|
940 |
+
'value' => $connector,
|
941 |
+
'classes' => 'connector',
|
942 |
+
)
|
943 |
+
);
|
944 |
Â
|
945 |
+
$context_input = $form->render_field(
|
946 |
+
'hidden', array(
|
947 |
+
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'context' ) ),
|
948 |
+
'value' => $context,
|
949 |
+
'classes' => 'context',
|
950 |
+
)
|
951 |
+
);
|
952 |
Â
|
953 |
Â
// Action dropdown menu
|
954 |
Â
$action_values = array();
|
955 |
Â
|
956 |
Â
foreach ( $this->get_terms_labels( 'action' ) as $action_id => $action_data ) {
|
957 |
+
$action_values[] = array(
|
958 |
+
'value' => $action_id,
|
959 |
+
'text' => $action_data,
|
960 |
+
);
|
961 |
Â
}
|
962 |
Â
|
963 |
+
$action_input = $form->render_field(
|
964 |
+
'select2', array(
|
965 |
+
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'action' ) ),
|
966 |
+
'value' => $action,
|
967 |
+
'options' => $action_values,
|
968 |
+
'classes' => 'action',
|
969 |
+
'data' => array(
|
970 |
+
'placeholder' => __( 'Any Action', 'stream' ),
|
971 |
+
),
|
972 |
+
)
|
973 |
+
);
|
974 |
Â
|
975 |
Â
// IP Address input
|
976 |
+
$ip_address_input = $form->render_field(
|
977 |
+
'select2', array(
|
978 |
+
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'ip_address' ) ),
|
979 |
+
'value' => $ip_address,
|
980 |
+
'classes' => 'ip_address',
|
981 |
+
'data' => array(
|
982 |
+
'placeholder' => esc_attr__( 'Any IP Address', 'stream' ),
|
983 |
+
'nonce' => esc_attr( wp_create_nonce( 'stream_get_ips' ) ),
|
984 |
+
),
|
985 |
+
'multiple' => true,
|
986 |
+
)
|
987 |
+
);
|
988 |
Â
|
989 |
Â
// Hidden helper input
|
990 |
Â
$helper_input = sprintf(
|
1004 |
Â
<td>%10$s</td>
|
1005 |
Â
<th scope="row" class="actions-column">%11$s</th>
|
1006 |
Â
</tr>',
|
1007 |
+
( 0 !== (int) $key % 2 ) ? 'alternate' : '',
|
1008 |
+
( 'helper' === (string) $key ) ? 'hidden helper' : '',
|
1009 |
Â
'<input class="cb-select" type="checkbox" />',
|
1010 |
Â
$helper_input,
|
1011 |
Â
$author_or_role_input,
|
1115 |
Â
* @param array $new_value
|
1116 |
Â
*/
|
1117 |
Â
public function updated_option_ttl_remove_records( $old_value, $new_value ) {
|
1118 |
+
$ttl_before = isset( $old_value['general_records_ttl'] ) ? (int) $old_value['general_records_ttl'] : - 1;
|
1119 |
+
$ttl_after = isset( $new_value['general_records_ttl'] ) ? (int) $new_value['general_records_ttl'] : - 1;
|
1120 |
Â
|
1121 |
Â
if ( $ttl_after < $ttl_before ) {
|
1122 |
Â
/**
|
classes/class-uninstall.php
CHANGED
@@ -22,7 +22,7 @@ class Uninstall {
|
|
22 |
Â
*/
|
23 |
Â
public $user_meta;
|
24 |
Â
|
25 |
-
function __construct( $plugin ) {
|
26 |
Â
$this->plugin = $plugin;
|
27 |
Â
|
28 |
Â
$this->user_meta = array(
|
@@ -197,7 +197,7 @@ class Uninstall {
|
|
197 |
Â
// Specific user meta
|
198 |
Â
foreach ( $this->user_meta as $meta_key ) {
|
199 |
Â
$wpdb->query(
|
200 |
-
$wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key =
|
201 |
Â
);
|
202 |
Â
}
|
203 |
Â
}
|
22 |
Â
*/
|
23 |
Â
public $user_meta;
|
24 |
Â
|
25 |
+
public function __construct( $plugin ) {
|
26 |
Â
$this->plugin = $plugin;
|
27 |
Â
|
28 |
Â
$this->user_meta = array(
|
197 |
Â
// Specific user meta
|
198 |
Â
foreach ( $this->user_meta as $meta_key ) {
|
199 |
Â
$wpdb->query(
|
200 |
+
$wpdb->prepare( "DELETE FROM {$wpdb->usermeta} WHERE meta_key = {$wpdb->prefix}%s;", $meta_key )
|
201 |
Â
);
|
202 |
Â
}
|
203 |
Â
}
|
connectors/class-connector-acf.php
CHANGED
@@ -58,7 +58,7 @@ class Connector_ACF extends Connector {
|
|
58 |
Â
if ( class_exists( 'acf' ) ) { //TODO: Should this be function_exists?
|
59 |
Â
$acf = \acf();
|
60 |
Â
if ( version_compare( $acf->settings['version'], self::PLUGIN_MIN_VERSION, '>=' ) ) {
|
61 |
-
|
62 |
Â
}
|
63 |
Â
}
|
64 |
Â
|
@@ -133,7 +133,7 @@ class Connector_ACF extends Connector {
|
|
133 |
Â
*/
|
134 |
Â
public function action_links( $links, $record ) {
|
135 |
Â
$posts_connector = new Connector_Posts();
|
136 |
-
$links
|
137 |
Â
|
138 |
Â
return $links;
|
139 |
Â
}
|
@@ -209,8 +209,9 @@ class Connector_ACF extends Connector {
|
|
209 |
Â
* @param mixed|null $meta_value
|
210 |
Â
*/
|
211 |
Â
public function check_meta( $type, $action, $meta_id, $object_id, $meta_key, $meta_value = null ) {
|
212 |
-
|
213 |
-
|
Â
|
|
214 |
Â
return;
|
215 |
Â
}
|
216 |
Â
|
@@ -223,6 +224,7 @@ class Connector_ACF extends Connector {
|
|
223 |
Â
}
|
224 |
Â
|
225 |
Â
$this->log(
|
Â
|
|
226 |
Â
esc_html_x( '"%1$s" field in "%2$s" %3$s', 'acf', 'stream' ),
|
227 |
Â
array(
|
228 |
Â
'label' => $meta_value['label'],
|
@@ -253,6 +255,7 @@ class Connector_ACF extends Connector {
|
|
253 |
Â
);
|
254 |
Â
|
255 |
Â
$this->log(
|
Â
|
|
256 |
Â
esc_html_x( 'Position of "%1$s" updated to "%2$s"', 'acf', 'stream' ),
|
257 |
Â
array(
|
258 |
Â
'title' => $post->post_title,
|
@@ -275,6 +278,7 @@ class Connector_ACF extends Connector {
|
|
275 |
Â
);
|
276 |
Â
|
277 |
Â
$this->log(
|
Â
|
|
278 |
Â
esc_html_x( 'Style of "%1$s" updated to "%2$s"', 'acf', 'stream' ),
|
279 |
Â
array(
|
280 |
Â
'title' => $post->post_title,
|
@@ -317,6 +321,7 @@ class Connector_ACF extends Connector {
|
|
317 |
Â
}
|
318 |
Â
|
319 |
Â
$this->log(
|
Â
|
|
320 |
Â
esc_html_x( '"%1$s" set to display on "%2$s"', 'acf', 'stream' ),
|
321 |
Â
array(
|
322 |
Â
'title' => $post->post_title,
|
@@ -369,7 +374,7 @@ class Connector_ACF extends Connector {
|
|
369 |
Â
$object_key = $taxonomy . '_' . $term_id;
|
370 |
Â
} elseif ( 'option' === $type ) {
|
371 |
Â
$object_key = 'options';
|
372 |
-
$key
|
373 |
Â
}
|
374 |
Â
|
375 |
Â
if ( isset( $this->cached_field_values_updates[ $object_key ][ $key ] ) ) {
|
@@ -389,7 +394,7 @@ class Connector_ACF extends Connector {
|
|
389 |
Â
$tax_obj = get_taxonomy( $taxonomy );
|
390 |
Â
$type_name = strtolower( get_taxonomy_labels( $tax_obj )->singular_name );
|
391 |
Â
} elseif ( 'option' === $type ) {
|
392 |
-
$title
|
393 |
Â
$type_name = 'option';
|
394 |
Â
} else {
|
395 |
Â
return false;
|
@@ -398,6 +403,7 @@ class Connector_ACF extends Connector {
|
|
398 |
Â
$cache = $this->cached_field_values_updates[ $object_key ][ $key ];
|
399 |
Â
|
400 |
Â
$this->log(
|
Â
|
|
401 |
Â
esc_html_x( '"%1$s" of "%2$s" %3$s updated', 'acf', 'stream' ),
|
402 |
Â
array(
|
403 |
Â
'field_label' => $cache['field']['label'],
|
@@ -436,6 +442,7 @@ class Connector_ACF extends Connector {
|
|
436 |
Â
$deleted = array_diff( $old, $new );
|
437 |
Â
|
438 |
Â
$this->log(
|
Â
|
|
439 |
Â
esc_html_x( 'Updated rules of "%1$s" (%2$d added, %3$d deleted)', 'acf', 'stream' ),
|
440 |
Â
array(
|
441 |
Â
'title' => $post->post_title,
|
@@ -503,6 +510,7 @@ class Connector_ACF extends Connector {
|
|
503 |
Â
// menu_order, aka Order No.
|
504 |
Â
if ( $data['menu_order'] !== $post->menu_order ) {
|
505 |
Â
$this->log(
|
Â
|
|
506 |
Â
esc_html_x( '"%1$s" reordered from %2$d to %3$d', 'acf', 'stream' ),
|
507 |
Â
array(
|
508 |
Â
'title' => $post->post_title,
|
@@ -554,6 +562,6 @@ class Connector_ACF extends Connector {
|
|
554 |
Â
* @return string
|
555 |
Â
*/
|
556 |
Â
private function get_saved_option_type( $key ) {
|
557 |
-
return substr( $key,0, 8 ) === 'options_' ? 'option' : 'taxonomy';
|
558 |
Â
}
|
559 |
Â
}
|
58 |
Â
if ( class_exists( 'acf' ) ) { //TODO: Should this be function_exists?
|
59 |
Â
$acf = \acf();
|
60 |
Â
if ( version_compare( $acf->settings['version'], self::PLUGIN_MIN_VERSION, '>=' ) ) {
|
61 |
+
return true;
|
62 |
Â
}
|
63 |
Â
}
|
64 |
Â
|
133 |
Â
*/
|
134 |
Â
public function action_links( $links, $record ) {
|
135 |
Â
$posts_connector = new Connector_Posts();
|
136 |
+
$links = $posts_connector->action_links( $links, $record );
|
137 |
Â
|
138 |
Â
return $links;
|
139 |
Â
}
|
209 |
Â
* @param mixed|null $meta_value
|
210 |
Â
*/
|
211 |
Â
public function check_meta( $type, $action, $meta_id, $object_id, $meta_key, $meta_value = null ) {
|
212 |
+
$post = get_post( $object_id );
|
213 |
+
if ( 'post' !== $type || ! $post || 'acf' !== $post->post_type ) {
|
214 |
+
$this->check_meta_values( $type, $action, $meta_id, $object_id, $meta_key, $meta_value );
|
215 |
Â
return;
|
216 |
Â
}
|
217 |
Â
|
224 |
Â
}
|
225 |
Â
|
226 |
Â
$this->log(
|
227 |
+
// translators: Placeholders refer to a field label, a form title, and an action (e.g. "Message", "Contact", "Created")
|
228 |
Â
esc_html_x( '"%1$s" field in "%2$s" %3$s', 'acf', 'stream' ),
|
229 |
Â
array(
|
230 |
Â
'label' => $meta_value['label'],
|
255 |
Â
);
|
256 |
Â
|
257 |
Â
$this->log(
|
258 |
+
// translators: Placeholders refer to a form title, and a position (e.g. "Contact", "Side")
|
259 |
Â
esc_html_x( 'Position of "%1$s" updated to "%2$s"', 'acf', 'stream' ),
|
260 |
Â
array(
|
261 |
Â
'title' => $post->post_title,
|
278 |
Â
);
|
279 |
Â
|
280 |
Â
$this->log(
|
281 |
+
// translators: Placeholders refer to a form title, and a layout (e.g. "Contact", "Seamless")
|
282 |
Â
esc_html_x( 'Style of "%1$s" updated to "%2$s"', 'acf', 'stream' ),
|
283 |
Â
array(
|
284 |
Â
'title' => $post->post_title,
|
321 |
Â
}
|
322 |
Â
|
323 |
Â
$this->log(
|
324 |
+
// translators: Placeholders refer to a form title, and a display option (e.g. "Contact", "All screens")
|
325 |
Â
esc_html_x( '"%1$s" set to display on "%2$s"', 'acf', 'stream' ),
|
326 |
Â
array(
|
327 |
Â
'title' => $post->post_title,
|
374 |
Â
$object_key = $taxonomy . '_' . $term_id;
|
375 |
Â
} elseif ( 'option' === $type ) {
|
376 |
Â
$object_key = 'options';
|
377 |
+
$key = preg_replace( '/^options_/', '', $key );
|
378 |
Â
}
|
379 |
Â
|
380 |
Â
if ( isset( $this->cached_field_values_updates[ $object_key ][ $key ] ) ) {
|
394 |
Â
$tax_obj = get_taxonomy( $taxonomy );
|
395 |
Â
$type_name = strtolower( get_taxonomy_labels( $tax_obj )->singular_name );
|
396 |
Â
} elseif ( 'option' === $type ) {
|
397 |
+
$title = 'settings page';
|
398 |
Â
$type_name = 'option';
|
399 |
Â
} else {
|
400 |
Â
return false;
|
403 |
Â
$cache = $this->cached_field_values_updates[ $object_key ][ $key ];
|
404 |
Â
|
405 |
Â
$this->log(
|
406 |
+
// translators: Placeholders refer to a field label, an object title, and an object type (e.g. "Message", "Hello World", "post")
|
407 |
Â
esc_html_x( '"%1$s" of "%2$s" %3$s updated', 'acf', 'stream' ),
|
408 |
Â
array(
|
409 |
Â
'field_label' => $cache['field']['label'],
|
442 |
Â
$deleted = array_diff( $old, $new );
|
443 |
Â
|
444 |
Â
$this->log(
|
445 |
+
// translators: Placeholders refer to a form title, the number of rules added, and the number of rules deleted (e.g. "Contact", "42", "7")
|
446 |
Â
esc_html_x( 'Updated rules of "%1$s" (%2$d added, %3$d deleted)', 'acf', 'stream' ),
|
447 |
Â
array(
|
448 |
Â
'title' => $post->post_title,
|
510 |
Â
// menu_order, aka Order No.
|
511 |
Â
if ( $data['menu_order'] !== $post->menu_order ) {
|
512 |
Â
$this->log(
|
513 |
+
// translators: Placeholders refer to a form title, a numeric position, and another numeric position (e.g. "Contact", "42", "7")
|
514 |
Â
esc_html_x( '"%1$s" reordered from %2$d to %3$d', 'acf', 'stream' ),
|
515 |
Â
array(
|
516 |
Â
'title' => $post->post_title,
|
562 |
Â
* @return string
|
563 |
Â
*/
|
564 |
Â
private function get_saved_option_type( $key ) {
|
565 |
+
return substr( $key, 0, 8 ) === 'options_' ? 'option' : 'taxonomy';
|
566 |
Â
}
|
567 |
Â
}
|
connectors/class-connector-bbpress.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
Â
<?php
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
-
class
|
5 |
Â
/**
|
6 |
Â
* Connector slug
|
7 |
Â
*
|
@@ -127,7 +127,7 @@ class Connector_bbPress extends Connector {
|
|
127 |
Â
*/
|
128 |
Â
public function action_links( $links, $record ) {
|
129 |
Â
if ( 'settings' === $record->context ) {
|
130 |
-
$option
|
131 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = esc_url(
|
132 |
Â
add_query_arg(
|
133 |
Â
array(
|
@@ -184,10 +184,12 @@ class Connector_bbPress extends Connector {
|
|
184 |
Â
} elseif ( 'posts' === $data['connector'] && in_array( $data['context'], array( 'forum', 'topic', 'reply' ), true ) ) {
|
185 |
Â
if ( 'reply' === $data['context'] ) {
|
186 |
Â
if ( 'updated' === $data['action'] ) {
|
187 |
-
|
Â
|
|
188 |
Â
$data['args']['post_title'] = get_post( wp_get_post_parent_id( $data['object_id'] ) )->post_title;
|
189 |
Â
}
|
190 |
Â
$data['args']['post_title'] = sprintf(
|
Â
|
|
191 |
Â
__( 'Reply to: %s', 'stream' ),
|
192 |
Â
get_post( wp_get_post_parent_id( $data['object_id'] ) )->post_title
|
193 |
Â
);
|
@@ -230,11 +232,12 @@ class Connector_bbPress extends Connector {
|
|
230 |
Â
$topic = get_post( $message['topic_id'] );
|
231 |
Â
|
232 |
Â
$this->log(
|
Â
|
|
233 |
Â
_x( '%1$s "%2$s" topic', '1: Action, 2: Topic title', 'stream' ),
|
234 |
Â
array(
|
235 |
Â
'action_title' => $actions[ $action ],
|
236 |
-
'topic_title'
|
237 |
-
'action'
|
238 |
Â
),
|
239 |
Â
$topic->ID,
|
240 |
Â
'topic',
|
1 |
Â
<?php
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
+
class Connector_BbPress extends Connector {
|
5 |
Â
/**
|
6 |
Â
* Connector slug
|
7 |
Â
*
|
127 |
Â
*/
|
128 |
Â
public function action_links( $links, $record ) {
|
129 |
Â
if ( 'settings' === $record->context ) {
|
130 |
+
$option = $record->get_meta( 'option', true );
|
131 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = esc_url(
|
132 |
Â
add_query_arg(
|
133 |
Â
array(
|
184 |
Â
} elseif ( 'posts' === $data['connector'] && in_array( $data['context'], array( 'forum', 'topic', 'reply' ), true ) ) {
|
185 |
Â
if ( 'reply' === $data['context'] ) {
|
186 |
Â
if ( 'updated' === $data['action'] ) {
|
187 |
+
// translators: Placeholder refers to a post title (e.g. "Hello World")
|
188 |
+
$data['message'] = esc_html__( 'Replied on "%1$s"', 'stream' );
|
189 |
Â
$data['args']['post_title'] = get_post( wp_get_post_parent_id( $data['object_id'] ) )->post_title;
|
190 |
Â
}
|
191 |
Â
$data['args']['post_title'] = sprintf(
|
192 |
+
// translators: Placeholder refers to a post title (e.g. "Hello World")
|
193 |
Â
__( 'Reply to: %s', 'stream' ),
|
194 |
Â
get_post( wp_get_post_parent_id( $data['object_id'] ) )->post_title
|
195 |
Â
);
|
232 |
Â
$topic = get_post( $message['topic_id'] );
|
233 |
Â
|
234 |
Â
$this->log(
|
235 |
+
// translators: Placeholders refer to an action, and a topic title (e.g. "Created", "Read this first")
|
236 |
Â
_x( '%1$s "%2$s" topic', '1: Action, 2: Topic title', 'stream' ),
|
237 |
Â
array(
|
238 |
Â
'action_title' => $actions[ $action ],
|
239 |
+
'topic_title' => $topic->post_title,
|
240 |
+
'action' => $action,
|
241 |
Â
),
|
242 |
Â
$topic->ID,
|
243 |
Â
'topic',
|
connectors/class-connector-blogs.php
CHANGED
@@ -128,6 +128,7 @@ class Connector_Blogs extends Connector {
|
|
128 |
Â
$blog = get_blog_details( $blog_id );
|
129 |
Â
|
130 |
Â
$this->log(
|
Â
|
|
131 |
Â
_x(
|
132 |
Â
'"%1$s" site was created',
|
133 |
Â
'1. Site name',
|
@@ -154,6 +155,7 @@ class Connector_Blogs extends Connector {
|
|
154 |
Â
$blog = get_blog_details( $blog_id );
|
155 |
Â
|
156 |
Â
$this->log(
|
Â
|
|
157 |
Â
_x(
|
158 |
Â
'"%1$s" site was registered',
|
159 |
Â
'1. Site name',
|
@@ -187,6 +189,7 @@ class Connector_Blogs extends Connector {
|
|
187 |
Â
}
|
188 |
Â
|
189 |
Â
$this->log(
|
Â
|
|
190 |
Â
_x(
|
191 |
Â
'%1$s was added to the "%2$s" site with %3$s capabilities',
|
192 |
Â
'1. User\'s name, 2. Site name, 3. Role',
|
@@ -220,6 +223,7 @@ class Connector_Blogs extends Connector {
|
|
220 |
Â
}
|
221 |
Â
|
222 |
Â
$this->log(
|
Â
|
|
223 |
Â
_x(
|
224 |
Â
'%1$s was removed from the "%2$s" site',
|
225 |
Â
'1. User\'s name, 2. Site name',
|
@@ -354,6 +358,7 @@ class Connector_Blogs extends Connector {
|
|
354 |
Â
$blog = get_blog_details( $blog_id );
|
355 |
Â
|
356 |
Â
$this->log(
|
Â
|
|
357 |
Â
_x(
|
358 |
Â
'"%1$s" site was %2$s',
|
359 |
Â
'1. Site name, 2. Status',
|
128 |
Â
$blog = get_blog_details( $blog_id );
|
129 |
Â
|
130 |
Â
$this->log(
|
131 |
+
// translators: Placeholder refers to site name (e.g. "FooBar Blog")
|
132 |
Â
_x(
|
133 |
Â
'"%1$s" site was created',
|
134 |
Â
'1. Site name',
|
155 |
Â
$blog = get_blog_details( $blog_id );
|
156 |
Â
|
157 |
Â
$this->log(
|
158 |
+
// translators: Placeholder refers to site name (e.g. "FooBar Blog")
|
159 |
Â
_x(
|
160 |
Â
'"%1$s" site was registered',
|
161 |
Â
'1. Site name',
|
189 |
Â
}
|
190 |
Â
|
191 |
Â
$this->log(
|
192 |
+
// translators: Placeholders refer to a user's display name, a site name, and a user role (e.g. "Jane Doe", "FooBar Blog", "subscriber")
|
193 |
Â
_x(
|
194 |
Â
'%1$s was added to the "%2$s" site with %3$s capabilities',
|
195 |
Â
'1. User\'s name, 2. Site name, 3. Role',
|
223 |
Â
}
|
224 |
Â
|
225 |
Â
$this->log(
|
226 |
+
// translators: Placeholders refer to a user's display name, and a site name (e.g. "Jane Doe", "FooBar Blog")
|
227 |
Â
_x(
|
228 |
Â
'%1$s was removed from the "%2$s" site',
|
229 |
Â
'1. User\'s name, 2. Site name',
|
358 |
Â
$blog = get_blog_details( $blog_id );
|
359 |
Â
|
360 |
Â
$this->log(
|
361 |
+
// translators: Placeholders refer to a site name, and a blog status (e.g. "FooBar Blog", "archived")
|
362 |
Â
_x(
|
363 |
Â
'"%1$s" site was %2$s',
|
364 |
Â
'1. Site name, 2. Status',
|
connectors/class-connector-buddypress.php
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
class Connector_BuddyPress extends Connector {
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Connector slug
|
7 |
Â
*
|
@@ -151,7 +153,7 @@ class Connector_BuddyPress extends Connector {
|
|
151 |
Â
*
|
152 |
Â
* @filter wp_stream_action_links_{connector}
|
153 |
Â
*
|
154 |
-
* @param array
|
155 |
Â
* @param object $record Stream record
|
156 |
Â
*
|
157 |
Â
* @return array Action links
|
@@ -191,7 +193,11 @@ class Connector_BuddyPress extends Connector {
|
|
191 |
Â
);
|
192 |
Â
} elseif ( in_array( $record->context, array( 'groups' ), true ) ) {
|
193 |
Â
$group_id = $record->get_meta( 'id', true );
|
194 |
-
$group = \groups_get_group(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
195 |
Â
|
196 |
Â
if ( $group ) {
|
197 |
Â
// Build actions URLs
|
@@ -200,13 +206,18 @@ class Connector_BuddyPress extends Connector {
|
|
200 |
Â
$edit_url = $base_url . '&action=edit';
|
201 |
Â
$visit_url = \bp_get_group_permalink( $group );
|
202 |
Â
|
203 |
-
$links[ esc_html__( 'Edit group', 'stream' ) ]
|
204 |
-
$links[ esc_html__( 'View group', 'stream' ) ]
|
205 |
Â
$links[ esc_html__( 'Delete group', 'stream' ) ] = $delete_url;
|
206 |
Â
}
|
207 |
Â
} elseif ( in_array( $record->context, array( 'activity' ), true ) ) {
|
208 |
Â
$activity_id = $record->get_meta( 'id', true );
|
209 |
-
$activities
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
210 |
Â
if ( ! empty( $activities['activities'] ) ) {
|
211 |
Â
$activity = reset( $activities['activities'] );
|
212 |
Â
|
@@ -230,18 +241,18 @@ class Connector_BuddyPress extends Connector {
|
|
230 |
Â
$group_id = $record->get_meta( 'group_id', true );
|
231 |
Â
|
232 |
Â
if ( empty( $field_id ) ) { // is a group action
|
233 |
-
$links[ esc_html__( 'Edit', 'stream' ) ]
|
234 |
Â
array(
|
235 |
-
'page'
|
236 |
-
'mode'
|
237 |
Â
'group_id' => $group_id,
|
238 |
Â
),
|
239 |
Â
admin_url( 'users.php' )
|
240 |
Â
);
|
241 |
Â
$links[ esc_html__( 'Delete', 'stream' ) ] = add_query_arg(
|
242 |
Â
array(
|
243 |
-
'page'
|
244 |
-
'mode'
|
245 |
Â
'group_id' => $group_id,
|
246 |
Â
),
|
247 |
Â
admin_url( 'users.php' )
|
@@ -251,10 +262,10 @@ class Connector_BuddyPress extends Connector {
|
|
251 |
Â
if ( empty( $field->type ) ) {
|
252 |
Â
return $links;
|
253 |
Â
}
|
254 |
-
$links[ esc_html__( 'Edit', 'stream' ) ]
|
255 |
Â
array(
|
256 |
-
'page'
|
257 |
-
'mode'
|
258 |
Â
'group_id' => $group_id,
|
259 |
Â
'field_id' => $field_id,
|
260 |
Â
),
|
@@ -262,8 +273,8 @@ class Connector_BuddyPress extends Connector {
|
|
262 |
Â
);
|
263 |
Â
$links[ esc_html__( 'Delete', 'stream' ) ] = add_query_arg(
|
264 |
Â
array(
|
265 |
-
'page'
|
266 |
-
'mode'
|
267 |
Â
'field_id' => $field_id,
|
268 |
Â
),
|
269 |
Â
admin_url( 'users.php' )
|
@@ -356,7 +367,10 @@ class Connector_BuddyPress extends Connector {
|
|
356 |
Â
$replacement = str_replace( '-', '_', $option );
|
357 |
Â
|
358 |
Â
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
359 |
-
call_user_func( array(
|
Â
|
|
Â
|
|
Â
|
|
360 |
Â
} else {
|
361 |
Â
$data = $this->options[ $option ];
|
362 |
Â
$option_title = $data['label'];
|
@@ -364,6 +378,7 @@ class Connector_BuddyPress extends Connector {
|
|
364 |
Â
$page = isset( $data['page'] ) ? $data['page'] : null;
|
365 |
Â
|
366 |
Â
$this->log(
|
Â
|
|
367 |
Â
__( '"%s" setting updated', 'stream' ),
|
368 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value', 'page' ),
|
369 |
Â
null,
|
@@ -398,6 +413,7 @@ class Connector_BuddyPress extends Connector {
|
|
398 |
Â
|
399 |
Â
$this->log(
|
400 |
Â
sprintf(
|
Â
|
|
401 |
Â
__( '"%1$s" component %2$s', 'stream' ),
|
402 |
Â
$components[ $option ]['title'],
|
403 |
Â
$actions[ $option_value ]
|
@@ -443,6 +459,7 @@ class Connector_BuddyPress extends Connector {
|
|
443 |
Â
|
444 |
Â
$this->log(
|
445 |
Â
sprintf(
|
Â
|
|
446 |
Â
__( '"%1$s" page set to "%2$s"', 'stream' ),
|
447 |
Â
$pages[ $option ],
|
448 |
Â
$page
|
@@ -464,6 +481,7 @@ class Connector_BuddyPress extends Connector {
|
|
464 |
Â
public function callback_bp_before_activity_delete( $args ) {
|
465 |
Â
if ( empty( $args['id'] ) ) { // Bail if we're deleting in bulk
|
466 |
Â
$this->_delete_activity_args = $args;
|
Â
|
|
467 |
Â
return;
|
468 |
Â
}
|
469 |
Â
|
@@ -477,14 +495,15 @@ class Connector_BuddyPress extends Connector {
|
|
477 |
Â
$activity = $this->_deleted_activity;
|
478 |
Â
$this->log(
|
479 |
Â
sprintf(
|
Â
|
|
480 |
Â
__( '"%s" activity deleted', 'stream' ),
|
481 |
Â
strip_tags( $activity->action )
|
482 |
Â
),
|
483 |
Â
array(
|
484 |
-
'id'
|
485 |
Â
'item_id' => $activity->item_id,
|
486 |
-
'type'
|
487 |
-
'author'
|
488 |
Â
),
|
489 |
Â
$activity->id,
|
490 |
Â
$activity->component,
|
@@ -495,10 +514,12 @@ class Connector_BuddyPress extends Connector {
|
|
495 |
Â
// activities, so we probably don't need to track those
|
496 |
Â
if ( $this->ignore_activity_bulk_deletion ) {
|
497 |
Â
$this->ignore_activity_bulk_deletion = false;
|
Â
|
|
498 |
Â
return;
|
499 |
Â
}
|
500 |
Â
$this->log(
|
501 |
Â
sprintf(
|
Â
|
|
502 |
Â
__( '"%s" activities were deleted', 'stream' ),
|
503 |
Â
count( $activities_ids )
|
504 |
Â
),
|
@@ -519,14 +540,15 @@ class Connector_BuddyPress extends Connector {
|
|
519 |
Â
|
520 |
Â
$this->log(
|
521 |
Â
sprintf(
|
Â
|
|
522 |
Â
__( 'Marked activity "%s" as spam', 'stream' ),
|
523 |
Â
strip_tags( $activity->action )
|
524 |
Â
),
|
525 |
Â
array(
|
526 |
-
'id'
|
527 |
Â
'item_id' => $activity->item_id,
|
528 |
-
'type'
|
529 |
-
'author'
|
530 |
Â
),
|
531 |
Â
$activity->id,
|
532 |
Â
$activity->component,
|
@@ -539,14 +561,15 @@ class Connector_BuddyPress extends Connector {
|
|
539 |
Â
|
540 |
Â
$this->log(
|
541 |
Â
sprintf(
|
Â
|
|
542 |
Â
__( 'Unmarked activity "%s" as spam', 'stream' ),
|
543 |
Â
strip_tags( $activity->action )
|
544 |
Â
),
|
545 |
Â
array(
|
546 |
-
'id'
|
547 |
Â
'item_id' => $activity->item_id,
|
548 |
-
'type'
|
549 |
-
'author'
|
550 |
Â
),
|
551 |
Â
$activity->id,
|
552 |
Â
$activity->component,
|
@@ -559,14 +582,15 @@ class Connector_BuddyPress extends Connector {
|
|
559 |
Â
|
560 |
Â
$this->log(
|
561 |
Â
sprintf(
|
Â
|
|
562 |
Â
__( '"%s" activity updated', 'stream' ),
|
563 |
Â
strip_tags( $activity->action )
|
564 |
Â
),
|
565 |
Â
array(
|
566 |
-
'id'
|
567 |
Â
'item_id' => $activity->item_id,
|
568 |
-
'type'
|
569 |
-
'author'
|
570 |
Â
),
|
571 |
Â
$activity->id,
|
572 |
Â
'activity',
|
@@ -576,7 +600,11 @@ class Connector_BuddyPress extends Connector {
|
|
576 |
Â
|
577 |
Â
public function group_action( $group, $action, $meta = array(), $message = null ) {
|
578 |
Â
if ( is_numeric( $group ) ) {
|
579 |
-
$group = \groups_get_group(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
580 |
Â
}
|
581 |
Â
|
582 |
Â
$replacements = array(
|
@@ -585,23 +613,31 @@ class Connector_BuddyPress extends Connector {
|
|
585 |
Â
|
586 |
Â
if ( ! $message ) {
|
587 |
Â
if ( 'created' === $action ) {
|
Â
|
|
588 |
Â
$message = esc_html__( '"%s" group created', 'stream' );
|
589 |
Â
} elseif ( 'updated' === $action ) {
|
Â
|
|
590 |
Â
$message = esc_html__( '"%s" group updated', 'stream' );
|
591 |
Â
} elseif ( 'deleted' === $action ) {
|
Â
|
|
592 |
Â
$message = esc_html__( '"%s" group deleted', 'stream' );
|
593 |
Â
} elseif ( 'joined' === $action ) {
|
Â
|
|
594 |
Â
$message = esc_html__( 'Joined group "%s"', 'stream' );
|
595 |
Â
} elseif ( 'left' === $action ) {
|
Â
|
|
596 |
Â
$message = esc_html__( 'Left group "%s"', 'stream' );
|
597 |
Â
} elseif ( 'banned' === $action ) {
|
598 |
-
|
Â
|
|
599 |
Â
$replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
|
600 |
Â
} elseif ( 'unbanned' === $action ) {
|
601 |
-
|
Â
|
|
602 |
Â
$replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
|
603 |
Â
} elseif ( 'removed' === $action ) {
|
604 |
-
|
Â
|
|
605 |
Â
$replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
|
606 |
Â
} else {
|
607 |
Â
return;
|
@@ -615,7 +651,7 @@ class Connector_BuddyPress extends Connector {
|
|
615 |
Â
),
|
616 |
Â
array_merge(
|
617 |
Â
array(
|
618 |
-
'id'
|
619 |
Â
'name' => $group->name,
|
620 |
Â
'slug' => $group->slug,
|
621 |
Â
),
|
@@ -666,13 +702,18 @@ class Connector_BuddyPress extends Connector {
|
|
666 |
Â
}
|
667 |
Â
|
668 |
Â
public function callback_groups_promote_member( $group_id, $user_id, $status ) {
|
669 |
-
$group
|
670 |
-
|
671 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
672 |
Â
'admin' => esc_html_x( 'Administrator', 'buddypress', 'stream' ),
|
673 |
Â
'mod' => esc_html_x( 'Moderator', 'buddypress', 'stream' ),
|
674 |
Â
);
|
675 |
Â
$message = sprintf(
|
Â
|
|
676 |
Â
__( 'Promoted "%1$s" to "%2$s" in "%3$s"', 'stream' ),
|
677 |
Â
$user->display_name,
|
678 |
Â
$roles[ $status ],
|
@@ -682,9 +723,14 @@ class Connector_BuddyPress extends Connector {
|
|
682 |
Â
}
|
683 |
Â
|
684 |
Â
public function callback_groups_demote_member( $group_id, $user_id ) {
|
685 |
-
$group
|
686 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
687 |
Â
$message = sprintf(
|
Â
|
|
688 |
Â
__( 'Demoted "%1$s" to "%2$s" in "%3$s"', 'stream' ),
|
689 |
Â
$user->display_name,
|
690 |
Â
_x( 'Member', 'buddypress', 'stream' ),
|
@@ -712,10 +758,13 @@ class Connector_BuddyPress extends Connector {
|
|
712 |
Â
|
713 |
Â
if ( ! $message ) {
|
714 |
Â
if ( 'created' === $action ) {
|
Â
|
|
715 |
Â
$message = esc_html__( 'Created profile field "%s"', 'stream' );
|
716 |
Â
} elseif ( 'updated' === $action ) {
|
Â
|
|
717 |
Â
$message = esc_html__( 'Updated profile field "%s"', 'stream' );
|
718 |
Â
} elseif ( 'deleted' === $action ) {
|
Â
|
|
719 |
Â
$message = esc_html__( 'Deleted profile field "%s"', 'stream' );
|
720 |
Â
} else {
|
721 |
Â
return;
|
@@ -757,10 +806,13 @@ class Connector_BuddyPress extends Connector {
|
|
757 |
Â
|
758 |
Â
if ( ! $message ) {
|
759 |
Â
if ( 'created' === $action ) {
|
Â
|
|
760 |
Â
$message = esc_html__( 'Created profile field group "%s"', 'stream' );
|
761 |
Â
} elseif ( 'updated' === $action ) {
|
Â
|
|
762 |
Â
$message = esc_html__( 'Updated profile field group "%s"', 'stream' );
|
763 |
Â
} elseif ( 'deleted' === $action ) {
|
Â
|
|
764 |
Â
$message = esc_html__( 'Deleted profile field group "%s"', 'stream' );
|
765 |
Â
} else {
|
766 |
Â
return;
|
@@ -806,7 +858,7 @@ class Connector_BuddyPress extends Connector {
|
|
806 |
Â
// Only components that need directories should be listed here
|
807 |
Â
if ( isset( $bp->{$component_id} ) && ! empty( $bp->{$component_id}->has_directory ) ) {
|
808 |
Â
// component->name was introduced in BP 1.5, so we must provide a fallback
|
809 |
-
$directory_pages[ $component_id ] = ! empty( $bp->{
|
810 |
Â
}
|
811 |
Â
}
|
812 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
class Connector_BuddyPress extends Connector {
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Connector slug
|
9 |
Â
*
|
153 |
Â
*
|
154 |
Â
* @filter wp_stream_action_links_{connector}
|
155 |
Â
*
|
156 |
+
* @param array $links Previous links registered
|
157 |
Â
* @param object $record Stream record
|
158 |
Â
*
|
159 |
Â
* @return array Action links
|
193 |
Â
);
|
194 |
Â
} elseif ( in_array( $record->context, array( 'groups' ), true ) ) {
|
195 |
Â
$group_id = $record->get_meta( 'id', true );
|
196 |
+
$group = \groups_get_group(
|
197 |
+
array(
|
198 |
+
'group_id' => $group_id,
|
199 |
+
)
|
200 |
+
);
|
201 |
Â
|
202 |
Â
if ( $group ) {
|
203 |
Â
// Build actions URLs
|
206 |
Â
$edit_url = $base_url . '&action=edit';
|
207 |
Â
$visit_url = \bp_get_group_permalink( $group );
|
208 |
Â
|
209 |
+
$links[ esc_html__( 'Edit group', 'stream' ) ] = $edit_url;
|
210 |
+
$links[ esc_html__( 'View group', 'stream' ) ] = $visit_url;
|
211 |
Â
$links[ esc_html__( 'Delete group', 'stream' ) ] = $delete_url;
|
212 |
Â
}
|
213 |
Â
} elseif ( in_array( $record->context, array( 'activity' ), true ) ) {
|
214 |
Â
$activity_id = $record->get_meta( 'id', true );
|
215 |
+
$activities = \bp_activity_get(
|
216 |
+
array(
|
217 |
+
'in' => $activity_id,
|
218 |
+
'spam' => 'all',
|
219 |
+
)
|
220 |
+
);
|
221 |
Â
if ( ! empty( $activities['activities'] ) ) {
|
222 |
Â
$activity = reset( $activities['activities'] );
|
223 |
Â
|
241 |
Â
$group_id = $record->get_meta( 'group_id', true );
|
242 |
Â
|
243 |
Â
if ( empty( $field_id ) ) { // is a group action
|
244 |
+
$links[ esc_html__( 'Edit', 'stream' ) ] = add_query_arg(
|
245 |
Â
array(
|
246 |
+
'page' => 'bp-profile-setup',
|
247 |
+
'mode' => 'edit_group',
|
248 |
Â
'group_id' => $group_id,
|
249 |
Â
),
|
250 |
Â
admin_url( 'users.php' )
|
251 |
Â
);
|
252 |
Â
$links[ esc_html__( 'Delete', 'stream' ) ] = add_query_arg(
|
253 |
Â
array(
|
254 |
+
'page' => 'bp-profile-setup',
|
255 |
+
'mode' => 'delete_group',
|
256 |
Â
'group_id' => $group_id,
|
257 |
Â
),
|
258 |
Â
admin_url( 'users.php' )
|
262 |
Â
if ( empty( $field->type ) ) {
|
263 |
Â
return $links;
|
264 |
Â
}
|
265 |
+
$links[ esc_html__( 'Edit', 'stream' ) ] = add_query_arg(
|
266 |
Â
array(
|
267 |
+
'page' => 'bp-profile-setup',
|
268 |
+
'mode' => 'edit_field',
|
269 |
Â
'group_id' => $group_id,
|
270 |
Â
'field_id' => $field_id,
|
271 |
Â
),
|
273 |
Â
);
|
274 |
Â
$links[ esc_html__( 'Delete', 'stream' ) ] = add_query_arg(
|
275 |
Â
array(
|
276 |
+
'page' => 'bp-profile-setup',
|
277 |
+
'mode' => 'delete_field',
|
278 |
Â
'field_id' => $field_id,
|
279 |
Â
),
|
280 |
Â
admin_url( 'users.php' )
|
367 |
Â
$replacement = str_replace( '-', '_', $option );
|
368 |
Â
|
369 |
Â
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
370 |
+
call_user_func( array(
|
371 |
+
$this,
|
372 |
+
'check_' . $replacement,
|
373 |
+
), $old_value, $new_value );
|
374 |
Â
} else {
|
375 |
Â
$data = $this->options[ $option ];
|
376 |
Â
$option_title = $data['label'];
|
378 |
Â
$page = isset( $data['page'] ) ? $data['page'] : null;
|
379 |
Â
|
380 |
Â
$this->log(
|
381 |
+
// translators: Placeholder refers to setting name (e.g. "Group Creation")
|
382 |
Â
__( '"%s" setting updated', 'stream' ),
|
383 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value', 'page' ),
|
384 |
Â
null,
|
413 |
Â
|
414 |
Â
$this->log(
|
415 |
Â
sprintf(
|
416 |
+
// translators: Placeholder refers to component title (e.g. "Members")
|
417 |
Â
__( '"%1$s" component %2$s', 'stream' ),
|
418 |
Â
$components[ $option ]['title'],
|
419 |
Â
$actions[ $option_value ]
|
459 |
Â
|
460 |
Â
$this->log(
|
461 |
Â
sprintf(
|
462 |
+
// translators: Placeholders refer to a directory page, and a page title (e.g. "Register", "Registration" )
|
463 |
Â
__( '"%1$s" page set to "%2$s"', 'stream' ),
|
464 |
Â
$pages[ $option ],
|
465 |
Â
$page
|
481 |
Â
public function callback_bp_before_activity_delete( $args ) {
|
482 |
Â
if ( empty( $args['id'] ) ) { // Bail if we're deleting in bulk
|
483 |
Â
$this->_delete_activity_args = $args;
|
484 |
+
|
485 |
Â
return;
|
486 |
Â
}
|
487 |
Â
|
495 |
Â
$activity = $this->_deleted_activity;
|
496 |
Â
$this->log(
|
497 |
Â
sprintf(
|
498 |
+
// translators: Placeholder refers to an activity title (e.g. "Update")
|
499 |
Â
__( '"%s" activity deleted', 'stream' ),
|
500 |
Â
strip_tags( $activity->action )
|
501 |
Â
),
|
502 |
Â
array(
|
503 |
+
'id' => $activity->id,
|
504 |
Â
'item_id' => $activity->item_id,
|
505 |
+
'type' => $activity->type,
|
506 |
+
'author' => $activity->user_id,
|
507 |
Â
),
|
508 |
Â
$activity->id,
|
509 |
Â
$activity->component,
|
514 |
Â
// activities, so we probably don't need to track those
|
515 |
Â
if ( $this->ignore_activity_bulk_deletion ) {
|
516 |
Â
$this->ignore_activity_bulk_deletion = false;
|
517 |
+
|
518 |
Â
return;
|
519 |
Â
}
|
520 |
Â
$this->log(
|
521 |
Â
sprintf(
|
522 |
+
// translators: Placeholder refers to an activity title (e.g. "Update")
|
523 |
Â
__( '"%s" activities were deleted', 'stream' ),
|
524 |
Â
count( $activities_ids )
|
525 |
Â
),
|
540 |
Â
|
541 |
Â
$this->log(
|
542 |
Â
sprintf(
|
543 |
+
// translators: Placeholder refers to an activity title (e.g. "Update")
|
544 |
Â
__( 'Marked activity "%s" as spam', 'stream' ),
|
545 |
Â
strip_tags( $activity->action )
|
546 |
Â
),
|
547 |
Â
array(
|
548 |
+
'id' => $activity->id,
|
549 |
Â
'item_id' => $activity->item_id,
|
550 |
+
'type' => $activity->type,
|
551 |
+
'author' => $activity->user_id,
|
552 |
Â
),
|
553 |
Â
$activity->id,
|
554 |
Â
$activity->component,
|
561 |
Â
|
562 |
Â
$this->log(
|
563 |
Â
sprintf(
|
564 |
+
// translators: Placeholder refers to an activity title (e.g. "Update")
|
565 |
Â
__( 'Unmarked activity "%s" as spam', 'stream' ),
|
566 |
Â
strip_tags( $activity->action )
|
567 |
Â
),
|
568 |
Â
array(
|
569 |
+
'id' => $activity->id,
|
570 |
Â
'item_id' => $activity->item_id,
|
571 |
+
'type' => $activity->type,
|
572 |
+
'author' => $activity->user_id,
|
573 |
Â
),
|
574 |
Â
$activity->id,
|
575 |
Â
$activity->component,
|
582 |
Â
|
583 |
Â
$this->log(
|
584 |
Â
sprintf(
|
585 |
+
// translators: Placeholder refers to an activity title (e.g. "Update")
|
586 |
Â
__( '"%s" activity updated', 'stream' ),
|
587 |
Â
strip_tags( $activity->action )
|
588 |
Â
),
|
589 |
Â
array(
|
590 |
+
'id' => $activity->id,
|
591 |
Â
'item_id' => $activity->item_id,
|
592 |
+
'type' => $activity->type,
|
593 |
+
'author' => $activity->user_id,
|
594 |
Â
),
|
595 |
Â
$activity->id,
|
596 |
Â
'activity',
|
600 |
Â
|
601 |
Â
public function group_action( $group, $action, $meta = array(), $message = null ) {
|
602 |
Â
if ( is_numeric( $group ) ) {
|
603 |
+
$group = \groups_get_group(
|
604 |
+
array(
|
605 |
+
'group_id' => $group,
|
606 |
+
)
|
607 |
+
);
|
608 |
Â
}
|
609 |
Â
|
610 |
Â
$replacements = array(
|
613 |
Â
|
614 |
Â
if ( ! $message ) {
|
615 |
Â
if ( 'created' === $action ) {
|
616 |
+
// translators: Placeholder refers to a group name (e.g. "Favourites")
|
617 |
Â
$message = esc_html__( '"%s" group created', 'stream' );
|
618 |
Â
} elseif ( 'updated' === $action ) {
|
619 |
+
// translators: Placeholder refers to a group name (e.g. "Favourites")
|
620 |
Â
$message = esc_html__( '"%s" group updated', 'stream' );
|
621 |
Â
} elseif ( 'deleted' === $action ) {
|
622 |
+
// translators: Placeholder refers to a group name (e.g. "Favourites")
|
623 |
Â
$message = esc_html__( '"%s" group deleted', 'stream' );
|
624 |
Â
} elseif ( 'joined' === $action ) {
|
625 |
+
// translators: Placeholder refers to a group name (e.g. "Favourites")
|
626 |
Â
$message = esc_html__( 'Joined group "%s"', 'stream' );
|
627 |
Â
} elseif ( 'left' === $action ) {
|
628 |
+
// translators: Placeholder refers to a group name (e.g. "Favourites")
|
629 |
Â
$message = esc_html__( 'Left group "%s"', 'stream' );
|
630 |
Â
} elseif ( 'banned' === $action ) {
|
631 |
+
// translators: Placeholders refer to a user display name, and a group name (e.g. "Jane Doe", "Favourites")
|
632 |
+
$message = esc_html__( 'Banned "%2$s" from "%1$s"', 'stream' );
|
633 |
Â
$replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
|
634 |
Â
} elseif ( 'unbanned' === $action ) {
|
635 |
+
// translators: Placeholders refer to a user display name, and a group name (e.g. "Jane Doe", "Favourites")
|
636 |
+
$message = esc_html__( 'Unbanned "%2$s" from "%1$s"', 'stream' );
|
637 |
Â
$replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
|
638 |
Â
} elseif ( 'removed' === $action ) {
|
639 |
+
// translators: Placeholders refer to a user display name, and a group name (e.g. "Jane Doe", "Favourites")
|
640 |
+
$message = esc_html__( 'Removed "%2$s" from "%1$s"', 'stream' );
|
641 |
Â
$replacements[] = get_user_by( 'id', $meta['user_id'] )->display_name;
|
642 |
Â
} else {
|
643 |
Â
return;
|
651 |
Â
),
|
652 |
Â
array_merge(
|
653 |
Â
array(
|
654 |
+
'id' => $group->id,
|
655 |
Â
'name' => $group->name,
|
656 |
Â
'slug' => $group->slug,
|
657 |
Â
),
|
702 |
Â
}
|
703 |
Â
|
704 |
Â
public function callback_groups_promote_member( $group_id, $user_id, $status ) {
|
705 |
+
$group = \groups_get_group(
|
706 |
+
array(
|
707 |
+
'group_id' => $group_id,
|
708 |
+
)
|
709 |
+
);
|
710 |
+
$user = new \WP_User( $user_id );
|
711 |
+
$roles = array(
|
712 |
Â
'admin' => esc_html_x( 'Administrator', 'buddypress', 'stream' ),
|
713 |
Â
'mod' => esc_html_x( 'Moderator', 'buddypress', 'stream' ),
|
714 |
Â
);
|
715 |
Â
$message = sprintf(
|
716 |
+
// translators: Placeholders refer to a user's display name, a user role, and a group name (e.g. "Jane Doe", "subscriber", "Favourites")
|
717 |
Â
__( 'Promoted "%1$s" to "%2$s" in "%3$s"', 'stream' ),
|
718 |
Â
$user->display_name,
|
719 |
Â
$roles[ $status ],
|
723 |
Â
}
|
724 |
Â
|
725 |
Â
public function callback_groups_demote_member( $group_id, $user_id ) {
|
726 |
+
$group = \groups_get_group(
|
727 |
+
array(
|
728 |
+
'group_id' => $group_id,
|
729 |
+
)
|
730 |
+
);
|
731 |
+
$user = new \WP_User( $user_id );
|
732 |
Â
$message = sprintf(
|
733 |
+
// translators: Placeholders refer to a user's display name, a user role, and a group name (e.g. "Jane Doe", "Member", "Favourites")
|
734 |
Â
__( 'Demoted "%1$s" to "%2$s" in "%3$s"', 'stream' ),
|
735 |
Â
$user->display_name,
|
736 |
Â
_x( 'Member', 'buddypress', 'stream' ),
|
758 |
Â
|
759 |
Â
if ( ! $message ) {
|
760 |
Â
if ( 'created' === $action ) {
|
761 |
+
// translators: Placeholder refers to a user profile field (e.g. "Job Title")
|
762 |
Â
$message = esc_html__( 'Created profile field "%s"', 'stream' );
|
763 |
Â
} elseif ( 'updated' === $action ) {
|
764 |
+
// translators: Placeholder refers to a user profile field (e.g. "Job Title")
|
765 |
Â
$message = esc_html__( 'Updated profile field "%s"', 'stream' );
|
766 |
Â
} elseif ( 'deleted' === $action ) {
|
767 |
+
// translators: Placeholder refers to a user profile field (e.g. "Job Title")
|
768 |
Â
$message = esc_html__( 'Deleted profile field "%s"', 'stream' );
|
769 |
Â
} else {
|
770 |
Â
return;
|
806 |
Â
|
807 |
Â
if ( ! $message ) {
|
808 |
Â
if ( 'created' === $action ) {
|
809 |
+
// translators: Placeholder refers to a user profile field group (e.g. "Appearance")
|
810 |
Â
$message = esc_html__( 'Created profile field group "%s"', 'stream' );
|
811 |
Â
} elseif ( 'updated' === $action ) {
|
812 |
+
// translators: Placeholder refers to a user profile field group (e.g. "Appearance")
|
813 |
Â
$message = esc_html__( 'Updated profile field group "%s"', 'stream' );
|
814 |
Â
} elseif ( 'deleted' === $action ) {
|
815 |
+
// translators: Placeholder refers to a user profile field group (e.g. "Appearance")
|
816 |
Â
$message = esc_html__( 'Deleted profile field group "%s"', 'stream' );
|
817 |
Â
} else {
|
818 |
Â
return;
|
858 |
Â
// Only components that need directories should be listed here
|
859 |
Â
if ( isset( $bp->{$component_id} ) && ! empty( $bp->{$component_id}->has_directory ) ) {
|
860 |
Â
// component->name was introduced in BP 1.5, so we must provide a fallback
|
861 |
+
$directory_pages[ $component_id ] = ! empty( $bp->{$component_id}->name ) ? $bp->{$component_id}->name : ucwords( $component_id );
|
862 |
Â
}
|
863 |
Â
}
|
864 |
Â
}
|
connectors/class-connector-comments.php
CHANGED
@@ -127,7 +127,8 @@ class Connector_Comments extends Connector {
|
|
127 |
Â
*/
|
128 |
Â
public function action_links( $links, $record ) {
|
129 |
Â
if ( $record->object_id ) {
|
130 |
-
|
Â
|
|
131 |
Â
$approve_nonce = wp_create_nonce( "approve-comment_$comment->comment_ID" );
|
132 |
Â
|
133 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = admin_url( "comment.php?action=editcomment&c=$comment->comment_ID" );
|
@@ -226,6 +227,7 @@ class Connector_Comments extends Connector {
|
|
226 |
Â
}
|
227 |
Â
|
228 |
Â
$this->log(
|
Â
|
|
229 |
Â
__( 'Comment flooding by %s detected and prevented', 'stream' ),
|
230 |
Â
compact( 'user_name', 'user_id', 'time_lastcomment', 'time_newcomment' ),
|
231 |
Â
null,
|
@@ -251,7 +253,8 @@ class Connector_Comments extends Connector {
|
|
251 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
252 |
Â
$post_id = $comment->comment_post_ID;
|
253 |
Â
$post_type = get_post_type( $post_id );
|
254 |
-
$
|
Â
|
|
255 |
Â
$comment_status = ( 1 === $comment->comment_approved ) ? esc_html__( 'approved automatically', 'stream' ) : esc_html__( 'pending approval', 'stream' );
|
256 |
Â
$is_spam = false;
|
257 |
Â
|
@@ -267,19 +270,19 @@ class Connector_Comments extends Connector {
|
|
267 |
Â
}
|
268 |
Â
}
|
269 |
Â
|
270 |
-
$comment_type
|
271 |
Â
|
272 |
Â
if ( $comment->comment_parent ) {
|
273 |
-
$
|
274 |
-
$parent_user_name = get_comment_author( $comment->comment_parent, 'name' );
|
275 |
Â
|
276 |
Â
$this->log(
|
Â
|
|
277 |
Â
_x(
|
278 |
Â
'Reply to %1$s\'s %5$s by %2$s on %3$s %4$s',
|
279 |
Â
"1: Parent comment's author, 2: Comment author, 3: Post title, 4: Comment status, 5: Comment type",
|
280 |
Â
'stream'
|
281 |
Â
),
|
282 |
-
compact( 'parent_user_name', 'user_name', 'post_title', 'comment_status', 'comment_type', 'post_id'
|
283 |
Â
$comment_id,
|
284 |
Â
$post_type,
|
285 |
Â
'replied',
|
@@ -287,6 +290,7 @@ class Connector_Comments extends Connector {
|
|
287 |
Â
);
|
288 |
Â
} else {
|
289 |
Â
$this->log(
|
Â
|
|
290 |
Â
_x(
|
291 |
Â
'New %4$s by %1$s on %2$s %3$s',
|
292 |
Â
'1: Comment author, 2: Post title 3: Comment status, 4: Comment type',
|
@@ -319,10 +323,12 @@ class Connector_Comments extends Connector {
|
|
319 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
320 |
Â
$post_id = $comment->comment_post_ID;
|
321 |
Â
$post_type = get_post_type( $post_id );
|
322 |
-
$
|
Â
|
|
323 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
324 |
Â
|
325 |
Â
$this->log(
|
Â
|
|
326 |
Â
_x(
|
327 |
Â
'%1$s\'s %3$s on %2$s edited',
|
328 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
@@ -383,7 +389,8 @@ class Connector_Comments extends Connector {
|
|
383 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
384 |
Â
$post_id = absint( $comment->comment_post_ID );
|
385 |
Â
$post_type = get_post_type( $post_id );
|
386 |
-
$
|
Â
|
|
387 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
388 |
Â
|
389 |
Â
if ( $this->delete_post === $post_id ) {
|
@@ -391,6 +398,7 @@ class Connector_Comments extends Connector {
|
|
391 |
Â
}
|
392 |
Â
|
393 |
Â
$this->log(
|
Â
|
|
394 |
Â
_x(
|
395 |
Â
'%1$s\'s %3$s on %2$s deleted permanently',
|
396 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
@@ -421,10 +429,12 @@ class Connector_Comments extends Connector {
|
|
421 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
422 |
Â
$post_id = $comment->comment_post_ID;
|
423 |
Â
$post_type = get_post_type( $post_id );
|
424 |
-
$
|
Â
|
|
425 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
426 |
Â
|
427 |
Â
$this->log(
|
Â
|
|
428 |
Â
_x(
|
429 |
Â
'%1$s\'s %3$s on %2$s trashed',
|
430 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
@@ -455,10 +465,12 @@ class Connector_Comments extends Connector {
|
|
455 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
456 |
Â
$post_id = $comment->comment_post_ID;
|
457 |
Â
$post_type = get_post_type( $post_id );
|
458 |
-
$
|
Â
|
|
459 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
460 |
Â
|
461 |
Â
$this->log(
|
Â
|
|
462 |
Â
_x(
|
463 |
Â
'%1$s\'s %3$s on %2$s restored',
|
464 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
@@ -489,10 +501,12 @@ class Connector_Comments extends Connector {
|
|
489 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
490 |
Â
$post_id = $comment->comment_post_ID;
|
491 |
Â
$post_type = get_post_type( $post_id );
|
492 |
-
$
|
Â
|
|
493 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
494 |
Â
|
495 |
Â
$this->log(
|
Â
|
|
496 |
Â
_x(
|
497 |
Â
'%1$s\'s %3$s on %2$s marked as spam',
|
498 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
@@ -523,10 +537,12 @@ class Connector_Comments extends Connector {
|
|
523 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
524 |
Â
$post_id = $comment->comment_post_ID;
|
525 |
Â
$post_type = get_post_type( $post_id );
|
526 |
-
$
|
Â
|
|
527 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
528 |
Â
|
529 |
Â
$this->log(
|
Â
|
|
530 |
Â
_x(
|
531 |
Â
'%1$s\'s %3$s on %2$s unmarked as spam',
|
532 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
@@ -561,10 +577,12 @@ class Connector_Comments extends Connector {
|
|
561 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
562 |
Â
$post_id = $comment->comment_post_ID;
|
563 |
Â
$post_type = get_post_type( $post_id );
|
564 |
-
$
|
Â
|
|
565 |
Â
$comment_type = get_comment_type( $comment->comment_ID );
|
566 |
Â
|
567 |
Â
$this->log(
|
Â
|
|
568 |
Â
_x(
|
569 |
Â
'%1$s\'s %3$s %2$s',
|
570 |
Â
'Comment status transition. 1: Comment author, 2: Post title, 3: Comment type',
|
@@ -599,10 +617,12 @@ class Connector_Comments extends Connector {
|
|
599 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
600 |
Â
$post_id = $comment->comment_post_ID;
|
601 |
Â
$post_type = get_post_type( $post_id );
|
602 |
-
$
|
Â
|
|
603 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
604 |
Â
|
605 |
Â
$this->log(
|
Â
|
|
606 |
Â
_x(
|
607 |
Â
'Duplicate %3$s by %1$s prevented on %2$s',
|
608 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
127 |
Â
*/
|
128 |
Â
public function action_links( $links, $record ) {
|
129 |
Â
if ( $record->object_id ) {
|
130 |
+
$comment = get_comment( $record->object_id );
|
131 |
+
if ( $comment ) {
|
132 |
Â
$approve_nonce = wp_create_nonce( "approve-comment_$comment->comment_ID" );
|
133 |
Â
|
134 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = admin_url( "comment.php?action=editcomment&c=$comment->comment_ID" );
|
227 |
Â
}
|
228 |
Â
|
229 |
Â
$this->log(
|
230 |
+
// translators: Placeholder refers to a username (e.g. "administrator")
|
231 |
Â
__( 'Comment flooding by %s detected and prevented', 'stream' ),
|
232 |
Â
compact( 'user_name', 'user_id', 'time_lastcomment', 'time_newcomment' ),
|
233 |
Â
null,
|
253 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
254 |
Â
$post_id = $comment->comment_post_ID;
|
255 |
Â
$post_type = get_post_type( $post_id );
|
256 |
+
$post = get_post( $post_id );
|
257 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
258 |
Â
$comment_status = ( 1 === $comment->comment_approved ) ? esc_html__( 'approved automatically', 'stream' ) : esc_html__( 'pending approval', 'stream' );
|
259 |
Â
$is_spam = false;
|
260 |
Â
|
270 |
Â
}
|
271 |
Â
}
|
272 |
Â
|
273 |
+
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
274 |
Â
|
275 |
Â
if ( $comment->comment_parent ) {
|
276 |
+
$parent_user_name = get_comment_author( $comment->comment_parent );
|
Â
|
|
277 |
Â
|
278 |
Â
$this->log(
|
279 |
+
// translators: Placeholders refer to a parent comment's author, a comment author, a post title, a comment status, and a comment type
|
280 |
Â
_x(
|
281 |
Â
'Reply to %1$s\'s %5$s by %2$s on %3$s %4$s',
|
282 |
Â
"1: Parent comment's author, 2: Comment author, 3: Post title, 4: Comment status, 5: Comment type",
|
283 |
Â
'stream'
|
284 |
Â
),
|
285 |
+
compact( 'parent_user_name', 'user_name', 'post_title', 'comment_status', 'comment_type', 'post_id' ),
|
286 |
Â
$comment_id,
|
287 |
Â
$post_type,
|
288 |
Â
'replied',
|
290 |
Â
);
|
291 |
Â
} else {
|
292 |
Â
$this->log(
|
293 |
+
// translators: Placeholders refer to a comment author, a post title, a comment status, and a comment type
|
294 |
Â
_x(
|
295 |
Â
'New %4$s by %1$s on %2$s %3$s',
|
296 |
Â
'1: Comment author, 2: Post title 3: Comment status, 4: Comment type',
|
323 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
324 |
Â
$post_id = $comment->comment_post_ID;
|
325 |
Â
$post_type = get_post_type( $post_id );
|
326 |
+
$post = get_post( $post_id );
|
327 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
328 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
329 |
Â
|
330 |
Â
$this->log(
|
331 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
332 |
Â
_x(
|
333 |
Â
'%1$s\'s %3$s on %2$s edited',
|
334 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
389 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
390 |
Â
$post_id = absint( $comment->comment_post_ID );
|
391 |
Â
$post_type = get_post_type( $post_id );
|
392 |
+
$post = get_post( $post_id );
|
393 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
394 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
395 |
Â
|
396 |
Â
if ( $this->delete_post === $post_id ) {
|
398 |
Â
}
|
399 |
Â
|
400 |
Â
$this->log(
|
401 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
402 |
Â
_x(
|
403 |
Â
'%1$s\'s %3$s on %2$s deleted permanently',
|
404 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
429 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
430 |
Â
$post_id = $comment->comment_post_ID;
|
431 |
Â
$post_type = get_post_type( $post_id );
|
432 |
+
$post = get_post( $post_id );
|
433 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
434 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
435 |
Â
|
436 |
Â
$this->log(
|
437 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
438 |
Â
_x(
|
439 |
Â
'%1$s\'s %3$s on %2$s trashed',
|
440 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
465 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
466 |
Â
$post_id = $comment->comment_post_ID;
|
467 |
Â
$post_type = get_post_type( $post_id );
|
468 |
+
$post = get_post( $post_id );
|
469 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
470 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
471 |
Â
|
472 |
Â
$this->log(
|
473 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
474 |
Â
_x(
|
475 |
Â
'%1$s\'s %3$s on %2$s restored',
|
476 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
501 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
502 |
Â
$post_id = $comment->comment_post_ID;
|
503 |
Â
$post_type = get_post_type( $post_id );
|
504 |
+
$post = get_post( $post_id );
|
505 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
506 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
507 |
Â
|
508 |
Â
$this->log(
|
509 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
510 |
Â
_x(
|
511 |
Â
'%1$s\'s %3$s on %2$s marked as spam',
|
512 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
537 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
538 |
Â
$post_id = $comment->comment_post_ID;
|
539 |
Â
$post_type = get_post_type( $post_id );
|
540 |
+
$post = get_post( $post_id );
|
541 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
542 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
543 |
Â
|
544 |
Â
$this->log(
|
545 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
546 |
Â
_x(
|
547 |
Â
'%1$s\'s %3$s on %2$s unmarked as spam',
|
548 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
577 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
578 |
Â
$post_id = $comment->comment_post_ID;
|
579 |
Â
$post_type = get_post_type( $post_id );
|
580 |
+
$post = get_post( $post_id );
|
581 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
582 |
Â
$comment_type = get_comment_type( $comment->comment_ID );
|
583 |
Â
|
584 |
Â
$this->log(
|
585 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
586 |
Â
_x(
|
587 |
Â
'%1$s\'s %3$s %2$s',
|
588 |
Â
'Comment status transition. 1: Comment author, 2: Post title, 3: Comment type',
|
617 |
Â
$user_name = $this->get_comment_author( $comment, 'name' );
|
618 |
Â
$post_id = $comment->comment_post_ID;
|
619 |
Â
$post_type = get_post_type( $post_id );
|
620 |
+
$post = get_post( $post_id );
|
621 |
+
$post_title = $post ? "\"$post->post_title\"" : esc_html__( 'a post', 'stream' );
|
622 |
Â
$comment_type = mb_strtolower( $this->get_comment_type_label( $comment_id ) );
|
623 |
Â
|
624 |
Â
$this->log(
|
625 |
+
// translators: Placeholders refer to a comment author, a post title, and a comment type
|
626 |
Â
_x(
|
627 |
Â
'Duplicate %3$s by %1$s prevented on %2$s',
|
628 |
Â
'1: Comment author, 2: Post title, 3: Comment type',
|
connectors/class-connector-edd.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
namespace WP_Stream;
|
3 |
Â
|
4 |
Â
class Connector_EDD extends Connector {
|
@@ -141,19 +142,20 @@ class Connector_EDD extends Connector {
|
|
141 |
Â
*
|
142 |
Â
* @filter wp_stream_action_links_{connector}
|
143 |
Â
*
|
144 |
-
* @param array $links
|
145 |
-
* @param object $record
|
146 |
Â
*
|
147 |
Â
* @return array Action links
|
148 |
Â
*/
|
149 |
Â
public function action_links( $links, $record ) {
|
150 |
Â
if ( in_array( $record->context, array( 'downloads' ), true ) ) {
|
151 |
Â
$posts_connector = new Connector_Posts();
|
152 |
-
$links
|
153 |
Â
} elseif ( in_array( $record->context, array( 'discounts' ), true ) ) {
|
154 |
Â
$post_type_label = get_post_type_labels( get_post_type_object( 'edd_discount' ) )->singular_name;
|
155 |
Â
$base = admin_url( 'edit.php?post_type=download&page=edd-discounts' );
|
156 |
Â
|
Â
|
|
157 |
Â
$links[ sprintf( esc_html__( 'Edit %s', 'stream' ), $post_type_label ) ] = add_query_arg(
|
158 |
Â
array(
|
159 |
Â
'edd-action' => 'edit_discount',
|
@@ -163,6 +165,7 @@ class Connector_EDD extends Connector {
|
|
163 |
Â
);
|
164 |
Â
|
165 |
Â
if ( 'active' === get_post( $record->object_id )->post_status ) {
|
Â
|
|
166 |
Â
$links[ sprintf( esc_html__( 'Deactivate %s', 'stream' ), $post_type_label ) ] = add_query_arg(
|
167 |
Â
array(
|
168 |
Â
'edd-action' => 'deactivate_discount',
|
@@ -171,6 +174,7 @@ class Connector_EDD extends Connector {
|
|
171 |
Â
$base
|
172 |
Â
);
|
173 |
Â
} else {
|
Â
|
|
174 |
Â
$links[ sprintf( esc_html__( 'Activate %s', 'stream' ), $post_type_label ) ] = add_query_arg(
|
175 |
Â
array(
|
176 |
Â
'edd-action' => 'activate_discount',
|
@@ -179,18 +183,44 @@ class Connector_EDD extends Connector {
|
|
179 |
Â
$base
|
180 |
Â
);
|
181 |
Â
}
|
182 |
-
} elseif ( in_array( $record->context, array(
|
Â
|
|
Â
|
|
Â
|
|
183 |
Â
$tax_label = get_taxonomy_labels( get_taxonomy( $record->context ) )->singular_name;
|
Â
|
|
184 |
Â
$links[ sprintf( esc_html__( 'Edit %s', 'stream' ), $tax_label ) ] = get_edit_term_link( $record->object_id, $record->get_meta( 'taxonomy', true ) );
|
185 |
Â
} elseif ( 'api_keys' === $record->context ) {
|
186 |
Â
$user = new \WP_User( $record->object_id );
|
187 |
Â
|
188 |
Â
if ( apply_filters( 'edd_api_log_requests', true ) ) {
|
189 |
-
$links[ esc_html__( 'View API Log', 'stream' ) ] = add_query_arg(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
190 |
Â
}
|
191 |
Â
|
192 |
-
$links[ esc_html__( 'Revoke', 'stream' ) ] = add_query_arg(
|
193 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
194 |
Â
}
|
195 |
Â
|
196 |
Â
return $links;
|
@@ -238,13 +268,17 @@ class Connector_EDD extends Connector {
|
|
238 |
Â
$replacement = str_replace( '-', '_', $option );
|
239 |
Â
|
240 |
Â
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
241 |
-
call_user_func( array(
|
Â
|
|
Â
|
|
Â
|
|
242 |
Â
} else {
|
243 |
Â
$data = $this->options[ $option ];
|
244 |
Â
$option_title = $data['label'];
|
245 |
Â
$context = isset( $data['context'] ) ? $data['context'] : 'settings';
|
246 |
Â
|
247 |
Â
$this->log(
|
Â
|
|
248 |
Â
__( '"%s" setting updated', 'stream' ),
|
249 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value' ),
|
250 |
Â
null,
|
@@ -275,7 +309,7 @@ class Connector_EDD extends Connector {
|
|
275 |
Â
$field = array(
|
276 |
Â
'name' => esc_html_x( 'Banned emails', 'edd', 'stream' ),
|
277 |
Â
);
|
278 |
-
$tab
|
279 |
Â
} else {
|
280 |
Â
foreach ( $settings as $tab => $fields ) {
|
281 |
Â
if ( isset( $fields[ $option ] ) ) {
|
@@ -290,6 +324,7 @@ class Connector_EDD extends Connector {
|
|
290 |
Â
}
|
291 |
Â
|
292 |
Â
$this->log(
|
Â
|
|
293 |
Â
__( '"%s" setting updated', 'stream' ),
|
294 |
Â
array(
|
295 |
Â
'option_title' => $field['name'],
|
@@ -319,7 +354,7 @@ class Connector_EDD extends Connector {
|
|
319 |
Â
|
320 |
Â
if ( 'posts' === $data['connector'] && 'download' === $data['context'] ) {
|
321 |
Â
// Download posts operations
|
322 |
-
$data['context']
|
323 |
Â
$data['connector'] = $this->name;
|
324 |
Â
} elseif ( 'posts' === $data['connector'] && 'edd_discount' === $data['context'] ) {
|
325 |
Â
// Discount posts operations
|
@@ -328,10 +363,11 @@ class Connector_EDD extends Connector {
|
|
328 |
Â
}
|
329 |
Â
|
330 |
Â
if ( 'deleted' === $data['action'] ) {
|
Â
|
|
331 |
Â
$data['message'] = esc_html__( '"%1s" discount deleted', 'stream' );
|
332 |
Â
}
|
333 |
Â
|
334 |
-
$data['context']
|
335 |
Â
$data['connector'] = $this->name;
|
336 |
Â
} elseif ( 'posts' === $data['connector'] && 'edd_payment' === $data['context'] ) {
|
337 |
Â
// Payment posts operations
|
@@ -360,6 +396,7 @@ class Connector_EDD extends Connector {
|
|
360 |
Â
|
361 |
Â
$this->log(
|
362 |
Â
sprintf(
|
Â
|
|
363 |
Â
__( '"%1$s" discount %2$s', 'stream' ),
|
364 |
Â
get_post( $code_id )->post_title,
|
365 |
Â
'active' === $new_status ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' )
|
@@ -377,20 +414,26 @@ class Connector_EDD extends Connector {
|
|
377 |
Â
private function callback_edd_generate_pdf() {
|
378 |
Â
$this->report_generated( 'pdf' );
|
379 |
Â
}
|
Â
|
|
380 |
Â
public function callback_edd_earnings_export() {
|
381 |
Â
$this->report_generated( 'earnings' );
|
382 |
Â
}
|
Â
|
|
383 |
Â
public function callback_edd_payment_export() {
|
384 |
Â
$this->report_generated( 'payments' );
|
385 |
Â
}
|
Â
|
|
386 |
Â
public function callback_edd_email_export() {
|
387 |
Â
$this->report_generated( 'emails' );
|
388 |
Â
}
|
Â
|
|
389 |
Â
public function callback_edd_downloads_history_export() {
|
390 |
Â
$this->report_generated( 'download-history' );
|
391 |
Â
}
|
392 |
Â
|
393 |
Â
private function report_generated( $type ) {
|
Â
|
|
Â
|
|
394 |
Â
if ( 'pdf' === $type ) {
|
395 |
Â
$label = esc_html__( 'Sales and Earnings', 'stream' );
|
396 |
Â
} elseif ( 'earnings' ) {
|
@@ -405,6 +448,7 @@ class Connector_EDD extends Connector {
|
|
405 |
Â
|
406 |
Â
$this->log(
|
407 |
Â
sprintf(
|
Â
|
|
408 |
Â
__( 'Generated %s report', 'stream' ),
|
409 |
Â
$label
|
410 |
Â
),
|
@@ -461,7 +505,10 @@ class Connector_EDD extends Connector {
|
|
461 |
Â
return false;
|
462 |
Â
}
|
463 |
Â
|
464 |
-
return call_user_func( array(
|
Â
|
|
Â
|
|
Â
|
|
465 |
Â
}
|
466 |
Â
|
467 |
Â
private function meta_edd_user_public_key( $user_id, $value, $is_add = false ) {
|
@@ -478,6 +525,7 @@ class Connector_EDD extends Connector {
|
|
478 |
Â
|
479 |
Â
$this->log(
|
480 |
Â
sprintf(
|
Â
|
|
481 |
Â
__( 'User API Key %s', 'stream' ),
|
482 |
Â
$action_title
|
483 |
Â
),
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
namespace WP_Stream;
|
4 |
Â
|
5 |
Â
class Connector_EDD extends Connector {
|
142 |
Â
*
|
143 |
Â
* @filter wp_stream_action_links_{connector}
|
144 |
Â
*
|
145 |
+
* @param array $links Previous links registered
|
146 |
+
* @param object $record Stream record
|
147 |
Â
*
|
148 |
Â
* @return array Action links
|
149 |
Â
*/
|
150 |
Â
public function action_links( $links, $record ) {
|
151 |
Â
if ( in_array( $record->context, array( 'downloads' ), true ) ) {
|
152 |
Â
$posts_connector = new Connector_Posts();
|
153 |
+
$links = $posts_connector->action_links( $links, $record );
|
154 |
Â
} elseif ( in_array( $record->context, array( 'discounts' ), true ) ) {
|
155 |
Â
$post_type_label = get_post_type_labels( get_post_type_object( 'edd_discount' ) )->singular_name;
|
156 |
Â
$base = admin_url( 'edit.php?post_type=download&page=edd-discounts' );
|
157 |
Â
|
158 |
+
// translators: Placeholder refers to a post type (e.g. "Post")
|
159 |
Â
$links[ sprintf( esc_html__( 'Edit %s', 'stream' ), $post_type_label ) ] = add_query_arg(
|
160 |
Â
array(
|
161 |
Â
'edd-action' => 'edit_discount',
|
165 |
Â
);
|
166 |
Â
|
167 |
Â
if ( 'active' === get_post( $record->object_id )->post_status ) {
|
168 |
+
// translators: Placeholder refers to a post type (e.g. "Post")
|
169 |
Â
$links[ sprintf( esc_html__( 'Deactivate %s', 'stream' ), $post_type_label ) ] = add_query_arg(
|
170 |
Â
array(
|
171 |
Â
'edd-action' => 'deactivate_discount',
|
174 |
Â
$base
|
175 |
Â
);
|
176 |
Â
} else {
|
177 |
+
// translators: Placeholder refers to a post type (e.g. "Post")
|
178 |
Â
$links[ sprintf( esc_html__( 'Activate %s', 'stream' ), $post_type_label ) ] = add_query_arg(
|
179 |
Â
array(
|
180 |
Â
'edd-action' => 'activate_discount',
|
183 |
Â
$base
|
184 |
Â
);
|
185 |
Â
}
|
186 |
+
} elseif ( in_array( $record->context, array(
|
187 |
+
'download_category',
|
188 |
+
'download_tag',
|
189 |
+
), true ) ) {
|
190 |
Â
$tax_label = get_taxonomy_labels( get_taxonomy( $record->context ) )->singular_name;
|
191 |
+
// translators: Placeholder refers to a taxonomy (e.g. "Category")
|
192 |
Â
$links[ sprintf( esc_html__( 'Edit %s', 'stream' ), $tax_label ) ] = get_edit_term_link( $record->object_id, $record->get_meta( 'taxonomy', true ) );
|
193 |
Â
} elseif ( 'api_keys' === $record->context ) {
|
194 |
Â
$user = new \WP_User( $record->object_id );
|
195 |
Â
|
196 |
Â
if ( apply_filters( 'edd_api_log_requests', true ) ) {
|
197 |
+
$links[ esc_html__( 'View API Log', 'stream' ) ] = add_query_arg(
|
198 |
+
array(
|
199 |
+
'view' => 'api_requests',
|
200 |
+
'post_type' => 'download',
|
201 |
+
'page' => 'edd-reports',
|
202 |
+
'tab' => 'logs',
|
203 |
+
's' => $user->user_email,
|
204 |
+
), 'edit.php'
|
205 |
+
);
|
206 |
Â
}
|
207 |
Â
|
208 |
+
$links[ esc_html__( 'Revoke', 'stream' ) ] = add_query_arg(
|
209 |
+
array(
|
210 |
+
'post_type' => 'download',
|
211 |
+
'user_id' => $record->object_id,
|
212 |
+
'edd_action' => 'process_api_key',
|
213 |
+
'edd_api_process' => 'revoke',
|
214 |
+
), 'edit.php'
|
215 |
+
);
|
216 |
+
$links[ esc_html__( 'Reissue', 'stream' ) ] = add_query_arg(
|
217 |
+
array(
|
218 |
+
'post_type' => 'download',
|
219 |
+
'user_id' => $record->object_id,
|
220 |
+
'edd_action' => 'process_api_key',
|
221 |
+
'edd_api_process' => 'regenerate',
|
222 |
+
), 'edit.php'
|
223 |
+
);
|
224 |
Â
}
|
225 |
Â
|
226 |
Â
return $links;
|
268 |
Â
$replacement = str_replace( '-', '_', $option );
|
269 |
Â
|
270 |
Â
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
271 |
+
call_user_func( array(
|
272 |
+
$this,
|
273 |
+
'check_' . $replacement,
|
274 |
+
), $old_value, $new_value );
|
275 |
Â
} else {
|
276 |
Â
$data = $this->options[ $option ];
|
277 |
Â
$option_title = $data['label'];
|
278 |
Â
$context = isset( $data['context'] ) ? $data['context'] : 'settings';
|
279 |
Â
|
280 |
Â
$this->log(
|
281 |
+
// translators: Placeholder refers to a setting title (e.g. "Language")
|
282 |
Â
__( '"%s" setting updated', 'stream' ),
|
283 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value' ),
|
284 |
Â
null,
|
309 |
Â
$field = array(
|
310 |
Â
'name' => esc_html_x( 'Banned emails', 'edd', 'stream' ),
|
311 |
Â
);
|
312 |
+
$tab = 'general';
|
313 |
Â
} else {
|
314 |
Â
foreach ( $settings as $tab => $fields ) {
|
315 |
Â
if ( isset( $fields[ $option ] ) ) {
|
324 |
Â
}
|
325 |
Â
|
326 |
Â
$this->log(
|
327 |
+
// translators: Placeholder refers to a setting title (e.g. "Language")
|
328 |
Â
__( '"%s" setting updated', 'stream' ),
|
329 |
Â
array(
|
330 |
Â
'option_title' => $field['name'],
|
354 |
Â
|
355 |
Â
if ( 'posts' === $data['connector'] && 'download' === $data['context'] ) {
|
356 |
Â
// Download posts operations
|
357 |
+
$data['context'] = 'downloads';
|
358 |
Â
$data['connector'] = $this->name;
|
359 |
Â
} elseif ( 'posts' === $data['connector'] && 'edd_discount' === $data['context'] ) {
|
360 |
Â
// Discount posts operations
|
363 |
Â
}
|
364 |
Â
|
365 |
Â
if ( 'deleted' === $data['action'] ) {
|
366 |
+
// translators: Placeholder refers to a discount title (e.g. "Mother's Day")
|
367 |
Â
$data['message'] = esc_html__( '"%1s" discount deleted', 'stream' );
|
368 |
Â
}
|
369 |
Â
|
370 |
+
$data['context'] = 'discounts';
|
371 |
Â
$data['connector'] = $this->name;
|
372 |
Â
} elseif ( 'posts' === $data['connector'] && 'edd_payment' === $data['context'] ) {
|
373 |
Â
// Payment posts operations
|
396 |
Â
|
397 |
Â
$this->log(
|
398 |
Â
sprintf(
|
399 |
+
// translators: Placeholders refer to a discount title, and a status (e.g. "Mother's Day", "activated")
|
400 |
Â
__( '"%1$s" discount %2$s', 'stream' ),
|
401 |
Â
get_post( $code_id )->post_title,
|
402 |
Â
'active' === $new_status ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' )
|
414 |
Â
private function callback_edd_generate_pdf() {
|
415 |
Â
$this->report_generated( 'pdf' );
|
416 |
Â
}
|
417 |
+
|
418 |
Â
public function callback_edd_earnings_export() {
|
419 |
Â
$this->report_generated( 'earnings' );
|
420 |
Â
}
|
421 |
+
|
422 |
Â
public function callback_edd_payment_export() {
|
423 |
Â
$this->report_generated( 'payments' );
|
424 |
Â
}
|
425 |
+
|
426 |
Â
public function callback_edd_email_export() {
|
427 |
Â
$this->report_generated( 'emails' );
|
428 |
Â
}
|
429 |
+
|
430 |
Â
public function callback_edd_downloads_history_export() {
|
431 |
Â
$this->report_generated( 'download-history' );
|
432 |
Â
}
|
433 |
Â
|
434 |
Â
private function report_generated( $type ) {
|
435 |
+
$label = '';
|
436 |
+
|
437 |
Â
if ( 'pdf' === $type ) {
|
438 |
Â
$label = esc_html__( 'Sales and Earnings', 'stream' );
|
439 |
Â
} elseif ( 'earnings' ) {
|
448 |
Â
|
449 |
Â
$this->log(
|
450 |
Â
sprintf(
|
451 |
+
// translators: Placeholder refers to a report title (e.g. "Sales and Earnings")
|
452 |
Â
__( 'Generated %s report', 'stream' ),
|
453 |
Â
$label
|
454 |
Â
),
|
505 |
Â
return false;
|
506 |
Â
}
|
507 |
Â
|
508 |
+
return call_user_func( array(
|
509 |
+
$this,
|
510 |
+
'meta_' . $key,
|
511 |
+
), $object_id, $value, $is_add );
|
512 |
Â
}
|
513 |
Â
|
514 |
Â
private function meta_edd_user_public_key( $user_id, $value, $is_add = false ) {
|
525 |
Â
|
526 |
Â
$this->log(
|
527 |
Â
sprintf(
|
528 |
+
// translators: Placeholder refers to a status (e.g. "revoked")
|
529 |
Â
__( 'User API Key %s', 'stream' ),
|
530 |
Â
$action_title
|
531 |
Â
),
|
connectors/class-connector-editor.php
CHANGED
@@ -115,6 +115,7 @@ class Connector_Editor extends Connector {
|
|
115 |
Â
* @return string Translated string
|
116 |
Â
*/
|
117 |
Â
public function get_message() {
|
Â
|
|
118 |
Â
return _x(
|
119 |
Â
'"%1$s" in "%2$s" updated',
|
120 |
Â
'1: File name, 2: Theme/plugin name',
|
@@ -146,15 +147,15 @@ class Connector_Editor extends Connector {
|
|
146 |
Â
if ( $theme_exists ) {
|
147 |
Â
$links[ esc_html__( 'Edit File', 'stream' ) ] = add_query_arg(
|
148 |
Â
array(
|
149 |
-
'theme' =>
|
150 |
-
'file' =>
|
151 |
Â
),
|
152 |
Â
self_admin_url( 'theme-editor.php' )
|
153 |
Â
);
|
154 |
Â
|
155 |
Â
$links[ esc_html__( 'Theme Details', 'stream' ) ] = add_query_arg(
|
156 |
Â
array(
|
157 |
-
'theme' =>
|
158 |
Â
),
|
159 |
Â
self_admin_url( 'themes.php' )
|
160 |
Â
);
|
@@ -163,8 +164,8 @@ class Connector_Editor extends Connector {
|
|
163 |
Â
if ( $plugin_exists ) {
|
164 |
Â
$links[ esc_html__( 'Edit File', 'stream' ) ] = add_query_arg(
|
165 |
Â
array(
|
166 |
-
'plugin' =>
|
167 |
-
'file' =>
|
168 |
Â
),
|
169 |
Â
self_admin_url( 'plugin-editor.php' )
|
170 |
Â
);
|
@@ -194,12 +195,14 @@ class Connector_Editor extends Connector {
|
|
194 |
Â
return;
|
195 |
Â
}
|
196 |
Â
|
197 |
-
|
198 |
-
|
Â
|
|
199 |
Â
}
|
200 |
Â
|
201 |
-
|
202 |
-
|
Â
|
|
203 |
Â
}
|
204 |
Â
}
|
205 |
Â
|
@@ -231,15 +234,13 @@ class Connector_Editor extends Connector {
|
|
231 |
Â
$file_path = sprintf( '%s/%s', $theme->get_stylesheet_directory(), $file_name );
|
232 |
Â
}
|
233 |
Â
|
234 |
-
|
235 |
-
$
|
236 |
-
|
237 |
-
$name = $theme->get( 'Name' );
|
238 |
Â
|
239 |
Â
$output = compact(
|
240 |
Â
'file_name',
|
241 |
Â
'file_path',
|
242 |
-
'
|
243 |
Â
'slug',
|
244 |
Â
'name'
|
245 |
Â
);
|
@@ -259,11 +260,8 @@ class Connector_Editor extends Connector {
|
|
259 |
Â
$slug = current( explode( '/', $slug ) );
|
260 |
Â
$file_name = wp_stream_filter_input( INPUT_POST, 'file' );
|
261 |
Â
$file_path = WP_PLUGIN_DIR . '/' . $file_name;
|
262 |
-
|
263 |
-
|
264 |
-
$file_contents_before = file_get_contents( $file_path );
|
265 |
-
|
266 |
-
$plugins = get_plugins();
|
267 |
Â
|
268 |
Â
foreach ( $plugins as $key => $plugin_data ) {
|
269 |
Â
if ( 0 === strpos( $key, $slug ) ) {
|
@@ -279,7 +277,7 @@ class Connector_Editor extends Connector {
|
|
279 |
Â
$output = compact(
|
280 |
Â
'file_name',
|
281 |
Â
'file_path',
|
282 |
-
'
|
283 |
Â
'slug',
|
284 |
Â
'name'
|
285 |
Â
);
|
@@ -293,7 +291,7 @@ class Connector_Editor extends Connector {
|
|
293 |
Â
public function log_changes( $location ) {
|
294 |
Â
if ( ! empty( $this->edited_file ) ) {
|
295 |
Â
// TODO: phpcs fix
|
296 |
-
if (
|
297 |
Â
$context = $this->get_context( $location );
|
298 |
Â
|
299 |
Â
switch ( $context ) {
|
115 |
Â
* @return string Translated string
|
116 |
Â
*/
|
117 |
Â
public function get_message() {
|
118 |
+
// translators: Placeholders refer to a file name, and a theme / plugin name (e.g. "index.php", "Stream")
|
119 |
Â
return _x(
|
120 |
Â
'"%1$s" in "%2$s" updated',
|
121 |
Â
'1: File name, 2: Theme/plugin name',
|
147 |
Â
if ( $theme_exists ) {
|
148 |
Â
$links[ esc_html__( 'Edit File', 'stream' ) ] = add_query_arg(
|
149 |
Â
array(
|
150 |
+
'theme' => rawurlencode( $theme_slug ),
|
151 |
+
'file' => rawurlencode( $file_name ),
|
152 |
Â
),
|
153 |
Â
self_admin_url( 'theme-editor.php' )
|
154 |
Â
);
|
155 |
Â
|
156 |
Â
$links[ esc_html__( 'Theme Details', 'stream' ) ] = add_query_arg(
|
157 |
Â
array(
|
158 |
+
'theme' => rawurlencode( $theme_slug ),
|
159 |
Â
),
|
160 |
Â
self_admin_url( 'themes.php' )
|
161 |
Â
);
|
164 |
Â
if ( $plugin_exists ) {
|
165 |
Â
$links[ esc_html__( 'Edit File', 'stream' ) ] = add_query_arg(
|
166 |
Â
array(
|
167 |
+
'plugin' => rawurlencode( $plugin_slug ),
|
168 |
+
'file' => rawurlencode( str_ireplace( trailingslashit( WP_PLUGIN_DIR ), '', $file_path ) ),
|
169 |
Â
),
|
170 |
Â
self_admin_url( 'plugin-editor.php' )
|
171 |
Â
);
|
195 |
Â
return;
|
196 |
Â
}
|
197 |
Â
|
198 |
+
$theme_slug = wp_stream_filter_input( INPUT_POST, 'theme' );
|
199 |
+
if ( $theme_slug ) {
|
200 |
+
$this->edited_file = $this->get_theme_data( $theme_slug );
|
201 |
Â
}
|
202 |
Â
|
203 |
+
$plugin_slug = wp_stream_filter_input( INPUT_POST, 'plugin' );
|
204 |
+
if ( $plugin_slug ) {
|
205 |
+
$this->edited_file = $this->get_plugin_data( $plugin_slug );
|
206 |
Â
}
|
207 |
Â
}
|
208 |
Â
|
234 |
Â
$file_path = sprintf( '%s/%s', $theme->get_stylesheet_directory(), $file_name );
|
235 |
Â
}
|
236 |
Â
|
237 |
+
$file_md5 = md5_file( $file_path );
|
238 |
+
$name = $theme->get( 'Name' );
|
Â
|
|
Â
|
|
239 |
Â
|
240 |
Â
$output = compact(
|
241 |
Â
'file_name',
|
242 |
Â
'file_path',
|
243 |
+
'file_md5',
|
244 |
Â
'slug',
|
245 |
Â
'name'
|
246 |
Â
);
|
260 |
Â
$slug = current( explode( '/', $slug ) );
|
261 |
Â
$file_name = wp_stream_filter_input( INPUT_POST, 'file' );
|
262 |
Â
$file_path = WP_PLUGIN_DIR . '/' . $file_name;
|
263 |
+
$file_md5 = md5_file( $file_path );
|
264 |
+
$plugins = get_plugins();
|
Â
|
|
Â
|
|
Â
|
|
265 |
Â
|
266 |
Â
foreach ( $plugins as $key => $plugin_data ) {
|
267 |
Â
if ( 0 === strpos( $key, $slug ) ) {
|
277 |
Â
$output = compact(
|
278 |
Â
'file_name',
|
279 |
Â
'file_path',
|
280 |
+
'file_md5',
|
281 |
Â
'slug',
|
282 |
Â
'name'
|
283 |
Â
);
|
291 |
Â
public function log_changes( $location ) {
|
292 |
Â
if ( ! empty( $this->edited_file ) ) {
|
293 |
Â
// TODO: phpcs fix
|
294 |
+
if ( md5_file( $this->edited_file['file_path'] ) !== $this->edited_file['file_md5'] ) {
|
295 |
Â
$context = $this->get_context( $location );
|
296 |
Â
|
297 |
Â
switch ( $context ) {
|
connectors/class-connector-gravityforms.php
CHANGED
@@ -140,7 +140,7 @@ class Connector_GravityForms extends Connector {
|
|
140 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = add_query_arg(
|
141 |
Â
array(
|
142 |
Â
'page' => 'gf_edit_forms',
|
143 |
-
'id'
|
144 |
Â
),
|
145 |
Â
admin_url( 'admin.php' )
|
146 |
Â
);
|
@@ -180,16 +180,16 @@ class Connector_GravityForms extends Connector {
|
|
180 |
Â
parent::register();
|
181 |
Â
|
182 |
Â
$this->options = array(
|
183 |
-
'rg_gforms_disable_css'
|
184 |
Â
'label' => esc_html_x( 'Output CSS', 'gravityforms', 'stream' ),
|
185 |
Â
),
|
186 |
-
'rg_gforms_enable_html5'
|
187 |
Â
'label' => esc_html_x( 'Output HTML5', 'gravityforms', 'stream' ),
|
188 |
Â
),
|
189 |
-
'gform_enable_noconflict'
|
190 |
Â
'label' => esc_html_x( 'No-Conflict Mode', 'gravityforms', 'stream' ),
|
191 |
Â
),
|
192 |
-
'rg_gforms_currency'
|
193 |
Â
'label' => esc_html_x( 'Currency', 'gravityforms', 'stream' ),
|
194 |
Â
),
|
195 |
Â
'rg_gforms_captcha_public_key' => array(
|
@@ -215,6 +215,7 @@ class Connector_GravityForms extends Connector {
|
|
215 |
Â
|
216 |
Â
$this->log(
|
217 |
Â
sprintf(
|
Â
|
|
218 |
Â
__( '"%1$s" form %2$s', 'stream' ),
|
219 |
Â
$title,
|
220 |
Â
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' )
|
@@ -245,6 +246,7 @@ class Connector_GravityForms extends Connector {
|
|
245 |
Â
|
246 |
Â
$this->log(
|
247 |
Â
sprintf(
|
Â
|
|
248 |
Â
__( '"%1$s" confirmation %2$s for "%3$s"', 'stream' ),
|
249 |
Â
$confirmation['name'],
|
250 |
Â
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
|
@@ -277,6 +279,7 @@ class Connector_GravityForms extends Connector {
|
|
277 |
Â
|
278 |
Â
$this->log(
|
279 |
Â
sprintf(
|
Â
|
|
280 |
Â
__( '"%1$s" notification %2$s for "%3$s"', 'stream' ),
|
281 |
Â
$notification['name'],
|
282 |
Â
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
|
@@ -304,6 +307,7 @@ class Connector_GravityForms extends Connector {
|
|
304 |
Â
public function callback_gform_pre_notification_deleted( $notification, $form ) {
|
305 |
Â
$this->log(
|
306 |
Â
sprintf(
|
Â
|
|
307 |
Â
__( '"%1$s" notification deleted from "%2$s"', 'stream' ),
|
308 |
Â
$notification['name'],
|
309 |
Â
$form['title']
|
@@ -328,6 +332,7 @@ class Connector_GravityForms extends Connector {
|
|
328 |
Â
public function callback_gform_pre_confirmation_deleted( $confirmation, $form ) {
|
329 |
Â
$this->log(
|
330 |
Â
sprintf(
|
Â
|
|
331 |
Â
__( '"%1$s" confirmation deleted from "%2$s"', 'stream' ),
|
332 |
Â
$confirmation['name'],
|
333 |
Â
$form['title']
|
@@ -353,6 +358,7 @@ class Connector_GravityForms extends Connector {
|
|
353 |
Â
public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
|
354 |
Â
$this->log(
|
355 |
Â
sprintf(
|
Â
|
|
356 |
Â
__( '"%1$s" confirmation %2$s from "%3$s"', 'stream' ),
|
357 |
Â
$confirmation['name'],
|
358 |
Â
$is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
|
@@ -380,6 +386,7 @@ class Connector_GravityForms extends Connector {
|
|
380 |
Â
public function callback_gform_notification_status( $notification, $form, $is_active ) {
|
381 |
Â
$this->log(
|
382 |
Â
sprintf(
|
Â
|
|
383 |
Â
__( '"%1$s" notification %2$s from "%3$s"', 'stream' ),
|
384 |
Â
$notification['name'],
|
385 |
Â
$is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
|
@@ -433,6 +440,7 @@ class Connector_GravityForms extends Connector {
|
|
433 |
Â
$context = isset( $data['context'] ) ? $data['context'] : 'settings';
|
434 |
Â
|
435 |
Â
$this->log(
|
Â
|
|
436 |
Â
__( '"%s" setting updated', 'stream' ),
|
437 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value' ),
|
438 |
Â
null,
|
@@ -448,6 +456,7 @@ class Connector_GravityForms extends Connector {
|
|
448 |
Â
|
449 |
Â
$this->log(
|
450 |
Â
sprintf(
|
Â
|
|
451 |
Â
__( 'Gravity Forms license key %s', 'stream' ),
|
452 |
Â
$is_update ? esc_html__( 'updated', 'stream' ) : esc_html__( 'deleted', 'stream' )
|
453 |
Â
),
|
@@ -461,12 +470,13 @@ class Connector_GravityForms extends Connector {
|
|
461 |
Â
public function callback_gform_post_export_entries( $form, $start_date, $end_date, $fields ) {
|
462 |
Â
unset( $fields );
|
463 |
Â
$this->log(
|
Â
|
|
464 |
Â
__( '"%s" form entries exported', 'stream' ),
|
465 |
Â
array(
|
466 |
Â
'form_title' => $form['title'],
|
467 |
Â
'form_id' => $form['id'],
|
468 |
Â
'start_date' => empty( $start_date ) ? null : $start_date,
|
469 |
-
'end_date' => empty( $end_date )
|
470 |
Â
),
|
471 |
Â
$form['id'],
|
472 |
Â
'export',
|
@@ -476,15 +486,14 @@ class Connector_GravityForms extends Connector {
|
|
476 |
Â
|
477 |
Â
public function callback_gform_forms_post_import( $forms ) {
|
478 |
Â
$forms_total = count( $forms );
|
479 |
-
$forms_label = ( 1 === $forms_total ) ? 'form' : 'forms';
|
480 |
Â
$forms_ids = wp_list_pluck( $forms, 'id' );
|
481 |
Â
$forms_titles = wp_list_pluck( $forms, 'title' );
|
482 |
Â
|
483 |
Â
$this->log(
|
484 |
-
|
Â
|
|
485 |
Â
array(
|
486 |
Â
'count' => $forms_total,
|
487 |
-
'label' => $forms_label,
|
488 |
Â
'ids' => $forms_ids,
|
489 |
Â
'titles' => $forms_titles,
|
490 |
Â
),
|
@@ -498,6 +507,7 @@ class Connector_GravityForms extends Connector {
|
|
498 |
Â
$form = $this->get_form( $form_id );
|
499 |
Â
|
500 |
Â
$this->log(
|
Â
|
|
501 |
Â
__( '"%s" form exported', 'stream' ),
|
502 |
Â
array(
|
503 |
Â
'form_title' => $form['title'],
|
@@ -516,7 +526,8 @@ class Connector_GravityForms extends Connector {
|
|
516 |
Â
$titles = wp_list_pluck( $forms, 'title' );
|
517 |
Â
|
518 |
Â
$this->log(
|
519 |
-
|
Â
|
|
520 |
Â
array(
|
521 |
Â
'count' => count( $forms ),
|
522 |
Â
'ids' => $ids,
|
@@ -535,6 +546,7 @@ class Connector_GravityForms extends Connector {
|
|
535 |
Â
$form = $this->get_form( $lead['form_id'] );
|
536 |
Â
|
537 |
Â
$this->log(
|
Â
|
|
538 |
Â
__( 'Lead #%1$d from "%2$s" deleted', 'stream' ),
|
539 |
Â
array(
|
540 |
Â
'lead_id' => $lead_id,
|
@@ -557,6 +569,7 @@ class Connector_GravityForms extends Connector {
|
|
557 |
Â
$form = $this->get_form( $lead['form_id'] );
|
558 |
Â
|
559 |
Â
$this->log(
|
Â
|
|
560 |
Â
__( 'Note #%1$d added to lead #%2$d on "%3$s" form', 'stream' ),
|
561 |
Â
array(
|
562 |
Â
'note_id' => $note_id,
|
@@ -575,6 +588,7 @@ class Connector_GravityForms extends Connector {
|
|
575 |
Â
$form = $this->get_form( $lead['form_id'] );
|
576 |
Â
|
577 |
Â
$this->log(
|
Â
|
|
578 |
Â
__( 'Note #%1$d deleted from lead #%2$d on "%3$s" form', 'stream' ),
|
579 |
Â
array(
|
580 |
Â
'note_id' => $note_id,
|
@@ -609,6 +623,7 @@ class Connector_GravityForms extends Connector {
|
|
609 |
Â
|
610 |
Â
$this->log(
|
611 |
Â
sprintf(
|
Â
|
|
612 |
Â
__( 'Lead #%1$d %2$s on "%3$s" form', 'stream' ),
|
613 |
Â
$lead_id,
|
614 |
Â
$actions[ $status ],
|
@@ -641,6 +656,7 @@ class Connector_GravityForms extends Connector {
|
|
641 |
Â
|
642 |
Â
$this->log(
|
643 |
Â
sprintf(
|
Â
|
|
644 |
Â
__( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'stream' ),
|
645 |
Â
$lead_id,
|
646 |
Â
$status,
|
@@ -674,6 +690,7 @@ class Connector_GravityForms extends Connector {
|
|
674 |
Â
|
675 |
Â
$this->log(
|
676 |
Â
sprintf(
|
Â
|
|
677 |
Â
__( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'stream' ),
|
678 |
Â
$lead_id,
|
679 |
Â
$status,
|
@@ -788,6 +805,7 @@ class Connector_GravityForms extends Connector {
|
|
788 |
Â
|
789 |
Â
$this->log(
|
790 |
Â
sprintf(
|
Â
|
|
791 |
Â
__( 'Form #%1$d ("%2$s") %3$s', 'stream' ),
|
792 |
Â
$form_id,
|
793 |
Â
$form['title'],
|
140 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = add_query_arg(
|
141 |
Â
array(
|
142 |
Â
'page' => 'gf_edit_forms',
|
143 |
+
'id' => $record->object_id,
|
144 |
Â
),
|
145 |
Â
admin_url( 'admin.php' )
|
146 |
Â
);
|
180 |
Â
parent::register();
|
181 |
Â
|
182 |
Â
$this->options = array(
|
183 |
+
'rg_gforms_disable_css' => array(
|
184 |
Â
'label' => esc_html_x( 'Output CSS', 'gravityforms', 'stream' ),
|
185 |
Â
),
|
186 |
+
'rg_gforms_enable_html5' => array(
|
187 |
Â
'label' => esc_html_x( 'Output HTML5', 'gravityforms', 'stream' ),
|
188 |
Â
),
|
189 |
+
'gform_enable_noconflict' => array(
|
190 |
Â
'label' => esc_html_x( 'No-Conflict Mode', 'gravityforms', 'stream' ),
|
191 |
Â
),
|
192 |
+
'rg_gforms_currency' => array(
|
193 |
Â
'label' => esc_html_x( 'Currency', 'gravityforms', 'stream' ),
|
194 |
Â
),
|
195 |
Â
'rg_gforms_captcha_public_key' => array(
|
215 |
Â
|
216 |
Â
$this->log(
|
217 |
Â
sprintf(
|
218 |
+
// translators: Placeholders refer to a form title, and a status (e.g. "Contact Form", "created")
|
219 |
Â
__( '"%1$s" form %2$s', 'stream' ),
|
220 |
Â
$title,
|
221 |
Â
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' )
|
246 |
Â
|
247 |
Â
$this->log(
|
248 |
Â
sprintf(
|
249 |
+
// translators: Placeholders refer to a confirmation name, a status, and a form title (e.g. "Email", "created", "Contact Form")
|
250 |
Â
__( '"%1$s" confirmation %2$s for "%3$s"', 'stream' ),
|
251 |
Â
$confirmation['name'],
|
252 |
Â
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
|
279 |
Â
|
280 |
Â
$this->log(
|
281 |
Â
sprintf(
|
282 |
+
// translators: Placeholders refer to a notification name, a status, and a form title (e.g. "Email", "created", "Contact Form")
|
283 |
Â
__( '"%1$s" notification %2$s for "%3$s"', 'stream' ),
|
284 |
Â
$notification['name'],
|
285 |
Â
$is_new ? esc_html__( 'created', 'stream' ) : esc_html__( 'updated', 'stream' ),
|
307 |
Â
public function callback_gform_pre_notification_deleted( $notification, $form ) {
|
308 |
Â
$this->log(
|
309 |
Â
sprintf(
|
310 |
+
// translators: Placeholders refer to a notification name, and a form title (e.g. "Email", "Contact Form")
|
311 |
Â
__( '"%1$s" notification deleted from "%2$s"', 'stream' ),
|
312 |
Â
$notification['name'],
|
313 |
Â
$form['title']
|
332 |
Â
public function callback_gform_pre_confirmation_deleted( $confirmation, $form ) {
|
333 |
Â
$this->log(
|
334 |
Â
sprintf(
|
335 |
+
// translators: Placeholders refer to a confirmation name, and a form title (e.g. "Email", "Contact Form")
|
336 |
Â
__( '"%1$s" confirmation deleted from "%2$s"', 'stream' ),
|
337 |
Â
$confirmation['name'],
|
338 |
Â
$form['title']
|
358 |
Â
public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
|
359 |
Â
$this->log(
|
360 |
Â
sprintf(
|
361 |
+
// translators: Placeholders refer to a confirmation name, a status, and a form title (e.g. "Email", "activated", "Contact Form")
|
362 |
Â
__( '"%1$s" confirmation %2$s from "%3$s"', 'stream' ),
|
363 |
Â
$confirmation['name'],
|
364 |
Â
$is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
|
386 |
Â
public function callback_gform_notification_status( $notification, $form, $is_active ) {
|
387 |
Â
$this->log(
|
388 |
Â
sprintf(
|
389 |
+
// translators: Placeholders refer to a notification name, a status, and a form title (e.g. "Email", "activated", "Contact Form")
|
390 |
Â
__( '"%1$s" notification %2$s from "%3$s"', 'stream' ),
|
391 |
Â
$notification['name'],
|
392 |
Â
$is_active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
|
440 |
Â
$context = isset( $data['context'] ) ? $data['context'] : 'settings';
|
441 |
Â
|
442 |
Â
$this->log(
|
443 |
+
// translators: Placeholder refers to a setting title (e.g. "Language")
|
444 |
Â
__( '"%s" setting updated', 'stream' ),
|
445 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value' ),
|
446 |
Â
null,
|
456 |
Â
|
457 |
Â
$this->log(
|
458 |
Â
sprintf(
|
459 |
+
// translators: Placeholder refers to a status (e.g. "updated")
|
460 |
Â
__( 'Gravity Forms license key %s', 'stream' ),
|
461 |
Â
$is_update ? esc_html__( 'updated', 'stream' ) : esc_html__( 'deleted', 'stream' )
|
462 |
Â
),
|
470 |
Â
public function callback_gform_post_export_entries( $form, $start_date, $end_date, $fields ) {
|
471 |
Â
unset( $fields );
|
472 |
Â
$this->log(
|
473 |
+
// translators: Placeholder refers to a form title (e.g. "Contact Form")
|
474 |
Â
__( '"%s" form entries exported', 'stream' ),
|
475 |
Â
array(
|
476 |
Â
'form_title' => $form['title'],
|
477 |
Â
'form_id' => $form['id'],
|
478 |
Â
'start_date' => empty( $start_date ) ? null : $start_date,
|
479 |
+
'end_date' => empty( $end_date ) ? null : $end_date,
|
480 |
Â
),
|
481 |
Â
$form['id'],
|
482 |
Â
'export',
|
486 |
Â
|
487 |
Â
public function callback_gform_forms_post_import( $forms ) {
|
488 |
Â
$forms_total = count( $forms );
|
Â
|
|
489 |
Â
$forms_ids = wp_list_pluck( $forms, 'id' );
|
490 |
Â
$forms_titles = wp_list_pluck( $forms, 'title' );
|
491 |
Â
|
492 |
Â
$this->log(
|
493 |
+
// translators: Placeholder refers to a number of forms (e.g. "42")
|
494 |
+
_n( '%d form imported', '%d forms imported', $forms_total, 'stream' ),
|
495 |
Â
array(
|
496 |
Â
'count' => $forms_total,
|
Â
|
|
497 |
Â
'ids' => $forms_ids,
|
498 |
Â
'titles' => $forms_titles,
|
499 |
Â
),
|
507 |
Â
$form = $this->get_form( $form_id );
|
508 |
Â
|
509 |
Â
$this->log(
|
510 |
+
// translators: Placeholder refers to a form title (e.g. "Contact Form")
|
511 |
Â
__( '"%s" form exported', 'stream' ),
|
512 |
Â
array(
|
513 |
Â
'form_title' => $form['title'],
|
526 |
Â
$titles = wp_list_pluck( $forms, 'title' );
|
527 |
Â
|
528 |
Â
$this->log(
|
529 |
+
// translators: Placeholder refers to a number of forms (e.g. "42")
|
530 |
+
_n( 'Export process started for %d form', 'Export process started for %d forms', count( $forms ), 'stream' ),
|
531 |
Â
array(
|
532 |
Â
'count' => count( $forms ),
|
533 |
Â
'ids' => $ids,
|
546 |
Â
$form = $this->get_form( $lead['form_id'] );
|
547 |
Â
|
548 |
Â
$this->log(
|
549 |
+
// translators: Placeholders refer to an ID, and a form title (e.g. "42", "Contact Form")
|
550 |
Â
__( 'Lead #%1$d from "%2$s" deleted', 'stream' ),
|
551 |
Â
array(
|
552 |
Â
'lead_id' => $lead_id,
|
569 |
Â
$form = $this->get_form( $lead['form_id'] );
|
570 |
Â
|
571 |
Â
$this->log(
|
572 |
+
// translators: Placeholders refer to an ID, another ID, and a form title (e.g. "42", "7", "Contact Form")
|
573 |
Â
__( 'Note #%1$d added to lead #%2$d on "%3$s" form', 'stream' ),
|
574 |
Â
array(
|
575 |
Â
'note_id' => $note_id,
|
588 |
Â
$form = $this->get_form( $lead['form_id'] );
|
589 |
Â
|
590 |
Â
$this->log(
|
591 |
+
// translators: Placeholders refer to an ID, another ID, and a form title (e.g. "42", "7", "Contact Form")
|
592 |
Â
__( 'Note #%1$d deleted from lead #%2$d on "%3$s" form', 'stream' ),
|
593 |
Â
array(
|
594 |
Â
'note_id' => $note_id,
|
623 |
Â
|
624 |
Â
$this->log(
|
625 |
Â
sprintf(
|
626 |
+
// translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "activated", "Contact Form")
|
627 |
Â
__( 'Lead #%1$d %2$s on "%3$s" form', 'stream' ),
|
628 |
Â
$lead_id,
|
629 |
Â
$actions[ $status ],
|
656 |
Â
|
657 |
Â
$this->log(
|
658 |
Â
sprintf(
|
659 |
+
// translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "unread", "Contact Form")
|
660 |
Â
__( 'Entry #%1$d marked as %2$s on form #%3$d ("%4$s")', 'stream' ),
|
661 |
Â
$lead_id,
|
662 |
Â
$status,
|
690 |
Â
|
691 |
Â
$this->log(
|
692 |
Â
sprintf(
|
693 |
+
// translators: Placeholders refer to an ID, a status, and a form title (e.g. "42", "starred", "Contact Form")
|
694 |
Â
__( 'Entry #%1$d %2$s on form #%3$d ("%4$s")', 'stream' ),
|
695 |
Â
$lead_id,
|
696 |
Â
$status,
|
805 |
Â
|
806 |
Â
$this->log(
|
807 |
Â
sprintf(
|
808 |
+
// translators: Placeholders refer to an ID, a form title, and a status (e.g. "42", "Contact Form", "Activated")
|
809 |
Â
__( 'Form #%1$d ("%2$s") %3$s', 'stream' ),
|
810 |
Â
$form_id,
|
811 |
Â
$form['title'],
|
connectors/class-connector-installer.php
CHANGED
@@ -81,7 +81,7 @@ class Connector_Installer extends Connector {
|
|
81 |
Â
* @return array Action links
|
82 |
Â
*/
|
83 |
Â
public function action_links( $links, $record ) {
|
84 |
-
if ( '
|
85 |
Â
global $wp_version;
|
86 |
Â
|
87 |
Â
$version = $record->get_meta( 'new_version', true );
|
@@ -168,16 +168,18 @@ class Connector_Installer extends Connector {
|
|
168 |
Â
$version = $theme->version;
|
169 |
Â
}
|
170 |
Â
|
171 |
-
$action
|
Â
|
|
172 |
Â
$message = _x(
|
173 |
Â
'Installed %1$s: %2$s %3$s',
|
174 |
Â
'Plugin/theme installation. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
|
175 |
Â
'stream'
|
176 |
Â
);
|
177 |
Â
|
178 |
-
$logs[]
|
179 |
Â
} elseif ( 'update' === $action ) {
|
180 |
-
$action
|
Â
|
|
181 |
Â
$message = _x(
|
182 |
Â
'Updated %1$s: %2$s %3$s',
|
183 |
Â
'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
|
@@ -211,7 +213,11 @@ class Connector_Installer extends Connector {
|
|
211 |
Â
foreach ( $slugs as $slug ) {
|
212 |
Â
$theme = wp_get_theme( $slug );
|
213 |
Â
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
|
214 |
-
$theme_data = get_file_data(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
215 |
Â
$name = $theme['Name'];
|
216 |
Â
$old_version = $theme['Version'];
|
217 |
Â
$version = $theme_data['Version'];
|
@@ -251,6 +257,7 @@ class Connector_Installer extends Connector {
|
|
251 |
Â
$network_wide = $network_wide ? esc_html__( 'network wide', 'stream' ) : null;
|
252 |
Â
|
253 |
Â
$this->log(
|
Â
|
|
254 |
Â
_x(
|
255 |
Â
'"%1$s" plugin activated %2$s',
|
256 |
Â
'1: Plugin name, 2: Single site or network wide',
|
@@ -269,6 +276,7 @@ class Connector_Installer extends Connector {
|
|
269 |
Â
$network_wide = $network_wide ? esc_html__( 'network wide', 'stream' ) : null;
|
270 |
Â
|
271 |
Â
$this->log(
|
Â
|
|
272 |
Â
_x(
|
273 |
Â
'"%1$s" plugin deactivated %2$s',
|
274 |
Â
'1: Plugin name, 2: Single site or network wide',
|
@@ -284,6 +292,7 @@ class Connector_Installer extends Connector {
|
|
284 |
Â
public function callback_switch_theme( $name, $theme ) {
|
285 |
Â
unset( $theme );
|
286 |
Â
$this->log(
|
Â
|
|
287 |
Â
__( '"%s" theme activated', 'stream' ),
|
288 |
Â
compact( 'name' ),
|
289 |
Â
null,
|
@@ -296,7 +305,7 @@ class Connector_Installer extends Connector {
|
|
296 |
Â
* @todo Core needs a delete_theme hook
|
297 |
Â
*/
|
298 |
Â
public function callback_delete_site_transient_update_themes() {
|
299 |
-
$backtrace = debug_backtrace();
|
300 |
Â
$delete_theme_call = null;
|
301 |
Â
|
302 |
Â
foreach ( $backtrace as $call ) {
|
@@ -314,6 +323,7 @@ class Connector_Installer extends Connector {
|
|
314 |
Â
// @todo Can we get the name of the theme? Or has it already been eliminated
|
315 |
Â
|
316 |
Â
$this->log(
|
Â
|
|
317 |
Â
__( '"%s" theme deleted', 'stream' ),
|
318 |
Â
compact( 'name' ),
|
319 |
Â
null,
|
@@ -361,11 +371,8 @@ class Connector_Installer extends Connector {
|
|
361 |
Â
* @todo This does not work in WP-CLI
|
362 |
Â
*/
|
363 |
Â
public function callback_pre_set_site_transient_update_plugins( $value ) {
|
364 |
-
|
365 |
-
|
366 |
-
||
|
367 |
-
! ( $plugins_to_delete = get_option( 'wp_stream_plugins_to_delete' ) )
|
368 |
-
) {
|
369 |
Â
return $value;
|
370 |
Â
}
|
371 |
Â
|
@@ -374,6 +381,7 @@ class Connector_Installer extends Connector {
|
|
374 |
Â
$network_wide = $data['Network'] ? esc_html__( 'network wide', 'stream' ) : '';
|
375 |
Â
|
376 |
Â
$this->log(
|
Â
|
|
377 |
Â
__( '"%s" plugin deleted', 'stream' ),
|
378 |
Â
compact( 'name', 'plugin', 'network_wide' ),
|
379 |
Â
null,
|
@@ -394,8 +402,10 @@ class Connector_Installer extends Connector {
|
|
394 |
Â
$auto_updated = ( 'update-core.php' !== $pagenow );
|
395 |
Â
|
396 |
Â
if ( $auto_updated ) {
|
Â
|
|
397 |
Â
$message = esc_html__( 'WordPress auto-updated to %s', 'stream' );
|
398 |
Â
} else {
|
Â
|
|
399 |
Â
$message = esc_html__( 'WordPress updated to %s', 'stream' );
|
400 |
Â
}
|
401 |
Â
|
@@ -403,7 +413,7 @@ class Connector_Installer extends Connector {
|
|
403 |
Â
$message,
|
404 |
Â
compact( 'new_version', 'old_version', 'auto_updated' ),
|
405 |
Â
null,
|
406 |
-
'
|
407 |
Â
'updated'
|
408 |
Â
);
|
409 |
Â
}
|
81 |
Â
* @return array Action links
|
82 |
Â
*/
|
83 |
Â
public function action_links( $links, $record ) {
|
84 |
+
if ( 'WordPress' === $record->context && 'updated' === $record->action ) {
|
85 |
Â
global $wp_version;
|
86 |
Â
|
87 |
Â
$version = $record->get_meta( 'new_version', true );
|
168 |
Â
$version = $theme->version;
|
169 |
Â
}
|
170 |
Â
|
171 |
+
$action = 'installed';
|
172 |
+
// translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2")
|
173 |
Â
$message = _x(
|
174 |
Â
'Installed %1$s: %2$s %3$s',
|
175 |
Â
'Plugin/theme installation. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
|
176 |
Â
'stream'
|
177 |
Â
);
|
178 |
Â
|
179 |
+
$logs[] = compact( 'slug', 'name', 'version', 'message', 'action' );
|
180 |
Â
} elseif ( 'update' === $action ) {
|
181 |
+
$action = 'updated';
|
182 |
+
// translators: Placeholders refer to a plugin/theme type, a plugin/theme name, and a plugin/theme version (e.g. "plugin", "Stream", "4.2")
|
183 |
Â
$message = _x(
|
184 |
Â
'Updated %1$s: %2$s %3$s',
|
185 |
Â
'Plugin/theme update. 1: Type (plugin/theme), 2: Plugin/theme name, 3: Plugin/theme version',
|
213 |
Â
foreach ( $slugs as $slug ) {
|
214 |
Â
$theme = wp_get_theme( $slug );
|
215 |
Â
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
|
216 |
+
$theme_data = get_file_data(
|
217 |
+
$stylesheet, array(
|
218 |
+
'Version' => 'Version',
|
219 |
+
)
|
220 |
+
);
|
221 |
Â
$name = $theme['Name'];
|
222 |
Â
$old_version = $theme['Version'];
|
223 |
Â
$version = $theme_data['Version'];
|
257 |
Â
$network_wide = $network_wide ? esc_html__( 'network wide', 'stream' ) : null;
|
258 |
Â
|
259 |
Â
$this->log(
|
260 |
+
// translators: Placeholders refer to a plugin name, and whether it is on a single site or network wide (e.g. "Stream", "network wide") (a single site results in a blank string)
|
261 |
Â
_x(
|
262 |
Â
'"%1$s" plugin activated %2$s',
|
263 |
Â
'1: Plugin name, 2: Single site or network wide',
|
276 |
Â
$network_wide = $network_wide ? esc_html__( 'network wide', 'stream' ) : null;
|
277 |
Â
|
278 |
Â
$this->log(
|
279 |
+
// translators: Placeholders refer to a plugin name, and whether it is on a single site or network wide (e.g. "Stream", "network wide") (a single site results in a blank string)
|
280 |
Â
_x(
|
281 |
Â
'"%1$s" plugin deactivated %2$s',
|
282 |
Â
'1: Plugin name, 2: Single site or network wide',
|
292 |
Â
public function callback_switch_theme( $name, $theme ) {
|
293 |
Â
unset( $theme );
|
294 |
Â
$this->log(
|
295 |
+
// translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen")
|
296 |
Â
__( '"%s" theme activated', 'stream' ),
|
297 |
Â
compact( 'name' ),
|
298 |
Â
null,
|
305 |
Â
* @todo Core needs a delete_theme hook
|
306 |
Â
*/
|
307 |
Â
public function callback_delete_site_transient_update_themes() {
|
308 |
+
$backtrace = debug_backtrace(); // @codingStandardsIgnoreLine This is used as a hack to determine a theme was deleted.
|
309 |
Â
$delete_theme_call = null;
|
310 |
Â
|
311 |
Â
foreach ( $backtrace as $call ) {
|
323 |
Â
// @todo Can we get the name of the theme? Or has it already been eliminated
|
324 |
Â
|
325 |
Â
$this->log(
|
326 |
+
// translators: Placeholder refers to a theme name (e.g. "Twenty Seventeen")
|
327 |
Â
__( '"%s" theme deleted', 'stream' ),
|
328 |
Â
compact( 'name' ),
|
329 |
Â
null,
|
371 |
Â
* @todo This does not work in WP-CLI
|
372 |
Â
*/
|
373 |
Â
public function callback_pre_set_site_transient_update_plugins( $value ) {
|
374 |
+
$plugins_to_delete = get_option( 'wp_stream_plugins_to_delete' );
|
375 |
+
if ( ! wp_stream_filter_input( INPUT_POST, 'verify-delete' ) || ! $plugins_to_delete ) {
|
Â
|
|
Â
|
|
Â
|
|
376 |
Â
return $value;
|
377 |
Â
}
|
378 |
Â
|
381 |
Â
$network_wide = $data['Network'] ? esc_html__( 'network wide', 'stream' ) : '';
|
382 |
Â
|
383 |
Â
$this->log(
|
384 |
+
// translators: Placeholder refers to a plugin name (e.g. "Stream")
|
385 |
Â
__( '"%s" plugin deleted', 'stream' ),
|
386 |
Â
compact( 'name', 'plugin', 'network_wide' ),
|
387 |
Â
null,
|
402 |
Â
$auto_updated = ( 'update-core.php' !== $pagenow );
|
403 |
Â
|
404 |
Â
if ( $auto_updated ) {
|
405 |
+
// translators: Placeholder refers to a version number (e.g. "4.2")
|
406 |
Â
$message = esc_html__( 'WordPress auto-updated to %s', 'stream' );
|
407 |
Â
} else {
|
408 |
+
// translators: Placeholder refers to a version number (e.g. "4.2")
|
409 |
Â
$message = esc_html__( 'WordPress updated to %s', 'stream' );
|
410 |
Â
}
|
411 |
Â
|
413 |
Â
$message,
|
414 |
Â
compact( 'new_version', 'old_version', 'auto_updated' ),
|
415 |
Â
null,
|
416 |
+
'WordPress',
|
417 |
Â
'updated'
|
418 |
Â
);
|
419 |
Â
}
|
connectors/class-connector-jetpack.php
CHANGED
@@ -193,21 +193,21 @@ class Connector_Jetpack extends Connector {
|
|
193 |
Â
add_filter( 'wp_stream_log_data', array( $this, 'log_override' ) );
|
194 |
Â
|
195 |
Â
$this->options = array(
|
196 |
-
'jetpack_options'
|
197 |
Â
// Sharing module
|
198 |
-
'hide_gplus'
|
199 |
-
'gplus_authors'
|
200 |
-
'sharing-options'
|
201 |
Â
'label' => esc_html__( 'Sharing options', 'stream' ),
|
202 |
Â
'context' => 'sharedaddy',
|
203 |
Â
),
|
204 |
-
'sharedaddy_disable_resources'
|
205 |
-
'jetpack-twitter-cards-site-tag'
|
206 |
Â
'label' => esc_html__( 'Twitter site tag', 'stream' ),
|
207 |
Â
'context' => 'sharedaddy',
|
208 |
Â
),
|
209 |
Â
// Stats module
|
210 |
-
'stats_options'
|
211 |
Â
'label' => esc_html__( 'WordPress.com Stats', 'stream' ),
|
212 |
Â
'context' => 'stats',
|
213 |
Â
),
|
@@ -217,16 +217,16 @@ class Connector_Jetpack extends Connector {
|
|
217 |
Â
'context' => 'jetpack-comments',
|
218 |
Â
),
|
219 |
Â
// Likes
|
220 |
-
'disabled_likes'
|
221 |
Â
'label' => esc_html__( 'WP.com Site-wide Likes', 'stream' ),
|
222 |
Â
'context' => 'likes',
|
223 |
Â
),
|
224 |
Â
// Mobile
|
225 |
-
'wp_mobile_excerpt'
|
226 |
Â
'label' => esc_html__( 'Excerpts appearance', 'stream' ),
|
227 |
Â
'context' => 'minileven',
|
228 |
Â
),
|
229 |
-
'wp_mobile_app_promos'
|
230 |
Â
'label' => esc_html__( 'App promos', 'stream' ),
|
231 |
Â
'context' => 'minileven',
|
232 |
Â
),
|
@@ -234,25 +234,25 @@ class Connector_Jetpack extends Connector {
|
|
234 |
Â
|
235 |
Â
$this->options_override = array(
|
236 |
Â
// Carousel Module
|
237 |
-
'carousel_background_color'
|
238 |
Â
'label' => esc_html__( 'Background color', 'stream' ),
|
239 |
Â
'context' => 'carousel',
|
240 |
Â
),
|
241 |
-
'carousel_display_exif'
|
242 |
Â
'label' => esc_html__( 'Metadata', 'stream' ),
|
243 |
Â
'context' => 'carousel',
|
244 |
Â
),
|
245 |
Â
// Subscriptions
|
246 |
-
'stb_enabled'
|
247 |
Â
'label' => esc_html__( 'Follow blog comment form button', 'stream' ),
|
248 |
Â
'context' => 'subscriptions',
|
249 |
Â
),
|
250 |
-
'stc_enabled'
|
251 |
Â
'label' => esc_html__( 'Follow comments form button', 'stream' ),
|
252 |
Â
'context' => 'subscriptions',
|
253 |
Â
),
|
254 |
Â
// Jetpack comments
|
255 |
-
'highlander_comment_form_prompt'
|
256 |
Â
'label' => esc_html__( 'Greeting Text', 'stream' ),
|
257 |
Â
'context' => 'jetpack-comments',
|
258 |
Â
),
|
@@ -267,16 +267,16 @@ class Connector_Jetpack extends Connector {
|
|
267 |
Â
'context' => 'protect',
|
268 |
Â
),
|
269 |
Â
// SSO
|
270 |
-
'jetpack_sso_require_two_step'
|
271 |
Â
'label' => esc_html__( 'Require Two-Step Authentication', 'stream' ),
|
272 |
Â
'context' => 'sso',
|
273 |
Â
),
|
274 |
-
'jetpack_sso_match_by_email'
|
275 |
Â
'label' => esc_html__( 'Match by Email', 'stream' ),
|
276 |
Â
'context' => 'sso',
|
277 |
Â
),
|
278 |
Â
// Related posts
|
279 |
-
'jetpack_relatedposts'
|
280 |
Â
'show_headline' => array(
|
281 |
Â
'label' => esc_html__( 'Show Related Posts Headline', 'stream' ),
|
282 |
Â
'context' => 'related-posts',
|
@@ -287,12 +287,12 @@ class Connector_Jetpack extends Connector {
|
|
287 |
Â
),
|
288 |
Â
),
|
289 |
Â
// Site verification
|
290 |
-
'verification_services_codes'
|
291 |
-
'google'
|
292 |
Â
'label' => esc_html__( 'Google Webmaster Tools Token', 'stream' ),
|
293 |
Â
'context' => 'verification-tools',
|
294 |
Â
),
|
295 |
-
'bing'
|
296 |
Â
'label' => esc_html__( 'Bing Webmaster Center Token', 'stream' ),
|
297 |
Â
'context' => 'verification-tools',
|
298 |
Â
),
|
@@ -302,7 +302,7 @@ class Connector_Jetpack extends Connector {
|
|
302 |
Â
),
|
303 |
Â
),
|
304 |
Â
// Tiled galleries
|
305 |
-
'tiled_galleries'
|
306 |
Â
'label' => esc_html__( 'Tiled Galleries', 'stream' ),
|
307 |
Â
'context' => 'tiled-gallery',
|
308 |
Â
),
|
@@ -343,6 +343,7 @@ class Connector_Jetpack extends Connector {
|
|
343 |
Â
$action = $method . 'd';
|
344 |
Â
$meta = compact( 'module_slug' );
|
345 |
Â
$message = sprintf(
|
Â
|
|
346 |
Â
__( '%1$s module %2$s', 'stream' ),
|
347 |
Â
$module_name,
|
348 |
Â
( 'activated' === $action ) ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' )
|
@@ -361,6 +362,7 @@ class Connector_Jetpack extends Connector {
|
|
361 |
Â
$action = $method;
|
362 |
Â
$meta = compact( 'user_id', 'user_email', 'user_login' );
|
363 |
Â
$message = sprintf(
|
Â
|
|
364 |
Â
__( '%1$s\'s account %2$s %3$s Jetpack', 'stream' ),
|
365 |
Â
$user->display_name,
|
366 |
Â
( 'unlink' === $action ) ? esc_html__( 'unlinked', 'stream' ) : esc_html__( 'linked', 'stream' ),
|
@@ -370,7 +372,7 @@ class Connector_Jetpack extends Connector {
|
|
370 |
Â
$context = 'blogs';
|
371 |
Â
$action = str_replace( 'subsite', '', $method );
|
372 |
Â
$is_multisite = ( 0 === strpos( $method, 'subsite' ) );
|
373 |
-
$blog_id = $is_multisite ? ( isset( $_GET['site_id'] ) ? intval( wp_unslash( $_GET['site_id'] ) ) : null ) : get_current_blog_id(); // phpcs: input var okay
|
374 |
Â
|
375 |
Â
if ( empty( $blog_id ) ) {
|
376 |
Â
return;
|
@@ -378,15 +380,21 @@ class Connector_Jetpack extends Connector {
|
|
378 |
Â
|
379 |
Â
if ( ! $is_multisite ) {
|
380 |
Â
$message = sprintf(
|
Â
|
|
381 |
Â
__( 'Site %s Jetpack', 'stream' ),
|
382 |
Â
( 'register' === $action ) ? esc_html__( 'connected to', 'stream' ) : esc_html__( 'disconnected from', 'stream' )
|
383 |
Â
);
|
384 |
Â
} else {
|
385 |
-
$blog_details = get_blog_details(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
386 |
Â
$blog_name = $blog_details->blogname;
|
387 |
Â
$meta += compact( 'blog_id', 'blog_name' );
|
388 |
Â
|
389 |
Â
$message = sprintf(
|
Â
|
|
390 |
Â
__( '"%1$s" blog %2$s Jetpack', 'stream' ),
|
391 |
Â
$blog_name,
|
392 |
Â
( 'register' === $action ) ? esc_html__( 'connected to', 'stream' ) : esc_html__( 'disconnected from', 'stream' )
|
@@ -445,6 +453,7 @@ class Connector_Jetpack extends Connector {
|
|
445 |
Â
}
|
446 |
Â
|
447 |
Â
$this->log(
|
Â
|
|
448 |
Â
__( 'Monitor notifications %s', 'stream' ),
|
449 |
Â
array(
|
450 |
Â
'status' => $active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
|
@@ -482,6 +491,7 @@ class Connector_Jetpack extends Connector {
|
|
482 |
Â
$user = wp_get_current_user();
|
483 |
Â
|
484 |
Â
$this->log(
|
Â
|
|
485 |
Â
__( '%1$s %2$s Post by Email', 'stream' ),
|
486 |
Â
array(
|
487 |
Â
'user_displayname' => $user->display_name,
|
@@ -506,6 +516,7 @@ class Connector_Jetpack extends Connector {
|
|
506 |
Â
$option_title = $data['label'];
|
507 |
Â
|
508 |
Â
$this->log(
|
Â
|
|
509 |
Â
__( '"%s" setting updated', 'stream' ),
|
510 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value' ),
|
511 |
Â
null,
|
@@ -561,6 +572,7 @@ class Connector_Jetpack extends Connector {
|
|
561 |
Â
}
|
562 |
Â
|
563 |
Â
$this->log(
|
Â
|
|
564 |
Â
__( 'G+ profile display %s', 'stream' ),
|
565 |
Â
array(
|
566 |
Â
'action' => $status ? esc_html__( 'enabled', 'stream' ) : esc_html__( 'disabled', 'stream' ),
|
@@ -578,6 +590,7 @@ class Connector_Jetpack extends Connector {
|
|
578 |
Â
$connected = is_array( $new_value ) && array_key_exists( $user->ID, $new_value );
|
579 |
Â
|
580 |
Â
$this->log(
|
Â
|
|
581 |
Â
__( '%1$s\'s Google+ account %2$s', 'stream' ),
|
582 |
Â
array(
|
583 |
Â
'display_name' => $user->display_name,
|
@@ -598,6 +611,7 @@ class Connector_Jetpack extends Connector {
|
|
598 |
Â
$status = ! $new_value ? 'enabled' : 'disabled'; // disabled = 1
|
599 |
Â
|
600 |
Â
$this->log(
|
Â
|
|
601 |
Â
__( 'Sharing CSS/JS %s', 'stream' ),
|
602 |
Â
compact( 'status', 'old_value', 'new_value' ),
|
603 |
Â
null,
|
@@ -657,6 +671,7 @@ class Connector_Jetpack extends Connector {
|
|
657 |
Â
$name = str_replace( 'publicize_connections::', '', $key );
|
658 |
Â
|
659 |
Â
return array(
|
Â
|
|
660 |
Â
'message' => esc_html__( '%1$s connection %2$s', 'stream' ),
|
661 |
Â
'meta' => array(
|
662 |
Â
'connection' => $publicize_ui->publicize->get_service_label( $name ),
|
@@ -681,6 +696,7 @@ class Connector_Jetpack extends Connector {
|
|
681 |
Â
}
|
682 |
Â
|
683 |
Â
return array(
|
Â
|
|
684 |
Â
'message' => esc_html__( '"%s" setting updated', 'stream' ),
|
685 |
Â
'meta' => array(
|
686 |
Â
'option_name' => $options[ $name ],
|
193 |
Â
add_filter( 'wp_stream_log_data', array( $this, 'log_override' ) );
|
194 |
Â
|
195 |
Â
$this->options = array(
|
196 |
+
'jetpack_options' => null,
|
197 |
Â
// Sharing module
|
198 |
+
'hide_gplus' => null,
|
199 |
+
'gplus_authors' => null,
|
200 |
+
'sharing-options' => array(
|
201 |
Â
'label' => esc_html__( 'Sharing options', 'stream' ),
|
202 |
Â
'context' => 'sharedaddy',
|
203 |
Â
),
|
204 |
+
'sharedaddy_disable_resources' => null,
|
205 |
+
'jetpack-twitter-cards-site-tag' => array(
|
206 |
Â
'label' => esc_html__( 'Twitter site tag', 'stream' ),
|
207 |
Â
'context' => 'sharedaddy',
|
208 |
Â
),
|
209 |
Â
// Stats module
|
210 |
+
'stats_options' => array(
|
211 |
Â
'label' => esc_html__( 'WordPress.com Stats', 'stream' ),
|
212 |
Â
'context' => 'stats',
|
213 |
Â
),
|
217 |
Â
'context' => 'jetpack-comments',
|
218 |
Â
),
|
219 |
Â
// Likes
|
220 |
+
'disabled_likes' => array(
|
221 |
Â
'label' => esc_html__( 'WP.com Site-wide Likes', 'stream' ),
|
222 |
Â
'context' => 'likes',
|
223 |
Â
),
|
224 |
Â
// Mobile
|
225 |
+
'wp_mobile_excerpt' => array(
|
226 |
Â
'label' => esc_html__( 'Excerpts appearance', 'stream' ),
|
227 |
Â
'context' => 'minileven',
|
228 |
Â
),
|
229 |
+
'wp_mobile_app_promos' => array(
|
230 |
Â
'label' => esc_html__( 'App promos', 'stream' ),
|
231 |
Â
'context' => 'minileven',
|
232 |
Â
),
|
234 |
Â
|
235 |
Â
$this->options_override = array(
|
236 |
Â
// Carousel Module
|
237 |
+
'carousel_background_color' => array(
|
238 |
Â
'label' => esc_html__( 'Background color', 'stream' ),
|
239 |
Â
'context' => 'carousel',
|
240 |
Â
),
|
241 |
+
'carousel_display_exif' => array(
|
242 |
Â
'label' => esc_html__( 'Metadata', 'stream' ),
|
243 |
Â
'context' => 'carousel',
|
244 |
Â
),
|
245 |
Â
// Subscriptions
|
246 |
+
'stb_enabled' => array(
|
247 |
Â
'label' => esc_html__( 'Follow blog comment form button', 'stream' ),
|
248 |
Â
'context' => 'subscriptions',
|
249 |
Â
),
|
250 |
+
'stc_enabled' => array(
|
251 |
Â
'label' => esc_html__( 'Follow comments form button', 'stream' ),
|
252 |
Â
'context' => 'subscriptions',
|
253 |
Â
),
|
254 |
Â
// Jetpack comments
|
255 |
+
'highlander_comment_form_prompt' => array(
|
256 |
Â
'label' => esc_html__( 'Greeting Text', 'stream' ),
|
257 |
Â
'context' => 'jetpack-comments',
|
258 |
Â
),
|
267 |
Â
'context' => 'protect',
|
268 |
Â
),
|
269 |
Â
// SSO
|
270 |
+
'jetpack_sso_require_two_step' => array(
|
271 |
Â
'label' => esc_html__( 'Require Two-Step Authentication', 'stream' ),
|
272 |
Â
'context' => 'sso',
|
273 |
Â
),
|
274 |
+
'jetpack_sso_match_by_email' => array(
|
275 |
Â
'label' => esc_html__( 'Match by Email', 'stream' ),
|
276 |
Â
'context' => 'sso',
|
277 |
Â
),
|
278 |
Â
// Related posts
|
279 |
+
'jetpack_relatedposts' => array(
|
280 |
Â
'show_headline' => array(
|
281 |
Â
'label' => esc_html__( 'Show Related Posts Headline', 'stream' ),
|
282 |
Â
'context' => 'related-posts',
|
287 |
Â
),
|
288 |
Â
),
|
289 |
Â
// Site verification
|
290 |
+
'verification_services_codes' => array(
|
291 |
+
'google' => array(
|
292 |
Â
'label' => esc_html__( 'Google Webmaster Tools Token', 'stream' ),
|
293 |
Â
'context' => 'verification-tools',
|
294 |
Â
),
|
295 |
+
'bing' => array(
|
296 |
Â
'label' => esc_html__( 'Bing Webmaster Center Token', 'stream' ),
|
297 |
Â
'context' => 'verification-tools',
|
298 |
Â
),
|
302 |
Â
),
|
303 |
Â
),
|
304 |
Â
// Tiled galleries
|
305 |
+
'tiled_galleries' => array(
|
306 |
Â
'label' => esc_html__( 'Tiled Galleries', 'stream' ),
|
307 |
Â
'context' => 'tiled-gallery',
|
308 |
Â
),
|
343 |
Â
$action = $method . 'd';
|
344 |
Â
$meta = compact( 'module_slug' );
|
345 |
Â
$message = sprintf(
|
346 |
+
// translators: Placeholders refer to a module name, and a status (e.g. "Photon", "activated")
|
347 |
Â
__( '%1$s module %2$s', 'stream' ),
|
348 |
Â
$module_name,
|
349 |
Â
( 'activated' === $action ) ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' )
|
362 |
Â
$action = $method;
|
363 |
Â
$meta = compact( 'user_id', 'user_email', 'user_login' );
|
364 |
Â
$message = sprintf(
|
365 |
+
// translators: Placeholders refer to a user display name, a status, and the connection either "from" or "to" (e.g. "Jane Doe", "unlinked", "from")
|
366 |
Â
__( '%1$s\'s account %2$s %3$s Jetpack', 'stream' ),
|
367 |
Â
$user->display_name,
|
368 |
Â
( 'unlink' === $action ) ? esc_html__( 'unlinked', 'stream' ) : esc_html__( 'linked', 'stream' ),
|
372 |
Â
$context = 'blogs';
|
373 |
Â
$action = str_replace( 'subsite', '', $method );
|
374 |
Â
$is_multisite = ( 0 === strpos( $method, 'subsite' ) );
|
375 |
+
$blog_id = $is_multisite ? ( isset( $_GET['site_id'] ) ? intval( wp_unslash( $_GET['site_id'] ) ) : null ) : get_current_blog_id(); // phpcs: input var okay, CSRF okay
|
376 |
Â
|
377 |
Â
if ( empty( $blog_id ) ) {
|
378 |
Â
return;
|
380 |
Â
|
381 |
Â
if ( ! $is_multisite ) {
|
382 |
Â
$message = sprintf(
|
383 |
+
// translators: Placeholder refers to a connection status. Either "connected to" or "disconnected from".
|
384 |
Â
__( 'Site %s Jetpack', 'stream' ),
|
385 |
Â
( 'register' === $action ) ? esc_html__( 'connected to', 'stream' ) : esc_html__( 'disconnected from', 'stream' )
|
386 |
Â
);
|
387 |
Â
} else {
|
388 |
+
$blog_details = get_blog_details(
|
389 |
+
array(
|
390 |
+
'blog_id' => $blog_id,
|
391 |
+
)
|
392 |
+
);
|
393 |
Â
$blog_name = $blog_details->blogname;
|
394 |
Â
$meta += compact( 'blog_id', 'blog_name' );
|
395 |
Â
|
396 |
Â
$message = sprintf(
|
397 |
+
// translators: Placeholder refers to a connection status. Either "connected to" or "disconnected from".
|
398 |
Â
__( '"%1$s" blog %2$s Jetpack', 'stream' ),
|
399 |
Â
$blog_name,
|
400 |
Â
( 'register' === $action ) ? esc_html__( 'connected to', 'stream' ) : esc_html__( 'disconnected from', 'stream' )
|
453 |
Â
}
|
454 |
Â
|
455 |
Â
$this->log(
|
456 |
+
// translators: Placeholder refers to a status (e.g. "activated")
|
457 |
Â
__( 'Monitor notifications %s', 'stream' ),
|
458 |
Â
array(
|
459 |
Â
'status' => $active ? esc_html__( 'activated', 'stream' ) : esc_html__( 'deactivated', 'stream' ),
|
491 |
Â
$user = wp_get_current_user();
|
492 |
Â
|
493 |
Â
$this->log(
|
494 |
+
// translators: Placeholders refer to a user display name, and a status (e.g. "Jane Doe", "enabled")
|
495 |
Â
__( '%1$s %2$s Post by Email', 'stream' ),
|
496 |
Â
array(
|
497 |
Â
'user_displayname' => $user->display_name,
|
516 |
Â
$option_title = $data['label'];
|
517 |
Â
|
518 |
Â
$this->log(
|
519 |
+
// translators: Placeholder refers to a setting name (e.g. "Language")
|
520 |
Â
__( '"%s" setting updated', 'stream' ),
|
521 |
Â
compact( 'option_title', 'option', 'old_value', 'new_value' ),
|
522 |
Â
null,
|
572 |
Â
}
|
573 |
Â
|
574 |
Â
$this->log(
|
575 |
+
// translators: Placeholder refers to a status (e.g. "enabled")
|
576 |
Â
__( 'G+ profile display %s', 'stream' ),
|
577 |
Â
array(
|
578 |
Â
'action' => $status ? esc_html__( 'enabled', 'stream' ) : esc_html__( 'disabled', 'stream' ),
|
590 |
Â
$connected = is_array( $new_value ) && array_key_exists( $user->ID, $new_value );
|
591 |
Â
|
592 |
Â
$this->log(
|
593 |
+
// translators: Placeholders refer to a user display name, and a status (e.g. "Jane Doe", "connected")
|
594 |
Â
__( '%1$s\'s Google+ account %2$s', 'stream' ),
|
595 |
Â
array(
|
596 |
Â
'display_name' => $user->display_name,
|
611 |
Â
$status = ! $new_value ? 'enabled' : 'disabled'; // disabled = 1
|
612 |
Â
|
613 |
Â
$this->log(
|
614 |
+
// translators: Placeholder refers to a status (e.g. "enabled")
|
615 |
Â
__( 'Sharing CSS/JS %s', 'stream' ),
|
616 |
Â
compact( 'status', 'old_value', 'new_value' ),
|
617 |
Â
null,
|
671 |
Â
$name = str_replace( 'publicize_connections::', '', $key );
|
672 |
Â
|
673 |
Â
return array(
|
674 |
+
// translators: Placeholders refer to a service, and a status (e.g. "Facebook", "added")
|
675 |
Â
'message' => esc_html__( '%1$s connection %2$s', 'stream' ),
|
676 |
Â
'meta' => array(
|
677 |
Â
'connection' => $publicize_ui->publicize->get_service_label( $name ),
|
696 |
Â
}
|
697 |
Â
|
698 |
Â
return array(
|
699 |
+
// translators: Placeholder refers to a setting name (e.g. "Language")
|
700 |
Â
'message' => esc_html__( '"%s" setting updated', 'stream' ),
|
701 |
Â
'meta' => array(
|
702 |
Â
'option_name' => $options[ $name ],
|
connectors/class-connector-media.php
CHANGED
@@ -104,11 +104,13 @@ class Connector_Media extends Connector {
|
|
104 |
Â
*/
|
105 |
Â
public function action_links( $links, $record ) {
|
106 |
Â
if ( $record->object_id ) {
|
107 |
-
|
108 |
-
|
Â
|
|
109 |
Â
}
|
110 |
-
|
111 |
-
|
Â
|
|
112 |
Â
}
|
113 |
Â
}
|
114 |
Â
|
@@ -125,12 +127,14 @@ class Connector_Media extends Connector {
|
|
125 |
Â
public function callback_add_attachment( $post_id ) {
|
126 |
Â
$post = get_post( $post_id );
|
127 |
Â
if ( $post->post_parent ) {
|
Â
|
|
128 |
Â
$message = _x(
|
129 |
Â
'Attached "%1$s" to "%2$s"',
|
130 |
Â
'1: Attachment title, 2: Parent post title',
|
131 |
Â
'stream'
|
132 |
Â
);
|
133 |
Â
} else {
|
Â
|
|
134 |
Â
$message = esc_html__( 'Added "%s" to Media library', 'stream' );
|
135 |
Â
}
|
136 |
Â
|
@@ -159,10 +163,12 @@ class Connector_Media extends Connector {
|
|
159 |
Â
*/
|
160 |
Â
public function callback_edit_attachment( $post_id ) {
|
161 |
Â
$post = get_post( $post_id );
|
162 |
-
$message = esc_html__( 'Updated "%s"', 'stream' );
|
163 |
Â
$name = $post->post_title;
|
164 |
Â
$attachment_type = $this->get_attachment_type( $post->guid );
|
165 |
Â
|
Â
|
|
Â
|
|
Â
|
|
166 |
Â
$this->log(
|
167 |
Â
$message,
|
168 |
Â
compact( 'name' ),
|
@@ -183,11 +189,13 @@ class Connector_Media extends Connector {
|
|
183 |
Â
$post = get_post( $post_id );
|
184 |
Â
$parent = $post->post_parent ? get_post( $post->post_parent ) : null;
|
185 |
Â
$parent_id = $parent ? $parent->ID : null;
|
186 |
-
$message = esc_html__( 'Deleted "%s"', 'stream' );
|
187 |
Â
$name = $post->post_title;
|
188 |
Â
$url = $post->guid;
|
189 |
Â
$attachment_type = $this->get_attachment_type( $post->guid );
|
190 |
Â
|
Â
|
|
Â
|
|
Â
|
|
191 |
Â
$this->log(
|
192 |
Â
$message,
|
193 |
Â
compact( 'name', 'parent_id', 'url' ),
|
@@ -219,6 +227,7 @@ class Connector_Media extends Connector {
|
|
219 |
Â
$attachment_type = $this->get_attachment_type( $post->guid );
|
220 |
Â
|
221 |
Â
$this->log(
|
Â
|
|
222 |
Â
__( 'Edited image "%s"', 'stream' ),
|
223 |
Â
compact( 'name', 'filename', 'post_id' ),
|
224 |
Â
$post_id,
|
104 |
Â
*/
|
105 |
Â
public function action_links( $links, $record ) {
|
106 |
Â
if ( $record->object_id ) {
|
107 |
+
$edit_post_link = get_edit_post_link( $record->object_id );
|
108 |
+
if ( $edit_post_link ) {
|
109 |
+
$links[ esc_html__( 'Edit Media', 'stream' ) ] = $edit_post_link;
|
110 |
Â
}
|
111 |
+
$permalink = get_permalink( $record->object_id );
|
112 |
+
if ( $permalink ) {
|
113 |
+
$links[ esc_html__( 'View', 'stream' ) ] = $permalink;
|
114 |
Â
}
|
115 |
Â
}
|
116 |
Â
|
127 |
Â
public function callback_add_attachment( $post_id ) {
|
128 |
Â
$post = get_post( $post_id );
|
129 |
Â
if ( $post->post_parent ) {
|
130 |
+
// translators: Placeholders refer to an attachment title, and a post title (e.g. "PIC001", "Hello World")
|
131 |
Â
$message = _x(
|
132 |
Â
'Attached "%1$s" to "%2$s"',
|
133 |
Â
'1: Attachment title, 2: Parent post title',
|
134 |
Â
'stream'
|
135 |
Â
);
|
136 |
Â
} else {
|
137 |
+
// translators: Placeholder refers to an attachment title (e.g. "PIC001")
|
138 |
Â
$message = esc_html__( 'Added "%s" to Media library', 'stream' );
|
139 |
Â
}
|
140 |
Â
|
163 |
Â
*/
|
164 |
Â
public function callback_edit_attachment( $post_id ) {
|
165 |
Â
$post = get_post( $post_id );
|
Â
|
|
166 |
Â
$name = $post->post_title;
|
167 |
Â
$attachment_type = $this->get_attachment_type( $post->guid );
|
168 |
Â
|
169 |
+
// translators: Placeholder refers to an attachment title (e.g. "PIC001")
|
170 |
+
$message = esc_html__( 'Updated "%s"', 'stream' );
|
171 |
+
|
172 |
Â
$this->log(
|
173 |
Â
$message,
|
174 |
Â
compact( 'name' ),
|
189 |
Â
$post = get_post( $post_id );
|
190 |
Â
$parent = $post->post_parent ? get_post( $post->post_parent ) : null;
|
191 |
Â
$parent_id = $parent ? $parent->ID : null;
|
Â
|
|
192 |
Â
$name = $post->post_title;
|
193 |
Â
$url = $post->guid;
|
194 |
Â
$attachment_type = $this->get_attachment_type( $post->guid );
|
195 |
Â
|
196 |
+
// translators: Placeholder refers to an attachment title (e.g. "PIC001")
|
197 |
+
$message = esc_html__( 'Deleted "%s"', 'stream' );
|
198 |
+
|
199 |
Â
$this->log(
|
200 |
Â
$message,
|
201 |
Â
compact( 'name', 'parent_id', 'url' ),
|
227 |
Â
$attachment_type = $this->get_attachment_type( $post->guid );
|
228 |
Â
|
229 |
Â
$this->log(
|
230 |
+
// translators: Placeholder refers to an attachment title (e.g. "PIC001")
|
231 |
Â
__( 'Edited image "%s"', 'stream' ),
|
232 |
Â
compact( 'name', 'filename', 'post_id' ),
|
233 |
Â
$post_id,
|
connectors/class-connector-menus.php
CHANGED
@@ -58,7 +58,11 @@ class Connector_Menus extends Connector {
|
|
58 |
Â
*/
|
59 |
Â
public function get_context_labels() {
|
60 |
Â
$labels = array();
|
61 |
-
$menus = get_terms(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
62 |
Â
|
63 |
Â
foreach ( $menus as $menu ) {
|
64 |
Â
$slug = sanitize_title( $menu->name );
|
@@ -109,6 +113,7 @@ class Connector_Menus extends Connector {
|
|
109 |
Â
$name = $menu_data['menu-name'];
|
110 |
Â
|
111 |
Â
$this->log(
|
Â
|
|
112 |
Â
__( 'Created new menu "%s"', 'stream' ),
|
113 |
Â
compact( 'name', 'menu_id' ),
|
114 |
Â
$menu_id,
|
@@ -133,6 +138,7 @@ class Connector_Menus extends Connector {
|
|
133 |
Â
$name = $menu_data['menu-name'];
|
134 |
Â
|
135 |
Â
$this->log(
|
Â
|
|
136 |
Â
_x( 'Updated menu "%s"', 'Menu name', 'stream' ),
|
137 |
Â
compact( 'name', 'menu_id', 'menu_data' ),
|
138 |
Â
$menu_id,
|
@@ -157,6 +163,7 @@ class Connector_Menus extends Connector {
|
|
157 |
Â
$menu_id = $term->term_id;
|
158 |
Â
|
159 |
Â
$this->log(
|
Â
|
|
160 |
Â
_x( 'Deleted "%s"', 'Menu name', 'stream' ),
|
161 |
Â
compact( 'name', 'menu_id' ),
|
162 |
Â
$menu_id,
|
@@ -204,6 +211,7 @@ class Connector_Menus extends Connector {
|
|
204 |
Â
if ( empty( $new[ $key ][ $location_id ] ) ) {
|
205 |
Â
$action = 'unassigned';
|
206 |
Â
$menu_id = isset( $old[ $key ][ $location_id ] ) ? $old[ $key ][ $location_id ] : 0;
|
Â
|
|
207 |
Â
$message = _x(
|
208 |
Â
'"%1$s" has been unassigned from "%2$s"',
|
209 |
Â
'1: Menu name, 2: Theme location',
|
@@ -212,6 +220,7 @@ class Connector_Menus extends Connector {
|
|
212 |
Â
} else {
|
213 |
Â
$action = 'assigned';
|
214 |
Â
$menu_id = isset( $new[ $key ][ $location_id ] ) ? $new[ $key ][ $location_id ] : 0;
|
Â
|
|
215 |
Â
$message = _x(
|
216 |
Â
'"%1$s" has been assigned to "%2$s"',
|
217 |
Â
'1: Menu name, 2: Theme location',
|
58 |
Â
*/
|
59 |
Â
public function get_context_labels() {
|
60 |
Â
$labels = array();
|
61 |
+
$menus = get_terms(
|
62 |
+
'nav_menu', array(
|
63 |
+
'hide_empty' => false,
|
64 |
+
)
|
65 |
+
);
|
66 |
Â
|
67 |
Â
foreach ( $menus as $menu ) {
|
68 |
Â
$slug = sanitize_title( $menu->name );
|
113 |
Â
$name = $menu_data['menu-name'];
|
114 |
Â
|
115 |
Â
$this->log(
|
116 |
+
// translators: Placeholder refers to a menu name (e.g. "Primary Menu")
|
117 |
Â
__( 'Created new menu "%s"', 'stream' ),
|
118 |
Â
compact( 'name', 'menu_id' ),
|
119 |
Â
$menu_id,
|
138 |
Â
$name = $menu_data['menu-name'];
|
139 |
Â
|
140 |
Â
$this->log(
|
141 |
+
// translators: Placeholder refers to a menu name (e.g. "Primary Menu")
|
142 |
Â
_x( 'Updated menu "%s"', 'Menu name', 'stream' ),
|
143 |
Â
compact( 'name', 'menu_id', 'menu_data' ),
|
144 |
Â
$menu_id,
|
163 |
Â
$menu_id = $term->term_id;
|
164 |
Â
|
165 |
Â
$this->log(
|
166 |
+
// translators: Placeholder refers to a menu name (e.g. "Primary Menu")
|
167 |
Â
_x( 'Deleted "%s"', 'Menu name', 'stream' ),
|
168 |
Â
compact( 'name', 'menu_id' ),
|
169 |
Â
$menu_id,
|
211 |
Â
if ( empty( $new[ $key ][ $location_id ] ) ) {
|
212 |
Â
$action = 'unassigned';
|
213 |
Â
$menu_id = isset( $old[ $key ][ $location_id ] ) ? $old[ $key ][ $location_id ] : 0;
|
214 |
+
// translators: Placeholders refer to a menu name, and a theme location (e.g. "Primary Menu", "primary_nav")
|
215 |
Â
$message = _x(
|
216 |
Â
'"%1$s" has been unassigned from "%2$s"',
|
217 |
Â
'1: Menu name, 2: Theme location',
|
220 |
Â
} else {
|
221 |
Â
$action = 'assigned';
|
222 |
Â
$menu_id = isset( $new[ $key ][ $location_id ] ) ? $new[ $key ][ $location_id ] : 0;
|
223 |
+
// translators: Placeholders refer to a menu name, and a theme location (e.g. "Primary Menu", "primary_nav")
|
224 |
Â
$message = _x(
|
225 |
Â
'"%1$s" has been assigned to "%2$s"',
|
226 |
Â
'1: Menu name, 2: Theme location',
|
connectors/class-connector-posts.php
CHANGED
@@ -61,7 +61,7 @@ class Connector_Posts extends Connector {
|
|
61 |
Â
$post_types = wp_filter_object_list( $wp_post_types, array(), null, 'label' );
|
62 |
Â
$post_types = array_diff_key( $post_types, array_flip( $this->get_excluded_post_types() ) );
|
63 |
Â
|
64 |
-
add_action( 'registered_post_type', array( $this, '
|
65 |
Â
|
66 |
Â
return $post_types;
|
67 |
Â
}
|
@@ -105,12 +105,16 @@ class Connector_Posts extends Connector {
|
|
105 |
Â
sprintf( 'delete-post_%d', $post->ID )
|
106 |
Â
);
|
107 |
Â
|
Â
|
|
108 |
Â
$links[ sprintf( esc_html_x( 'Restore %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $untrash;
|
Â
|
|
109 |
Â
$links[ sprintf( esc_html_x( 'Delete %s Permenantly', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
|
110 |
Â
} else {
|
Â
|
|
111 |
Â
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = get_edit_post_link( $post->ID );
|
112 |
Â
|
113 |
-
|
Â
|
|
114 |
Â
$links[ esc_html__( 'View', 'stream' ) ] = $view_link;
|
115 |
Â
}
|
116 |
Â
|
@@ -127,14 +131,14 @@ class Connector_Posts extends Connector {
|
|
127 |
Â
}
|
128 |
Â
|
129 |
Â
/**
|
130 |
-
* Catch
|
131 |
Â
*
|
132 |
Â
* @action registered_post_type
|
133 |
Â
*
|
134 |
Â
* @param string $post_type Post type slug
|
135 |
Â
* @param array $args Arguments used to register the post type
|
136 |
Â
*/
|
137 |
-
public function
|
138 |
Â
unset( $args );
|
139 |
Â
|
140 |
Â
$post_type_obj = get_post_type_object( $post_type );
|
@@ -162,12 +166,14 @@ class Connector_Posts extends Connector {
|
|
162 |
Â
} elseif ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
163 |
Â
return;
|
164 |
Â
} elseif ( 'draft' === $new && 'publish' === $old ) {
|
Â
|
|
165 |
Â
$summary = _x(
|
166 |
Â
'"%1$s" %2$s unpublished',
|
167 |
Â
'1: Post title, 2: Post type singular name',
|
168 |
Â
'stream'
|
169 |
Â
);
|
170 |
Â
} elseif ( 'trash' === $old && 'trash' !== $new ) {
|
Â
|
|
171 |
Â
$summary = _x(
|
172 |
Â
'"%1$s" %2$s restored from trash',
|
173 |
Â
'1: Post title, 2: Post type singular name',
|
@@ -175,48 +181,56 @@ class Connector_Posts extends Connector {
|
|
175 |
Â
);
|
176 |
Â
$action = 'untrashed';
|
177 |
Â
} elseif ( 'draft' === $new && 'draft' === $old ) {
|
Â
|
|
178 |
Â
$summary = _x(
|
179 |
Â
'"%1$s" %2$s draft saved',
|
180 |
Â
'1: Post title, 2: Post type singular name',
|
181 |
Â
'stream'
|
182 |
Â
);
|
183 |
Â
} elseif ( 'publish' === $new && 'draft' === $old ) {
|
Â
|
|
184 |
Â
$summary = _x(
|
185 |
Â
'"%1$s" %2$s published',
|
186 |
Â
'1: Post title, 2: Post type singular name',
|
187 |
Â
'stream'
|
188 |
Â
);
|
189 |
Â
} elseif ( 'draft' === $new ) {
|
Â
|
|
190 |
Â
$summary = _x(
|
191 |
Â
'"%1$s" %2$s drafted',
|
192 |
Â
'1: Post title, 2: Post type singular name',
|
193 |
Â
'stream'
|
194 |
Â
);
|
195 |
Â
} elseif ( 'pending' === $new ) {
|
Â
|
|
196 |
Â
$summary = _x(
|
197 |
Â
'"%1$s" %2$s pending review',
|
198 |
Â
'1: Post title, 2: Post type singular name',
|
199 |
Â
'stream'
|
200 |
Â
);
|
201 |
Â
} elseif ( 'future' === $new ) {
|
Â
|
|
202 |
Â
$summary = _x(
|
203 |
Â
'"%1$s" %2$s scheduled for %3$s',
|
204 |
Â
'1: Post title, 2: Post type singular name, 3: Scheduled post date',
|
205 |
Â
'stream'
|
206 |
Â
);
|
207 |
Â
} elseif ( 'future' === $old && 'publish' === $new ) {
|
Â
|
|
208 |
Â
$summary = _x(
|
209 |
Â
'"%1$s" scheduled %2$s published',
|
210 |
Â
'1: Post title, 2: Post type singular name',
|
211 |
Â
'stream'
|
212 |
Â
);
|
213 |
Â
} elseif ( 'private' === $new ) {
|
Â
|
|
214 |
Â
$summary = _x(
|
215 |
Â
'"%1$s" %2$s privately published',
|
216 |
Â
'1: Post title, 2: Post type singular name',
|
217 |
Â
'stream'
|
218 |
Â
);
|
219 |
Â
} elseif ( 'trash' === $new ) {
|
Â
|
|
220 |
Â
$summary = _x(
|
221 |
Â
'"%1$s" %2$s trashed',
|
222 |
Â
'1: Post title, 2: Post type singular name',
|
@@ -224,6 +238,7 @@ class Connector_Posts extends Connector {
|
|
224 |
Â
);
|
225 |
Â
$action = 'trashed';
|
226 |
Â
} else {
|
Â
|
|
227 |
Â
$summary = _x(
|
228 |
Â
'"%1$s" %2$s updated',
|
229 |
Â
'1: Post title, 2: Post type singular name',
|
@@ -289,7 +304,7 @@ class Connector_Posts extends Connector {
|
|
289 |
Â
$post = get_post( $post_id );
|
290 |
Â
|
291 |
Â
// We check if post is an instance of WP_Post as it doesn't always resolve in unit testing
|
292 |
-
if ( ! ( $post instanceof \WP_Post ) || in_array( $post->post_type, $this->get_excluded_post_types(), true )
|
293 |
Â
return;
|
294 |
Â
}
|
295 |
Â
|
@@ -301,6 +316,7 @@ class Connector_Posts extends Connector {
|
|
301 |
Â
$post_type_name = strtolower( $this->get_post_type_name( $post->post_type ) );
|
302 |
Â
|
303 |
Â
$this->log(
|
Â
|
|
304 |
Â
_x(
|
305 |
Â
'"%1$s" %2$s deleted from trash',
|
306 |
Â
'1: Post title, 2: Post type singular name',
|
61 |
Â
$post_types = wp_filter_object_list( $wp_post_types, array(), null, 'label' );
|
62 |
Â
$post_types = array_diff_key( $post_types, array_flip( $this->get_excluded_post_types() ) );
|
63 |
Â
|
64 |
+
add_action( 'registered_post_type', array( $this, 'registered_post_type' ), 10, 2 );
|
65 |
Â
|
66 |
Â
return $post_types;
|
67 |
Â
}
|
105 |
Â
sprintf( 'delete-post_%d', $post->ID )
|
106 |
Â
);
|
107 |
Â
|
108 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
109 |
Â
$links[ sprintf( esc_html_x( 'Restore %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $untrash;
|
110 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
111 |
Â
$links[ sprintf( esc_html_x( 'Delete %s Permenantly', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
|
112 |
Â
} else {
|
113 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
114 |
Â
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = get_edit_post_link( $post->ID );
|
115 |
Â
|
116 |
+
$view_link = get_permalink( $post->ID );
|
117 |
+
if ( $view_link ) {
|
118 |
Â
$links[ esc_html__( 'View', 'stream' ) ] = $view_link;
|
119 |
Â
}
|
120 |
Â
|
131 |
Â
}
|
132 |
Â
|
133 |
Â
/**
|
134 |
+
* Catch registration of post_types after initial loading, to cache its labels
|
135 |
Â
*
|
136 |
Â
* @action registered_post_type
|
137 |
Â
*
|
138 |
Â
* @param string $post_type Post type slug
|
139 |
Â
* @param array $args Arguments used to register the post type
|
140 |
Â
*/
|
141 |
+
public function registered_post_type( $post_type, $args ) {
|
142 |
Â
unset( $args );
|
143 |
Â
|
144 |
Â
$post_type_obj = get_post_type_object( $post_type );
|
166 |
Â
} elseif ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
167 |
Â
return;
|
168 |
Â
} elseif ( 'draft' === $new && 'publish' === $old ) {
|
169 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
170 |
Â
$summary = _x(
|
171 |
Â
'"%1$s" %2$s unpublished',
|
172 |
Â
'1: Post title, 2: Post type singular name',
|
173 |
Â
'stream'
|
174 |
Â
);
|
175 |
Â
} elseif ( 'trash' === $old && 'trash' !== $new ) {
|
176 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
177 |
Â
$summary = _x(
|
178 |
Â
'"%1$s" %2$s restored from trash',
|
179 |
Â
'1: Post title, 2: Post type singular name',
|
181 |
Â
);
|
182 |
Â
$action = 'untrashed';
|
183 |
Â
} elseif ( 'draft' === $new && 'draft' === $old ) {
|
184 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
185 |
Â
$summary = _x(
|
186 |
Â
'"%1$s" %2$s draft saved',
|
187 |
Â
'1: Post title, 2: Post type singular name',
|
188 |
Â
'stream'
|
189 |
Â
);
|
190 |
Â
} elseif ( 'publish' === $new && 'draft' === $old ) {
|
191 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
192 |
Â
$summary = _x(
|
193 |
Â
'"%1$s" %2$s published',
|
194 |
Â
'1: Post title, 2: Post type singular name',
|
195 |
Â
'stream'
|
196 |
Â
);
|
197 |
Â
} elseif ( 'draft' === $new ) {
|
198 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
199 |
Â
$summary = _x(
|
200 |
Â
'"%1$s" %2$s drafted',
|
201 |
Â
'1: Post title, 2: Post type singular name',
|
202 |
Â
'stream'
|
203 |
Â
);
|
204 |
Â
} elseif ( 'pending' === $new ) {
|
205 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
206 |
Â
$summary = _x(
|
207 |
Â
'"%1$s" %2$s pending review',
|
208 |
Â
'1: Post title, 2: Post type singular name',
|
209 |
Â
'stream'
|
210 |
Â
);
|
211 |
Â
} elseif ( 'future' === $new ) {
|
212 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
213 |
Â
$summary = _x(
|
214 |
Â
'"%1$s" %2$s scheduled for %3$s',
|
215 |
Â
'1: Post title, 2: Post type singular name, 3: Scheduled post date',
|
216 |
Â
'stream'
|
217 |
Â
);
|
218 |
Â
} elseif ( 'future' === $old && 'publish' === $new ) {
|
219 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
220 |
Â
$summary = _x(
|
221 |
Â
'"%1$s" scheduled %2$s published',
|
222 |
Â
'1: Post title, 2: Post type singular name',
|
223 |
Â
'stream'
|
224 |
Â
);
|
225 |
Â
} elseif ( 'private' === $new ) {
|
226 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
227 |
Â
$summary = _x(
|
228 |
Â
'"%1$s" %2$s privately published',
|
229 |
Â
'1: Post title, 2: Post type singular name',
|
230 |
Â
'stream'
|
231 |
Â
);
|
232 |
Â
} elseif ( 'trash' === $new ) {
|
233 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
234 |
Â
$summary = _x(
|
235 |
Â
'"%1$s" %2$s trashed',
|
236 |
Â
'1: Post title, 2: Post type singular name',
|
238 |
Â
);
|
239 |
Â
$action = 'trashed';
|
240 |
Â
} else {
|
241 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
242 |
Â
$summary = _x(
|
243 |
Â
'"%1$s" %2$s updated',
|
244 |
Â
'1: Post title, 2: Post type singular name',
|
304 |
Â
$post = get_post( $post_id );
|
305 |
Â
|
306 |
Â
// We check if post is an instance of WP_Post as it doesn't always resolve in unit testing
|
307 |
+
if ( ! ( $post instanceof \WP_Post ) || in_array( $post->post_type, $this->get_excluded_post_types(), true ) ) {
|
308 |
Â
return;
|
309 |
Â
}
|
310 |
Â
|
316 |
Â
$post_type_name = strtolower( $this->get_post_type_name( $post->post_type ) );
|
317 |
Â
|
318 |
Â
$this->log(
|
319 |
+
// translators: Placeholders refer to a post title, and a post type singular name (e.g. "Hello World", "Post")
|
320 |
Â
_x(
|
321 |
Â
'"%1$s" %2$s deleted from trash',
|
322 |
Â
'1: Post title, 2: Post type singular name',
|
connectors/class-connector-settings.php
CHANGED
@@ -287,7 +287,7 @@ class Connector_Settings extends Connector {
|
|
287 |
Â
'background_attachment',
|
288 |
Â
'background_color',
|
289 |
Â
),
|
290 |
-
'custom_header'
|
291 |
Â
'header_image',
|
292 |
Â
'header_textcolor',
|
293 |
Â
),
|
@@ -458,10 +458,10 @@ class Connector_Settings extends Connector {
|
|
458 |
Â
*/
|
459 |
Â
public function action_links( $links, $record ) {
|
460 |
Â
$context_labels = $this->get_context_labels();
|
461 |
-
$plugin
|
462 |
Â
|
463 |
Â
$rules = array(
|
464 |
-
'stream'
|
465 |
Â
'menu_slug' => 'wp_stream',
|
466 |
Â
'submenu_slug' => $plugin->admin->settings_page_slug,
|
467 |
Â
'url' => function( $rule, $record ) use ( $plugin ) {
|
@@ -504,7 +504,7 @@ class Connector_Settings extends Connector {
|
|
504 |
Â
return in_array( $record->context, array( 'custom_header', 'custom_background' ), true );
|
505 |
Â
},
|
506 |
Â
),
|
507 |
-
'general'
|
508 |
Â
'menu_slug' => 'options-general.php',
|
509 |
Â
'submenu_slug' => function( $record ) {
|
510 |
Â
return sprintf( 'options-%s.php', $record->context );
|
@@ -516,7 +516,7 @@ class Connector_Settings extends Connector {
|
|
516 |
Â
return ! empty( $submenu['options-general.php'] );
|
517 |
Â
},
|
518 |
Â
),
|
519 |
-
'network'
|
520 |
Â
'menu_slug' => 'settings.php',
|
521 |
Â
'submenu_slug' => function( $record ) {
|
522 |
Â
return 'settings.php';
|
@@ -553,19 +553,23 @@ class Connector_Settings extends Connector {
|
|
553 |
Â
if ( isset( $submenu[ $menu_slug ] ) ) {
|
554 |
Â
$found_submenus = wp_list_filter(
|
555 |
Â
$submenu[ $menu_slug ],
|
556 |
-
array(
|
Â
|
|
Â
|
|
557 |
Â
);
|
558 |
Â
}
|
559 |
Â
|
560 |
Â
if ( ! empty( $found_submenus ) ) {
|
561 |
-
$target_submenu
|
562 |
Â
list( $menu_title, $capability ) = $target_submenu;
|
563 |
Â
|
564 |
Â
if ( current_user_can( $capability ) ) {
|
565 |
Â
$url = apply_filters( 'wp_stream_action_link_url', $url, $record );
|
566 |
-
$text = sprintf( esc_html__( 'Edit %s Settings', 'stream' ), $context_labels[ $record->context ] );
|
567 |
Â
$field_name = $record->get_meta( 'option_key', true );
|
568 |
Â
|
Â
|
|
Â
|
|
Â
|
|
569 |
Â
if ( '' === $field_name ) {
|
570 |
Â
$field_name = $record->get_meta( 'option', true );
|
571 |
Â
}
|
@@ -682,8 +686,12 @@ class Connector_Settings extends Connector {
|
|
682 |
Â
$options = array_merge(
|
683 |
Â
(array) $whitelist_options,
|
684 |
Â
(array) $new_whitelist_options,
|
685 |
-
array(
|
686 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
687 |
Â
);
|
688 |
Â
|
689 |
Â
foreach ( $options as $key => $opts ) {
|
@@ -702,7 +710,7 @@ class Connector_Settings extends Connector {
|
|
702 |
Â
if ( $this->is_option_group( $value ) ) {
|
703 |
Â
foreach ( $this->get_changed_keys( $old_value, $value ) as $field_key ) {
|
704 |
Â
if ( ! $this->is_key_ignored( $option, $field_key ) ) {
|
705 |
-
$key_context
|
706 |
Â
$changed_options[] = array(
|
707 |
Â
'label' => $this->get_serialized_field_label( $option, $field_key ),
|
708 |
Â
'option' => $option,
|
@@ -725,6 +733,7 @@ class Connector_Settings extends Connector {
|
|
725 |
Â
|
726 |
Â
foreach ( $changed_options as $properties ) {
|
727 |
Â
$this->log(
|
Â
|
|
728 |
Â
__( '"%s" setting was updated', 'stream' ),
|
729 |
Â
$properties,
|
730 |
Â
null,
|
@@ -744,7 +753,7 @@ class Connector_Settings extends Connector {
|
|
744 |
Â
<script>
|
745 |
Â
(function ($) {
|
746 |
Â
$(function () {
|
747 |
-
var hashPrefix = <?php echo wp_stream_json_encode( self::HIGHLIGHT_FIELD_URL_HASH_PREFIX ) // xss ok ?>,
|
748 |
Â
hashFieldName = "",
|
749 |
Â
fieldNames = [],
|
750 |
Â
$select2Choices = {},
|
@@ -830,7 +839,7 @@ class Connector_Settings extends Connector {
|
|
830 |
Â
public function sanitize_value( $value ) {
|
831 |
Â
if ( is_array( $value ) ) {
|
832 |
Â
return '';
|
833 |
-
} elseif ( is_object( $value ) && ! in_array( '__toString', get_class_methods( $value ) ) ) {
|
834 |
Â
return '';
|
835 |
Â
}
|
836 |
Â
|
287 |
Â
'background_attachment',
|
288 |
Â
'background_color',
|
289 |
Â
),
|
290 |
+
'custom_header' => array(
|
291 |
Â
'header_image',
|
292 |
Â
'header_textcolor',
|
293 |
Â
),
|
458 |
Â
*/
|
459 |
Â
public function action_links( $links, $record ) {
|
460 |
Â
$context_labels = $this->get_context_labels();
|
461 |
+
$plugin = wp_stream_get_instance();
|
462 |
Â
|
463 |
Â
$rules = array(
|
464 |
+
'stream' => array(
|
465 |
Â
'menu_slug' => 'wp_stream',
|
466 |
Â
'submenu_slug' => $plugin->admin->settings_page_slug,
|
467 |
Â
'url' => function( $rule, $record ) use ( $plugin ) {
|
504 |
Â
return in_array( $record->context, array( 'custom_header', 'custom_background' ), true );
|
505 |
Â
},
|
506 |
Â
),
|
507 |
+
'general' => array(
|
508 |
Â
'menu_slug' => 'options-general.php',
|
509 |
Â
'submenu_slug' => function( $record ) {
|
510 |
Â
return sprintf( 'options-%s.php', $record->context );
|
516 |
Â
return ! empty( $submenu['options-general.php'] );
|
517 |
Â
},
|
518 |
Â
),
|
519 |
+
'network' => array(
|
520 |
Â
'menu_slug' => 'settings.php',
|
521 |
Â
'submenu_slug' => function( $record ) {
|
522 |
Â
return 'settings.php';
|
553 |
Â
if ( isset( $submenu[ $menu_slug ] ) ) {
|
554 |
Â
$found_submenus = wp_list_filter(
|
555 |
Â
$submenu[ $menu_slug ],
|
556 |
+
array(
|
557 |
+
2 => $submenu_slug,
|
558 |
+
)
|
559 |
Â
);
|
560 |
Â
}
|
561 |
Â
|
562 |
Â
if ( ! empty( $found_submenus ) ) {
|
563 |
+
$target_submenu = array_pop( $found_submenus );
|
564 |
Â
list( $menu_title, $capability ) = $target_submenu;
|
565 |
Â
|
566 |
Â
if ( current_user_can( $capability ) ) {
|
567 |
Â
$url = apply_filters( 'wp_stream_action_link_url', $url, $record );
|
Â
|
|
568 |
Â
$field_name = $record->get_meta( 'option_key', true );
|
569 |
Â
|
570 |
+
// translators: Placeholder refers to a context (e.g. "Editor")
|
571 |
+
$text = sprintf( esc_html__( 'Edit %s Settings', 'stream' ), $context_labels[ $record->context ] );
|
572 |
+
|
573 |
Â
if ( '' === $field_name ) {
|
574 |
Â
$field_name = $record->get_meta( 'option', true );
|
575 |
Â
}
|
686 |
Â
$options = array_merge(
|
687 |
Â
(array) $whitelist_options,
|
688 |
Â
(array) $new_whitelist_options,
|
689 |
+
array(
|
690 |
+
'permalink' => $this->permalink_options,
|
691 |
+
),
|
692 |
+
array(
|
693 |
+
'network' => $this->network_options,
|
694 |
+
)
|
695 |
Â
);
|
696 |
Â
|
697 |
Â
foreach ( $options as $key => $opts ) {
|
710 |
Â
if ( $this->is_option_group( $value ) ) {
|
711 |
Â
foreach ( $this->get_changed_keys( $old_value, $value ) as $field_key ) {
|
712 |
Â
if ( ! $this->is_key_ignored( $option, $field_key ) ) {
|
713 |
+
$key_context = $this->get_context_by_key( $option, $field_key );
|
714 |
Â
$changed_options[] = array(
|
715 |
Â
'label' => $this->get_serialized_field_label( $option, $field_key ),
|
716 |
Â
'option' => $option,
|
733 |
Â
|
734 |
Â
foreach ( $changed_options as $properties ) {
|
735 |
Â
$this->log(
|
736 |
+
// translators: Placeholder refers to a setting name (e.g. "Language")
|
737 |
Â
__( '"%s" setting was updated', 'stream' ),
|
738 |
Â
$properties,
|
739 |
Â
null,
|
753 |
Â
<script>
|
754 |
Â
(function ($) {
|
755 |
Â
$(function () {
|
756 |
+
var hashPrefix = <?php echo wp_stream_json_encode( self::HIGHLIGHT_FIELD_URL_HASH_PREFIX ); // xss ok ?>,
|
757 |
Â
hashFieldName = "",
|
758 |
Â
fieldNames = [],
|
759 |
Â
$select2Choices = {},
|
839 |
Â
public function sanitize_value( $value ) {
|
840 |
Â
if ( is_array( $value ) ) {
|
841 |
Â
return '';
|
842 |
+
} elseif ( is_object( $value ) && ! in_array( '__toString', get_class_methods( $value ), true ) ) {
|
843 |
Â
return '';
|
844 |
Â
}
|
845 |
Â
|
connectors/class-connector-taxonomies.php
CHANGED
@@ -74,9 +74,9 @@ class Connector_Taxonomies extends Connector {
|
|
74 |
Â
|
75 |
Â
$labels = wp_list_pluck( $wp_taxonomies, 'labels' );
|
76 |
Â
|
77 |
-
$this->context_labels
|
78 |
Â
|
79 |
-
add_action( 'registered_taxonomy', array( $this, '
|
80 |
Â
|
81 |
Â
return $this->context_labels;
|
82 |
Â
}
|
@@ -92,13 +92,8 @@ class Connector_Taxonomies extends Connector {
|
|
92 |
Â
* @return array Action links
|
93 |
Â
*/
|
94 |
Â
public function action_links( $links, $record ) {
|
95 |
-
|
96 |
-
|
97 |
-
&&
|
98 |
-
'deleted' !== $record->action
|
99 |
-
&&
|
100 |
-
( $term = get_term_by( 'term_taxonomy_id', $record->object_id, $record->context ) ) // wpcom_vip_get_term_by() does not indicate support for `term_taxonomy_id`
|
101 |
-
) {
|
102 |
Â
if ( ! is_wp_error( $term ) ) {
|
103 |
Â
$tax_obj = get_taxonomy( $term->taxonomy );
|
104 |
Â
$tax_label = isset( $tax_obj->labels->singular_name ) ? $tax_obj->labels->singular_name : null;
|
@@ -109,6 +104,7 @@ class Connector_Taxonomies extends Connector {
|
|
109 |
Â
|
110 |
Â
$term_id = empty( $term_id ) ? $term->term_id : $term_id;
|
111 |
Â
|
Â
|
|
112 |
Â
$links[ sprintf( _x( 'Edit %s', 'Term singular name', 'stream' ), $tax_label ) ] = get_edit_term_link( $term_id, $term->taxonomy );
|
113 |
Â
$links[ esc_html__( 'View', 'stream' ) ] = wp_stream_is_vip() ? \wpcom_vip_get_term_link( $term_id, $term->taxonomy ) : get_term_link( $term_id, $term->taxonomy );
|
114 |
Â
}
|
@@ -126,7 +122,7 @@ class Connector_Taxonomies extends Connector {
|
|
126 |
Â
* @param array|string $object_type Object type or array of object types
|
127 |
Â
* @param array|string $args Array or string of taxonomy registration arguments
|
128 |
Â
*/
|
129 |
-
public function
|
130 |
Â
unset( $object_type );
|
131 |
Â
|
132 |
Â
$taxonomy_obj = (object) $args;
|
@@ -157,6 +153,7 @@ class Connector_Taxonomies extends Connector {
|
|
157 |
Â
$term_parent = $term->parent;
|
158 |
Â
|
159 |
Â
$this->log(
|
Â
|
|
160 |
Â
_x(
|
161 |
Â
'"%1$s" %2$s created',
|
162 |
Â
'1: Term name, 2: Taxonomy singular label',
|
@@ -189,6 +186,7 @@ class Connector_Taxonomies extends Connector {
|
|
189 |
Â
$taxonomy_label = strtolower( $this->context_labels[ $taxonomy ] );
|
190 |
Â
|
191 |
Â
$this->log(
|
Â
|
|
192 |
Â
_x(
|
193 |
Â
'"%1$s" %2$s deleted',
|
194 |
Â
'1: Term name, 2: Taxonomy singular label',
|
@@ -231,6 +229,7 @@ class Connector_Taxonomies extends Connector {
|
|
231 |
Â
$term_parent = $term->parent;
|
232 |
Â
|
233 |
Â
$this->log(
|
Â
|
|
234 |
Â
_x(
|
235 |
Â
'"%1$s" %2$s updated',
|
236 |
Â
'1: Term name, 2: Taxonomy singular label',
|
74 |
Â
|
75 |
Â
$labels = wp_list_pluck( $wp_taxonomies, 'labels' );
|
76 |
Â
|
77 |
+
$this->context_labels = wp_list_pluck( $labels, 'singular_name' );
|
78 |
Â
|
79 |
+
add_action( 'registered_taxonomy', array( $this, 'registered_taxonomy' ), 10, 3 );
|
80 |
Â
|
81 |
Â
return $this->context_labels;
|
82 |
Â
}
|
92 |
Â
* @return array Action links
|
93 |
Â
*/
|
94 |
Â
public function action_links( $links, $record ) {
|
95 |
+
$term = get_term_by( 'term_taxonomy_id', $record->object_id, $record->context ); // wpcom_vip_get_term_by() does not indicate support for `term_taxonomy_id`
|
96 |
+
if ( $record->object_id && 'deleted' !== $record->action && $term ) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
97 |
Â
if ( ! is_wp_error( $term ) ) {
|
98 |
Â
$tax_obj = get_taxonomy( $term->taxonomy );
|
99 |
Â
$tax_label = isset( $tax_obj->labels->singular_name ) ? $tax_obj->labels->singular_name : null;
|
104 |
Â
|
105 |
Â
$term_id = empty( $term_id ) ? $term->term_id : $term_id;
|
106 |
Â
|
107 |
+
// translators: Placeholder refers to a term singular name (e.g. "Tag")
|
108 |
Â
$links[ sprintf( _x( 'Edit %s', 'Term singular name', 'stream' ), $tax_label ) ] = get_edit_term_link( $term_id, $term->taxonomy );
|
109 |
Â
$links[ esc_html__( 'View', 'stream' ) ] = wp_stream_is_vip() ? \wpcom_vip_get_term_link( $term_id, $term->taxonomy ) : get_term_link( $term_id, $term->taxonomy );
|
110 |
Â
}
|
122 |
Â
* @param array|string $object_type Object type or array of object types
|
123 |
Â
* @param array|string $args Array or string of taxonomy registration arguments
|
124 |
Â
*/
|
125 |
+
public function registered_taxonomy( $taxonomy, $object_type, $args ) {
|
126 |
Â
unset( $object_type );
|
127 |
Â
|
128 |
Â
$taxonomy_obj = (object) $args;
|
153 |
Â
$term_parent = $term->parent;
|
154 |
Â
|
155 |
Â
$this->log(
|
156 |
+
// translators: Placeholders refer to a term name, and a taxonomy singular label (e.g. "Tags", "Genre")
|
157 |
Â
_x(
|
158 |
Â
'"%1$s" %2$s created',
|
159 |
Â
'1: Term name, 2: Taxonomy singular label',
|
186 |
Â
$taxonomy_label = strtolower( $this->context_labels[ $taxonomy ] );
|
187 |
Â
|
188 |
Â
$this->log(
|
189 |
+
// translators: Placeholders refer to a term name, and a taxonomy singular label (e.g. "Tags", "Genre")
|
190 |
Â
_x(
|
191 |
Â
'"%1$s" %2$s deleted',
|
192 |
Â
'1: Term name, 2: Taxonomy singular label',
|
229 |
Â
$term_parent = $term->parent;
|
230 |
Â
|
231 |
Â
$this->log(
|
232 |
+
// translators: Placeholders refer to a term name, and a taxonomy singular label (e.g. "Tags", "Genre")
|
233 |
Â
_x(
|
234 |
Â
'"%1$s" %2$s updated',
|
235 |
Â
'1: Term name, 2: Taxonomy singular label',
|
connectors/class-connector-user-switching.php
CHANGED
@@ -105,12 +105,13 @@ class Connector_User_Switching extends Connector {
|
|
105 |
Â
* @param Connectors $connectors The Connectors object instance
|
106 |
Â
*/
|
107 |
Â
public function callback_wp_stream_after_connectors_registration( array $labels, Connectors $connectors ) {
|
Â
|
|
108 |
Â
|
109 |
-
if ( !
|
110 |
Â
return;
|
111 |
Â
}
|
112 |
Â
|
113 |
-
switch ( $
|
114 |
Â
|
115 |
Â
case 'switch_to_user':
|
116 |
Â
$this->unhook_user_action( $connectors, 'clear_auth_cookie' );
|
@@ -140,7 +141,8 @@ class Connector_User_Switching extends Connector {
|
|
140 |
Â
|
141 |
Â
$user = get_userdata( $user_id );
|
142 |
Â
$old_user = get_userdata( $old_user_id );
|
143 |
-
|
Â
|
|
144 |
Â
'Switched user to %1$s (%2$s)',
|
145 |
Â
'1: User display name, 2: User login',
|
146 |
Â
'stream'
|
@@ -169,8 +171,9 @@ class Connector_User_Switching extends Connector {
|
|
169 |
Â
*/
|
170 |
Â
public function callback_switch_back_user( $user_id, $old_user_id ) {
|
171 |
Â
|
172 |
-
$user
|
173 |
-
|
Â
|
|
174 |
Â
'Switched back to %1$s (%2$s)',
|
175 |
Â
'1: User display name, 2: User login',
|
176 |
Â
'stream'
|
105 |
Â
* @param Connectors $connectors The Connectors object instance
|
106 |
Â
*/
|
107 |
Â
public function callback_wp_stream_after_connectors_registration( array $labels, Connectors $connectors ) {
|
108 |
+
$action = wp_stream_filter_input( INPUT_GET, 'action' ) ?: wp_stream_filter_input( INPUT_POST, 'action' );
|
109 |
Â
|
110 |
+
if ( ! $action ) {
|
111 |
Â
return;
|
112 |
Â
}
|
113 |
Â
|
114 |
+
switch ( $action ) {
|
115 |
Â
|
116 |
Â
case 'switch_to_user':
|
117 |
Â
$this->unhook_user_action( $connectors, 'clear_auth_cookie' );
|
141 |
Â
|
142 |
Â
$user = get_userdata( $user_id );
|
143 |
Â
$old_user = get_userdata( $old_user_id );
|
144 |
+
// translators: Placeholders refer to a user display name, and a username (e.g. "Jane Doe", "administrator")
|
145 |
+
$message = _x(
|
146 |
Â
'Switched user to %1$s (%2$s)',
|
147 |
Â
'1: User display name, 2: User login',
|
148 |
Â
'stream'
|
171 |
Â
*/
|
172 |
Â
public function callback_switch_back_user( $user_id, $old_user_id ) {
|
173 |
Â
|
174 |
+
$user = get_userdata( $user_id );
|
175 |
+
// translators: Placeholders refer to a user display name, and a username (e.g. "Jane Doe", "administrator")
|
176 |
+
$message = _x(
|
177 |
Â
'Switched back to %1$s (%2$s)',
|
178 |
Â
'1: User display name, 2: User login',
|
179 |
Â
'stream'
|
connectors/class-connector-users.php
CHANGED
@@ -86,7 +86,8 @@ class Connector_Users extends Connector {
|
|
86 |
Â
*/
|
87 |
Â
public function action_links( $links, $record ) {
|
88 |
Â
if ( $record->object_id ) {
|
89 |
-
|
Â
|
|
90 |
Â
$links [ esc_html__( 'Edit User', 'stream' ) ] = $link;
|
91 |
Â
}
|
92 |
Â
}
|
@@ -139,6 +140,7 @@ class Connector_Users extends Connector {
|
|
139 |
Â
$message = esc_html__( 'New user registration', 'stream' );
|
140 |
Â
$user_to_log = $registered_user->ID;
|
141 |
Â
} else { // Current logged-in user created a new user
|
Â
|
|
142 |
Â
$message = _x(
|
143 |
Â
'New user account created for %1$s (%2$s)',
|
144 |
Â
'1: User display name, 2: User role',
|
@@ -172,6 +174,7 @@ class Connector_Users extends Connector {
|
|
172 |
Â
unset( $user_id );
|
173 |
Â
|
174 |
Â
$this->log(
|
Â
|
|
175 |
Â
__( '%s\'s profile was updated', 'stream' ),
|
176 |
Â
array(
|
177 |
Â
'display_name' => $user->display_name,
|
@@ -199,6 +202,7 @@ class Connector_Users extends Connector {
|
|
199 |
Â
global $wp_roles;
|
200 |
Â
|
201 |
Â
$this->log(
|
Â
|
|
202 |
Â
_x(
|
203 |
Â
'%1$s\'s role was changed from %2$s to %3$s',
|
204 |
Â
'1: User display name, 2: Old role, 3: New role',
|
@@ -206,8 +210,8 @@ class Connector_Users extends Connector {
|
|
206 |
Â
),
|
207 |
Â
array(
|
208 |
Â
'display_name' => get_user_by( 'id', $user_id )->display_name,
|
209 |
-
'old_role' => translate_user_role( $wp_roles->role_names[ $old_roles
|
210 |
-
'new_role' => translate_user_role( $wp_roles->role_names[ $new_role ] ),
|
211 |
Â
),
|
212 |
Â
$user_id,
|
213 |
Â
'profiles',
|
@@ -224,6 +228,7 @@ class Connector_Users extends Connector {
|
|
224 |
Â
*/
|
225 |
Â
public function callback_password_reset( $user ) {
|
226 |
Â
$this->log(
|
Â
|
|
227 |
Â
__( '%s\'s password was reset', 'stream' ),
|
228 |
Â
array(
|
229 |
Â
'email' => $user->display_name,
|
@@ -250,8 +255,11 @@ class Connector_Users extends Connector {
|
|
250 |
Â
}
|
251 |
Â
|
252 |
Â
$this->log(
|
Â
|
|
253 |
Â
__( '%s\'s password was requested to be reset', 'stream' ),
|
254 |
-
array(
|
Â
|
|
Â
|
|
255 |
Â
$user->ID,
|
256 |
Â
'sessions',
|
257 |
Â
'forgot-password',
|
@@ -276,8 +284,11 @@ class Connector_Users extends Connector {
|
|
276 |
Â
$user = get_user_by( 'id', $user_id );
|
277 |
Â
|
278 |
Â
$this->log(
|
Â
|
|
279 |
Â
__( '%s logged in', 'stream' ),
|
280 |
-
array(
|
Â
|
|
Â
|
|
281 |
Â
$user->ID,
|
282 |
Â
'sessions',
|
283 |
Â
'login',
|
@@ -299,8 +310,11 @@ class Connector_Users extends Connector {
|
|
299 |
Â
}
|
300 |
Â
|
301 |
Â
$this->log(
|
Â
|
|
302 |
Â
__( '%s logged out', 'stream' ),
|
303 |
-
array(
|
Â
|
|
Â
|
|
304 |
Â
$user->ID,
|
305 |
Â
'sessions',
|
306 |
Â
'logout',
|
@@ -334,6 +348,7 @@ class Connector_Users extends Connector {
|
|
334 |
Â
$user = wp_get_current_user();
|
335 |
Â
|
336 |
Â
if ( isset( $this->_users_object_pre_deleted[ $user_id ] ) ) {
|
Â
|
|
337 |
Â
$message = _x(
|
338 |
Â
'%1$s\'s account was deleted (%2$s)',
|
339 |
Â
'1: User display name, 2: User roles',
|
@@ -343,6 +358,7 @@ class Connector_Users extends Connector {
|
|
343 |
Â
$deleted_user = $this->_users_object_pre_deleted[ $user_id ];
|
344 |
Â
unset( $this->_users_object_pre_deleted[ $user_id ] );
|
345 |
Â
} else {
|
Â
|
|
346 |
Â
$message = esc_html__( 'User account #%d was deleted', 'stream' );
|
347 |
Â
$display_name = $user_id;
|
348 |
Â
$deleted_user = $user_id;
|
86 |
Â
*/
|
87 |
Â
public function action_links( $links, $record ) {
|
88 |
Â
if ( $record->object_id ) {
|
89 |
+
$link = get_edit_user_link( $record->object_id );
|
90 |
+
if ( $link ) {
|
91 |
Â
$links [ esc_html__( 'Edit User', 'stream' ) ] = $link;
|
92 |
Â
}
|
93 |
Â
}
|
140 |
Â
$message = esc_html__( 'New user registration', 'stream' );
|
141 |
Â
$user_to_log = $registered_user->ID;
|
142 |
Â
} else { // Current logged-in user created a new user
|
143 |
+
// translators: Placeholders refer to a user display name, and a user role (e.g. "Jane Doe", "subscriber")
|
144 |
Â
$message = _x(
|
145 |
Â
'New user account created for %1$s (%2$s)',
|
146 |
Â
'1: User display name, 2: User role',
|
174 |
Â
unset( $user_id );
|
175 |
Â
|
176 |
Â
$this->log(
|
177 |
+
// translators: Placeholder refers to a user display name (e.g. "Jane Doe")
|
178 |
Â
__( '%s\'s profile was updated', 'stream' ),
|
179 |
Â
array(
|
180 |
Â
'display_name' => $user->display_name,
|
202 |
Â
global $wp_roles;
|
203 |
Â
|
204 |
Â
$this->log(
|
205 |
+
// translators: Placeholders refer to a user display name, a user role, and another user role (e.g. "Jane Doe", "editor", "subscriber")
|
206 |
Â
_x(
|
207 |
Â
'%1$s\'s role was changed from %2$s to %3$s',
|
208 |
Â
'1: User display name, 2: Old role, 3: New role',
|
210 |
Â
),
|
211 |
Â
array(
|
212 |
Â
'display_name' => get_user_by( 'id', $user_id )->display_name,
|
213 |
+
'old_role' => translate_user_role( $wp_roles->role_names[ current( $old_roles ) ] ),
|
214 |
+
'new_role' => $new_role ? translate_user_role( $wp_roles->role_names[ $new_role ] ) : __( 'N/A', 'stream' ),
|
215 |
Â
),
|
216 |
Â
$user_id,
|
217 |
Â
'profiles',
|
228 |
Â
*/
|
229 |
Â
public function callback_password_reset( $user ) {
|
230 |
Â
$this->log(
|
231 |
+
// translators: Placeholder refers to a user display name (e.g. "Jane Doe")
|
232 |
Â
__( '%s\'s password was reset', 'stream' ),
|
233 |
Â
array(
|
234 |
Â
'email' => $user->display_name,
|
255 |
Â
}
|
256 |
Â
|
257 |
Â
$this->log(
|
258 |
+
// translators: Placeholder refers to a user display name (e.g. "Jane Doe")
|
259 |
Â
__( '%s\'s password was requested to be reset', 'stream' ),
|
260 |
+
array(
|
261 |
+
'display_name' => $user->display_name,
|
262 |
+
),
|
263 |
Â
$user->ID,
|
264 |
Â
'sessions',
|
265 |
Â
'forgot-password',
|
284 |
Â
$user = get_user_by( 'id', $user_id );
|
285 |
Â
|
286 |
Â
$this->log(
|
287 |
+
// translators: Placeholder refers to a user display name (e.g. "Jane Doe")
|
288 |
Â
__( '%s logged in', 'stream' ),
|
289 |
+
array(
|
290 |
+
'display_name' => $user->display_name,
|
291 |
+
),
|
292 |
Â
$user->ID,
|
293 |
Â
'sessions',
|
294 |
Â
'login',
|
310 |
Â
}
|
311 |
Â
|
312 |
Â
$this->log(
|
313 |
+
// translators: Placeholder refers to a user display name (e.g. "Jane Doe")
|
314 |
Â
__( '%s logged out', 'stream' ),
|
315 |
+
array(
|
316 |
+
'display_name' => $user->display_name,
|
317 |
+
),
|
318 |
Â
$user->ID,
|
319 |
Â
'sessions',
|
320 |
Â
'logout',
|
348 |
Â
$user = wp_get_current_user();
|
349 |
Â
|
350 |
Â
if ( isset( $this->_users_object_pre_deleted[ $user_id ] ) ) {
|
351 |
+
// translators: Placeholders refer to a user display name, and a user role (e.g. "Jane Doe", "subscriber")
|
352 |
Â
$message = _x(
|
353 |
Â
'%1$s\'s account was deleted (%2$s)',
|
354 |
Â
'1: User display name, 2: User roles',
|
358 |
Â
$deleted_user = $this->_users_object_pre_deleted[ $user_id ];
|
359 |
Â
unset( $this->_users_object_pre_deleted[ $user_id ] );
|
360 |
Â
} else {
|
361 |
+
// translators: Placeholders refer to a user display name, and a user role (e.g. "Jane Doe", "subscriber")
|
362 |
Â
$message = esc_html__( 'User account #%d was deleted', 'stream' );
|
363 |
Â
$display_name = $user_id;
|
364 |
Â
$deleted_user = $user_id;
|
connectors/class-connector-widgets.php
CHANGED
@@ -96,7 +96,8 @@ class Connector_Widgets extends Connector {
|
|
96 |
Â
* @return array Action links
|
97 |
Â
*/
|
98 |
Â
public function action_links( $links, $record ) {
|
99 |
-
|
Â
|
|
100 |
Â
global $wp_registered_sidebars;
|
101 |
Â
|
102 |
Â
if ( array_key_exists( $sidebar, $wp_registered_sidebars ) ) {
|
@@ -128,7 +129,7 @@ class Connector_Widgets extends Connector {
|
|
128 |
Â
if ( did_action( 'customize_save' ) ) {
|
129 |
Â
if ( is_null( $this->customizer_initial_sidebars_widgets ) ) {
|
130 |
Â
$this->customizer_initial_sidebars_widgets = $old;
|
131 |
-
add_action( 'customize_save_after', array( $this, '
|
132 |
Â
}
|
133 |
Â
} else {
|
134 |
Â
$this->handle_sidebars_widgets_changes( $old, $new );
|
@@ -142,7 +143,7 @@ class Connector_Widgets extends Connector {
|
|
142 |
Â
*
|
143 |
Â
* @see callback_update_option_sidebars_widgets()
|
144 |
Â
*/
|
145 |
-
public function
|
146 |
Â
$old_sidebars_widgets = $this->customizer_initial_sidebars_widgets;
|
147 |
Â
$new_sidebars_widgets = get_option( 'sidebars_widgets' );
|
148 |
Â
|
@@ -196,15 +197,19 @@ class Connector_Widgets extends Connector {
|
|
196 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
197 |
Â
|
198 |
Â
if ( $name && $title ) {
|
Â
|
|
199 |
Â
$message = _x( '%1$s widget named "%2$s" from "%3$s" deactivated', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
200 |
Â
} elseif ( $name ) {
|
201 |
Â
// Empty title, but we have the name
|
Â
|
|
202 |
Â
$message = _x( '%1$s widget from "%3$s" deactivated', '1: Name, 3: Sidebar Name', 'stream' );
|
203 |
Â
} elseif ( $title ) {
|
204 |
Â
// Likely a single widget since no name is available
|
Â
|
|
205 |
Â
$message = _x( 'Unknown widget type named "%2$s" from "%3$s" deactivated', '2: Title, 3: Sidebar Name', 'stream' );
|
206 |
Â
} else {
|
207 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
208 |
Â
$message = _x( '%4$s widget from "%3$s" deactivated', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
209 |
Â
}
|
210 |
Â
|
@@ -245,15 +250,19 @@ class Connector_Widgets extends Connector {
|
|
245 |
Â
$title = $this->get_widget_title( $widget_id );
|
246 |
Â
|
247 |
Â
if ( $name && $title ) {
|
Â
|
|
248 |
Â
$message = _x( '%1$s widget named "%2$s" reactivated', '1: Name, 2: Title', 'stream' );
|
249 |
Â
} elseif ( $name ) {
|
250 |
Â
// Empty title, but we have the name
|
Â
|
|
251 |
Â
$message = _x( '%1$s widget reactivated', '1: Name', 'stream' );
|
252 |
Â
} elseif ( $title ) {
|
253 |
Â
// Likely a single widget since no name is available
|
Â
|
|
254 |
Â
$message = _x( 'Unknown widget type named "%2$s" reactivated', '2: Title', 'stream' );
|
255 |
Â
} else {
|
256 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
257 |
Â
$message = _x( '%3$s widget reactivated', '3: Widget ID', 'stream' );
|
258 |
Â
}
|
259 |
Â
|
@@ -301,15 +310,19 @@ class Connector_Widgets extends Connector {
|
|
301 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
302 |
Â
|
303 |
Â
if ( $name && $title ) {
|
Â
|
|
304 |
Â
$message = _x( '%1$s widget named "%2$s" removed from "%3$s"', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
305 |
Â
} elseif ( $name ) {
|
306 |
Â
// Empty title, but we have the name
|
Â
|
|
307 |
Â
$message = _x( '%1$s widget removed from "%3$s"', '1: Name, 3: Sidebar Name', 'stream' );
|
308 |
Â
} elseif ( $title ) {
|
309 |
Â
// Likely a single widget since no name is available
|
Â
|
|
310 |
Â
$message = _x( 'Unknown widget type named "%2$s" removed from "%3$s"', '2: Title, 3: Sidebar Name', 'stream' );
|
311 |
Â
} else {
|
312 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
313 |
Â
$message = _x( '%4$s widget removed from "%3$s"', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
314 |
Â
}
|
315 |
Â
|
@@ -354,15 +367,19 @@ class Connector_Widgets extends Connector {
|
|
354 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
355 |
Â
|
356 |
Â
if ( $name && $title ) {
|
Â
|
|
357 |
Â
$message = _x( '%1$s widget named "%2$s" added to "%3$s"', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
358 |
Â
} elseif ( $name ) {
|
359 |
Â
// Empty title, but we have the name
|
Â
|
|
360 |
Â
$message = _x( '%1$s widget added to "%3$s"', '1: Name, 3: Sidebar Name', 'stream' );
|
361 |
Â
} elseif ( $title ) {
|
362 |
Â
// Likely a single widget since no name is available
|
Â
|
|
363 |
Â
$message = _x( 'Unknown widget type named "%2$s" added to "%3$s"', '2: Title, 3: Sidebar Name', 'stream' );
|
364 |
Â
} else {
|
365 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
366 |
Â
$message = _x( '%4$s widget added to "%3$s"', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
367 |
Â
}
|
368 |
Â
|
@@ -405,8 +422,10 @@ class Connector_Widgets extends Connector {
|
|
405 |
Â
$labels = $this->get_context_labels();
|
406 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
407 |
Â
$old_widget_ids = $old[ $sidebar_id ];
|
408 |
-
|
409 |
-
|
Â
|
|
Â
|
|
410 |
Â
|
411 |
Â
$this->log(
|
412 |
Â
$message,
|
@@ -460,15 +479,19 @@ class Connector_Widgets extends Connector {
|
|
460 |
Â
$new_sidebar_name = isset( $labels[ $new_sidebar_id ] ) ? $labels[ $new_sidebar_id ] : $new_sidebar_id;
|
461 |
Â
|
462 |
Â
if ( $name && $title ) {
|
Â
|
|
463 |
Â
$message = _x( '%1$s widget named "%2$s" moved from "%4$s" to "%5$s"', '1: Name, 2: Title, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
464 |
Â
} elseif ( $name ) {
|
465 |
Â
// Empty title, but we have the name
|
Â
|
|
466 |
Â
$message = _x( '%1$s widget moved from "%4$s" to "%5$s"', '1: Name, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
467 |
Â
} elseif ( $title ) {
|
468 |
Â
// Likely a single widget since no name is available
|
Â
|
|
469 |
Â
$message = _x( 'Unknown widget type named "%2$s" moved from "%4$s" to "%5$s"', '2: Title, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
470 |
Â
} else {
|
471 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
472 |
Â
$message = _x( '%3$s widget moved from "%4$s" to "%5$s"', '3: Widget ID, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
473 |
Â
}
|
474 |
Â
|
@@ -520,11 +543,11 @@ class Connector_Widgets extends Connector {
|
|
520 |
Â
$created_widget_numbers = array_diff( array_keys( $new_value ), array_keys( $old_value ) );
|
521 |
Â
|
522 |
Â
foreach ( $created_widget_numbers as $widget_number ) {
|
523 |
-
$instance
|
524 |
-
$widget_id
|
525 |
-
$name
|
526 |
-
$title
|
527 |
-
$sidebar_id
|
528 |
Â
|
529 |
Â
$creates[] = compact( 'name', 'title', 'widget_id', 'sidebar_id', 'instance' );
|
530 |
Â
}
|
@@ -556,11 +579,11 @@ class Connector_Widgets extends Connector {
|
|
556 |
Â
$deleted_widget_numbers = array_diff( array_keys( $old_value ), array_keys( $new_value ) );
|
557 |
Â
|
558 |
Â
foreach ( $deleted_widget_numbers as $widget_number ) {
|
559 |
-
$instance
|
560 |
-
$widget_id
|
561 |
-
$name
|
562 |
-
$title
|
563 |
-
$sidebar_id
|
564 |
Â
|
565 |
Â
$deletes[] = compact( 'name', 'title', 'widget_id', 'sidebar_id', 'instance' );
|
566 |
Â
}
|
@@ -582,15 +605,19 @@ class Connector_Widgets extends Connector {
|
|
582 |
Â
*/
|
583 |
Â
foreach ( $updates as $update ) {
|
584 |
Â
if ( $update['name'] && $update['title'] ) {
|
Â
|
|
585 |
Â
$message = _x( '%1$s widget named "%2$s" in "%3$s" updated', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
586 |
Â
} elseif ( $update['name'] ) {
|
587 |
Â
// Empty title, but we have the name
|
Â
|
|
588 |
Â
$message = _x( '%1$s widget in "%3$s" updated', '1: Name, 3: Sidebar Name', 'stream' );
|
589 |
Â
} elseif ( $update['title'] ) {
|
590 |
Â
// Likely a single widget since no name is available
|
Â
|
|
591 |
Â
$message = _x( 'Unknown widget type named "%2$s" in "%3$s" updated', '2: Title, 3: Sidebar Name', 'stream' );
|
592 |
Â
} else {
|
593 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
594 |
Â
$message = _x( '%4$s widget in "%3$s" updated', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
595 |
Â
}
|
596 |
Â
|
@@ -622,15 +649,19 @@ class Connector_Widgets extends Connector {
|
|
622 |
Â
*/
|
623 |
Â
foreach ( $creates as $create ) {
|
624 |
Â
if ( $create['name'] && $create['title'] ) {
|
Â
|
|
625 |
Â
$message = _x( '%1$s widget named "%2$s" created', '1: Name, 2: Title', 'stream' );
|
626 |
Â
} elseif ( $create['name'] ) {
|
627 |
Â
// Empty title, but we have the name
|
Â
|
|
628 |
Â
$message = _x( '%1$s widget created', '1: Name', 'stream' );
|
629 |
Â
} elseif ( $create['title'] ) {
|
630 |
Â
// Likely a single widget since no name is available
|
Â
|
|
631 |
Â
$message = _x( 'Unknown widget type named "%2$s" created', '2: Title', 'stream' );
|
632 |
Â
} else {
|
633 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
634 |
Â
$message = _x( '%3$s widget created', '3: Widget ID', 'stream' );
|
635 |
Â
}
|
636 |
Â
|
@@ -652,15 +683,19 @@ class Connector_Widgets extends Connector {
|
|
652 |
Â
*/
|
653 |
Â
foreach ( $deletes as $delete ) {
|
654 |
Â
if ( $delete['name'] && $delete['title'] ) {
|
Â
|
|
655 |
Â
$message = _x( '%1$s widget named "%2$s" deleted', '1: Name, 2: Title', 'stream' );
|
656 |
Â
} elseif ( $delete['name'] ) {
|
657 |
Â
// Empty title, but we have the name
|
Â
|
|
658 |
Â
$message = _x( '%1$s widget deleted', '1: Name', 'stream' );
|
659 |
Â
} elseif ( $delete['title'] ) {
|
660 |
Â
// Likely a single widget since no name is available
|
Â
|
|
661 |
Â
$message = _x( 'Unknown widget type named "%2$s" deleted', '2: Title', 'stream' );
|
662 |
Â
} else {
|
663 |
Â
// Neither a name nor a title are available, so use the widget ID
|
Â
|
|
664 |
Â
$message = _x( '%3$s widget deleted', '3: Widget ID', 'stream' );
|
665 |
Â
}
|
666 |
Â
|
96 |
Â
* @return array Action links
|
97 |
Â
*/
|
98 |
Â
public function action_links( $links, $record ) {
|
99 |
+
$sidebar = $record->get_meta( 'sidebar_id', true );
|
100 |
+
if ( $sidebar ) {
|
101 |
Â
global $wp_registered_sidebars;
|
102 |
Â
|
103 |
Â
if ( array_key_exists( $sidebar, $wp_registered_sidebars ) ) {
|
129 |
Â
if ( did_action( 'customize_save' ) ) {
|
130 |
Â
if ( is_null( $this->customizer_initial_sidebars_widgets ) ) {
|
131 |
Â
$this->customizer_initial_sidebars_widgets = $old;
|
132 |
+
add_action( 'customize_save_after', array( $this, 'callback_customize_save_after' ) );
|
133 |
Â
}
|
134 |
Â
} else {
|
135 |
Â
$this->handle_sidebars_widgets_changes( $old, $new );
|
143 |
Â
*
|
144 |
Â
* @see callback_update_option_sidebars_widgets()
|
145 |
Â
*/
|
146 |
+
public function callback_customize_save_after() {
|
147 |
Â
$old_sidebars_widgets = $this->customizer_initial_sidebars_widgets;
|
148 |
Â
$new_sidebars_widgets = get_option( 'sidebars_widgets' );
|
149 |
Â
|
197 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
198 |
Â
|
199 |
Â
if ( $name && $title ) {
|
200 |
+
// translators: Placeholders refer to a widget name, a widget title, and a sidebar name (e.g. "Archives", "Browse", "Footer Area 1")
|
201 |
Â
$message = _x( '%1$s widget named "%2$s" from "%3$s" deactivated', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
202 |
Â
} elseif ( $name ) {
|
203 |
Â
// Empty title, but we have the name
|
204 |
+
// translators: Placeholders refer to a widget name, and a sidebar name (e.g. "Archives", "Footer Area 1")
|
205 |
Â
$message = _x( '%1$s widget from "%3$s" deactivated', '1: Name, 3: Sidebar Name', 'stream' );
|
206 |
Â
} elseif ( $title ) {
|
207 |
Â
// Likely a single widget since no name is available
|
208 |
+
// translators: Placeholders refer to a widget title, and a sidebar name (e.g. "Browse", "Footer Area 1")
|
209 |
Â
$message = _x( 'Unknown widget type named "%2$s" from "%3$s" deactivated', '2: Title, 3: Sidebar Name', 'stream' );
|
210 |
Â
} else {
|
211 |
Â
// Neither a name nor a title are available, so use the widget ID
|
212 |
+
// translators: Placeholders refer to a widget ID, and a sidebar name (e.g. "42", "Footer Area 1")
|
213 |
Â
$message = _x( '%4$s widget from "%3$s" deactivated', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
214 |
Â
}
|
215 |
Â
|
250 |
Â
$title = $this->get_widget_title( $widget_id );
|
251 |
Â
|
252 |
Â
if ( $name && $title ) {
|
253 |
+
// translators: Placeholders refer to a widget name, and a widget title (e.g. "Archives", "Browse")
|
254 |
Â
$message = _x( '%1$s widget named "%2$s" reactivated', '1: Name, 2: Title', 'stream' );
|
255 |
Â
} elseif ( $name ) {
|
256 |
Â
// Empty title, but we have the name
|
257 |
+
// translators: Placeholder refers to a widget name (e.g. "Archives")
|
258 |
Â
$message = _x( '%1$s widget reactivated', '1: Name', 'stream' );
|
259 |
Â
} elseif ( $title ) {
|
260 |
Â
// Likely a single widget since no name is available
|
261 |
+
// translators: Placeholder refers to a widget title (e.g. "Browse")
|
262 |
Â
$message = _x( 'Unknown widget type named "%2$s" reactivated', '2: Title', 'stream' );
|
263 |
Â
} else {
|
264 |
Â
// Neither a name nor a title are available, so use the widget ID
|
265 |
+
// translators: Placeholder refers to a widget ID (e.g. "42")
|
266 |
Â
$message = _x( '%3$s widget reactivated', '3: Widget ID', 'stream' );
|
267 |
Â
}
|
268 |
Â
|
310 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
311 |
Â
|
312 |
Â
if ( $name && $title ) {
|
313 |
+
// translators: Placeholders refer to a widget name, a widget title, and a sidebar name (e.g. "Archives", "Browse", "Footer Area 1")
|
314 |
Â
$message = _x( '%1$s widget named "%2$s" removed from "%3$s"', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
315 |
Â
} elseif ( $name ) {
|
316 |
Â
// Empty title, but we have the name
|
317 |
+
// translators: Placeholders refer to a widget name, and a sidebar name (e.g. "Archives", "Footer Area 1")
|
318 |
Â
$message = _x( '%1$s widget removed from "%3$s"', '1: Name, 3: Sidebar Name', 'stream' );
|
319 |
Â
} elseif ( $title ) {
|
320 |
Â
// Likely a single widget since no name is available
|
321 |
+
// translators: Placeholders refer to a widget title, and a sidebar name (e.g. "Browse", "Footer Area 1")
|
322 |
Â
$message = _x( 'Unknown widget type named "%2$s" removed from "%3$s"', '2: Title, 3: Sidebar Name', 'stream' );
|
323 |
Â
} else {
|
324 |
Â
// Neither a name nor a title are available, so use the widget ID
|
325 |
+
// translators: Placeholders refer to a widget ID, and a sidebar name (e.g. "42", "Footer Area 1")
|
326 |
Â
$message = _x( '%4$s widget removed from "%3$s"', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
327 |
Â
}
|
328 |
Â
|
367 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
368 |
Â
|
369 |
Â
if ( $name && $title ) {
|
370 |
+
// translators: Placeholders refer to a widget name, a widget title, and a sidebar name (e.g. "Archives", "Browse", "Footer Area 1")
|
371 |
Â
$message = _x( '%1$s widget named "%2$s" added to "%3$s"', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
372 |
Â
} elseif ( $name ) {
|
373 |
Â
// Empty title, but we have the name
|
374 |
+
// translators: Placeholders refer to a widget name, and a sidebar name (e.g. "Archives", "Footer Area 1")
|
375 |
Â
$message = _x( '%1$s widget added to "%3$s"', '1: Name, 3: Sidebar Name', 'stream' );
|
376 |
Â
} elseif ( $title ) {
|
377 |
Â
// Likely a single widget since no name is available
|
378 |
+
// translators: Placeholders refer to a widget title, and a sidebar name (e.g. "Browse", "Footer Area 1")
|
379 |
Â
$message = _x( 'Unknown widget type named "%2$s" added to "%3$s"', '2: Title, 3: Sidebar Name', 'stream' );
|
380 |
Â
} else {
|
381 |
Â
// Neither a name nor a title are available, so use the widget ID
|
382 |
+
// translators: Placeholders refer to a widget ID, and a sidebar name (e.g. "42", "Footer Area 1")
|
383 |
Â
$message = _x( '%4$s widget added to "%3$s"', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
384 |
Â
}
|
385 |
Â
|
422 |
Â
$labels = $this->get_context_labels();
|
423 |
Â
$sidebar_name = isset( $labels[ $sidebar_id ] ) ? $labels[ $sidebar_id ] : $sidebar_id;
|
424 |
Â
$old_widget_ids = $old[ $sidebar_id ];
|
425 |
+
|
426 |
+
// translators: Placeholder refers to a sidebar name (e.g. "Footer Area 1")
|
427 |
+
$message = _x( 'Widgets reordered in "%s"', 'Sidebar name', 'stream' );
|
428 |
+
$message = sprintf( $message, $sidebar_name );
|
429 |
Â
|
430 |
Â
$this->log(
|
431 |
Â
$message,
|
479 |
Â
$new_sidebar_name = isset( $labels[ $new_sidebar_id ] ) ? $labels[ $new_sidebar_id ] : $new_sidebar_id;
|
480 |
Â
|
481 |
Â
if ( $name && $title ) {
|
482 |
+
// translators: Placeholders refer to a widget name, a widget title, a sidebar name, and another sidebar name (e.g. "Archives", "Browse", "Footer Area 1", "Footer Area 2")
|
483 |
Â
$message = _x( '%1$s widget named "%2$s" moved from "%4$s" to "%5$s"', '1: Name, 2: Title, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
484 |
Â
} elseif ( $name ) {
|
485 |
Â
// Empty title, but we have the name
|
486 |
+
// translators: Placeholders refer to a widget name, a sidebar name, and another sidebar name (e.g. "Archives", "Footer Area 1", "Footer Area 2")
|
487 |
Â
$message = _x( '%1$s widget moved from "%4$s" to "%5$s"', '1: Name, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
488 |
Â
} elseif ( $title ) {
|
489 |
Â
// Likely a single widget since no name is available
|
490 |
+
// translators: Placeholders refer to a widget title, a sidebar name, and another sidebar name (e.g. "Browse", "Footer Area 1", "Footer Area 2")
|
491 |
Â
$message = _x( 'Unknown widget type named "%2$s" moved from "%4$s" to "%5$s"', '2: Title, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
492 |
Â
} else {
|
493 |
Â
// Neither a name nor a title are available, so use the widget ID
|
494 |
+
// translators: Placeholders refer to a widget ID, a sidebar name, and another sidebar name (e.g. "42", "Footer Area 1", "Footer Area 2")
|
495 |
Â
$message = _x( '%3$s widget moved from "%4$s" to "%5$s"', '3: Widget ID, 4: Old Sidebar Name, 5: New Sidebar Name', 'stream' );
|
496 |
Â
}
|
497 |
Â
|
543 |
Â
$created_widget_numbers = array_diff( array_keys( $new_value ), array_keys( $old_value ) );
|
544 |
Â
|
545 |
Â
foreach ( $created_widget_numbers as $widget_number ) {
|
546 |
+
$instance = $new_value[ $widget_number ];
|
547 |
+
$widget_id = sprintf( $widget_id_format, $widget_number );
|
548 |
+
$name = $this->get_widget_name( $widget_id );
|
549 |
+
$title = ! empty( $instance['title'] ) ? $instance['title'] : null;
|
550 |
+
$sidebar_id = $this->get_widget_sidebar_id( $widget_id ); // @todo May not be assigned yet
|
551 |
Â
|
552 |
Â
$creates[] = compact( 'name', 'title', 'widget_id', 'sidebar_id', 'instance' );
|
553 |
Â
}
|
579 |
Â
$deleted_widget_numbers = array_diff( array_keys( $old_value ), array_keys( $new_value ) );
|
580 |
Â
|
581 |
Â
foreach ( $deleted_widget_numbers as $widget_number ) {
|
582 |
+
$instance = $old_value[ $widget_number ];
|
583 |
+
$widget_id = sprintf( $widget_id_format, $widget_number );
|
584 |
+
$name = $this->get_widget_name( $widget_id );
|
585 |
+
$title = ! empty( $instance['title'] ) ? $instance['title'] : null;
|
586 |
+
$sidebar_id = $this->get_widget_sidebar_id( $widget_id ); // @todo May not be assigned anymore
|
587 |
Â
|
588 |
Â
$deletes[] = compact( 'name', 'title', 'widget_id', 'sidebar_id', 'instance' );
|
589 |
Â
}
|
605 |
Â
*/
|
606 |
Â
foreach ( $updates as $update ) {
|
607 |
Â
if ( $update['name'] && $update['title'] ) {
|
608 |
+
// translators: Placeholders refer to a widget name, a widget title, and a sidebar name (e.g. "Archives", "Browse", "Footer Area 1")
|
609 |
Â
$message = _x( '%1$s widget named "%2$s" in "%3$s" updated', '1: Name, 2: Title, 3: Sidebar Name', 'stream' );
|
610 |
Â
} elseif ( $update['name'] ) {
|
611 |
Â
// Empty title, but we have the name
|
612 |
+
// translators: Placeholders refer to a widget name, and a sidebar name (e.g. "Archives", "Footer Area 1")
|
613 |
Â
$message = _x( '%1$s widget in "%3$s" updated', '1: Name, 3: Sidebar Name', 'stream' );
|
614 |
Â
} elseif ( $update['title'] ) {
|
615 |
Â
// Likely a single widget since no name is available
|
616 |
+
// translators: Placeholders refer to a widget title, and a sidebar name (e.g. "Browse", "Footer Area 1")
|
617 |
Â
$message = _x( 'Unknown widget type named "%2$s" in "%3$s" updated', '2: Title, 3: Sidebar Name', 'stream' );
|
618 |
Â
} else {
|
619 |
Â
// Neither a name nor a title are available, so use the widget ID
|
620 |
+
// translators: Placeholders refer to a widget ID, and a sidebar name (e.g. "42", "Footer Area 1")
|
621 |
Â
$message = _x( '%4$s widget in "%3$s" updated', '4: Widget ID, 3: Sidebar Name', 'stream' );
|
622 |
Â
}
|
623 |
Â
|
649 |
Â
*/
|
650 |
Â
foreach ( $creates as $create ) {
|
651 |
Â
if ( $create['name'] && $create['title'] ) {
|
652 |
+
// translators: Placeholders refer to a widget name, and a widget title (e.g. "Archives", "Browse")
|
653 |
Â
$message = _x( '%1$s widget named "%2$s" created', '1: Name, 2: Title', 'stream' );
|
654 |
Â
} elseif ( $create['name'] ) {
|
655 |
Â
// Empty title, but we have the name
|
656 |
+
// translators: Placeholder refers to a widget name (e.g. "Archives")
|
657 |
Â
$message = _x( '%1$s widget created', '1: Name', 'stream' );
|
658 |
Â
} elseif ( $create['title'] ) {
|
659 |
Â
// Likely a single widget since no name is available
|
660 |
+
// translators: Placeholder refers to a widget title (e.g. "Browse")
|
661 |
Â
$message = _x( 'Unknown widget type named "%2$s" created', '2: Title', 'stream' );
|
662 |
Â
} else {
|
663 |
Â
// Neither a name nor a title are available, so use the widget ID
|
664 |
+
// translators: Placeholder refers to a widget ID (e.g. "42")
|
665 |
Â
$message = _x( '%3$s widget created', '3: Widget ID', 'stream' );
|
666 |
Â
}
|
667 |
Â
|
683 |
Â
*/
|
684 |
Â
foreach ( $deletes as $delete ) {
|
685 |
Â
if ( $delete['name'] && $delete['title'] ) {
|
686 |
+
// translators: Placeholders refer to a widget name, and a widget title (e.g. "Archives", "Browse")
|
687 |
Â
$message = _x( '%1$s widget named "%2$s" deleted', '1: Name, 2: Title', 'stream' );
|
688 |
Â
} elseif ( $delete['name'] ) {
|
689 |
Â
// Empty title, but we have the name
|
690 |
+
// translators: Placeholder refers to a widget name (e.g. "Archives")
|
691 |
Â
$message = _x( '%1$s widget deleted', '1: Name', 'stream' );
|
692 |
Â
} elseif ( $delete['title'] ) {
|
693 |
Â
// Likely a single widget since no name is available
|
694 |
+
// translators: Placeholder refers to a widget title (e.g. "Browse")
|
695 |
Â
$message = _x( 'Unknown widget type named "%2$s" deleted', '2: Title', 'stream' );
|
696 |
Â
} else {
|
697 |
Â
// Neither a name nor a title are available, so use the widget ID
|
698 |
+
// translators: Placeholder refers to a widget ID (e.g. "42")
|
699 |
Â
$message = _x( '%3$s widget deleted', '3: Widget ID', 'stream' );
|
700 |
Â
}
|
701 |
Â
|
connectors/class-connector-woocommerce.php
CHANGED
@@ -114,7 +114,7 @@ class Connector_Woocommerce extends Connector {
|
|
114 |
Â
|
115 |
Â
if ( class_exists( 'Connector_Posts' ) ) {
|
116 |
Â
$posts_connector = new Connector_Posts();
|
117 |
-
$context_labels
|
118 |
Â
$context_labels,
|
119 |
Â
$posts_connector->get_context_labels()
|
120 |
Â
);
|
@@ -140,21 +140,21 @@ class Connector_Woocommerce extends Connector {
|
|
140 |
Â
*/
|
141 |
Â
public function get_custom_settings() {
|
142 |
Â
$custom_settings = array(
|
143 |
-
'woocommerce_frontend_css_colors'
|
144 |
Â
'title' => esc_html__( 'Frontend Styles', 'stream' ),
|
145 |
Â
'page' => 'wc-settings',
|
146 |
Â
'tab' => 'general',
|
147 |
Â
'section' => '',
|
148 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
149 |
Â
),
|
150 |
-
'woocommerce_default_gateway'
|
151 |
Â
'title' => esc_html__( 'Gateway Display Default', 'stream' ),
|
152 |
Â
'page' => 'wc-settings',
|
153 |
Â
'tab' => 'checkout',
|
154 |
Â
'section' => '',
|
155 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
156 |
Â
),
|
157 |
-
'woocommerce_gateway_order'
|
158 |
Â
'title' => esc_html__( 'Gateway Display Order', 'stream' ),
|
159 |
Â
'page' => 'wc-settings',
|
160 |
Â
'tab' => 'checkout',
|
@@ -168,28 +168,28 @@ class Connector_Woocommerce extends Connector {
|
|
168 |
Â
'section' => '',
|
169 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
170 |
Â
),
|
171 |
-
'woocommerce_shipping_method_order'
|
172 |
Â
'title' => esc_html__( 'Shipping Methods Order', 'stream' ),
|
173 |
Â
'page' => 'wc-settings',
|
174 |
Â
'tab' => 'shipping',
|
175 |
Â
'section' => '',
|
176 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
177 |
Â
),
|
178 |
-
'shipping_debug_mode'
|
179 |
Â
'title' => esc_html__( 'Shipping Debug Mode', 'stream' ),
|
180 |
Â
'page' => 'wc-status',
|
181 |
Â
'tab' => 'tools',
|
182 |
Â
'section' => '',
|
183 |
Â
'type' => esc_html__( 'tool', 'stream' ),
|
184 |
Â
),
|
185 |
-
'template_debug_mode'
|
186 |
Â
'title' => esc_html__( 'Template Debug Mode', 'stream' ),
|
187 |
Â
'page' => 'wc-status',
|
188 |
Â
'tab' => 'tools',
|
189 |
Â
'section' => '',
|
190 |
Â
'type' => esc_html__( 'tool', 'stream' ),
|
191 |
Â
),
|
192 |
-
'uninstall_data'
|
193 |
Â
'title' => esc_html__( 'Remove post types on uninstall', 'stream' ),
|
194 |
Â
'page' => 'wc-status',
|
195 |
Â
'tab' => 'tools',
|
@@ -213,14 +213,17 @@ class Connector_Woocommerce extends Connector {
|
|
213 |
Â
*/
|
214 |
Â
public function action_links( $links, $record ) {
|
215 |
Â
if ( in_array( $record->context, $this->post_types, true ) && get_post( $record->object_id ) ) {
|
216 |
-
|
Â
|
|
217 |
Â
$posts_connector = new Connector_Posts();
|
218 |
-
$post_type_name
|
219 |
-
|
Â
|
|
220 |
Â
}
|
221 |
Â
|
222 |
-
|
223 |
-
|
Â
|
|
224 |
Â
}
|
225 |
Â
}
|
226 |
Â
|
@@ -231,9 +234,14 @@ class Connector_Woocommerce extends Connector {
|
|
231 |
Â
$option_section = $record->get_meta( 'section', true );
|
232 |
Â
|
233 |
Â
if ( $option_key && $option_tab ) {
|
Â
|
|
234 |
Â
$text = sprintf( esc_html__( 'Edit WooCommerce %s', 'stream' ), $context_labels[ $record->context ] );
|
235 |
Â
$url = add_query_arg(
|
236 |
-
array(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
237 |
Â
admin_url( 'admin.php' ) // Not self_admin_url here, as WooCommerce doesn't exist in Network Admin
|
238 |
Â
);
|
239 |
Â
|
@@ -308,6 +316,7 @@ class Connector_Woocommerce extends Connector {
|
|
308 |
Â
if ( in_array( $new, array( 'auto-draft', 'draft', 'inherit' ), true ) ) {
|
309 |
Â
return;
|
310 |
Â
} elseif ( 'auto-draft' === $old && 'publish' === $new ) {
|
Â
|
|
311 |
Â
$message = esc_html_x(
|
312 |
Â
'%s created',
|
313 |
Â
'Order title',
|
@@ -315,6 +324,7 @@ class Connector_Woocommerce extends Connector {
|
|
315 |
Â
);
|
316 |
Â
$action = 'created';
|
317 |
Â
} elseif ( 'trash' === $new ) {
|
Â
|
|
318 |
Â
$message = esc_html_x(
|
319 |
Â
'%s trashed',
|
320 |
Â
'Order title',
|
@@ -322,6 +332,7 @@ class Connector_Woocommerce extends Connector {
|
|
322 |
Â
);
|
323 |
Â
$action = 'trashed';
|
324 |
Â
} elseif ( 'trash' === $old && 'publish' === $new ) {
|
Â
|
|
325 |
Â
$message = esc_html_x(
|
326 |
Â
'%s restored from the trash',
|
327 |
Â
'Order title',
|
@@ -329,6 +340,7 @@ class Connector_Woocommerce extends Connector {
|
|
329 |
Â
);
|
330 |
Â
$action = 'untrashed';
|
331 |
Â
} else {
|
Â
|
|
332 |
Â
$message = esc_html_x(
|
333 |
Â
'%s updated',
|
334 |
Â
'Order title',
|
@@ -386,6 +398,7 @@ class Connector_Woocommerce extends Connector {
|
|
386 |
Â
$order_type_name = esc_html__( 'order', 'stream' );
|
387 |
Â
|
388 |
Â
$this->log(
|
Â
|
|
389 |
Â
_x(
|
390 |
Â
'"%s" deleted from trash',
|
391 |
Â
'Order title',
|
@@ -425,12 +438,13 @@ class Connector_Woocommerce extends Connector {
|
|
425 |
Â
$old_status_name = wc_get_order_status_name( $old );
|
426 |
Â
$new_status_name = wc_get_order_status_name( $new );
|
427 |
Â
} else {
|
428 |
-
$old_status
|
429 |
-
$new_status
|
430 |
Â
$new_status_name = $new_status->name;
|
431 |
Â
$old_status_name = $old_status->name;
|
432 |
Â
}
|
433 |
Â
|
Â
|
|
434 |
Â
$message = esc_html_x(
|
435 |
Â
'%1$s status changed from %2$s to %3$s',
|
436 |
Â
'1. Order title, 2. Old status, 3. New status',
|
@@ -468,6 +482,7 @@ class Connector_Woocommerce extends Connector {
|
|
468 |
Â
*/
|
469 |
Â
public function callback_woocommerce_attribute_added( $attribute_id, $attribute ) {
|
470 |
Â
$this->log(
|
Â
|
|
471 |
Â
_x(
|
472 |
Â
'"%s" product attribute created',
|
473 |
Â
'Term name',
|
@@ -490,6 +505,7 @@ class Connector_Woocommerce extends Connector {
|
|
490 |
Â
*/
|
491 |
Â
public function callback_woocommerce_attribute_updated( $attribute_id, $attribute ) {
|
492 |
Â
$this->log(
|
Â
|
|
493 |
Â
_x(
|
494 |
Â
'"%s" product attribute updated',
|
495 |
Â
'Term name',
|
@@ -512,6 +528,7 @@ class Connector_Woocommerce extends Connector {
|
|
512 |
Â
*/
|
513 |
Â
public function callback_woocommerce_attribute_deleted( $attribute_id, $attribute_name ) {
|
514 |
Â
$this->log(
|
Â
|
|
515 |
Â
_x(
|
516 |
Â
'"%s" product attribute deleted',
|
517 |
Â
'Term name',
|
@@ -536,6 +553,7 @@ class Connector_Woocommerce extends Connector {
|
|
536 |
Â
*/
|
537 |
Â
public function callback_woocommerce_tax_rate_added( $tax_rate_id, $tax_rate ) {
|
538 |
Â
$this->log(
|
Â
|
|
539 |
Â
_x(
|
540 |
Â
'"%4$s" tax rate created',
|
541 |
Â
'Tax rate name',
|
@@ -558,6 +576,7 @@ class Connector_Woocommerce extends Connector {
|
|
558 |
Â
*/
|
559 |
Â
public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) {
|
560 |
Â
$this->log(
|
Â
|
|
561 |
Â
_x(
|
562 |
Â
'"%4$s" tax rate updated',
|
563 |
Â
'Tax rate name',
|
@@ -590,6 +609,7 @@ class Connector_Woocommerce extends Connector {
|
|
590 |
Â
);
|
591 |
Â
|
592 |
Â
$this->log(
|
Â
|
|
593 |
Â
_x(
|
594 |
Â
'"%s" tax rate deleted',
|
595 |
Â
'Tax rate name',
|
@@ -651,6 +671,7 @@ class Connector_Woocommerce extends Connector {
|
|
651 |
Â
}
|
652 |
Â
|
653 |
Â
$this->log(
|
Â
|
|
654 |
Â
__( '"%1$s" %2$s updated', 'stream' ),
|
655 |
Â
array(
|
656 |
Â
'label' => $this->settings[ $option ]['title'],
|
@@ -679,8 +700,9 @@ class Connector_Woocommerce extends Connector {
|
|
679 |
Â
}
|
680 |
Â
|
681 |
Â
$settings_cache_key = 'stream_connector_woocommerce_settings_' . sanitize_key( WC_VERSION );
|
Â
|
|
682 |
Â
|
683 |
-
if ( $settings_transient
|
684 |
Â
$settings = $settings_transient['settings'];
|
685 |
Â
$settings_pages = $settings_transient['settings_pages'];
|
686 |
Â
} else {
|
@@ -715,7 +737,7 @@ class Connector_Woocommerce extends Connector {
|
|
715 |
Â
);
|
716 |
Â
|
717 |
Â
foreach ( $_fields as $field ) {
|
718 |
-
$title
|
719 |
Â
$fields[ $field['id'] ] = array(
|
720 |
Â
'title' => $title,
|
721 |
Â
'page' => 'wc-settings',
|
@@ -731,9 +753,11 @@ class Connector_Woocommerce extends Connector {
|
|
731 |
Â
}
|
732 |
Â
|
733 |
Â
// Provide additional context for each of the settings pages
|
734 |
-
array_walk(
|
735 |
-
$
|
736 |
-
|
Â
|
|
Â
|
|
737 |
Â
|
738 |
Â
// Load Payment Gateway Settings
|
739 |
Â
$payment_gateway_settings = array();
|
114 |
Â
|
115 |
Â
if ( class_exists( 'Connector_Posts' ) ) {
|
116 |
Â
$posts_connector = new Connector_Posts();
|
117 |
+
$context_labels = array_merge(
|
118 |
Â
$context_labels,
|
119 |
Â
$posts_connector->get_context_labels()
|
120 |
Â
);
|
140 |
Â
*/
|
141 |
Â
public function get_custom_settings() {
|
142 |
Â
$custom_settings = array(
|
143 |
+
'woocommerce_frontend_css_colors' => array(
|
144 |
Â
'title' => esc_html__( 'Frontend Styles', 'stream' ),
|
145 |
Â
'page' => 'wc-settings',
|
146 |
Â
'tab' => 'general',
|
147 |
Â
'section' => '',
|
148 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
149 |
Â
),
|
150 |
+
'woocommerce_default_gateway' => array(
|
151 |
Â
'title' => esc_html__( 'Gateway Display Default', 'stream' ),
|
152 |
Â
'page' => 'wc-settings',
|
153 |
Â
'tab' => 'checkout',
|
154 |
Â
'section' => '',
|
155 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
156 |
Â
),
|
157 |
+
'woocommerce_gateway_order' => array(
|
158 |
Â
'title' => esc_html__( 'Gateway Display Order', 'stream' ),
|
159 |
Â
'page' => 'wc-settings',
|
160 |
Â
'tab' => 'checkout',
|
168 |
Â
'section' => '',
|
169 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
170 |
Â
),
|
171 |
+
'woocommerce_shipping_method_order' => array(
|
172 |
Â
'title' => esc_html__( 'Shipping Methods Order', 'stream' ),
|
173 |
Â
'page' => 'wc-settings',
|
174 |
Â
'tab' => 'shipping',
|
175 |
Â
'section' => '',
|
176 |
Â
'type' => esc_html__( 'setting', 'stream' ),
|
177 |
Â
),
|
178 |
+
'shipping_debug_mode' => array(
|
179 |
Â
'title' => esc_html__( 'Shipping Debug Mode', 'stream' ),
|
180 |
Â
'page' => 'wc-status',
|
181 |
Â
'tab' => 'tools',
|
182 |
Â
'section' => '',
|
183 |
Â
'type' => esc_html__( 'tool', 'stream' ),
|
184 |
Â
),
|
185 |
+
'template_debug_mode' => array(
|
186 |
Â
'title' => esc_html__( 'Template Debug Mode', 'stream' ),
|
187 |
Â
'page' => 'wc-status',
|
188 |
Â
'tab' => 'tools',
|
189 |
Â
'section' => '',
|
190 |
Â
'type' => esc_html__( 'tool', 'stream' ),
|
191 |
Â
),
|
192 |
+
'uninstall_data' => array(
|
193 |
Â
'title' => esc_html__( 'Remove post types on uninstall', 'stream' ),
|
194 |
Â
'page' => 'wc-status',
|
195 |
Â
'tab' => 'tools',
|
213 |
Â
*/
|
214 |
Â
public function action_links( $links, $record ) {
|
215 |
Â
if ( in_array( $record->context, $this->post_types, true ) && get_post( $record->object_id ) ) {
|
216 |
+
$edit_post_link = get_edit_post_link( $record->object_id );
|
217 |
+
if ( $edit_post_link ) {
|
218 |
Â
$posts_connector = new Connector_Posts();
|
219 |
+
$post_type_name = $posts_connector->get_post_type_name( get_post_type( $record->object_id ) );
|
220 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
221 |
+
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $edit_post_link;
|
222 |
Â
}
|
223 |
Â
|
224 |
+
$permalink = get_permalink( $record->object_id );
|
225 |
+
if ( post_type_exists( get_post_type( $record->object_id ) ) && $permalink ) {
|
226 |
+
$links[ esc_html__( 'View', 'stream' ) ] = $permalink;
|
227 |
Â
}
|
228 |
Â
}
|
229 |
Â
|
234 |
Â
$option_section = $record->get_meta( 'section', true );
|
235 |
Â
|
236 |
Â
if ( $option_key && $option_tab ) {
|
237 |
+
// translators: Placeholder refers to a context (e.g. "Attribute")
|
238 |
Â
$text = sprintf( esc_html__( 'Edit WooCommerce %s', 'stream' ), $context_labels[ $record->context ] );
|
239 |
Â
$url = add_query_arg(
|
240 |
+
array(
|
241 |
+
'page' => $option_page,
|
242 |
+
'tab' => $option_tab,
|
243 |
+
'section' => $option_section,
|
244 |
+
),
|
245 |
Â
admin_url( 'admin.php' ) // Not self_admin_url here, as WooCommerce doesn't exist in Network Admin
|
246 |
Â
);
|
247 |
Â
|
316 |
Â
if ( in_array( $new, array( 'auto-draft', 'draft', 'inherit' ), true ) ) {
|
317 |
Â
return;
|
318 |
Â
} elseif ( 'auto-draft' === $old && 'publish' === $new ) {
|
319 |
+
// translators: Placeholder refers to an order title (e.g. "Order #42")
|
320 |
Â
$message = esc_html_x(
|
321 |
Â
'%s created',
|
322 |
Â
'Order title',
|
324 |
Â
);
|
325 |
Â
$action = 'created';
|
326 |
Â
} elseif ( 'trash' === $new ) {
|
327 |
+
// translators: Placeholder refers to an order title (e.g. "Order #42")
|
328 |
Â
$message = esc_html_x(
|
329 |
Â
'%s trashed',
|
330 |
Â
'Order title',
|
332 |
Â
);
|
333 |
Â
$action = 'trashed';
|
334 |
Â
} elseif ( 'trash' === $old && 'publish' === $new ) {
|
335 |
+
// translators: Placeholder refers to an order title (e.g. "Order #42")
|
336 |
Â
$message = esc_html_x(
|
337 |
Â
'%s restored from the trash',
|
338 |
Â
'Order title',
|
340 |
Â
);
|
341 |
Â
$action = 'untrashed';
|
342 |
Â
} else {
|
343 |
+
// translators: Placeholder refers to an order title (e.g. "Order #42")
|
344 |
Â
$message = esc_html_x(
|
345 |
Â
'%s updated',
|
346 |
Â
'Order title',
|
398 |
Â
$order_type_name = esc_html__( 'order', 'stream' );
|
399 |
Â
|
400 |
Â
$this->log(
|
401 |
+
// translators: Placeholder refers to an order title (e.g. "Order #42")
|
402 |
Â
_x(
|
403 |
Â
'"%s" deleted from trash',
|
404 |
Â
'Order title',
|
438 |
Â
$old_status_name = wc_get_order_status_name( $old );
|
439 |
Â
$new_status_name = wc_get_order_status_name( $new );
|
440 |
Â
} else {
|
441 |
+
$old_status = wp_stream_is_vip() ? wpcom_vip_get_term_by( 'slug', $old, 'shop_order_status' ) : get_term_by( 'slug', $old, 'shop_order_status' );
|
442 |
+
$new_status = wp_stream_is_vip() ? wpcom_vip_get_term_by( 'slug', $new, 'shop_order_status' ) : get_term_by( 'slug', $new, 'shop_order_status' );
|
443 |
Â
$new_status_name = $new_status->name;
|
444 |
Â
$old_status_name = $old_status->name;
|
445 |
Â
}
|
446 |
Â
|
447 |
+
// translators: Placeholders refer to an order title, and order status, and another order status (e.g. "Order #42", "processing", "complete")
|
448 |
Â
$message = esc_html_x(
|
449 |
Â
'%1$s status changed from %2$s to %3$s',
|
450 |
Â
'1. Order title, 2. Old status, 3. New status',
|
482 |
Â
*/
|
483 |
Â
public function callback_woocommerce_attribute_added( $attribute_id, $attribute ) {
|
484 |
Â
$this->log(
|
485 |
+
// translators: Placeholder refers to a term name (e.g. "color")
|
486 |
Â
_x(
|
487 |
Â
'"%s" product attribute created',
|
488 |
Â
'Term name',
|
505 |
Â
*/
|
506 |
Â
public function callback_woocommerce_attribute_updated( $attribute_id, $attribute ) {
|
507 |
Â
$this->log(
|
508 |
+
// translators: Placeholder refers to a term name (e.g. "color")
|
509 |
Â
_x(
|
510 |
Â
'"%s" product attribute updated',
|
511 |
Â
'Term name',
|
528 |
Â
*/
|
529 |
Â
public function callback_woocommerce_attribute_deleted( $attribute_id, $attribute_name ) {
|
530 |
Â
$this->log(
|
531 |
+
// translators: Placeholder refers to a term name (e.g. "color")
|
532 |
Â
_x(
|
533 |
Â
'"%s" product attribute deleted',
|
534 |
Â
'Term name',
|
553 |
Â
*/
|
554 |
Â
public function callback_woocommerce_tax_rate_added( $tax_rate_id, $tax_rate ) {
|
555 |
Â
$this->log(
|
556 |
+
// translators: Placeholder refers to a tax rate name (e.g. "GST")
|
557 |
Â
_x(
|
558 |
Â
'"%4$s" tax rate created',
|
559 |
Â
'Tax rate name',
|
576 |
Â
*/
|
577 |
Â
public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) {
|
578 |
Â
$this->log(
|
579 |
+
// translators: Placeholder refers to a tax rate name (e.g. "GST")
|
580 |
Â
_x(
|
581 |
Â
'"%4$s" tax rate updated',
|
582 |
Â
'Tax rate name',
|
609 |
Â
);
|
610 |
Â
|
611 |
Â
$this->log(
|
612 |
+
// translators: Placeholder refers to a tax rate name (e.g. "GST")
|
613 |
Â
_x(
|
614 |
Â
'"%s" tax rate deleted',
|
615 |
Â
'Tax rate name',
|
671 |
Â
}
|
672 |
Â
|
673 |
Â
$this->log(
|
674 |
+
// translators: Placeholders refer to a setting name and a setting type (e.g. "Direct Deposit", "Payment Method")
|
675 |
Â
__( '"%1$s" %2$s updated', 'stream' ),
|
676 |
Â
array(
|
677 |
Â
'label' => $this->settings[ $option ]['title'],
|
700 |
Â
}
|
701 |
Â
|
702 |
Â
$settings_cache_key = 'stream_connector_woocommerce_settings_' . sanitize_key( WC_VERSION );
|
703 |
+
$settings_transient = get_transient( $settings_cache_key );
|
704 |
Â
|
705 |
+
if ( $settings_transient ) {
|
706 |
Â
$settings = $settings_transient['settings'];
|
707 |
Â
$settings_pages = $settings_transient['settings_pages'];
|
708 |
Â
} else {
|
737 |
Â
);
|
738 |
Â
|
739 |
Â
foreach ( $_fields as $field ) {
|
740 |
+
$title = isset( $field['title'] ) ? $field['title'] : ( isset( $field['desc'] ) ? $field['desc'] : 'N/A' );
|
741 |
Â
$fields[ $field['id'] ] = array(
|
742 |
Â
'title' => $title,
|
743 |
Â
'page' => 'wc-settings',
|
753 |
Â
}
|
754 |
Â
|
755 |
Â
// Provide additional context for each of the settings pages
|
756 |
+
array_walk(
|
757 |
+
$settings_pages, function( &$value ) {
|
758 |
+
$value .= ' ' . esc_html__( 'Settings', 'stream' );
|
759 |
+
}
|
760 |
+
);
|
761 |
Â
|
762 |
Â
// Load Payment Gateway Settings
|
763 |
Â
$payment_gateway_settings = array();
|
connectors/class-connector-wordpress-seo.php
CHANGED
@@ -111,7 +111,8 @@ class Connector_WordPress_SEO extends Connector {
|
|
111 |
Â
*/
|
112 |
Â
public function action_links( $links, $record ) {
|
113 |
Â
// Options
|
114 |
-
|
Â
|
|
115 |
Â
$key = $record->get_meta( 'option_key', true );
|
116 |
Â
|
117 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = add_query_arg(
|
@@ -132,7 +133,7 @@ class Connector_WordPress_SEO extends Connector {
|
|
132 |
Â
|
133 |
Â
if ( $post ) {
|
134 |
Â
$posts_connector = new Connector_Posts();
|
135 |
-
$post_type_name
|
136 |
Â
|
137 |
Â
if ( 'trash' === $post->post_status ) {
|
138 |
Â
$untrash = wp_nonce_url(
|
@@ -157,16 +158,21 @@ class Connector_WordPress_SEO extends Connector {
|
|
157 |
Â
sprintf( 'delete-post_%d', $post->ID )
|
158 |
Â
);
|
159 |
Â
|
Â
|
|
160 |
Â
$links[ sprintf( esc_html_x( 'Restore %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $untrash;
|
Â
|
|
161 |
Â
$links[ sprintf( esc_html_x( 'Delete %s Permenantly', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
|
162 |
Â
} else {
|
Â
|
|
163 |
Â
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = get_edit_post_link( $post->ID );
|
164 |
Â
|
165 |
-
|
Â
|
|
166 |
Â
$links[ esc_html__( 'View', 'stream' ) ] = $view_link;
|
167 |
Â
}
|
168 |
Â
|
169 |
-
|
Â
|
|
170 |
Â
$links[ esc_html__( 'Revision', 'stream' ) ] = get_edit_post_link( $revision_id );
|
171 |
Â
}
|
172 |
Â
}
|
@@ -186,7 +192,7 @@ class Connector_WordPress_SEO extends Connector {
|
|
186 |
Â
/* @var $class WPSEO_Options */
|
187 |
Â
$this->option_groups[ $class::get_instance()->group_name ] = array(
|
188 |
Â
'class' => $class,
|
189 |
-
'name'
|
190 |
Â
);
|
191 |
Â
}
|
192 |
Â
|
@@ -197,7 +203,7 @@ class Connector_WordPress_SEO extends Connector {
|
|
197 |
Â
public function admin_enqueue_scripts( $hook ) {
|
198 |
Â
if ( 0 === strpos( $hook, 'seo_page_' ) ) {
|
199 |
Â
$stream = wp_stream_get_instance();
|
200 |
-
$src
|
201 |
Â
wp_enqueue_script( 'stream-connector-wpseo', $src, array( 'jquery' ), $stream->get_version() );
|
202 |
Â
}
|
203 |
Â
}
|
@@ -222,12 +228,13 @@ class Connector_WordPress_SEO extends Connector {
|
|
222 |
Â
if ( isset( $opts[ $key ] ) ) {
|
223 |
Â
$this->log(
|
224 |
Â
sprintf(
|
Â
|
|
225 |
Â
__( 'Imported settings from %1$s%2$s', 'stream' ),
|
226 |
Â
$name,
|
227 |
Â
isset( $opts['deleteolddata'] ) ? esc_html__( ', and deleted old data', 'stream' ) : ''
|
228 |
Â
),
|
229 |
Â
array(
|
230 |
-
'key'
|
231 |
Â
'deleteolddata' => isset( $opts['deleteolddata'] ),
|
232 |
Â
),
|
233 |
Â
null,
|
@@ -244,6 +251,7 @@ class Connector_WordPress_SEO extends Connector {
|
|
244 |
Â
if ( wp_stream_filter_input( INPUT_POST, 'wpseo_export' ) ) {
|
245 |
Â
$this->log(
|
246 |
Â
sprintf(
|
Â
|
|
247 |
Â
__( 'Exported settings%s', 'stream' ),
|
248 |
Â
isset( $opts['include_taxonomy_meta'] ) ? esc_html__( ', including taxonomy meta', 'stream' ) : ''
|
249 |
Â
),
|
@@ -257,6 +265,7 @@ class Connector_WordPress_SEO extends Connector {
|
|
257 |
Â
} elseif ( isset( $_FILES['settings_import_file']['name'] ) ) { // phpcs: input var okay
|
258 |
Â
$this->log(
|
259 |
Â
sprintf(
|
Â
|
|
260 |
Â
__( 'Tried importing settings from "%s"', 'stream' ),
|
261 |
Â
sanitize_text_field( wp_unslash( $_FILES['settings_import_file']['name'] ) ) // phpcs: input var okay
|
262 |
Â
),
|
@@ -330,17 +339,16 @@ class Connector_WordPress_SEO extends Connector {
|
|
330 |
Â
|
331 |
Â
$this->log(
|
332 |
Â
sprintf(
|
Â
|
|
333 |
Â
__( 'Updated "%1$s" of "%2$s" %3$s', 'stream' ),
|
334 |
Â
$field['title'],
|
335 |
Â
$post->post_title,
|
336 |
Â
$post_type_label
|
337 |
Â
),
|
338 |
Â
array(
|
339 |
-
|
340 |
-
'meta_key' => $meta_key,
|
341 |
Â
'meta_value' => $meta_value,
|
342 |
-
|
343 |
-
'post_type' => $post->post_type,
|
344 |
Â
),
|
345 |
Â
$object_id,
|
346 |
Â
'wpseo_meta',
|
@@ -374,7 +382,9 @@ class Connector_WordPress_SEO extends Connector {
|
|
374 |
Â
return $data;
|
375 |
Â
}
|
376 |
Â
|
377 |
-
|
Â
|
|
Â
|
|
378 |
Â
$data['message'] = esc_html__( '%s settings updated', 'stream' );
|
379 |
Â
$label = $labels[ $page ];
|
380 |
Â
}
|
@@ -391,75 +401,75 @@ class Connector_WordPress_SEO extends Connector {
|
|
391 |
Â
private function settings_labels( $option ) {
|
392 |
Â
$labels = array(
|
393 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/dashboard.php:
|
394 |
-
'yoast_tracking'
|
395 |
-
'disableadvanced_meta'
|
396 |
-
'alexaverify'
|
397 |
-
'msverify'
|
398 |
-
'googleverify'
|
399 |
-
'pinterestverify'
|
400 |
-
'yandexverify'
|
401 |
Â
|
402 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/advanced.php:
|
403 |
-
'breadcrumbs-enable'
|
404 |
-
'breadcrumbs-sep'
|
405 |
-
'breadcrumbs-home'
|
406 |
-
'breadcrumbs-prefix'
|
407 |
-
'breadcrumbs-archiveprefix'
|
408 |
-
'breadcrumbs-searchprefix'
|
409 |
-
'breadcrumbs-404crumb'
|
410 |
-
'breadcrumbs-blog-remove'
|
411 |
-
'breadcrumbs-boldlast'
|
412 |
-
'post_types-post-maintax'
|
413 |
Â
|
414 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/metas.php:
|
415 |
-
'forcerewritetitle'
|
416 |
-
'noindex-subpages-wpseo'
|
417 |
-
'usemetakeywords'
|
418 |
-
'noodp'
|
419 |
-
'noydir'
|
420 |
-
'hide-rsdlink'
|
421 |
-
'hide-wlwmanifest'
|
422 |
-
'hide-shortlink'
|
423 |
-
'hide-feedlinks'
|
424 |
-
'disable-author'
|
425 |
-
'disable-date'
|
426 |
Â
|
427 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/network.php:
|
428 |
-
'access'
|
429 |
-
'defaultblog'
|
430 |
-
'restoreblog'
|
431 |
Â
|
432 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/permalinks.php:
|
433 |
-
'stripcategorybase'
|
434 |
-
'trailingslash'
|
435 |
-
'cleanslugs'
|
436 |
-
'redirectattachment'
|
437 |
-
'cleanreplytocom'
|
438 |
-
'cleanpermalinks'
|
439 |
-
'force_transport'
|
440 |
-
'cleanpermalink-googlesitesearch'
|
441 |
-
'cleanpermalink-googlecampaign'
|
442 |
-
'cleanpermalink-extravars'
|
443 |
Â
|
444 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/social.php:
|
445 |
-
'opengraph'
|
446 |
-
'facebook_site'
|
447 |
-
'instagram_url'
|
448 |
-
'linkedin_url'
|
449 |
-
'myspace_url'
|
450 |
-
'pinterest_url'
|
451 |
-
'youtube_url'
|
452 |
-
'google_plus_url'
|
453 |
-
'og_frontpage_image'
|
454 |
-
'og_frontpage_desc'
|
455 |
-
'og_frontpage_title'
|
456 |
-
'og_default_image'
|
457 |
-
'twitter'
|
458 |
-
'twitter_site'
|
459 |
-
'twitter_card_type'
|
460 |
-
'googleplus'
|
461 |
-
'plus-publisher'
|
462 |
-
'fbadminapp'
|
463 |
Â
|
464 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/xml-sitemaps.php:
|
465 |
Â
'enablexmlsitemap' => esc_html_x( 'Check this box to enable XML sitemap functionality.', 'wordpress-seo', 'stream' ), # type = checkbox
|
@@ -481,8 +491,8 @@ class Connector_WordPress_SEO extends Connector {
|
|
481 |
Â
'taxonomies-post_tag-not_in_sitemap' => _x( 'Taxonomies Tags (<code>post_tag</code>)', 'wordpress-seo', 'stream' ), # type = checkbox
|
482 |
Â
|
483 |
Â
// Added manually
|
484 |
-
'rssbefore'
|
485 |
-
'rssafter'
|
486 |
Â
);
|
487 |
Â
|
488 |
Â
$ast_labels = array(
|
111 |
Â
*/
|
112 |
Â
public function action_links( $links, $record ) {
|
113 |
Â
// Options
|
114 |
+
$option = $record->get_meta( 'option', true );
|
115 |
+
if ( $option ) {
|
116 |
Â
$key = $record->get_meta( 'option_key', true );
|
117 |
Â
|
118 |
Â
$links[ esc_html__( 'Edit', 'stream' ) ] = add_query_arg(
|
133 |
Â
|
134 |
Â
if ( $post ) {
|
135 |
Â
$posts_connector = new Connector_Posts();
|
136 |
+
$post_type_name = $posts_connector->get_post_type_name( get_post_type( $post->ID ) );
|
137 |
Â
|
138 |
Â
if ( 'trash' === $post->post_status ) {
|
139 |
Â
$untrash = wp_nonce_url(
|
158 |
Â
sprintf( 'delete-post_%d', $post->ID )
|
159 |
Â
);
|
160 |
Â
|
161 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
162 |
Â
$links[ sprintf( esc_html_x( 'Restore %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = $untrash;
|
163 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
164 |
Â
$links[ sprintf( esc_html_x( 'Delete %s Permenantly', 'Post type singular name', 'stream' ), $post_type_name ) ] = $delete;
|
165 |
Â
} else {
|
166 |
+
// translators: Placeholder refers to a post type singular name (e.g. "Post")
|
167 |
Â
$links[ sprintf( esc_html_x( 'Edit %s', 'Post type singular name', 'stream' ), $post_type_name ) ] = get_edit_post_link( $post->ID );
|
168 |
Â
|
169 |
+
$view_link = get_permalink( $post->ID );
|
170 |
+
if ( $view_link ) {
|
171 |
Â
$links[ esc_html__( 'View', 'stream' ) ] = $view_link;
|
172 |
Â
}
|
173 |
Â
|
174 |
+
$revision_id = $record->get_meta( 'revision_id', true );
|
175 |
+
if ( $revision_id ) {
|
176 |
Â
$links[ esc_html__( 'Revision', 'stream' ) ] = get_edit_post_link( $revision_id );
|
177 |
Â
}
|
178 |
Â
}
|
192 |
Â
/* @var $class WPSEO_Options */
|
193 |
Â
$this->option_groups[ $class::get_instance()->group_name ] = array(
|
194 |
Â
'class' => $class,
|
195 |
+
'name' => $class::get_instance()->option_name,
|
196 |
Â
);
|
197 |
Â
}
|
198 |
Â
|
203 |
Â
public function admin_enqueue_scripts( $hook ) {
|
204 |
Â
if ( 0 === strpos( $hook, 'seo_page_' ) ) {
|
205 |
Â
$stream = wp_stream_get_instance();
|
206 |
+
$src = $stream->locations['url'] . '/ui/js/wpseo-admin.js';
|
207 |
Â
wp_enqueue_script( 'stream-connector-wpseo', $src, array( 'jquery' ), $stream->get_version() );
|
208 |
Â
}
|
209 |
Â
}
|
228 |
Â
if ( isset( $opts[ $key ] ) ) {
|
229 |
Â
$this->log(
|
230 |
Â
sprintf(
|
231 |
+
// translators: Placeholders refer to an import method, and an extra string (sometimes blank) (e.g. "HeadSpace2", ", and deleted old data")
|
232 |
Â
__( 'Imported settings from %1$s%2$s', 'stream' ),
|
233 |
Â
$name,
|
234 |
Â
isset( $opts['deleteolddata'] ) ? esc_html__( ', and deleted old data', 'stream' ) : ''
|
235 |
Â
),
|
236 |
Â
array(
|
237 |
+
'key' => $key,
|
238 |
Â
'deleteolddata' => isset( $opts['deleteolddata'] ),
|
239 |
Â
),
|
240 |
Â
null,
|
251 |
Â
if ( wp_stream_filter_input( INPUT_POST, 'wpseo_export' ) ) {
|
252 |
Â
$this->log(
|
253 |
Â
sprintf(
|
254 |
+
// translators: Placeholder refers to an extra string (sometimes blank) (e.g. ", including taxonomy meta")
|
255 |
Â
__( 'Exported settings%s', 'stream' ),
|
256 |
Â
isset( $opts['include_taxonomy_meta'] ) ? esc_html__( ', including taxonomy meta', 'stream' ) : ''
|
257 |
Â
),
|
265 |
Â
} elseif ( isset( $_FILES['settings_import_file']['name'] ) ) { // phpcs: input var okay
|
266 |
Â
$this->log(
|
267 |
Â
sprintf(
|
268 |
+
// translators: Placeholder refers to a filename (e.g. "test.xml")
|
269 |
Â
__( 'Tried importing settings from "%s"', 'stream' ),
|
270 |
Â
sanitize_text_field( wp_unslash( $_FILES['settings_import_file']['name'] ) ) // phpcs: input var okay
|
271 |
Â
),
|
339 |
Â
|
340 |
Â
$this->log(
|
341 |
Â
sprintf(
|
342 |
+
// translators: Placeholders refer to a meta field title, a post title, and a post type (e.g. "Description", "Hello World", "Post")
|
343 |
Â
__( 'Updated "%1$s" of "%2$s" %3$s', 'stream' ),
|
344 |
Â
$field['title'],
|
345 |
Â
$post->post_title,
|
346 |
Â
$post_type_label
|
347 |
Â
),
|
348 |
Â
array(
|
349 |
+
'meta_key' => $meta_key,
|
Â
|
|
350 |
Â
'meta_value' => $meta_value,
|
351 |
+
'post_type' => $post->post_type,
|
Â
|
|
352 |
Â
),
|
353 |
Â
$object_id,
|
354 |
Â
'wpseo_meta',
|
382 |
Â
return $data;
|
383 |
Â
}
|
384 |
Â
|
385 |
+
$label = $this->settings_labels( $data['args']['option_key'] );
|
386 |
+
if ( ! $label ) {
|
387 |
+
// translators: Placeholder refers to a context (e.g. "Dashboard")
|
388 |
Â
$data['message'] = esc_html__( '%s settings updated', 'stream' );
|
389 |
Â
$label = $labels[ $page ];
|
390 |
Â
}
|
401 |
Â
private function settings_labels( $option ) {
|
402 |
Â
$labels = array(
|
403 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/dashboard.php:
|
404 |
+
'yoast_tracking' => esc_html_x( "Allow tracking of this WordPress install's anonymous data.", 'wordpress-seo', 'stream' ), # type = checkbox
|
405 |
+
'disableadvanced_meta' => esc_html_x( 'Disable the Advanced part of the WordPress SEO meta box', 'wordpress-seo', 'stream' ), # type = checkbox
|
406 |
+
'alexaverify' => esc_html_x( 'Alexa Verification ID', 'wordpress-seo', 'stream' ), # type = textinput
|
407 |
+
'msverify' => esc_html_x( 'Bing Webmaster Tools', 'wordpress-seo', 'stream' ), # type = textinput
|
408 |
+
'googleverify' => esc_html_x( 'Google Webmaster Tools', 'wordpress-seo', 'stream' ), # type = textinput
|
409 |
+
'pinterestverify' => esc_html_x( 'Pinterest', 'wordpress-seo', 'stream' ), # type = textinput
|
410 |
+
'yandexverify' => esc_html_x( 'Yandex Webmaster Tools', 'wordpress-seo', 'stream' ), # type = textinput
|
411 |
Â
|
412 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/advanced.php:
|
413 |
+
'breadcrumbs-enable' => esc_html_x( 'Enable Breadcrumbs', 'wordpress-seo', 'stream' ), # type = checkbox
|
414 |
+
'breadcrumbs-sep' => esc_html_x( 'Separator between breadcrumbs', 'wordpress-seo', 'stream' ), # type = textinput
|
415 |
+
'breadcrumbs-home' => esc_html_x( 'Anchor text for the Homepage', 'wordpress-seo', 'stream' ), # type = textinput
|
416 |
+
'breadcrumbs-prefix' => esc_html_x( 'Prefix for the breadcrumb path', 'wordpress-seo', 'stream' ), # type = textinput
|
417 |
+
'breadcrumbs-archiveprefix' => esc_html_x( 'Prefix for Archive breadcrumbs', 'wordpress-seo', 'stream' ), # type = textinput
|
418 |
+
'breadcrumbs-searchprefix' => esc_html_x( 'Prefix for Search Page breadcrumbs', 'wordpress-seo', 'stream' ), # type = textinput
|
419 |
+
'breadcrumbs-404crumb' => esc_html_x( 'Breadcrumb for 404 Page', 'wordpress-seo', 'stream' ), # type = textinput
|
420 |
+
'breadcrumbs-blog-remove' => esc_html_x( 'Remove Blog page from Breadcrumbs', 'wordpress-seo', 'stream' ), # type = checkbox
|
421 |
+
'breadcrumbs-boldlast' => esc_html_x( 'Bold the last page in the breadcrumb', 'wordpress-seo', 'stream' ), # type = checkbox
|
422 |
+
'post_types-post-maintax' => esc_html_x( 'Taxonomy to show in breadcrumbs for post types', 'wordpress-seo', 'stream' ), # type = select
|
423 |
Â
|
424 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/metas.php:
|
425 |
+
'forcerewritetitle' => esc_html_x( 'Force rewrite titles', 'wordpress-seo', 'stream' ), # type = checkbox
|
426 |
+
'noindex-subpages-wpseo' => esc_html_x( 'Noindex subpages of archives', 'wordpress-seo', 'stream' ), # type = checkbox
|
427 |
+
'usemetakeywords' => _x( 'Use <code>meta</code> keywords tag?', 'wordpress-seo', 'stream' ), # type = checkbox
|
428 |
+
'noodp' => _x( 'Add <code>noodp</code> meta robots tag sitewide', 'wordpress-seo', 'stream' ), # type = checkbox
|
429 |
+
'noydir' => _x( 'Add <code>noydir</code> meta robots tag sitewide', 'wordpress-seo', 'stream' ), # type = checkbox
|
430 |
+
'hide-rsdlink' => esc_html_x( 'Hide RSD Links', 'wordpress-seo', 'stream' ), # type = checkbox
|
431 |
+
'hide-wlwmanifest' => esc_html_x( 'Hide WLW Manifest Links', 'wordpress-seo', 'stream' ), # type = checkbox
|
432 |
+
'hide-shortlink' => esc_html_x( 'Hide Shortlink for posts', 'wordpress-seo', 'stream' ), # type = checkbox
|
433 |
+
'hide-feedlinks' => esc_html_x( 'Hide RSS Links', 'wordpress-seo', 'stream' ), # type = checkbox
|
434 |
+
'disable-author' => esc_html_x( 'Disable the author archives', 'wordpress-seo', 'stream' ), # type = checkbox
|
435 |
+
'disable-date' => esc_html_x( 'Disable the date-based archives', 'wordpress-seo', 'stream' ), # type = checkbox
|
436 |
Â
|
437 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/network.php:
|
438 |
+
'access' => esc_html_x( 'Who should have access to the WordPress SEO settings', 'wordpress-seo', 'stream' ), # type = select
|
439 |
+
'defaultblog' => esc_html_x( 'New blogs get the SEO settings from this blog', 'wordpress-seo', 'stream' ), # type = textinput
|
440 |
+
'restoreblog' => esc_html_x( 'Blog ID', 'wordpress-seo', 'stream' ), # type = textinput
|
441 |
Â
|
442 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/permalinks.php:
|
443 |
+
'stripcategorybase' => _x( 'Strip the category base (usually <code>/category/</code>) from the category URL.', 'wordpress-seo', 'stream' ), # type = checkbox
|
444 |
+
'trailingslash' => esc_html_x( "Enforce a trailing slash on all category and tag URL's", 'wordpress-seo', 'stream' ), # type = checkbox
|
445 |
+
'cleanslugs' => esc_html_x( 'Remove stop words from slugs.', 'wordpress-seo', 'stream' ), # type = checkbox
|
446 |
+
'redirectattachment' => esc_html_x( "Redirect attachment URL's to parent post URL.", 'wordpress-seo', 'stream' ), # type = checkbox
|
447 |
+
'cleanreplytocom' => _x( 'Remove the <code>?replytocom</code> variables.', 'wordpress-seo', 'stream' ), # type = checkbox
|
448 |
+
'cleanpermalinks' => esc_html_x( "Redirect ugly URL's to clean permalinks. (Not recommended in many cases!)", 'wordpress-seo', 'stream' ), # type = checkbox
|
449 |
+
'force_transport' => esc_html_x( 'Force Transport', 'wordpress-seo', 'stream' ), # type = select
|
450 |
+
'cleanpermalink-googlesitesearch' => esc_html_x( "Prevent cleaning out Google Site Search URL's.", 'wordpress-seo', 'stream' ), # type = checkbox
|
451 |
+
'cleanpermalink-googlecampaign' => esc_html_x( 'Prevent cleaning out Google Analytics Campaign & Google AdWords Parameters.', 'wordpress-seo', 'stream' ), # type = checkbox
|
452 |
+
'cleanpermalink-extravars' => esc_html_x( 'Other variables not to clean', 'wordpress-seo', 'stream' ), # type = textinput
|
453 |
Â
|
454 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/social.php:
|
455 |
+
'opengraph' => esc_html_x( 'Add Open Graph meta data', 'wordpress-seo', 'stream' ), # type = checkbox
|
456 |
+
'facebook_site' => esc_html_x( 'Facebook Page URL', 'wordpress-seo', 'stream' ), # type = textinput
|
457 |
+
'instagram_url' => esc_html_x( 'Instagram URL', 'wordpress-seo', 'stream' ), # type = textinput
|
458 |
+
'linkedin_url' => esc_html_x( 'LinkedIn URL', 'wordpress-seo', 'stream' ), # type = textinput
|
459 |
+
'myspace_url' => esc_html_x( 'MySpace URL', 'wordpress-seo', 'stream' ), # type = textinput
|
460 |
+
'pinterest_url' => esc_html_x( 'Pinterest URL', 'wordpress-seo', 'stream' ), # type = textinput
|
461 |
+
'youtube_url' => esc_html_x( 'YouTube URL', 'wordpress-seo', 'stream' ), # type = textinput
|
462 |
+
'google_plus_url' => esc_html_x( 'Google+ URL', 'wordpress-seo', 'stream' ), # type = textinput
|
463 |
+
'og_frontpage_image' => esc_html_x( 'Image URL', 'wordpress-seo', 'stream' ), # type = textinput
|
464 |
+
'og_frontpage_desc' => esc_html_x( 'Description', 'wordpress-seo', 'stream' ), # type = textinput
|
465 |
+
'og_frontpage_title' => esc_html_x( 'Title', 'wordpress-seo', 'stream' ), # type = textinput
|
466 |
+
'og_default_image' => esc_html_x( 'Image URL', 'wordpress-seo', 'stream' ), # type = textinput
|
467 |
+
'twitter' => esc_html_x( 'Add Twitter card meta data', 'wordpress-seo', 'stream' ), # type = checkbox
|
468 |
+
'twitter_site' => esc_html_x( 'Site Twitter Username', 'wordpress-seo', 'stream' ), # type = textinput
|
469 |
+
'twitter_card_type' => esc_html_x( 'The default card type to use', 'wordpress-seo', 'stream' ), # type = select
|
470 |
+
'googleplus' => esc_html_x( 'Add Google+ specific post meta data (excluding author metadata)', 'wordpress-seo', 'stream' ), # type = checkbox
|
471 |
+
'plus-publisher' => esc_html_x( 'Google Publisher Page', 'wordpress-seo', 'stream' ), # type = textinput
|
472 |
+
'fbadminapp' => esc_html_x( 'Facebook App ID', 'wordpress-seo', 'stream' ), # type = textinput
|
473 |
Â
|
474 |
Â
// wp-content/plugins/wordpress-seo/admin/pages/xml-sitemaps.php:
|
475 |
Â
'enablexmlsitemap' => esc_html_x( 'Check this box to enable XML sitemap functionality.', 'wordpress-seo', 'stream' ), # type = checkbox
|
491 |
Â
'taxonomies-post_tag-not_in_sitemap' => _x( 'Taxonomies Tags (<code>post_tag</code>)', 'wordpress-seo', 'stream' ), # type = checkbox
|
492 |
Â
|
493 |
Â
// Added manually
|
494 |
+
'rssbefore' => esc_html_x( 'Content to put before each post in the feed', 'wordpress-seo', 'stream' ),
|
495 |
+
'rssafter' => esc_html_x( 'Content to put after each post', 'wordpress-seo', 'stream' ),
|
496 |
Â
);
|
497 |
Â
|
498 |
Â
$ast_labels = array(
|
includes/db-updates.php
CHANGED
@@ -32,9 +32,21 @@ function wp_stream_update_302( $db_version, $current_version ) {
|
|
32 |
Â
$class = 'Connector_' . $entry->context;
|
33 |
Â
if ( class_exists( $class ) ) {
|
34 |
Â
$connector = new $class();
|
35 |
-
$wpdb->update(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
36 |
Â
} else {
|
37 |
-
$wpdb->update(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
}
|
39 |
Â
}
|
40 |
Â
|
32 |
Â
$class = 'Connector_' . $entry->context;
|
33 |
Â
if ( class_exists( $class ) ) {
|
34 |
Â
$connector = new $class();
|
35 |
+
$wpdb->update(
|
36 |
+
$wpdb->base_prefix . 'stream', array(
|
37 |
+
'connector' => $connector->name,
|
38 |
+
), array(
|
39 |
+
'ID' => $entry->ID,
|
40 |
+
)
|
41 |
+
);
|
42 |
Â
} else {
|
43 |
+
$wpdb->update(
|
44 |
+
$wpdb->base_prefix . 'stream', array(
|
45 |
+
'connector' => strtolower( $entry->connector ),
|
46 |
+
), array(
|
47 |
+
'ID' => $entry->ID,
|
48 |
+
)
|
49 |
+
);
|
50 |
Â
}
|
51 |
Â
}
|
52 |
Â
|
includes/feeds/atom.php
CHANGED
@@ -3,15 +3,15 @@ header( 'Content-Type: ' . feed_content_type( 'atom' ) . '; charset=' . get_opti
|
|
3 |
Â
printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_charset' ) ) );
|
4 |
Â
?>
|
5 |
Â
|
6 |
-
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="<?php echo esc_attr( bloginfo_rss( 'language' ) ) ?>" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" <?php do_action( 'atom_ns' ) ?>>
|
7 |
-
<title><?php bloginfo_rss( 'name' ) ?> - <?php esc_html_e( 'Stream Feed', 'stream' ) ?></title>
|
8 |
-
<link href="<?php self_link() ?>" rel="self" type="application/rss+xml" />
|
9 |
-
<link href="<?php echo esc_url( $records_admin_url ) ?>" />
|
10 |
-
<subtitle type="html"><?php esc_html( bloginfo_rss( 'description' ) ) ?></subtitle>
|
11 |
-
<updated><?php echo esc_html( mysql2date( 'c', $latest_record, false ) ) ?></updated>
|
12 |
-
<id><?php echo esc_url( $latest_link ) ?></id>
|
13 |
-
<sy:updatePeriod><?php echo esc_html( 'hourly' ) ?></sy:updatePeriod>
|
14 |
-
<sy:updateFrequency><?php echo absint( 1 ) ?></sy:updateFrequency>
|
15 |
Â
<?php
|
16 |
Â
/**
|
17 |
Â
* Action fires during RSS head
|
@@ -19,7 +19,7 @@ printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_chars
|
|
19 |
Â
do_action( 'atom_head' );
|
20 |
Â
|
21 |
Â
foreach ( $records as $record ) :
|
22 |
-
$record_link
|
23 |
Â
array(
|
24 |
Â
'record__in' => $record->ID,
|
25 |
Â
),
|
@@ -30,18 +30,18 @@ printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_chars
|
|
30 |
Â
$display_name = isset( $author->display_name ) ? $author->display_name : 'N/A';
|
31 |
Â
?>
|
32 |
Â
<entry>
|
33 |
-
<title type="html"><![CDATA[[<?php echo esc_html( $domain ) ?>] <?php echo esc_html( $record->summary ) // xss ok ?> ]]></title>
|
34 |
-
<link href="<?php echo esc_url( $record_link ) ?>" />
|
35 |
-
<updated><?php echo esc_html( mysql2date( 'c', $record->created, false ) ) ?></updated>
|
36 |
Â
<author>
|
37 |
-
<name><?php echo esc_html( $display_name ) ?></name>
|
38 |
Â
</author>
|
39 |
-
<category term="connector" label="<?php echo esc_html( $record->connector ) ?>" />
|
40 |
-
<category term="context" label="<?php echo esc_html( $record->context ) ?>"/>
|
41 |
-
<category term="action" label="<?php echo esc_html( $record->action ) ?>" />
|
42 |
-
<category term="ip" label="<?php echo esc_html( $record->ip ) ?>" />
|
43 |
-
<id><?php echo esc_url( $record_link ) ?></id>
|
44 |
-
<summary type="html"><![CDATA[- <?php echo esc_html( $display_name ) ?> ]]></summary>
|
45 |
Â
<?php
|
46 |
Â
/**
|
47 |
Â
* Action fires during Atom item
|
3 |
Â
printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_charset' ) ) );
|
4 |
Â
?>
|
5 |
Â
|
6 |
+
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="<?php echo esc_attr( bloginfo_rss( 'language' ) ); ?>" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" <?php do_action( 'atom_ns' ); ?>>
|
7 |
+
<title><?php bloginfo_rss( 'name' ); ?> - <?php esc_html_e( 'Stream Feed', 'stream' ); ?></title>
|
8 |
+
<link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
9 |
+
<link href="<?php echo esc_url( $records_admin_url ); ?>" />
|
10 |
+
<subtitle type="html"><?php esc_html( bloginfo_rss( 'description' ) ); ?></subtitle>
|
11 |
+
<updated><?php echo esc_html( mysql2date( 'c', $latest_record, false ) ); ?></updated>
|
12 |
+
<id><?php echo esc_url( $latest_link ); ?></id>
|
13 |
+
<sy:updatePeriod><?php echo esc_html( 'hourly' ); ?></sy:updatePeriod>
|
14 |
+
<sy:updateFrequency><?php echo absint( 1 ); ?></sy:updateFrequency>
|
15 |
Â
<?php
|
16 |
Â
/**
|
17 |
Â
* Action fires during RSS head
|
19 |
Â
do_action( 'atom_head' );
|
20 |
Â
|
21 |
Â
foreach ( $records as $record ) :
|
22 |
+
$record_link = add_query_arg(
|
23 |
Â
array(
|
24 |
Â
'record__in' => $record->ID,
|
25 |
Â
),
|
30 |
Â
$display_name = isset( $author->display_name ) ? $author->display_name : 'N/A';
|
31 |
Â
?>
|
32 |
Â
<entry>
|
33 |
+
<title type="html"><![CDATA[[<?php echo esc_html( $domain ); ?>] <?php echo esc_html( $record->summary ); // xss ok ?> ]]></title>
|
34 |
+
<link href="<?php echo esc_url( $record_link ); ?>" />
|
35 |
+
<updated><?php echo esc_html( mysql2date( 'c', $record->created, false ) ); ?></updated>
|
36 |
Â
<author>
|
37 |
+
<name><?php echo esc_html( $display_name ); ?></name>
|
38 |
Â
</author>
|
39 |
+
<category term="connector" label="<?php echo esc_html( $record->connector ); ?>" />
|
40 |
+
<category term="context" label="<?php echo esc_html( $record->context ); ?>"/>
|
41 |
+
<category term="action" label="<?php echo esc_html( $record->action ); ?>" />
|
42 |
+
<category term="ip" label="<?php echo esc_html( $record->ip ); ?>" />
|
43 |
+
<id><?php echo esc_url( $record_link ); ?></id>
|
44 |
+
<summary type="html"><![CDATA[- <?php echo esc_html( $display_name ); ?> ]]></summary>
|
45 |
Â
<?php
|
46 |
Â
/**
|
47 |
Â
* Action fires during Atom item
|
includes/feeds/rss-2.0.php
CHANGED
@@ -18,14 +18,14 @@ printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_chars
|
|
18 |
Â
?>
|
19 |
Â
>
|
20 |
Â
<channel>
|
21 |
-
<title><?php bloginfo_rss( 'name' ) ?> - <?php esc_html_e( 'Stream Feed', 'stream' ) ?></title>
|
22 |
-
<atom:link href="<?php self_link() ?>" rel="self" type="application/rss+xml" />
|
23 |
-
<link><?php echo esc_url( $records_admin_url ) ?></link>
|
24 |
-
<description><?php bloginfo_rss( 'description' ) ?></description>
|
25 |
-
<lastBuildDate><?php echo esc_html( mysql2date( 'r', $latest_record, false ) ) ?></lastBuildDate>
|
26 |
-
<language><?php bloginfo_rss( 'language' ) ?></language>
|
27 |
-
<sy:updatePeriod><?php echo esc_html( 'hourly' ) ?></sy:updatePeriod>
|
28 |
-
<sy:updateFrequency><?php echo absint( 1 ) ?></sy:updateFrequency>
|
29 |
Â
<?php
|
30 |
Â
/**
|
31 |
Â
* Action fires during RSS head
|
@@ -33,7 +33,7 @@ printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_chars
|
|
33 |
Â
do_action( 'rss2_head' );
|
34 |
Â
|
35 |
Â
foreach ( $records as $record ) :
|
36 |
-
$record_link
|
37 |
Â
array(
|
38 |
Â
'record__in' => $record->ID,
|
39 |
Â
),
|
@@ -44,15 +44,15 @@ printf( '<?xml version="1.0" encoding="%s"?>', esc_attr( get_option( 'blog_chars
|
|
44 |
Â
$display_name = isset( $author->display_name ) ? $author->display_name : 'N/A';
|
45 |
Â
?>
|
46 |
Â
<item>
|
47 |
-
<title><![CDATA[ <?php echo esc_html( $record->summary ) // xss ok ?> ]]></title>
|
48 |
-
<pubDate><?php echo esc_html( mysql2date( 'r', $record->created, false ) ) ?></pubDate>
|
49 |
-
<dc:creator><?php echo esc_html( $display_name ) ?></dc:creator>
|
50 |
-
<category domain="connector"><![CDATA[ <?php echo esc_html( $record->connector ) ?> ]]></category>
|
51 |
-
<category domain="context"><![CDATA[ <?php echo esc_html( $record->context ) ?> ]]></category>
|
52 |
-
<category domain="action"><![CDATA[ <?php echo esc_html( $record->action ) ?> ]]></category>
|
53 |
-
<category domain="ip"><?php echo esc_html( $record->ip ) ?></category>
|
54 |
-
<guid isPermaLink="false"><?php echo esc_url( $record_link ) ?></guid>
|
55 |
-
<link><?php echo esc_url( $record_link ) ?></link>
|
56 |
Â
<?php
|
57 |
Â
/**
|
58 |
Â
* Action fires during RSS item
|
18 |
Â
?>
|
19 |
Â
>
|
20 |
Â
<channel>
|
21 |
+
<title><?php bloginfo_rss( 'name' ); ?> - <?php esc_html_e( 'Stream Feed', 'stream' ); ?></title>
|
22 |
+
<atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
|
23 |
+
<link><?php echo esc_url( $records_admin_url ); ?></link>
|
24 |
+
<description><?php bloginfo_rss( 'description' ); ?></description>
|
25 |
+
<lastBuildDate><?php echo esc_html( mysql2date( 'r', $latest_record, false ) ); ?></lastBuildDate>
|
26 |
+
<language><?php bloginfo_rss( 'language' ); ?></language>
|
27 |
+
<sy:updatePeriod><?php echo esc_html( 'hourly' ); ?></sy:updatePeriod>
|
28 |
+
<sy:updateFrequency><?php echo absint( 1 ); ?></sy:updateFrequency>
|
29 |
Â
<?php
|
30 |
Â
/**
|
31 |
Â
* Action fires during RSS head
|
33 |
Â
do_action( 'rss2_head' );
|
34 |
Â
|
35 |
Â
foreach ( $records as $record ) :
|
36 |
+
$record_link = add_query_arg(
|
37 |
Â
array(
|
38 |
Â
'record__in' => $record->ID,
|
39 |
Â
),
|
44 |
Â
$display_name = isset( $author->display_name ) ? $author->display_name : 'N/A';
|
45 |
Â
?>
|
46 |
Â
<item>
|
47 |
+
<title><![CDATA[ <?php echo esc_html( $record->summary ); // xss ok ?> ]]></title>
|
48 |
+
<pubDate><?php echo esc_html( mysql2date( 'r', $record->created, false ) ); ?></pubDate>
|
49 |
+
<dc:creator><?php echo esc_html( $display_name ); ?></dc:creator>
|
50 |
+
<category domain="connector"><![CDATA[ <?php echo esc_html( $record->connector ); ?> ]]></category>
|
51 |
+
<category domain="context"><![CDATA[ <?php echo esc_html( $record->context ); ?> ]]></category>
|
52 |
+
<category domain="action"><![CDATA[ <?php echo esc_html( $record->action ); ?> ]]></category>
|
53 |
+
<category domain="ip"><?php echo esc_html( $record->ip ); ?></category>
|
54 |
+
<guid isPermaLink="false"><?php echo esc_url( $record_link ); ?></guid>
|
55 |
+
<link><?php echo esc_url( $record_link ); ?></link>
|
56 |
Â
<?php
|
57 |
Â
/**
|
58 |
Â
* Action fires during RSS item
|
includes/functions.php
CHANGED
@@ -98,7 +98,7 @@ function wp_stream_get_sites( $args = array() ) {
|
|
98 |
Â
$sites = get_sites( $args );
|
99 |
Â
} else {
|
100 |
Â
$sites = array();
|
101 |
-
foreach ( wp_get_sites( $args ) as $site ) {
|
102 |
Â
$sites[] = WP_Site::get_instance( $site['blog_id'] );
|
103 |
Â
}
|
104 |
Â
}
|
@@ -123,3 +123,17 @@ function wp_stream_is_vip() {
|
|
123 |
Â
function wp_stream_is_cron_enabled() {
|
124 |
Â
return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true;
|
125 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
98 |
Â
$sites = get_sites( $args );
|
99 |
Â
} else {
|
100 |
Â
$sites = array();
|
101 |
+
foreach ( wp_get_sites( $args ) as $site ) { // @codingStandardsIgnoreLine Specifically for old version of WP first, in order to provide backward compatibility
|
102 |
Â
$sites[] = WP_Site::get_instance( $site['blog_id'] );
|
103 |
Â
}
|
104 |
Â
}
|
123 |
Â
function wp_stream_is_cron_enabled() {
|
124 |
Â
return ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ? false : true;
|
125 |
Â
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Get the asset min suffix if defined.
|
129 |
+
*
|
130 |
+
* @return string
|
131 |
+
*/
|
132 |
+
function wp_stream_min_suffix() {
|
133 |
+
$min = '';
|
134 |
+
if ( ! defined( 'SCRIPT_DEBUG' ) || false === SCRIPT_DEBUG ) {
|
135 |
+
$min = 'min.';
|
136 |
+
}
|
137 |
+
|
138 |
+
return $min;
|
139 |
+
}
|
includes/lib/Carbon.php
CHANGED
@@ -675,12 +675,13 @@ class Carbon extends DateTime
|
|
675 |
Â
* @param integer $hour
|
676 |
Â
* @param integer $minute
|
677 |
Â
* @param integer $second
|
Â
|
|
678 |
Â
*
|
679 |
Â
* @return static
|
680 |
Â
*/
|
681 |
-
public function setTime($hour, $minute, $second = 0)
|
682 |
Â
{
|
683 |
-
parent::setTime($hour, $minute, $second);
|
684 |
Â
|
685 |
Â
return $this;
|
686 |
Â
}
|
675 |
Â
* @param integer $hour
|
676 |
Â
* @param integer $minute
|
677 |
Â
* @param integer $second
|
678 |
+
* @param integer $microseconds
|
679 |
Â
*
|
680 |
Â
* @return static
|
681 |
Â
*/
|
682 |
+
public function setTime($hour, $minute, $second = 0, $microseconds = 0 )
|
683 |
Â
{
|
684 |
+
parent::setTime($hour, $minute, $second, $microseconds );
|
685 |
Â
|
686 |
Â
return $this;
|
687 |
Â
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Â
Contributors: lukecarbis, fjarrett, stream, xwp
|
3 |
Â
Tags: wp stream, stream, activity, logs, track
|
4 |
Â
Requires at least: 3.9
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 3.2.
|
7 |
Â
License: GPLv2 or later
|
8 |
Â
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Â
|
@@ -79,6 +79,21 @@ Thank you for wanting to make Stream better for everyone!
|
|
79 |
Â
|
80 |
Â
== Changelog ==
|
81 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
82 |
Â
= 3.2.2 - September 13, 2017 =
|
83 |
Â
|
84 |
Â
* Fix: Prevent fatal error when attempting to store an Object in the database.
|
@@ -92,6 +107,7 @@ Thank you for wanting to make Stream better for everyone!
|
|
92 |
Â
* Fix: Readme spelling fixes (localised [sic] for en_US). ([#928](https://github.com/xwp/stream/pull/928))
|
93 |
Â
* Fix: Undefined index ID issue when trashing post with customize-posts. ([#936](https://github.com/xwp/stream/pull/936))
|
94 |
Â
* Fix: Stream fails to install properly (sometimes) due to database error. ([#934](https://github.com/xwp/stream/pull/934))
|
Â
|
|
95 |
Â
|
96 |
Â
= 3.2.0 - March 15, 2017 =
|
97 |
Â
|
@@ -520,13 +536,13 @@ Language pack for Polish. Bug fixes. Props [@powelski](https://github.com/powels
|
|
520 |
Â
Language pack for Spanish. Bug fixes. Props [omniwired](https://github.com/omniwired), [@shadyvb](https://github.com/shadyvb)
|
521 |
Â
|
522 |
Â
= 1.0.2 - January 15, 2014 =
|
523 |
-
Ensure the dashboard widget
|
524 |
Â
|
525 |
Â
= 1.0.1 - January 15, 2014 =
|
526 |
Â
Require nonce for generating a new user feed key. Props [@johnregan3](https://github.com/johnregan3)
|
527 |
Â
|
528 |
Â
= 1.0.0 - January 13, 2014 =
|
529 |
-
Allow list table to be
|
530 |
Â
|
531 |
Â
= 0.9.9 - January 8, 2014 =
|
532 |
Â
Updated screenshot assets and descriptions. Props [@fjarrett](https://github.com/fjarrett)
|
2 |
Â
Contributors: lukecarbis, fjarrett, stream, xwp
|
3 |
Â
Tags: wp stream, stream, activity, logs, track
|
4 |
Â
Requires at least: 3.9
|
5 |
+
Tested up to: 4.9.5
|
6 |
+
Stable tag: 3.2.3
|
7 |
Â
License: GPLv2 or later
|
8 |
Â
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
Â
|
79 |
Â
|
80 |
Â
== Changelog ==
|
81 |
Â
|
82 |
+
= 3.2.3 - April 23, 2018 =
|
83 |
+
|
84 |
+
* New: Use minimized assets ([#973](https://github.com/xwp/stream/pull/973))
|
85 |
+
* New: Alert type – Slack alerts! ([#970](https://github.com/xwp/stream/pull/970) [#962](https://github.com/xwp/stream/pull/962))
|
86 |
+
* Fix: PHP 7.1 compatibility fix ([#974](https://github.com/xwp/stream/pull/974))
|
87 |
+
* Fix: Make reset nonce unique ([#972](https://github.com/xwp/stream/pull/972))
|
88 |
+
* Fix: Stripped settings and alerts inputs ([#968](https://github.com/xwp/stream/pull/968))
|
89 |
+
* Fix: Update Datetime extension ([#966](https://github.com/xwp/stream/pull/966))
|
90 |
+
* Fix: WP CLI Namespace collision ([#944](https://github.com/xwp/stream/pull/944))
|
91 |
+
* Tweak: Coding standards updates ([#975](https://github.com/xwp/stream/pull/975))
|
92 |
+
* Tweak: Show real client IP (if available) when in reverse-proxy mode ([#969](https://github.com/xwp/stream/pull/969) [#963](https://github.com/xwp/stream/pull/963))
|
93 |
+
* Tweak: Performance improvement when listing roles ([#964](https://github.com/xwp/stream/pull/964))
|
94 |
+
|
95 |
+
Props [@DavidCramer](https://github.com/DavidCramer), [@lukecarbis](https://github.com/lukecarbis), [@frozzare](https://github.com/frozzare), [@fjarrett](https://github.com/fjarrett), [@shadyvb](https://github.com/shadyvb), [@valendesigns](https://github.com/valendesigns), [@robbiet480](https://github.com/robbiet480), [@cfoellmann](https://github.com/cfoellmann)
|
96 |
+
|
97 |
Â
= 3.2.2 - September 13, 2017 =
|
98 |
Â
|
99 |
Â
* Fix: Prevent fatal error when attempting to store an Object in the database.
|
107 |
Â
* Fix: Readme spelling fixes (localised [sic] for en_US). ([#928](https://github.com/xwp/stream/pull/928))
|
108 |
Â
* Fix: Undefined index ID issue when trashing post with customize-posts. ([#936](https://github.com/xwp/stream/pull/936))
|
109 |
Â
* Fix: Stream fails to install properly (sometimes) due to database error. ([#934](https://github.com/xwp/stream/pull/934))
|
110 |
+
* Fix: Stream is network activated if it's a must-use plugin on a multisite ([#956](https://github.com/xwp/stream/pull/956))
|
111 |
Â
|
112 |
Â
= 3.2.0 - March 15, 2017 =
|
113 |
Â
|
536 |
Â
Language pack for Spanish. Bug fixes. Props [omniwired](https://github.com/omniwired), [@shadyvb](https://github.com/shadyvb)
|
537 |
Â
|
538 |
Â
= 1.0.2 - January 15, 2014 =
|
539 |
+
Ensure the dashboard widget respects the Role Access setting. Props [@fjarrett](https://github.com/fjarrett)
|
540 |
Â
|
541 |
Â
= 1.0.1 - January 15, 2014 =
|
542 |
Â
Require nonce for generating a new user feed key. Props [@johnregan3](https://github.com/johnregan3)
|
543 |
Â
|
544 |
Â
= 1.0.0 - January 13, 2014 =
|
545 |
+
Allow list table to be extensible. Hook added to prevent tables from being created, if desired. Props [@johnregan3](https://github.com/johnregan3), [@fjarrett](https://github.com/fjarrett), [@jonathanbardo](https://github.com/jonathanbardo)
|
546 |
Â
|
547 |
Â
= 0.9.9 - January 8, 2014 =
|
548 |
Â
Updated screenshot assets and descriptions. Props [@fjarrett](https://github.com/fjarrett)
|
stream.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.2.
|
7 |
Â
* Author: XWP
|
8 |
Â
* Author URI: https://xwp.co/
|
9 |
Â
* License: GPLv2+
|
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.2.3
|
7 |
Â
* Author: XWP
|
8 |
Â
* Author URI: https://xwp.co/
|
9 |
Â
* License: GPLv2+
|
ui/css/admin.css
CHANGED
@@ -229,10 +229,10 @@
|
|
229 |
Â
background-color: #ffffe0 !important;
|
230 |
Â
|
231 |
Â
-webkit-transition: background 0.5s linear;
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
Â
}
|
237 |
Â
|
238 |
Â
.toplevel_page_wp_stream .new-row.alternate,
|
@@ -397,9 +397,9 @@
|
|
397 |
Â
|
398 |
Â
.post-type-wp_stream_alerts .select2-search-choice-close {
|
399 |
Â
-webkit-transition: none;
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
Â
}
|
404 |
Â
|
405 |
Â
.wp-stream-select2-icon {
|
@@ -411,10 +411,10 @@
|
|
411 |
Â
}
|
412 |
Â
|
413 |
Â
.select2-disabled .wp-stream-select2-icon {
|
414 |
-
|
415 |
-
|
416 |
Â
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
|
417 |
-
|
418 |
Â
}
|
419 |
Â
|
420 |
Â
|
229 |
Â
background-color: #ffffe0 !important;
|
230 |
Â
|
231 |
Â
-webkit-transition: background 0.5s linear;
|
232 |
+
-moz-transition: background 0.5s linear;
|
233 |
+
-ms-transition: background 0.5s linear;
|
234 |
+
-o-transition: background 0.5s linear;
|
235 |
+
transition: background 0.5s linear;
|
236 |
Â
}
|
237 |
Â
|
238 |
Â
.toplevel_page_wp_stream .new-row.alternate,
|
397 |
Â
|
398 |
Â
.post-type-wp_stream_alerts .select2-search-choice-close {
|
399 |
Â
-webkit-transition: none;
|
400 |
+
-moz-transition: none;
|
401 |
+
-o-transition: all 0 none;
|
402 |
+
transition: none;
|
403 |
Â
}
|
404 |
Â
|
405 |
Â
.wp-stream-select2-icon {
|
411 |
Â
}
|
412 |
Â
|
413 |
Â
.select2-disabled .wp-stream-select2-icon {
|
414 |
+
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 3.5+ */
|
415 |
+
filter: gray; /* IE6-9 */
|
416 |
Â
-webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */
|
417 |
+
-moz-filter: grayscale(100%); /* Firefox < 3.5 */
|
418 |
Â
}
|
419 |
Â
|
420 |
Â
|
ui/css/admin.min.css
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
.toplevel_page_wp_stream .tablenav{padding-top:6px}.toplevel_page_wp_stream #record-actions-form{margin-top:-32px}.toplevel_page_wp_stream #record-actions-form .button{margin-left:6px;float:left}.toplevel_page_wp_stream .tablenav .actions{padding:0;overflow:visible}.post-type-wp_stream_alerts .select2 .select2-selection,.stream-exclude-list .select2 .select2-selection{border-color:#ccc;background:#f7f7f7;-webkit-box-shadow:0 1px 0 #ccc;box-shadow:0 1px 0 #ccc}.post-type-wp_stream_alerts .select2 .select2-selection--multiple,.stream-exclude-list .select2 .select2-selection--multiple{font-size:0;min-height:28px}.post-type-wp_stream_alerts .select2-container.select2-container--focus .select2-selection--multiple,.stream-exclude-list .select2-container.select2-container--focus .select2-selection--multiple{border:solid #ccc 1px}.post-type-wp_stream_alerts .select2-container .select2-selection--multiple .select2-selection__choice,.stream-exclude-list .select2-container .select2-selection--multiple .select2-selection__choice{margin-top:4px;margin-bottom:3px}.post-type-wp_stream_alerts .select2 .select2-selection .select2-selection__rendered,.stream-exclude-list .select2 .select2-selection .select2-selection__rendered{color:#555}#record-query-reset{position:relative;margin-left:5px;line-height:28px;text-decoration:none;display:inline-block}#record-query-reset span.dashicons{position:absolute;top:.5em;left:0;font-size:13px}#record-query-reset .record-query-reset-text{margin-left:19px}.toplevel_page_wp_stream .chosen-container-single{margin-top:3px;margin-right:6px}.toplevel_page_wp_stream .view-switch{display:none}.toplevel_page_wp_stream #filter-date-range{float:left;margin-right:6px}.toplevel_page_wp_stream .manage-column{width:12%}.toplevel_page_wp_stream .column-date{min-width:10%;white-space:nowrap}.toplevel_page_wp_stream .column-date .timeago{padding-right:1em}.toplevel_page_wp_stream .column-user_id{width:18%}.toplevel_page_wp_stream .column-summary{width:auto}.toplevel_page_wp_stream .column-ip{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.toplevel_page_wp_stream .stream-filter-object-id{padding-left:5px;visibility:hidden}.toplevel_page_wp_stream td.summary:hover .stream-filter-object-id{visibility:visible}.toplevel_page_wp_stream .tablenav .stream-export-tablenav{margin-top:6px;height:28px;float:right}.toplevel_page_wp_stream .tablenav .stream-export-tablenav a{margin-top:0}@media only screen and (min-width:782px){.toplevel_page_wp_stream .tablenav .tablenav-pages{margin-bottom:4px}.toplevel_page_wp_stream .tablenav .stream-export-tablenav{margin-bottom:4px;float:left}.toplevel_page_wp_stream .tablenav .stream-export-tablenav a{margin-top:5px;display:inline-block}}@media only screen and (max-width:782px){.toplevel_page_wp_stream .tablenav.bottom .displaying-num{top:-8px}}@media only screen and (max-width:900px){.toplevel_page_wp_stream .fixed .manage-column,.toplevel_page_wp_stream .fixed tbody tr td{display:none!important}.toplevel_page_wp_stream .fixed .column-date,.toplevel_page_wp_stream .fixed .column-summary,.toplevel_page_wp_stream .fixed .column-user_id,.toplevel_page_wp_stream .fixed tbody tr.no-items td{display:table-cell!important}.toplevel_page_wp_stream .fixed .column-date{width:100px}.toplevel_page_wp_stream .fixed .column-user_id{width:50%}.toplevel_page_wp_stream .fixed .column-summary{width:100%}}@media only screen and (max-width:480px){.toplevel_page_wp_stream .fixed .column-user_id{display:none}}.toplevel_page_wp_stream .wp-list-table tr td::before{content:""!important}.toplevel_page_wp_stream .column-user_id a{vertical-align:top}.toplevel_page_wp_stream .column-user_id img{float:left;margin:1px 10px 8px 0;width:32px;height:32px}.toplevel_page_wp_stream .column-user_id .deleted{font-style:italic;color:#aaa}.toplevel_page_wp_stream .filter-date-range{margin-top:-1px}.toplevel_page_wp_stream .alignleft.actions input[type=text]{height:28px;line-height:19px}.toplevel_page_wp_stream .date-interval{display:inline}.toplevel_page_wp_stream .select2-container{margin-right:6px;margin-bottom:6px}.toplevel_page_wp_stream .select2-container.select2-allowclear .select2-choice abbr{margin-top:-2px}.toplevel_page_wp_stream .stream-live-update-checkbox .spinner{margin-top:5px}#dashboard_stream_activity .new-row,.toplevel_page_wp_stream .new-row{background-color:#ffffe0!important;-webkit-transition:background .5s linear;-moz-transition:background .5s linear;-ms-transition:background .5s linear;-o-transition:background .5s linear;transition:background .5s linear}#dashboard_stream_activity .new-row.alternate,.toplevel_page_wp_stream .new-row.alternate{background-color:#ffffcd!important}#dashboard_stream_activity .new-row.fadeout,.toplevel_page_wp_stream .new-row.fadeout{background-color:transparent!important}#dashboard_stream_activity .new-row.alternate.fadeout,.toplevel_page_wp_stream .new-row.alternate.fadeout{background-color:#f9f9f9!important}.toplevel_page_wp_stream #the-list .no-items .stream-list-table-no-items{text-align:center}.toplevel_page_wp_stream #the-list .no-items .stream-list-table-no-items p{margin:2px 0}.wp_stream_default_settings .select2.select2-container,.wp_stream_network_settings .select2.select2-container,.wp_stream_settings .select2.select2-container{min-width:160px;max-width:100%}.wp_stream_default_settings .tablenav,.wp_stream_network_settings .tablenav,.wp_stream_settings .tablenav{margin-top:16px}.wp_stream_default_settings .tablenav input,.wp_stream_network_settings .tablenav input,.wp_stream_settings .tablenav input{margin-right:1em}.post-type-wp_stream_alerts a.warning{color:#a00}.post-type-wp_stream_alerts a.warning:hover{color:red}.post-type-wp_stream_alerts .date-interval .field-predefined{width:165px;float:left;margin-right:6px;margin-bottom:6px}.post-type-wp_stream_alerts .date-interval .date-inputs{float:left;margin-right:6px;margin-bottom:6px}.post-type-wp_stream_alerts .date-interval .date-inputs .field-from,.post-type-wp_stream_alerts .date-interval .date-inputs .field-to{line-height:28px;height:28px;margin:0;width:125px}.post-type-wp_stream_alerts .date-interval .date-inputs .box{position:relative;display:block;float:left}.post-type-wp_stream_alerts .date-interval .date-inputs .box .date-remove{display:none;position:absolute;cursor:pointer;top:0;right:0;width:20px;height:28px;line-height:28px;font-size:14px;padding-top:1px;padding-right:2px}.post-type-wp_stream_alerts .date-interval .date-inputs .box .date-remove:before{content:'\f158'}.post-type-wp_stream_alerts .date-interval .date-inputs .connector{display:block;float:left;border:1px solid #ddd;border-left:0;border-right:0;height:26px;line-height:28px;padding-left:2px;width:20px;text-align:center;font-size:14px}.post-type-wp_stream_alerts .date-interval .date-inputs .connector:before{content:'\f345'}.post-type-wp_stream_alerts li.select2-no-results,.post-type-wp_stream_alerts li.select2-searching{background:0 0;padding:7px 7px 0;color:#999}.post-type-wp_stream_alerts .select2 .select2-selection .select2-selection__placeholder{color:#72777c}.post-type-wp_stream_alerts .select2-results .select2-disabled{background:0 0;color:#aaa}.post-type-wp_stream_alerts .select2 .select2-search--inline{float:none;margin-bottom:4px;margin-left:2px}.post-type-wp_stream_alerts .select2-selection .icon16{margin:-3px 1px 0 -3px;padding:0;width:16px;height:16px}.post-type-wp_stream_alerts .select2-selection .icon16{padding-right:8px}.post-type-wp_stream_alerts .select2-chosen .icon16:before,.post-type-wp_stream_alerts .select2-search-choice .icon16:before{font-size:15px!important;color:#656565}.post-type-wp_stream_alerts .select2-search-choice-close{-webkit-transition:none;-moz-transition:none;-o-transition:all 0 none;transition:none}.wp-stream-select2-icon{position:relative;top:3px;margin-right:4px;width:16px;height:16px}.select2-disabled .wp-stream-select2-icon{filter:url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");filter:gray;-webkit-filter:grayscale(100%);-moz-filter:grayscale(100%)}.stream-exclude-list{margin-top:1em}.stream-exclude-list th{font-weight:400;padding:8px 10px;width:auto}.stream-exclude-list tbody tr.no-items{background-color:#fff}.stream-exclude-list tbody tr.no-items td{padding:8px 10px;font-size:13px}.stream-exclude-list tbody th.check-column{padding:16px 0 0 3px}.stream-exclude-list thead th.actions-column{width:3em}.stream-exclude-list tbody th.actions-column{padding:21px 10px 20px 0}.stream-exclude-list tbody th.actions-column a{display:none;color:#a00;font-size:13px}.stream-exclude-list tbody tr:hover th.actions-column a{display:block}.stream-exclude-list tbody th.actions-column a:hover{color:red}.stream-exclude-list tbody th.actions-column .dashicons{margin-top:4px}.stream-exclude-list tbody td .ip_address{width:100%}.stream-exclude-list tbody td .ip_address.invalid{border:1px solid rgba(160,0,0,.75)}.stream-exclude-list .icon-users{top:-3px!important;position:relative!important}.wp_stream_screen .select2-results__option .parent{font-weight:700}.wp_stream_screen .select2-results__option .child{padding-left:8px}@media screen and (max-width:900px){.wp_stream_network_settings .stream-exclude-list .actions-column,.wp_stream_settings .stream-exclude-list .actions-column{display:none}}@media screen and (max-width:782px){.toplevel_page_wp_stream #record-actions-form{margin-top:0;margin-bottom:35px}.wp_stream_default_settings .stream-exclude-list td,.wp_stream_network_settings .stream-exclude-list td,.wp_stream_settings .stream-exclude-list td{padding:10px 10px 0 0}.wp_stream_default_settings .stream-exclude-list th,.wp_stream_network_settings .stream-exclude-list th,.wp_stream_settings .stream-exclude-list th{display:none}.wp_stream_default_settings .stream-exclude-list .check-column,.wp_stream_network_settings .stream-exclude-list .check-column,.wp_stream_settings .stream-exclude-list .check-column{display:table-cell;padding:13px 10px 0 3px}.wp_stream_default_settings .stream-exclude-list thead .actions-column,.wp_stream_network_settings .stream-exclude-list thead .actions-column,.wp_stream_settings .stream-exclude-list thead .actions-column{display:table-cell;width:auto}.wp_stream_default_settings .stream-exclude-list thead .actions-column .hidden,.wp_stream_network_settings .stream-exclude-list thead .actions-column .hidden,.wp_stream_settings .stream-exclude-list thead .actions-column .hidden{display:block}.wp_stream_default_settings .stream-exclude-list tfoot,.wp_stream_network_settings .stream-exclude-list tfoot,.wp_stream_settings .stream-exclude-list tfoot{display:none}}.toplevel_page_wp_stream .alert-highlight.highlight-yellow{background-color:#ffffe0}.toplevel_page_wp_stream .alert-highlight.highlight-red{background-color:#fbeaea}.toplevel_page_wp_stream .alert-highlight.highlight-green{background-color:#ecf7ed}.toplevel_page_wp_stream .alert-highlight.highlight-blue{background-color:#e5f5fa}.post-type-stream_notification .view-switch{display:none}
|
ui/css/alerts-list.css
CHANGED
@@ -76,11 +76,11 @@
|
|
76 |
Â
}
|
77 |
Â
|
78 |
Â
.edit-php.post-type-wp_stream_alerts span.select2-selection__rendered {
|
79 |
-
|
80 |
Â
}
|
81 |
Â
|
82 |
Â
#add-new-alert.inline-edit-row.inline-edit-row-page .inline-edit-col-right {
|
83 |
-
|
84 |
Â
}
|
85 |
Â
.edit-php.post-type-wp_stream_alerts #add-new-alert .select2.select2-container {
|
86 |
Â
display: block;
|
@@ -139,4 +139,4 @@
|
|
139 |
Â
.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value:last-child:after {
|
140 |
Â
border-top: none;
|
141 |
Â
border-right: none;
|
142 |
-
}
|
76 |
Â
}
|
77 |
Â
|
78 |
Â
.edit-php.post-type-wp_stream_alerts span.select2-selection__rendered {
|
79 |
+
font-style: normal;
|
80 |
Â
}
|
81 |
Â
|
82 |
Â
#add-new-alert.inline-edit-row.inline-edit-row-page .inline-edit-col-right {
|
83 |
+
margin-top: 32px;
|
84 |
Â
}
|
85 |
Â
.edit-php.post-type-wp_stream_alerts #add-new-alert .select2.select2-container {
|
86 |
Â
display: block;
|
139 |
Â
.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value:last-child:after {
|
140 |
Â
border-top: none;
|
141 |
Â
border-right: none;
|
142 |
+
}
|
ui/css/alerts-list.min.css
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
.edit-php.post-type-wp_stream_alerts .inline-edit-col,.edit-php.post-type-wp_stream_alerts .widefat .inline-edit-col,.edit-php.post-type-wp_stream_alerts .widefat p{color:#444;font-size:12px;display:block;margin:.2em 0;line-height:2.5}.edit-php.post-type-wp_stream_alerts .inline-edit-col .wp_stream_alert_type_description{line-height:1.5em;display:inline-block}.edit-php.post-type-wp_stream_alerts .inline-edit-col{padding:0 .5em!important}.edit-php.post-type-wp_stream_alerts .inline-edit-col legend{padding:.2em 0!important;color:#555}.edit-php.post-type-wp_stream_alerts .inline-edit-col .select2-container{display:block}#wp_stream_alert_type_form{max-height:14em;border:1px solid #ddd;overflow-y:scroll;padding:.2em .5em;margin:6px 0;background-color:#fff;display:none}#wp_stream_alert_type_form select{width:100%}#wp_stream_alert_type_form .dashicons{position:relative;top:7px;left:-2px;font-size:1em}.edit-php.post-type-wp_stream_alerts #misc-publishing-actions,.edit-php.post-type-wp_stream_alerts .misc-pub-section.misc-pub-post-status{padding:0}@media (min-width:781px){.wp-stream-show-mobile{display:none}.edit-php.post-type-wp_stream_alerts .inline-edit-col.inline-edit-wp_stream_alerts{float:left;width:100%;max-width:20%}}.edit-php.post-type-wp_stream_alerts .select2 .select2-selection{border-color:#ccc;background:#f7f7f7;-webkit-box-shadow:0 1px 0 #ccc;box-shadow:0 1px 0 #ccc}.edit-php.post-type-wp_stream_alerts label{font-style:italic}.edit-php.post-type-wp_stream_alerts select{width:auto}.edit-php.post-type-wp_stream_alerts span.select2-selection__rendered{font-style:normal}#add-new-alert.inline-edit-row.inline-edit-row-page .inline-edit-col-right{margin-top:32px}.edit-php.post-type-wp_stream_alerts #add-new-alert .select2.select2-container{display:block}.edit-php.post-type-wp_stream_alerts #add-new-alert .inline-edit-add-new-notifications,.edit-php.post-type-wp_stream_alerts #add-new-alert .inline-edit-add-new-status{margin-top:33px}#add-new-alert .inline-edit-add-new-triggers label{margin:.2em 0;line-height:2.5}.post-type-wp_stream_alerts .select2-container{margin-bottom:6px;min-width:165px}.post-type-wp_stream_alerts #posts-filter #post-query-submit{display:none}.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value{padding:3px 20px 3px 10px;border-top:1px solid #e5e5e5;border-bottom:1px solid #e5e5e5;background:#fff;display:inline-block;height:22px;line-height:22px;box-shadow:0 1px 1px rgba(0,0,0,.04)}.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value:first-child{border-left:1px solid #e5e5e5}.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value:last-child{padding-right:10px;border-right:1px solid #e5e5e5}.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value:after{content:"";position:absolute;margin-left:7px;margin-top:6px;display:inline-block;height:8px;width:8px;transform:rotate(45deg);border-top:2px solid #e5e5e5;border-right:2px solid #e5e5e5}.post-type-wp_stream_alerts .wp-list-table .alert_trigger_value:last-child:after{border-top:none;border-right:none}
|
ui/css/datepicker.css
CHANGED
@@ -156,8 +156,8 @@
|
|
156 |
Â
border: 1px solid #ddd;
|
157 |
Â
|
158 |
Â
-webkit-border-radius: 0;
|
159 |
-
|
160 |
-
|
161 |
Â
}
|
162 |
Â
|
163 |
Â
#ui-datepicker-div.stream-datepicker.ui-datepicker * {
|
@@ -186,8 +186,8 @@
|
|
186 |
Â
cursor: pointer;
|
187 |
Â
|
188 |
Â
-webkit-border-radius: 0;
|
189 |
-
|
190 |
-
|
191 |
Â
}
|
192 |
Â
|
193 |
Â
#ui-datepicker-div.stream-datepicker.ui-datepicker thead {
|
@@ -197,8 +197,8 @@
|
|
197 |
Â
|
198 |
Â
#ui-datepicker-div.stream-datepicker .ui-corner-all {
|
199 |
Â
-webkit-border-radius: 0;
|
200 |
-
|
201 |
-
|
202 |
Â
}
|
203 |
Â
|
204 |
Â
#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title {
|
156 |
Â
border: 1px solid #ddd;
|
157 |
Â
|
158 |
Â
-webkit-border-radius: 0;
|
159 |
+
-moz-border-radius: 0;
|
160 |
+
border-radius: 0;
|
161 |
Â
}
|
162 |
Â
|
163 |
Â
#ui-datepicker-div.stream-datepicker.ui-datepicker * {
|
186 |
Â
cursor: pointer;
|
187 |
Â
|
188 |
Â
-webkit-border-radius: 0;
|
189 |
+
-moz-border-radius: 0;
|
190 |
+
border-radius: 0;
|
191 |
Â
}
|
192 |
Â
|
193 |
Â
#ui-datepicker-div.stream-datepicker.ui-datepicker thead {
|
197 |
Â
|
198 |
Â
#ui-datepicker-div.stream-datepicker .ui-corner-all {
|
199 |
Â
-webkit-border-radius: 0;
|
200 |
+
-moz-border-radius: 0;
|
201 |
+
border-radius: 0;
|
202 |
Â
}
|
203 |
Â
|
204 |
Â
#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title {
|
ui/css/datepicker.min.css
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-next,.ui-datepicker .ui-datepicker-prev{position:absolute;top:2px}.ui-datepicker .ui-datepicker-prev{left:12px}.ui-datepicker .ui-datepicker-next{right:12px}.ui-datepicker .ui-datepicker-next span,.ui-datepicker .ui-datepicker-prev span{font-size:0;width:12px;height:12px;display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:700;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td a,.ui-datepicker td span{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}#ui-datepicker-div.stream-datepicker.ui-widget{margin-top:5px;border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}#ui-datepicker-div.stream-datepicker.ui-datepicker *{padding:0;font-family:'Open Sans',sans-serif}#ui-datepicker-div.stream-datepicker.ui-datepicker{padding:0}#ui-datepicker-div.stream-datepicker.ui-datepicker table{font-size:13px}#ui-datepicker-div.stream-datepicker .ui-datepicker-header{border:none;background:#23282d;color:#fff;font-weight:400}#ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover{background:#23282d;border-color:transparent;cursor:pointer;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}#ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#23282d;color:#fff}#ui-datepicker-div.stream-datepicker .ui-corner-all{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title{color:#fff;font-size:14px}#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-next,#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-next-hover,#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-prev,#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-prev-hover{top:.33em;border:none}#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-next span,#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-prev span{background-image:url(../stream-icons/datepicker-icons.png);background-position:-32px 0;margin-top:0;top:0;font-weight:400}#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-prev span{background-position:-96px 0}#ui-datepicker-div.stream-datepicker.ui-datepicker table{margin:0}#ui-datepicker-div.stream-datepicker.ui-datepicker th{padding:.75em 0;color:#fff;font-weight:400;border:none;border-top:1px solid #32373c}#ui-datepicker-div.stream-datepicker.ui-datepicker td{background:#f1f1f1;border:none;padding:0}#ui-datepicker-div.stream-datepicker td .ui-state-default{background:0 0;border:none;text-align:center;padding:.5em;margin:0;font-weight:400;color:#32373c}#ui-datepicker-div.stream-datepicker td.ui-state-disabled .ui-state-default,#ui-datepicker-div.stream-datepicker.ui-datepicker .ui-widget-content td.ui-state-disabled,#ui-datepicker-div.stream-datepicker.ui-datepicker td.ui-state-disabled{opacity:1;color:#999}#ui-datepicker-div.stream-datepicker td .ui-state-active,#ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#0074a2;color:#fff}.admin-color-light #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-light #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-light #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-light #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#e5e5e5}.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker td{background:#fff}.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-next span,.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-prev span{background-image:url(../stream-icons/datepicker-icons-gray.png)}.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#fff}.admin-color-light #ui-datepicker-div.stream-datepicker td .ui-state-default,.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#555}.admin-color-light #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-light #ui-datepicker-div.stream-datepicker td .ui-state-hover{color:#fff;background:#888}.admin-color-light #ui-datepicker-div.stream-datepicker td.ui-state-disabled .ui-state-default,.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-widget-content td.ui-state-disabled,.admin-color-light #ui-datepicker-div.stream-datepicker.ui-datepicker td.ui-state-disabled{color:#ccc}.admin-color-blue #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-blue #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-blue #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-blue #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-blue #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#4796b3}.admin-color-blue #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#52accc}.admin-color-blue #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-blue #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#fff}.admin-color-blue #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-blue #ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#096484}.admin-color-coffee #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-coffee #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-coffee #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-coffee #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-coffee #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#46403c}.admin-color-coffee #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#59524c}.admin-color-coffee #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-coffee #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#fff}.admin-color-coffee #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-coffee #ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#c7a589}.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#413256}.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#523f6d}.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#fff}.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-ectoplasm #ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#a3b745}.admin-color-midnight #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-midnight #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-midnight #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-midnight #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-midnight #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#26292c}.admin-color-midnight #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#363b3f}.admin-color-midnight #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-midnight #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#fff}.admin-color-midnight #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-midnight #ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#e14d43}.admin-color-ocean #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-ocean #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-ocean #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-ocean #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-ocean #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#627c83}.admin-color-ocean #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#738e96}.admin-color-ocean #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-ocean #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#fff}.admin-color-ocean #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-ocean #ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#9ebaa0}.admin-color-sunrise #ui-datepicker-div.stream-datepicker .ui-datepicker-header,.admin-color-sunrise #ui-datepicker-div.stream-datepicker .ui-datepicker-header .ui-state-hover,.admin-color-sunrise #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-sunrise #ui-datepicker-div.stream-datepicker td .ui-state-hover,.admin-color-sunrise #ui-datepicker-div.stream-datepicker.ui-datepicker thead{background:#be3631}.admin-color-sunrise #ui-datepicker-div.stream-datepicker.ui-datepicker th{border-color:#cf4944}.admin-color-sunrise #ui-datepicker-div.stream-datepicker.ui-datepicker .ui-datepicker-title,.admin-color-sunrise #ui-datepicker-div.stream-datepicker.ui-datepicker th{color:#fff}.admin-color-sunrise #ui-datepicker-div.stream-datepicker td .ui-state-active,.admin-color-sunrise #ui-datepicker-div.stream-datepicker td .ui-state-hover{background:#dd823b}
|
ui/js/admin.js
CHANGED
@@ -1,508 +1,570 @@
|
|
1 |
Â
/* globals wp_stream, ajaxurl */
|
2 |
-
jQuery(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
13 |
Â
|
14 |
-
|
15 |
Â
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
Â
|
|
22 |
Â
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
Â
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
Â
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
Â
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
},
|
48 |
-
templateSelection = function( record ) {
|
49 |
-
if ( '- ' === record.text.substring( 0, 2 ) ) {
|
50 |
-
record.text = record.text.substring( 2 );
|
51 |
-
}
|
52 |
-
return record.text;
|
53 |
-
};
|
54 |
-
|
55 |
-
if ( $( el ).find( 'option' ).not( ':selected' ).not( ':empty' ).length > 0 ) {
|
56 |
-
args = {
|
57 |
-
minimumResultsForSearch: 10,
|
58 |
-
templateResult: templateResult,
|
59 |
-
templateSelection: templateSelection,
|
60 |
-
allowClear: true,
|
61 |
-
width: '165px'
|
62 |
-
};
|
63 |
-
} else {
|
64 |
-
args = {
|
65 |
-
minimumInputLength: 3,
|
66 |
-
allowClear: true,
|
67 |
-
width: '165px',
|
68 |
-
ajax: {
|
69 |
-
url: ajaxurl,
|
70 |
-
dataType: 'json',
|
71 |
-
quietMillis: 100,
|
72 |
-
data: function( term ) {
|
73 |
-
return {
|
74 |
-
action: 'wp_stream_filters',
|
75 |
-
nonce: $( '#stream_filters_user_search_nonce' ).val(),
|
76 |
-
filter: $( el ).attr( 'name' ),
|
77 |
-
q: term.term
|
78 |
-
};
|
79 |
Â
},
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
90 |
Â
};
|
91 |
Â
}
|
92 |
-
},
|
93 |
-
templateResult: templateResult,
|
94 |
-
templateSelection: templateSelection
|
95 |
-
};
|
96 |
-
}
|
97 |
-
|
98 |
-
$( el ).select2( args );
|
99 |
-
});
|
100 |
-
|
101 |
-
var $queryVars = $.streamGetQueryVars();
|
102 |
-
var $contextInput = $( '.toplevel_page_wp_stream select.chosen-select[name="context"]' );
|
103 |
-
|
104 |
-
if ( ( 'undefined' === typeof $queryVars.context || '' === $queryVars.context ) && 'undefined' !== typeof $queryVars.connector ) {
|
105 |
-
$contextInput.val( 'group-' + $queryVars.connector );
|
106 |
-
$contextInput.trigger( 'change' );
|
107 |
-
}
|
108 |
-
|
109 |
-
$( 'input[type=submit]', '#record-filter-form' ).click( function() {
|
110 |
-
$( 'input[type=submit]', $( this ).parents( 'form' ) ).removeAttr( 'clicked' );
|
111 |
-
$( this ).attr( 'clicked', 'true' );
|
112 |
-
});
|
113 |
-
|
114 |
-
$( '#record-filter-form' ).submit( function() {
|
115 |
-
var $context = $( '.toplevel_page_wp_stream :input.chosen-select[name="context"]' ),
|
116 |
-
$option = $context.find( 'option:selected' ),
|
117 |
-
$connector = $context.parent().find( '.record-filter-connector' ),
|
118 |
-
optionConnector = $option.data( 'group' ),
|
119 |
-
optionClass = $option.prop( 'class' ),
|
120 |
-
$recordAction = $( '.recordactions select' );
|
121 |
-
|
122 |
-
if ( $( '#record-actions-submit' ).attr( 'clicked' ) !== 'true' ) {
|
123 |
-
$recordAction.val( '' );
|
124 |
-
}
|
125 |
-
|
126 |
-
$connector.val( optionConnector );
|
127 |
-
|
128 |
-
if ( 'level-1' === optionClass ) {
|
129 |
-
$option.val( '' );
|
130 |
-
}
|
131 |
-
});
|
132 |
Â
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
// Confirmation on some important actions
|
138 |
-
$( 'body' ).on( 'click', '#wp_stream_advanced_delete_all_records, #wp_stream_network_advanced_delete_all_records', function( e ) {
|
139 |
-
if ( ! window.confirm( wp_stream.i18n.confirm_purge ) ) {
|
140 |
-
e.preventDefault();
|
141 |
-
}
|
142 |
-
});
|
143 |
Â
|
144 |
-
|
145 |
-
|
146 |
-
e.preventDefault();
|
147 |
-
}
|
148 |
-
});
|
149 |
Â
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
Â
}
|
154 |
-
});
|
155 |
-
|
156 |
-
// Admin page tabs
|
157 |
-
var $tabs = $( '.wp_stream_screen .nav-tab-wrapper' ),
|
158 |
-
$panels = $( '.wp_stream_screen .nav-tab-content table.form-table' ),
|
159 |
-
$activeTab = $tabs.find( '.nav-tab-active' ),
|
160 |
-
defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
|
161 |
-
hashIndex = window.location.hash.match( /^#(\d+)$/ ),
|
162 |
-
currentHash = ( null !== hashIndex ? hashIndex[ 1 ] : defaultIndex ),
|
163 |
-
syncFormAction = function( index ) {
|
164 |
-
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
165 |
-
if ( $optionsForm.length === 0 ) {
|
166 |
-
return;
|
167 |
-
}
|
168 |
-
var currentAction = $optionsForm.attr( 'action' );
|
169 |
-
|
170 |
-
$optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
|
171 |
-
};
|
172 |
-
|
173 |
-
$tabs.on( 'click', 'a', function() {
|
174 |
-
var index = $tabs.find( 'a' ).index( $( this ) ),
|
175 |
-
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
176 |
-
|
177 |
-
$panels.hide().eq( index ).show();
|
178 |
-
$tabs
|
179 |
-
.find( 'a' )
|
180 |
-
.removeClass( 'nav-tab-active' )
|
181 |
-
.filter( $( this ) )
|
182 |
-
.addClass( 'nav-tab-active' );
|
183 |
Â
|
184 |
-
|
185 |
-
|
186 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
187 |
Â
|
188 |
-
|
189 |
Â
|
190 |
-
|
191 |
-
|
Â
|
|
Â
|
|
Â
|
|
192 |
Â
|
193 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
194 |
Â
|
195 |
-
|
196 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
197 |
Â
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
Â
|
|
204 |
Â
|
205 |
-
|
206 |
-
|
207 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
208 |
Â
|
209 |
-
|
Â
|
|
210 |
Â
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
action: 'stream_enable_live_update',
|
216 |
-
nonce: nonce,
|
217 |
-
user: user,
|
218 |
-
checked: checked,
|
219 |
-
heartbeat: heartbeat
|
220 |
-
},
|
221 |
-
dataType: 'json',
|
222 |
-
beforeSend: function() {
|
223 |
-
$( '.stream-live-update-checkbox .spinner' ).show().css( { 'display': 'inline-block' } );
|
224 |
-
},
|
225 |
-
success: function( response ) {
|
226 |
-
$( '.stream-live-update-checkbox .spinner' ).hide();
|
227 |
Â
|
228 |
-
|
229 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
230 |
Â
|
231 |
-
|
232 |
-
|
233 |
-
}
|
234 |
Â
}
|
235 |
-
}
|
236 |
-
});
|
237 |
-
});
|
238 |
-
|
239 |
-
function toggle_filter_submit() {
|
240 |
-
var all_hidden = true;
|
241 |
-
|
242 |
-
// If all filters are hidden, hide the button
|
243 |
-
if ( $( 'div.metabox-prefs [name="date-hide"]' ).is( ':checked' ) ) {
|
244 |
-
all_hidden = false;
|
245 |
-
}
|
246 |
Â
|
247 |
-
|
248 |
Â
|
249 |
-
divs.each( function() {
|
250 |
-
if ( ! $( this ).is( ':hidden' ) ) {
|
251 |
-
all_hidden = false;
|
252 |
Â
return false;
|
253 |
Â
}
|
254 |
-
|
255 |
-
|
256 |
-
if ( all_hidden ) {
|
257 |
-
$( 'input#record-query-submit' ).hide();
|
258 |
-
$( 'span.filter_info' ).show();
|
259 |
-
} else {
|
260 |
-
$( 'input#record-query-submit' ).show();
|
261 |
-
$( 'span.filter_info' ).hide();
|
262 |
-
}
|
263 |
-
}
|
264 |
-
|
265 |
-
if ( $( 'div.metabox-prefs [name="date-hide"]' ).is( ':checked' ) ) {
|
266 |
-
$( 'div.date-interval' ).show();
|
267 |
-
} else {
|
268 |
-
$( 'div.date-interval' ).hide();
|
269 |
-
}
|
270 |
-
|
271 |
-
$( 'div.actions select.chosen-select' ).each( function() {
|
272 |
-
var name = $( this ).prop( 'name' );
|
273 |
Â
|
274 |
-
|
275 |
-
$( this ).prev( '.select2-container' ).show();
|
276 |
-
} else {
|
277 |
-
$( this ).prev( '.select2-container' ).hide();
|
278 |
-
}
|
279 |
-
});
|
280 |
Â
|
281 |
-
|
Â
|
|
Â
|
|
282 |
Â
|
283 |
-
|
284 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
285 |
Â
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
} else {
|
290 |
-
$( 'div.date-interval' ).hide();
|
291 |
-
}
|
292 |
-
} else {
|
293 |
-
id = id.replace( '-hide', '' );
|
294 |
-
|
295 |
-
if ( $( this ).is( ':checked' ) ) {
|
296 |
-
$( '[name="' + id + '"]' ).prev( '.select2-container' ).show();
|
297 |
-
} else {
|
298 |
-
$( '[name="' + id + '"]' ).prev( '.select2-container' ).hide();
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
toggle_filter_submit();
|
303 |
-
});
|
304 |
-
|
305 |
-
$( '#ui-datepicker-div' ).addClass( 'stream-datepicker' );
|
306 |
-
});
|
307 |
-
|
308 |
-
// Relative time
|
309 |
-
$( 'table.wp-list-table' ).on( 'updated', function() {
|
310 |
-
var timeObjects = $( this ).find( 'time.relative-time' );
|
311 |
-
timeObjects.each( function( i, el ) {
|
312 |
-
var timeEl = $( el );
|
313 |
-
timeEl.removeClass( 'relative-time' );
|
314 |
-
$( '<strong><time datetime="' + timeEl.attr( 'datetime' ) + '" class="timeago"/></time></strong><br/>' )
|
315 |
-
.prependTo( timeEl.parent().parent() )
|
316 |
-
.find( 'time.timeago' )
|
317 |
-
.timeago();
|
318 |
-
});
|
319 |
-
}).trigger( 'updated' );
|
320 |
-
|
321 |
-
var intervals = {
|
322 |
-
init: function( $wrapper ) {
|
323 |
-
this.wrapper = $wrapper;
|
324 |
-
this.save_interval( this.wrapper.find( '.button-primary' ), this.wrapper );
|
325 |
-
|
326 |
-
this.$ = this.wrapper.each( function( i, val ) {
|
327 |
-
var container = $( val ),
|
328 |
-
dateinputs = container.find( '.date-inputs' ),
|
329 |
-
from = container.find( '.field-from' ),
|
330 |
-
to = container.find( '.field-to' ),
|
331 |
-
to_remove = to.prev( '.date-remove' ),
|
332 |
-
from_remove = from.prev( '.date-remove' ),
|
333 |
-
predefined = container.children( '.field-predefined' ),
|
334 |
-
datepickers = $( '' ).add( to ).add( from );
|
335 |
-
|
336 |
-
if ( jQuery.datepicker ) {
|
337 |
-
|
338 |
-
// Apply a GMT offset due to Date() using the visitor's local time
|
339 |
-
var siteGMTOffsetHours = parseFloat( wp_stream.gmt_offset ),
|
340 |
-
localGMTOffsetHours = new Date().getTimezoneOffset() / 60 * -1,
|
341 |
-
totalGMTOffsetHours = siteGMTOffsetHours - localGMTOffsetHours,
|
342 |
-
localTime = new Date(),
|
343 |
-
siteTime = new Date( localTime.getTime() + ( totalGMTOffsetHours * 60 * 60 * 1000 ) ),
|
344 |
-
maxOffset = 0,
|
345 |
-
minOffset = null;
|
346 |
-
|
347 |
-
// Check if the site date is different from the local date, and set a day offset
|
348 |
-
if ( localTime.getDate() !== siteTime.getDate() || localTime.getMonth() !== siteTime.getMonth() ) {
|
349 |
-
if ( localTime.getTime() < siteTime.getTime() ) {
|
350 |
-
maxOffset = '+1d';
|
351 |
-
} else {
|
352 |
-
maxOffset = '-1d';
|
353 |
-
}
|
354 |
-
}
|
355 |
Â
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
366 |
Â
}
|
367 |
-
|
368 |
Â
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
predefined.select2({
|
373 |
-
'allowClear': true
|
374 |
-
});
|
375 |
Â
|
376 |
-
|
377 |
-
|
378 |
-
|
Â
|
|
379 |
Â
|
380 |
-
|
381 |
-
to_remove.show();
|
382 |
-
}
|
383 |
Â
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
Â
|
|
Â
|
|
390 |
Â
|
391 |
-
if (
|
392 |
-
|
393 |
-
|
394 |
Â
} else {
|
395 |
-
|
396 |
-
|
397 |
Â
}
|
Â
|
|
398 |
Â
|
399 |
-
|
400 |
-
|
Â
|
|
Â
|
|
Â
|
|
401 |
Â
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
},
|
409 |
-
'check_options': function () {
|
410 |
-
if ( '' !== to.val() && '' !== from.val() ) {
|
411 |
-
var option = predefined
|
412 |
-
.find( 'option' )
|
413 |
-
.filter( '[data-to="' + to.val() + '"]' )
|
414 |
-
.filter( '[data-from="' + from.val() + '"]' );
|
415 |
-
if ( 0 !== option.length ) {
|
416 |
-
predefined.val( option.attr( 'value' ) ).trigger( 'change', [ true ] );
|
417 |
Â
} else {
|
418 |
-
|
419 |
Â
}
|
420 |
-
} else if ( '' === to.val() && '' === from.val() ) {
|
421 |
-
predefined.val( '' ).trigger( 'change', [ true ] );
|
422 |
-
} else {
|
423 |
-
predefined.val( 'custom' ).trigger( 'change', [ true ] );
|
424 |
Â
}
|
425 |
-
|
426 |
-
});
|
427 |
Â
|
428 |
-
|
429 |
-
if ( '' !== from.val() ) {
|
430 |
-
from_remove.show();
|
431 |
-
to.datepicker( 'option', 'minDate', from.val() );
|
432 |
-
} else {
|
433 |
-
from_remove.hide();
|
434 |
-
}
|
435 |
Â
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
Â
|
440 |
-
|
441 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
442 |
Â
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
}
|
450 |
Â
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
Â
|
455 |
-
|
456 |
-
}
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
$( this ).
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
481 |
Â
|
482 |
-
|
483 |
-
|
Â
|
|
Â
|
|
Â
|
|
484 |
Â
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
Â
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
493 |
Â
}
|
494 |
-
|
495 |
Â
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
501 |
Â
|
502 |
-
}
|
Â
|
|
503 |
Â
|
504 |
-
jQuery.extend(
|
505 |
-
|
506 |
-
|
Â
|
|
Â
|
|
507 |
Â
}
|
508 |
-
|
1 |
Â
/* globals wp_stream, ajaxurl */
|
2 |
+
jQuery(
|
3 |
+
function( $ ) {
|
4 |
+
|
5 |
+
// Shorter timeago strings for English locale
|
6 |
+
if ( 'en' === wp_stream.locale && 'undefined' !== typeof $.timeago ) {
|
7 |
+
$.timeago.settings.strings.seconds = 'seconds';
|
8 |
+
$.timeago.settings.strings.minute = 'a minute';
|
9 |
+
$.timeago.settings.strings.hour = 'an hour';
|
10 |
+
$.timeago.settings.strings.hours = '%d hours';
|
11 |
+
$.timeago.settings.strings.month = 'a month';
|
12 |
+
$.timeago.settings.strings.year = 'a year';
|
13 |
+
}
|
14 |
Â
|
15 |
+
$( 'li.toplevel_page_wp_stream ul li.wp-first-item.current' ).parent().parent().find( '.update-plugins' ).remove();
|
16 |
Â
|
17 |
+
$( '.toplevel_page_wp_stream :input.chosen-select' ).each(
|
18 |
+
function( i, el ) {
|
19 |
+
var args = {},
|
20 |
+
templateResult = function( record ) {
|
21 |
+
var $result = $( '<span>' ),
|
22 |
+
$elem = $( record.element ),
|
23 |
+
icon = '';
|
24 |
Â
|
25 |
+
if ( '- ' === record.text.substring( 0, 2 ) ) {
|
26 |
+
record.text = record.text.substring( 2 );
|
27 |
+
}
|
28 |
Â
|
29 |
+
if ( 'undefined' !== typeof record.id ) {
|
30 |
+
if ( record.id.indexOf( 'group-' ) === 0 ) {
|
31 |
+
$result.addClass( 'parent' );
|
32 |
+
} else if ( $elem.hasClass( 'level-2' ) ) {
|
33 |
+
$result.addClass( 'child' );
|
34 |
+
}
|
35 |
+
}
|
36 |
Â
|
37 |
+
if ( undefined !== record.icon ) {
|
38 |
+
icon = record.icon;
|
39 |
+
} else if ( undefined !== $elem && '' !== $elem.data( 'icon' ) ) {
|
40 |
+
icon = $elem.data( 'icon' );
|
41 |
+
}
|
42 |
Â
|
43 |
+
if ( icon ) {
|
44 |
+
$result.html( '<img src="' + icon + '" class="wp-stream-select2-icon">' );
|
45 |
+
}
|
46 |
+
$result.append( record.text );
|
47 |
+
|
48 |
+
return $result;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
49 |
Â
},
|
50 |
+
templateSelection = function( record ) {
|
51 |
+
if ( '- ' === record.text.substring( 0, 2 ) ) {
|
52 |
+
record.text = record.text.substring( 2 );
|
53 |
+
}
|
54 |
+
return record.text;
|
55 |
+
};
|
56 |
+
|
57 |
+
if ( $( el ).find( 'option' ).not( ':selected' ).not( ':empty' ).length > 0 ) {
|
58 |
+
args = {
|
59 |
+
minimumResultsForSearch: 10,
|
60 |
+
templateResult: templateResult,
|
61 |
+
templateSelection: templateSelection,
|
62 |
+
allowClear: true,
|
63 |
+
width: '165px'
|
64 |
+
};
|
65 |
+
} else {
|
66 |
+
args = {
|
67 |
+
minimumInputLength: 3,
|
68 |
+
allowClear: true,
|
69 |
+
width: '165px',
|
70 |
+
ajax: {
|
71 |
+
url: ajaxurl,
|
72 |
+
dataType: 'json',
|
73 |
+
quietMillis: 100,
|
74 |
+
data: function( term ) {
|
75 |
+
return {
|
76 |
+
action: 'wp_stream_filters',
|
77 |
+
nonce: $( '#stream_filters_user_search_nonce' ).val(),
|
78 |
+
filter: $( el ).attr( 'name' ),
|
79 |
+
q: term.term
|
80 |
+
};
|
81 |
+
},
|
82 |
+
processResults: function( data ) {
|
83 |
+
var results = [];
|
84 |
+
$.each(
|
85 |
+
data, function( index, item ){
|
86 |
+
results.push(
|
87 |
+
{
|
88 |
+
id: item.id,
|
89 |
+
text: item.label
|
90 |
+
}
|
91 |
+
);
|
92 |
+
}
|
93 |
+
);
|
94 |
+
return {
|
95 |
+
results: results
|
96 |
+
};
|
97 |
+
}
|
98 |
+
},
|
99 |
+
templateResult: templateResult,
|
100 |
+
templateSelection: templateSelection
|
101 |
Â
};
|
102 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
103 |
Â
|
104 |
+
$( el ).select2( args );
|
105 |
+
}
|
106 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
107 |
Â
|
108 |
+
var $queryVars = $.streamGetQueryVars();
|
109 |
+
var $contextInput = $( '.toplevel_page_wp_stream select.chosen-select[name="context"]' );
|
Â
|
|
Â
|
|
Â
|
|
110 |
Â
|
111 |
+
if ( ( 'undefined' === typeof $queryVars.context || '' === $queryVars.context ) && 'undefined' !== typeof $queryVars.connector ) {
|
112 |
+
$contextInput.val( 'group-' + $queryVars.connector );
|
113 |
+
$contextInput.trigger( 'change' );
|
114 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
115 |
Â
|
116 |
+
$( 'input[type=submit]', '#record-filter-form' ).click(
|
117 |
+
function() {
|
118 |
+
$( 'input[type=submit]', $( this ).parents( 'form' ) ).removeAttr( 'clicked' );
|
119 |
+
$( this ).attr( 'clicked', 'true' );
|
120 |
+
}
|
121 |
+
);
|
122 |
+
|
123 |
+
$( '#record-filter-form' ).submit(
|
124 |
+
function() {
|
125 |
+
var $context = $( '.toplevel_page_wp_stream :input.chosen-select[name="context"]' ),
|
126 |
+
$option = $context.find( 'option:selected' ),
|
127 |
+
$connector = $context.parent().find( '.record-filter-connector' ),
|
128 |
+
optionConnector = $option.data( 'group' ),
|
129 |
+
optionClass = $option.prop( 'class' ),
|
130 |
+
$recordAction = $( '.recordactions select' );
|
131 |
+
|
132 |
+
if ( $( '#record-actions-submit' ).attr( 'clicked' ) !== 'true' ) {
|
133 |
+
$recordAction.val( '' );
|
134 |
+
}
|
135 |
Â
|
136 |
+
$connector.val( optionConnector );
|
137 |
Â
|
138 |
+
if ( 'level-1' === optionClass ) {
|
139 |
+
$option.val( '' );
|
140 |
+
}
|
141 |
+
}
|
142 |
+
);
|
143 |
Â
|
144 |
+
$( window ).load(
|
145 |
+
function() {
|
146 |
+
$( '.toplevel_page_wp_stream input[type="search"]' ).off( 'mousedown' );
|
147 |
+
}
|
148 |
+
);
|
149 |
Â
|
150 |
+
// Confirmation on some important actions
|
151 |
+
$( 'body' ).on(
|
152 |
+
'click', '#wp_stream_advanced_delete_all_records, #wp_stream_network_advanced_delete_all_records', function( e ) {
|
153 |
+
if ( ! window.confirm( wp_stream.i18n.confirm_purge ) ) {
|
154 |
+
e.preventDefault();
|
155 |
+
}
|
156 |
+
}
|
157 |
+
);
|
158 |
Â
|
159 |
+
$( 'body' ).on(
|
160 |
+
'click', '#wp_stream_advanced_reset_site_settings, #wp_stream_network_advanced_reset_site_settings', function( e ) {
|
161 |
+
if ( ! window.confirm( wp_stream.i18n.confirm_defaults ) ) {
|
162 |
+
e.preventDefault();
|
163 |
+
}
|
164 |
+
}
|
165 |
+
);
|
166 |
Â
|
167 |
+
$( 'body' ).on(
|
168 |
+
'click', '#wp_stream_uninstall', function( e ) {
|
169 |
+
if ( ! window.confirm( wp_stream.i18n.confirm_uninstall ) ) {
|
170 |
+
e.preventDefault();
|
171 |
+
}
|
172 |
+
}
|
173 |
+
);
|
174 |
+
|
175 |
+
// Admin page tabs
|
176 |
+
var $tabs = $( '.wp_stream_screen .nav-tab-wrapper' ),
|
177 |
+
$panels = $( '.wp_stream_screen .nav-tab-content table.form-table' ),
|
178 |
+
$activeTab = $tabs.find( '.nav-tab-active' ),
|
179 |
+
defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
|
180 |
+
hashIndex = window.location.hash.match( /^#(\d+)$/ ),
|
181 |
+
currentHash = ( null !== hashIndex ? hashIndex[ 1 ] : defaultIndex ),
|
182 |
+
syncFormAction = function( index ) {
|
183 |
+
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
184 |
+
if ( $optionsForm.length === 0 ) {
|
185 |
+
return;
|
186 |
+
}
|
187 |
+
var currentAction = $optionsForm.attr( 'action' );
|
188 |
Â
|
189 |
+
$optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
|
190 |
+
};
|
191 |
Â
|
192 |
+
$tabs.on(
|
193 |
+
'click', 'a', function() {
|
194 |
+
var index = $tabs.find( 'a' ).index( $( this ) ),
|
195 |
+
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
196 |
Â
|
197 |
+
$panels.hide().eq( index ).show();
|
198 |
+
$tabs
|
199 |
+
.find( 'a' )
|
200 |
+
.removeClass( 'nav-tab-active' )
|
201 |
+
.filter( $( this ) )
|
202 |
+
.addClass( 'nav-tab-active' );
|
203 |
Â
|
204 |
+
if ( '' === window.location.hash || null !== hashIndex ) {
|
205 |
+
window.location.hash = index;
|
Â
|
|
206 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
207 |
Â
|
208 |
+
syncFormAction( index );
|
209 |
Â
|
Â
|
|
Â
|
|
Â
|
|
210 |
Â
return false;
|
211 |
Â
}
|
212 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
213 |
Â
|
214 |
+
$tabs.children().eq( currentHash ).trigger( 'click' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
215 |
Â
|
216 |
+
// Live Updates screen option
|
217 |
+
$( document ).ready(
|
218 |
+
function() {
|
219 |
Â
|
220 |
+
// Enable Live Updates checkbox ajax
|
221 |
+
$( '#enable_live_update' ).click(
|
222 |
+
function() {
|
223 |
+
var nonce = $( '#stream_live_update_nonce' ).val(),
|
224 |
+
user = $( '#enable_live_update_user' ).val(),
|
225 |
+
checked = 'unchecked',
|
226 |
+
heartbeat = 'true';
|
227 |
Â
|
228 |
+
if ( $( '#enable_live_update' ).is( ':checked' ) ) {
|
229 |
+
checked = 'checked';
|
230 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
231 |
Â
|
232 |
+
heartbeat = $( '#enable_live_update' ).data( 'heartbeat' );
|
233 |
+
|
234 |
+
$.ajax(
|
235 |
+
{
|
236 |
+
type: 'POST',
|
237 |
+
url: ajaxurl,
|
238 |
+
data: {
|
239 |
+
action: 'stream_enable_live_update',
|
240 |
+
nonce: nonce,
|
241 |
+
user: user,
|
242 |
+
checked: checked,
|
243 |
+
heartbeat: heartbeat
|
244 |
+
},
|
245 |
+
dataType: 'json',
|
246 |
+
beforeSend: function() {
|
247 |
+
$( '.stream-live-update-checkbox .spinner' ).show().css( { 'display': 'inline-block' } );
|
248 |
+
},
|
249 |
+
success: function( response ) {
|
250 |
+
$( '.stream-live-update-checkbox .spinner' ).hide();
|
251 |
+
|
252 |
+
if ( false === response.success ) {
|
253 |
+
$( '#enable_live_update' ).prop( 'checked', false );
|
254 |
+
|
255 |
+
if ( response.data ) {
|
256 |
+
window.alert( response.data );
|
257 |
+
}
|
258 |
+
}
|
259 |
+
}
|
260 |
+
}
|
261 |
+
);
|
262 |
Â
}
|
263 |
+
);
|
264 |
Â
|
265 |
+
function toggle_filter_submit() {
|
266 |
+
var all_hidden = true;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
267 |
Â
|
268 |
+
// If all filters are hidden, hide the button
|
269 |
+
if ( $( 'div.metabox-prefs [name="date-hide"]' ).is( ':checked' ) ) {
|
270 |
+
all_hidden = false;
|
271 |
+
}
|
272 |
Â
|
273 |
+
var divs = $( 'div.alignleft.actions div.select2-container' );
|
Â
|
|
Â
|
|
274 |
Â
|
275 |
+
divs.each(
|
276 |
+
function() {
|
277 |
+
if ( ! $( this ).is( ':hidden' ) ) {
|
278 |
+
all_hidden = false;
|
279 |
+
return false;
|
280 |
+
}
|
281 |
+
}
|
282 |
+
);
|
283 |
Â
|
284 |
+
if ( all_hidden ) {
|
285 |
+
$( 'input#record-query-submit' ).hide();
|
286 |
+
$( 'span.filter_info' ).show();
|
287 |
Â
} else {
|
288 |
+
$( 'input#record-query-submit' ).show();
|
289 |
+
$( 'span.filter_info' ).hide();
|
290 |
Â
}
|
291 |
+
}
|
292 |
Â
|
293 |
+
if ( $( 'div.metabox-prefs [name="date-hide"]' ).is( ':checked' ) ) {
|
294 |
+
$( 'div.date-interval' ).show();
|
295 |
+
} else {
|
296 |
+
$( 'div.date-interval' ).hide();
|
297 |
+
}
|
298 |
Â
|
299 |
+
$( 'div.actions select.chosen-select' ).each(
|
300 |
+
function() {
|
301 |
+
var name = $( this ).prop( 'name' );
|
302 |
+
|
303 |
+
if ( $( 'div.metabox-prefs [name="' + name + '-hide"]' ).is( ':checked' ) ) {
|
304 |
+
$( this ).prev( '.select2-container' ).show();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
305 |
Â
} else {
|
306 |
+
$( this ).prev( '.select2-container' ).hide();
|
307 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
308 |
Â
}
|
309 |
+
);
|
Â
|
|
310 |
Â
|
311 |
+
toggle_filter_submit();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
312 |
Â
|
313 |
+
$( 'div.metabox-prefs [type="checkbox"]' ).click(
|
314 |
+
function() {
|
315 |
+
var id = $( this ).prop( 'id' );
|
316 |
Â
|
317 |
+
if ( 'date-hide' === id ) {
|
318 |
+
if ( $( this ).is( ':checked' ) ) {
|
319 |
+
$( 'div.date-interval' ).show();
|
320 |
+
} else {
|
321 |
+
$( 'div.date-interval' ).hide();
|
322 |
+
}
|
323 |
+
} else {
|
324 |
+
id = id.replace( '-hide', '' );
|
325 |
Â
|
326 |
+
if ( $( this ).is( ':checked' ) ) {
|
327 |
+
$( '[name="' + id + '"]' ).prev( '.select2-container' ).show();
|
328 |
+
} else {
|
329 |
+
$( '[name="' + id + '"]' ).prev( '.select2-container' ).hide();
|
330 |
+
}
|
331 |
+
}
|
Â
|
|
332 |
Â
|
333 |
+
toggle_filter_submit();
|
334 |
+
}
|
335 |
+
);
|
336 |
Â
|
337 |
+
$( '#ui-datepicker-div' ).addClass( 'stream-datepicker' );
|
338 |
+
}
|
339 |
+
);
|
340 |
+
|
341 |
+
// Relative time
|
342 |
+
$( 'table.wp-list-table' ).on(
|
343 |
+
'updated', function() {
|
344 |
+
var timeObjects = $( this ).find( 'time.relative-time' );
|
345 |
+
timeObjects.each(
|
346 |
+
function( i, el ) {
|
347 |
+
var timeEl = $( el );
|
348 |
+
timeEl.removeClass( 'relative-time' );
|
349 |
+
$( '<strong><time datetime="' + timeEl.attr( 'datetime' ) + '" class="timeago"/></time></strong><br/>' )
|
350 |
+
.prependTo( timeEl.parent().parent() )
|
351 |
+
.find( 'time.timeago' )
|
352 |
+
.timeago();
|
353 |
+
}
|
354 |
+
);
|
355 |
+
}
|
356 |
+
).trigger( 'updated' );
|
357 |
+
|
358 |
+
var intervals = {
|
359 |
+
init: function( $wrapper ) {
|
360 |
+
this.wrapper = $wrapper;
|
361 |
+
this.save_interval( this.wrapper.find( '.button-primary' ), this.wrapper );
|
362 |
+
|
363 |
+
this.$ = this.wrapper.each(
|
364 |
+
function( i, val ) {
|
365 |
+
var container = $( val ),
|
366 |
+
dateinputs = container.find( '.date-inputs' ),
|
367 |
+
from = container.find( '.field-from' ),
|
368 |
+
to = container.find( '.field-to' ),
|
369 |
+
to_remove = to.prev( '.date-remove' ),
|
370 |
+
from_remove = from.prev( '.date-remove' ),
|
371 |
+
predefined = container.children( '.field-predefined' ),
|
372 |
+
datepickers = $( '' ).add( to ).add( from );
|
373 |
+
|
374 |
+
if ( jQuery.datepicker ) {
|
375 |
+
|
376 |
+
// Apply a GMT offset due to Date() using the visitor's local time
|
377 |
+
var siteGMTOffsetHours = parseFloat( wp_stream.gmt_offset ),
|
378 |
+
localGMTOffsetHours = new Date().getTimezoneOffset() / 60 * -1,
|
379 |
+
totalGMTOffsetHours = siteGMTOffsetHours - localGMTOffsetHours,
|
380 |
+
localTime = new Date(),
|
381 |
+
siteTime = new Date( localTime.getTime() + ( totalGMTOffsetHours * 60 * 60 * 1000 ) ),
|
382 |
+
maxOffset = 0,
|
383 |
+
minOffset = null;
|
384 |
+
|
385 |
+
// Check if the site date is different from the local date, and set a day offset
|
386 |
+
if ( localTime.getDate() !== siteTime.getDate() || localTime.getMonth() !== siteTime.getMonth() ) {
|
387 |
+
if ( localTime.getTime() < siteTime.getTime() ) {
|
388 |
+
maxOffset = '+1d';
|
389 |
+
} else {
|
390 |
+
maxOffset = '-1d';
|
391 |
+
}
|
392 |
+
}
|
393 |
+
|
394 |
+
datepickers.datepicker(
|
395 |
+
{
|
396 |
+
dateFormat: 'yy/mm/dd',
|
397 |
+
minDate: minOffset,
|
398 |
+
maxDate: maxOffset,
|
399 |
+
defaultDate: siteTime,
|
400 |
+
beforeShow: function() {
|
401 |
+
$( this ).prop( 'disabled', true );
|
402 |
+
},
|
403 |
+
onClose: function() {
|
404 |
+
$( this ).prop( 'disabled', false );
|
405 |
+
}
|
406 |
+
}
|
407 |
+
);
|
408 |
+
|
409 |
+
datepickers.datepicker( 'widget' ).addClass( 'stream-datepicker' );
|
410 |
+
}
|
411 |
Â
|
412 |
+
predefined.select2(
|
413 |
+
{
|
414 |
+
'allowClear': true
|
415 |
+
}
|
416 |
+
);
|
417 |
Â
|
418 |
+
if ( '' !== from.val() ) {
|
419 |
+
from_remove.show();
|
420 |
+
}
|
421 |
Â
|
422 |
+
if ( '' !== to.val() ) {
|
423 |
+
to_remove.show();
|
424 |
+
}
|
425 |
+
|
426 |
+
predefined.on(
|
427 |
+
{
|
428 |
+
'change': function () {
|
429 |
+
var value = $( this ).val(),
|
430 |
+
option = predefined.find( '[value="' + value + '"]' ),
|
431 |
+
to_val = option.data( 'to' ),
|
432 |
+
from_val = option.data( 'from' );
|
433 |
+
|
434 |
+
if ( 'custom' === value ) {
|
435 |
+
dateinputs.show();
|
436 |
+
return false;
|
437 |
+
} else {
|
438 |
+
dateinputs.hide();
|
439 |
+
datepickers.datepicker( 'hide' );
|
440 |
+
}
|
441 |
+
|
442 |
+
from.val( from_val ).trigger( 'change', [ true ] );
|
443 |
+
to.val( to_val ).trigger( 'change', [ true ] );
|
444 |
+
|
445 |
+
if ( jQuery.datepicker && datepickers.datepicker( 'widget' ).is( ':visible' ) ) {
|
446 |
+
datepickers.datepicker( 'refresh' ).datepicker( 'hide' );
|
447 |
+
}
|
448 |
+
},
|
449 |
+
'select2-removed': function() {
|
450 |
+
predefined.val( '' ).trigger( 'change' );
|
451 |
+
},
|
452 |
+
'check_options': function () {
|
453 |
+
if ( '' !== to.val() && '' !== from.val() ) {
|
454 |
+
var option = predefined
|
455 |
+
.find( 'option' )
|
456 |
+
.filter( '[data-to="' + to.val() + '"]' )
|
457 |
+
.filter( '[data-from="' + from.val() + '"]' );
|
458 |
+
if ( 0 !== option.length ) {
|
459 |
+
predefined.val( option.attr( 'value' ) ).trigger( 'change', [ true ] );
|
460 |
+
} else {
|
461 |
+
predefined.val( 'custom' ).trigger( 'change', [ true ] );
|
462 |
+
}
|
463 |
+
} else if ( '' === to.val() && '' === from.val() ) {
|
464 |
+
predefined.val( '' ).trigger( 'change', [ true ] );
|
465 |
+
} else {
|
466 |
+
predefined.val( 'custom' ).trigger( 'change', [ true ] );
|
467 |
+
}
|
468 |
+
}
|
469 |
+
}
|
470 |
+
);
|
471 |
+
|
472 |
+
from.on(
|
473 |
+
'change', function() {
|
474 |
+
if ( '' !== from.val() ) {
|
475 |
+
from_remove.show();
|
476 |
+
to.datepicker( 'option', 'minDate', from.val() );
|
477 |
+
} else {
|
478 |
+
from_remove.hide();
|
479 |
+
}
|
480 |
+
|
481 |
+
if ( true === arguments[ arguments.length - 1 ] ) {
|
482 |
+
return false;
|
483 |
+
}
|
484 |
+
|
485 |
+
predefined.trigger( 'check_options' );
|
486 |
+
}
|
487 |
+
);
|
488 |
+
|
489 |
+
to.on(
|
490 |
+
'change', function() {
|
491 |
+
if ( '' !== to.val() ) {
|
492 |
+
to_remove.show();
|
493 |
+
from.datepicker( 'option', 'maxDate', to.val() );
|
494 |
+
} else {
|
495 |
+
to_remove.hide();
|
496 |
+
}
|
497 |
+
|
498 |
+
if ( true === arguments[ arguments.length - 1 ] ) {
|
499 |
+
return false;
|
500 |
+
}
|
501 |
+
|
502 |
+
predefined.trigger( 'check_options' );
|
503 |
+
}
|
504 |
+
);
|
505 |
+
|
506 |
+
// Trigger change on load
|
507 |
+
predefined.trigger( 'change' );
|
508 |
+
|
509 |
+
$( '' ).add( from_remove ).add( to_remove ).on(
|
510 |
+
'click', function() {
|
511 |
+
$( this ).next( 'input' ).val( '' ).trigger( 'change' );
|
512 |
+
}
|
513 |
+
);
|
514 |
+
}
|
515 |
+
);
|
516 |
+
},
|
517 |
+
|
518 |
+
save_interval: function( $btn ) {
|
519 |
+
var $wrapper = this.wrapper;
|
520 |
+
$btn.click(
|
521 |
+
function() {
|
522 |
+
var data = {
|
523 |
+
key: $wrapper.find( 'select.field-predefined' ).find( ':selected' ).val(),
|
524 |
+
start: $wrapper.find( '.date-inputs .field-from' ).val(),
|
525 |
+
end: $wrapper.find( '.date-inputs .field-to' ).val()
|
526 |
+
};
|
527 |
+
|
528 |
+
// Add params to URL
|
529 |
+
$( this ).attr( 'href', $( this ).attr( 'href' ) + '&' + $.param( data ) );
|
530 |
+
}
|
531 |
+
);
|
532 |
Â
}
|
533 |
+
};
|
534 |
Â
|
535 |
+
$( document ).ready(
|
536 |
+
function() {
|
537 |
+
intervals.init( $( '.date-interval' ) );
|
538 |
+
|
539 |
+
// Disable option groups whose children are all disabled
|
540 |
+
$( 'select[name="context"] .level-1' ).each(
|
541 |
+
function() {
|
542 |
+
var all_disabled = true;
|
543 |
+
|
544 |
+
$( this ).nextUntil( '.level-1' ).each(
|
545 |
+
function() {
|
546 |
+
if ( $( this ).is( ':not(:disabled)' ) ) {
|
547 |
+
all_disabled = false;
|
548 |
+
return false;
|
549 |
+
}
|
550 |
+
}
|
551 |
+
);
|
552 |
+
|
553 |
+
if ( true === all_disabled ) {
|
554 |
+
$( this ).prop( 'disabled', true );
|
555 |
+
}
|
556 |
+
}
|
557 |
+
);
|
558 |
+
}
|
559 |
+
);
|
560 |
Â
|
561 |
+
}
|
562 |
+
);
|
563 |
Â
|
564 |
+
jQuery.extend(
|
565 |
+
{
|
566 |
+
streamGetQueryVars: function( str ) {
|
567 |
+
return ( str || document.location.search ).replace( /(^\?)/, '' ).split( '&' ).map( function( n ) { return n = n.split( '=' ), this[n[0]] = n[1], this; }.bind( {} ) )[0];
|
568 |
+
}
|
569 |
Â
}
|
570 |
+
);
|
ui/js/admin.min.js
ADDED
@@ -0,0 +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]}});
|
ui/js/alerts-list.js
CHANGED
@@ -1,11 +1,15 @@
|
|
1 |
Â
/* globals jQuery */
|
2 |
Â
( function( $ ) {
|
3 |
-
$( document ).ready(
|
4 |
-
|
5 |
-
|
6 |
-
|
Â
|
|
Â
|
|
Â
|
|
7 |
Â
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
})( jQuery );
|
1 |
Â
/* globals jQuery */
|
2 |
Â
( function( $ ) {
|
3 |
+
$( document ).ready(
|
4 |
+
function() {
|
5 |
+
$( '.inline-edit-col-left, .inline-edit-col-right, #major-publishing-actions', '.edit-php.post-type-wp_stream_alerts' ).each(
|
6 |
+
function() {
|
7 |
+
$( this ).remove();
|
8 |
+
}
|
9 |
+
);
|
10 |
Â
|
11 |
+
// This is done with JS instead of CSS to override the inline styles added by Select2's JS.
|
12 |
+
$( '.select2-container', '.inline-edit-col' ).css( { 'width': '100%' } );
|
13 |
+
}
|
14 |
+
);
|
15 |
Â
})( jQuery );
|
ui/js/alerts-list.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
!function(e){e(document).ready(function(){e(".inline-edit-col-left, .inline-edit-col-right, #major-publishing-actions",".edit-php.post-type-wp_stream_alerts").each(function(){e(this).remove()}),e(".select2-container",".inline-edit-col").css({width:"100%"})})}(jQuery);
|
ui/js/alerts.js
CHANGED
@@ -1,271 +1,309 @@
|
|
1 |
Â
/* globals jQuery, streamAlerts, inlineEditPost */
|
2 |
-
jQuery(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
Â
|
29 |
-
|
30 |
Â
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
Â
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
Â
|
40 |
-
|
41 |
-
|
42 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
43 |
Â
}
|
44 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
45 |
Â
|
46 |
-
|
47 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
48 |
Â
}
|
Â
|
|
49 |
Â
}
|
Â
|
|
50 |
Â
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
if ( '' === parts[1] ) {
|
67 |
-
parts.splice( 1, 1 );
|
68 |
-
}
|
69 |
-
$( el ).val( parts.join( '-' ) ).trigger( 'change' );
|
70 |
-
});
|
71 |
Â
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
allowClear: true,
|
78 |
-
placeholder: streamAlerts.any + ' ' + select_name
|
79 |
-
});
|
80 |
-
});
|
81 |
-
};
|
82 |
-
var $alertSettingSelect = $( '#wp_stream_alert_type' );
|
83 |
Â
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
});
|
103 |
-
};
|
104 |
Â
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
var connector_split = connector.split( '-' );
|
110 |
-
connector = connector_split[0];
|
111 |
-
}
|
112 |
-
getActions( connector );
|
113 |
-
}
|
114 |
-
});
|
115 |
Â
|
116 |
-
|
117 |
-
|
118 |
-
trigger_action.empty();
|
119 |
-
trigger_action.prop( 'disabled', true );
|
120 |
Â
|
121 |
-
|
122 |
-
|
Â
|
|
Â
|
|
123 |
Â
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
128 |
Â
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
if ( ! success ) {
|
133 |
-
return;
|
134 |
-
}
|
135 |
-
for ( var key in actions ) {
|
136 |
-
if ( actions.hasOwnProperty( key ) ) {
|
137 |
-
var value = actions[key];
|
138 |
-
var option = $( '<option/>', {value: key, text: value} );
|
139 |
-
trigger_action.append( option );
|
140 |
Â
}
|
141 |
-
|
142 |
-
trigger_action.prop( 'disabled', false );
|
143 |
-
$( document ).trigger( 'alert-actions-updated' );
|
144 |
-
});
|
145 |
-
};
|
146 |
Â
|
147 |
-
|
148 |
-
|
149 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
150 |
Â
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
'action': 'get_new_alert_triggers_notifications'
|
160 |
-
};
|
161 |
-
$.post( window.ajaxurl, data, function( response ) {
|
162 |
-
if ( true === response.success ) {
|
163 |
-
alert_form_html = response.data.html;
|
164 |
-
$( 'tbody#the-list' ).prepend( '<tr id="add-new-alert" class="inline-edit-row inline-edit-row-page inline-edit-page quick-edit-row quick-edit-row-page inline-edit-page inline-editor" style=""><td colspan="4" class="colspanchange">' + alert_form_html + '<p class="submit inline-edit-save"> <button type="button" class="button-secondary cancel alignleft">Cancel</button> <input type="hidden" id="_inline_edit" name="_inline_edit" value="3550d271fe"> <button type="button" class="button-primary save alignright">Save</button> <span class="spinner"></span><span class="error" style="display:none"></span> <br class="clear"></p></td></tr>' );
|
165 |
-
var add_new_alert = $( '#add-new-alert' );
|
166 |
-
var current_bg_color = add_new_alert.css( 'background-color' );
|
167 |
Â
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
174 |
Â
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
$( '#add-new-alert' ).remove();
|
180 |
-
});
|
181 |
-
add_new_alert.on( 'click', '.button-primary.save', save_new_alert );
|
182 |
-
|
183 |
-
setupSelectTwo( '#add-new-alert' );
|
184 |
-
}
|
185 |
-
});
|
186 |
Â
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
Â
|
|
Â
|
|
Â
|
|
206 |
Â
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
Â
|
|
Â
|
|
214 |
Â
|
215 |
-
|
216 |
-
|
217 |
Â
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
Â
|
224 |
-
|
225 |
Â
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
Â
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
Â
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
Â
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
Â
|
|
Â
|
|
254 |
Â
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
Â
|
|
Â
|
|
Â
|
|
269 |
Â
}
|
270 |
Â
}
|
271 |
-
|
1 |
Â
/* globals jQuery, streamAlerts, inlineEditPost */
|
2 |
+
jQuery(
|
3 |
+
function( $ ) {
|
4 |
+
'use strict';
|
5 |
+
var $post_row,
|
6 |
+
$edit_row;
|
7 |
+
var setupSelectTwo = function setupSelectTwo( id ) {
|
8 |
+
var $target = $( id );
|
9 |
+
$target.find( '.select2-select.connector_or_context' ).each(
|
10 |
+
function( k, el ) {
|
11 |
+
$( el ).select2(
|
12 |
+
{
|
13 |
+
allowClear: true,
|
14 |
+
placeholder: streamAlerts.anyContext,
|
15 |
+
templateResult: function( item ) {
|
16 |
+
if ( 'undefined' === typeof item.id ) {
|
17 |
+
return item.text;
|
18 |
+
}
|
19 |
+
if ( -1 === item.id.indexOf( '-' ) ) {
|
20 |
+
return $( '<span class="parent">' + item.text + '</span>' );
|
21 |
+
} else {
|
22 |
+
return $( '<span class="child">' + item.text + '</span>' );
|
23 |
+
}
|
24 |
+
},
|
25 |
+
matcher: function (params, data) {
|
26 |
+
var match = $.extend( true, {}, data );
|
27 |
Â
|
28 |
+
if (null === params.term || '' === $.trim( params.term )) {
|
29 |
+
return match;
|
30 |
+
}
|
31 |
Â
|
32 |
+
var term = params.term.toLowerCase();
|
33 |
Â
|
34 |
+
match.id = match.id.replace( 'blogs', 'sites' );
|
35 |
+
if (match.id.toLowerCase().indexOf( term ) >= 0) {
|
36 |
+
return match;
|
37 |
+
}
|
38 |
Â
|
39 |
+
if (match.children) {
|
40 |
+
for (var i = match.children.length - 1; i >= 0; i--) {
|
41 |
+
var child = match.children[i];
|
42 |
Â
|
43 |
+
// Remove term from results if it doesn't match.
|
44 |
+
if (-1 === child.id.toLowerCase().indexOf( term )) {
|
45 |
+
match.children.splice( i, 1 );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
if (match.children.length > 0) {
|
50 |
+
return match;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
return null;
|
55 |
+
}
|
56 |
Â
}
|
57 |
+
).change(
|
58 |
+
function() {
|
59 |
+
var value = $( this ).val();
|
60 |
+
if ( value ) {
|
61 |
+
var parts = value.split( '-' );
|
62 |
+
$( this ).siblings( '.connector' ).val( parts[0] );
|
63 |
+
$( this ).siblings( '.context' ).val( parts[1] );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
);
|
67 |
Â
|
68 |
+
var parts = [
|
69 |
+
$( el ).siblings( '.connector' ).val(),
|
70 |
+
$( el ).siblings( '.context' ).val()
|
71 |
+
];
|
72 |
+
if ( '' === parts[1] ) {
|
73 |
+
parts.splice( 1, 1 );
|
74 |
Â
}
|
75 |
+
$( el ).val( parts.join( '-' ) ).trigger( 'change' );
|
76 |
Â
}
|
77 |
+
);
|
78 |
Â
|
79 |
+
$target.find( 'select.select2-select:not(.connector_or_context)' ).each(
|
80 |
+
function() {
|
81 |
+
var element_id_split = $( this ).attr( 'id' ).split( '_' );
|
82 |
+
var select_name = element_id_split[element_id_split.length - 1].charAt( 0 ).toUpperCase() +
|
83 |
+
element_id_split[element_id_split.length - 1].slice( 1 );
|
84 |
+
$( this ).select2(
|
85 |
+
{
|
86 |
+
allowClear: true,
|
87 |
+
placeholder: streamAlerts.any + ' ' + select_name
|
88 |
+
}
|
89 |
+
);
|
90 |
+
}
|
91 |
+
);
|
92 |
+
};
|
93 |
+
var $alertSettingSelect = $( '#wp_stream_alert_type' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
94 |
Â
|
95 |
+
var loadAlertSettings = function( alert_type ) {
|
96 |
+
var data = {
|
97 |
+
'action' : 'load_alerts_settings',
|
98 |
+
'alert_type' : alert_type
|
99 |
+
};
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
100 |
Â
|
101 |
+
var $edit_row = $( '#wp_stream_alert_type' ).closest( 'tr' );
|
102 |
+
var row_id = $edit_row.attr( 'id' );
|
103 |
+
data.post_id = row_id.split( '-' )[1];
|
104 |
+
$.post(
|
105 |
+
window.ajaxurl, data, function( response ) {
|
106 |
+
var $alert_type_settings = $( '#wp_stream_alert_type_form' );
|
107 |
+
var alert_type = $( '#wp_stream_alert_type' ).val();
|
108 |
+
if ('none' === alert_type) {
|
109 |
+
$alert_type_settings.hide();
|
110 |
+
return;
|
111 |
+
}
|
112 |
+
$alert_type_settings.html( response.data.html );
|
113 |
+
$alert_type_settings.show();
|
114 |
+
}
|
115 |
+
);
|
116 |
+
};
|
117 |
Â
|
118 |
+
$( '#the-list' ).on(
|
119 |
+
'change', '#wp_stream_trigger_connector_or_context', function() {
|
120 |
+
if ( 'wp_stream_trigger_connector_or_context' === $( this ).attr( 'id' ) ) {
|
121 |
+
var connector = $( this ).val();
|
122 |
+
if ( connector && 0 < connector.indexOf( '-' ) ) {
|
123 |
+
var connector_split = connector.split( '-' );
|
124 |
+
connector = connector_split[0];
|
125 |
+
}
|
126 |
+
getActions( connector );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
);
|
Â
|
|
Â
|
|
130 |
Â
|
131 |
+
var getActions = function( connector ) {
|
132 |
+
var trigger_action = $( '#wp_stream_trigger_action' );
|
133 |
+
trigger_action.empty();
|
134 |
+
trigger_action.prop( 'disabled', true );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
135 |
Â
|
136 |
+
var placeholder = $( '<option/>', {value: '', text: ''} );
|
137 |
+
trigger_action.append( placeholder );
|
Â
|
|
Â
|
|
138 |
Â
|
139 |
+
var data = {
|
140 |
+
'action' : 'get_actions',
|
141 |
+
'connector' : connector
|
142 |
+
};
|
143 |
Â
|
144 |
+
$.post(
|
145 |
+
window.ajaxurl, data, function( response ) {
|
146 |
+
var success = response.success,
|
147 |
+
actions = response.data;
|
148 |
+
if ( ! success ) {
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
for ( var key in actions ) {
|
152 |
+
if ( actions.hasOwnProperty( key ) ) {
|
153 |
+
var value = actions[key];
|
154 |
+
var option = $( '<option/>', {value: key, text: value} );
|
155 |
+
trigger_action.append( option );
|
156 |
+
}
|
157 |
+
}
|
158 |
+
trigger_action.prop( 'disabled', false );
|
159 |
+
$( document ).trigger( 'alert-actions-updated' );
|
160 |
+
}
|
161 |
+
);
|
162 |
+
};
|
163 |
Â
|
164 |
+
$alertSettingSelect.change(
|
165 |
+
function() {
|
166 |
+
loadAlertSettings( $( this ).val() );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
167 |
Â
}
|
168 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
169 |
Â
|
170 |
+
$( '#wpbody-content' ).on(
|
171 |
+
'click', 'a.page-title-action', function( e ) {
|
172 |
+
e.preventDefault();
|
173 |
+
$( '#add-new-alert' ).remove();
|
174 |
+
if ( $( '.inline-edit-wp_stream_alerts' ).length > 0 ) {
|
175 |
+
$( '.inline-edit-wp_stream_alerts .inline-edit-save button.button-secondary.cancel' ).trigger( 'click' );
|
176 |
+
}
|
177 |
+
var alert_form_html = '';
|
178 |
+
var data = {
|
179 |
+
'action': 'get_new_alert_triggers_notifications'
|
180 |
+
};
|
181 |
+
$.post(
|
182 |
+
window.ajaxurl, data, function( response ) {
|
183 |
+
if ( true === response.success ) {
|
184 |
+
alert_form_html = response.data.html;
|
185 |
+
$( 'tbody#the-list' ).prepend( '<tr id="add-new-alert" class="inline-edit-row inline-edit-row-page inline-edit-page quick-edit-row quick-edit-row-page inline-edit-page inline-editor" style=""><td colspan="4" class="colspanchange">' + alert_form_html + '<p class="submit inline-edit-save"> <button type="button" class="button-secondary cancel alignleft">Cancel</button> <input type="hidden" id="_inline_edit" name="_inline_edit" value="3550d271fe"> <button type="button" class="button-primary save alignright">Save</button> <span class="spinner"></span><span class="error" style="display:none"></span> <br class="clear"></p></td></tr>' );
|
186 |
+
var add_new_alert = $( '#add-new-alert' );
|
187 |
+
var current_bg_color = add_new_alert.css( 'background-color' );
|
188 |
Â
|
189 |
+
// Color taken from /wp-admin/css/forms.css
|
190 |
+
// #pass-strength-result.strong
|
191 |
+
add_new_alert.css( 'background-color', '#C1E1B9' );
|
192 |
+
setTimeout(
|
193 |
+
function() {
|
194 |
+
add_new_alert.css( 'background-color', current_bg_color );
|
195 |
+
}, 250
|
196 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
197 |
Â
|
198 |
+
$( '#wp_stream_alert_type' ).change(
|
199 |
+
function() {
|
200 |
+
loadAlertSettings( $( this ).val() );
|
201 |
+
}
|
202 |
+
);
|
203 |
+
add_new_alert.on(
|
204 |
+
'click', '.button-secondary.cancel', function() {
|
205 |
+
$( '#add-new-alert' ).remove();
|
206 |
+
}
|
207 |
+
);
|
208 |
+
add_new_alert.on( 'click', '.button-primary.save', save_new_alert );
|
209 |
Â
|
210 |
+
setupSelectTwo( '#add-new-alert' );
|
211 |
+
}
|
212 |
+
}
|
213 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
214 |
Â
|
215 |
+
}
|
216 |
+
);
|
217 |
+
var save_new_alert = function save_new_alert( e ) {
|
218 |
+
e.preventDefault();
|
219 |
+
$( '#add-new-alert' ).find( 'p.submit.inline-edit-save span.spinner' ).css( 'visibility', 'visible' );
|
220 |
+
var data = {
|
221 |
+
'action': 'save_new_alert',
|
222 |
+
'wp_stream_alerts_nonce': $( '#wp_stream_alerts_nonce' ).val(),
|
223 |
+
'wp_stream_trigger_author': $( '#wp_stream_trigger_author' ).val(),
|
224 |
+
'wp_stream_trigger_context': $( '#wp_stream_trigger_connector_or_context' ).val(),
|
225 |
+
'wp_stream_trigger_action': $( '#wp_stream_trigger_action' ).val(),
|
226 |
+
'wp_stream_alert_type': $( '#wp_stream_alert_type' ).val(),
|
227 |
+
'wp_stream_alert_status': $( '#wp_stream_alert_status' ).val()
|
228 |
+
};
|
229 |
+
$( '#wp_stream_alert_type_form' ).find( ':input' ).each(
|
230 |
+
function(){
|
231 |
+
var alert_type_data_id = $( this ).attr( 'id' );
|
232 |
+
if ( $( this ).val() ) {
|
233 |
+
data[alert_type_data_id] = $( this ).val();
|
234 |
+
}
|
235 |
+
}
|
236 |
+
);
|
237 |
Â
|
238 |
+
$.post(
|
239 |
+
window.ajaxurl, data, function( response ) {
|
240 |
+
if ( true === response.success ) {
|
241 |
+
$( '#add-new-alert' ).find( 'p.submit.inline-edit-save span.spinner' ).css( 'visibility', 'hidden' );
|
242 |
+
location.reload();
|
243 |
+
}
|
244 |
+
}
|
245 |
+
);
|
246 |
+
};
|
247 |
Â
|
248 |
+
// we create a copy of the WP inline edit post function
|
249 |
+
var $wp_inline_edit = inlineEditPost.edit;
|
250 |
Â
|
251 |
+
// and then we overwrite the function with our own code
|
252 |
+
inlineEditPost.edit = function( id ) {
|
253 |
+
// "call" the original WP edit function
|
254 |
+
// we don't want to leave WordPress hanging
|
255 |
+
$wp_inline_edit.apply( this, arguments );
|
256 |
Â
|
257 |
+
// now we take care of our business
|
258 |
Â
|
259 |
+
// get the post ID
|
260 |
+
var post_id = 0;
|
261 |
+
if ( typeof( id ) === 'object' ) {
|
262 |
+
post_id = parseInt( this.getId( id ), 10 );
|
263 |
+
}
|
264 |
Â
|
265 |
+
if ( post_id > 0 ) {
|
266 |
+
// define the edit row
|
267 |
+
$edit_row = $( '#edit-' + post_id );
|
268 |
+
$post_row = $( '#post-' + post_id );
|
269 |
Â
|
270 |
+
// get the data
|
271 |
+
var alert_trigger_connector = $post_row.find( 'input[name="wp_stream_trigger_connector"]' ).val();
|
272 |
+
var alert_trigger_context = $post_row.find( 'input[name="wp_stream_trigger_context"]' ).val();
|
273 |
+
var alert_trigger_connector_context = alert_trigger_connector + '-' + alert_trigger_context;
|
274 |
+
var alert_trigger_action = $post_row.find( 'input[name="wp_stream_trigger_action"]' ).val();
|
275 |
+
var alert_status = $post_row.find( 'input[name="wp_stream_alert_status"]' ).val();
|
276 |
Â
|
277 |
+
// populate the data
|
278 |
+
$edit_row.find( 'input[name="wp_stream_trigger_connector"]' ).attr( 'value', alert_trigger_connector );
|
279 |
+
$edit_row.find( 'input[name="wp_stream_trigger_context"]' ).attr( 'value', alert_trigger_context );
|
280 |
+
$edit_row.find( 'select[name="wp_stream_trigger_connector_or_context"] option[value="' + alert_trigger_connector_context + '"]' ).attr( 'selected', 'selected' );
|
281 |
+
$( document ).one(
|
282 |
+
'alert-actions-updated', function() {
|
283 |
+
$edit_row.find( 'input[name="wp_stream_trigger_action"]' ).attr( 'value', alert_trigger_action );
|
284 |
+
$edit_row.find( 'select[name="wp_stream_trigger_action"] option[value="' + alert_trigger_action + '"]' ).attr( 'selected', 'selected' ).trigger( 'change' );
|
285 |
+
}
|
286 |
+
);
|
287 |
+
$edit_row.find( 'select[name="wp_stream_alert_status"] option[value="' + alert_status + '"]' ).attr( 'selected', 'selected' );
|
288 |
+
setupSelectTwo( '#edit-' + post_id );
|
289 |
Â
|
290 |
+
// Alert type handling
|
291 |
+
$( '#wp_stream_alert_type_form' ).hide();
|
292 |
+
var alert_type = $post_row.find( 'input[name="wp_stream_alert_type"]' ).val();
|
293 |
+
$edit_row.find( 'select[name="wp_stream_alert_type"] option[value="' + alert_type + '"]' ).attr( 'selected', 'selected' ).trigger( 'change' );
|
294 |
+
}
|
295 |
+
};
|
296 |
+
if ( window.location.hash ) {
|
297 |
+
var $target_post_row = $( window.location.hash );
|
298 |
+
if ( $target_post_row.length ) {
|
299 |
+
var scroll_to_position = $target_post_row.offset().top - $( '#wpadminbar' ).height();
|
300 |
+
$( 'html, body' ).animate(
|
301 |
+
{
|
302 |
+
scrollTop: scroll_to_position
|
303 |
+
}, 1000
|
304 |
+
);
|
305 |
+
$target_post_row.find( '.row-actions a.editinline' ).trigger( 'click' );
|
306 |
+
}
|
307 |
Â
}
|
308 |
Â
}
|
309 |
+
);
|
ui/js/alerts.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
jQuery(function(t){"use strict";var e,n,a=function(e){var n=t(e);n.find(".select2-select.connector_or_context").each(function(e,n){t(n).select2({allowClear:!0,placeholder:streamAlerts.anyContext,templateResult:function(e){return void 0===e.id?e.text:t(-1===e.id.indexOf("-")?'<span class="parent">'+e.text+"</span>":'<span class="child">'+e.text+"</span>")},matcher:function(e,n){var a=t.extend(!0,{},n);if(null===e.term||""===t.trim(e.term))return a;var i=e.term.toLowerCase();if(a.id=a.id.replace("blogs","sites"),a.id.toLowerCase().indexOf(i)>=0)return a;if(a.children){for(var r=a.children.length-1;r>=0;r--)-1===a.children[r].id.toLowerCase().indexOf(i)&&a.children.splice(r,1);if(a.children.length>0)return a}return null}}).change(function(){var e=t(this).val();if(e){var n=e.split("-");t(this).siblings(".connector").val(n[0]),t(this).siblings(".context").val(n[1])}});var a=[t(n).siblings(".connector").val(),t(n).siblings(".context").val()];""===a[1]&&a.splice(1,1),t(n).val(a.join("-")).trigger("change")}),n.find("select.select2-select:not(.connector_or_context)").each(function(){var e=t(this).attr("id").split("_"),n=e[e.length-1].charAt(0).toUpperCase()+e[e.length-1].slice(1);t(this).select2({allowClear:!0,placeholder:streamAlerts.any+" "+n})})},i=t("#wp_stream_alert_type"),r=function(e){var n={action:"load_alerts_settings",alert_type:e},a=t("#wp_stream_alert_type").closest("tr").attr("id");n.post_id=a.split("-")[1],t.post(window.ajaxurl,n,function(e){var n=t("#wp_stream_alert_type_form");"none"!==t("#wp_stream_alert_type").val()?(n.html(e.data.html),n.show()):n.hide()})};t("#the-list").on("change","#wp_stream_trigger_connector_or_context",function(){if("wp_stream_trigger_connector_or_context"===t(this).attr("id")){var e=t(this).val();e&&0<e.indexOf("-")&&(e=e.split("-")[0]),s(e)}});var s=function(e){var n=t("#wp_stream_trigger_action");n.empty(),n.prop("disabled",!0);var a=t("<option/>",{value:"",text:""});n.append(a);var i={action:"get_actions",connector:e};t.post(window.ajaxurl,i,function(e){var a=e.success,i=e.data;if(a){for(var r in i)if(i.hasOwnProperty(r)){var s=i[r],l=t("<option/>",{value:r,text:s});n.append(l)}n.prop("disabled",!1),t(document).trigger("alert-actions-updated")}})};i.change(function(){r(t(this).val())}),t("#wpbody-content").on("click","a.page-title-action",function(e){e.preventDefault(),t("#add-new-alert").remove(),t(".inline-edit-wp_stream_alerts").length>0&&t(".inline-edit-wp_stream_alerts .inline-edit-save button.button-secondary.cancel").trigger("click");var n="",i={action:"get_new_alert_triggers_notifications"};t.post(window.ajaxurl,i,function(e){if(!0===e.success){n=e.data.html,t("tbody#the-list").prepend('<tr id="add-new-alert" class="inline-edit-row inline-edit-row-page inline-edit-page quick-edit-row quick-edit-row-page inline-edit-page inline-editor" style=""><td colspan="4" class="colspanchange">'+n+'<p class="submit inline-edit-save"> <button type="button" class="button-secondary cancel alignleft">Cancel</button> <input type="hidden" id="_inline_edit" name="_inline_edit" value="3550d271fe"> <button type="button" class="button-primary save alignright">Save</button> <span class="spinner"></span><span class="error" style="display:none"></span> <br class="clear"></p></td></tr>');var i=t("#add-new-alert"),s=i.css("background-color");i.css("background-color","#C1E1B9"),setTimeout(function(){i.css("background-color",s)},250),t("#wp_stream_alert_type").change(function(){r(t(this).val())}),i.on("click",".button-secondary.cancel",function(){t("#add-new-alert").remove()}),i.on("click",".button-primary.save",l),a("#add-new-alert")}})});var l=function(e){e.preventDefault(),t("#add-new-alert").find("p.submit.inline-edit-save span.spinner").css("visibility","visible");var n={action:"save_new_alert",wp_stream_alerts_nonce:t("#wp_stream_alerts_nonce").val(),wp_stream_trigger_author:t("#wp_stream_trigger_author").val(),wp_stream_trigger_context:t("#wp_stream_trigger_connector_or_context").val(),wp_stream_trigger_action:t("#wp_stream_trigger_action").val(),wp_stream_alert_type:t("#wp_stream_alert_type").val(),wp_stream_alert_status:t("#wp_stream_alert_status").val()};t("#wp_stream_alert_type_form").find(":input").each(function(){var e=t(this).attr("id");t(this).val()&&(n[e]=t(this).val())}),t.post(window.ajaxurl,n,function(e){!0===e.success&&(t("#add-new-alert").find("p.submit.inline-edit-save span.spinner").css("visibility","hidden"),location.reload())})},o=inlineEditPost.edit;if(inlineEditPost.edit=function(i){o.apply(this,arguments);var r=0;if("object"==typeof i&&(r=parseInt(this.getId(i),10)),r>0){n=t("#edit-"+r);var s=(e=t("#post-"+r)).find('input[name="wp_stream_trigger_connector"]').val(),l=e.find('input[name="wp_stream_trigger_context"]').val(),c=s+"-"+l,p=e.find('input[name="wp_stream_trigger_action"]').val(),_=e.find('input[name="wp_stream_alert_status"]').val();n.find('input[name="wp_stream_trigger_connector"]').attr("value",s),n.find('input[name="wp_stream_trigger_context"]').attr("value",l),n.find('select[name="wp_stream_trigger_connector_or_context"] option[value="'+c+'"]').attr("selected","selected"),t(document).one("alert-actions-updated",function(){n.find('input[name="wp_stream_trigger_action"]').attr("value",p),n.find('select[name="wp_stream_trigger_action"] option[value="'+p+'"]').attr("selected","selected").trigger("change")}),n.find('select[name="wp_stream_alert_status"] option[value="'+_+'"]').attr("selected","selected"),a("#edit-"+r),t("#wp_stream_alert_type_form").hide();var d=e.find('input[name="wp_stream_alert_type"]').val();n.find('select[name="wp_stream_alert_type"] option[value="'+d+'"]').attr("selected","selected").trigger("change")}},window.location.hash){var c=t(window.location.hash);if(c.length){var p=c.offset().top-t("#wpadminbar").height();t("html, body").animate({scrollTop:p},1e3),c.find(".row-actions a.editinline").trigger("click")}}});
|
ui/js/exclude.js
CHANGED
@@ -1,401 +1,465 @@
|
|
1 |
Â
/* globals ajaxurl, wp_stream_regenerate_alt_rows */
|
2 |
-
jQuery(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
17 |
Â
}
|
18 |
-
|
19 |
-
matcher: function( params, data ) {
|
20 |
-
var match = $.extend( true, {}, data );
|
21 |
Â
|
22 |
-
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
return match;
|
31 |
Â
}
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
}
|
42 |
-
|
43 |
-
|
44 |
-
if ( match.children.length > 0 ) {
|
45 |
-
return match;
|
46 |
-
}
|
47 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
48 |
Â
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
if ( connector && 0 < connector.indexOf( '-' ) ) {
|
55 |
-
var connector_split = connector.split( '-' );
|
56 |
-
connector = connector_split[0];
|
57 |
-
}
|
58 |
-
getActions( row, connector );
|
59 |
-
});
|
60 |
-
});
|
61 |
-
|
62 |
-
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.action' ).each( function( k, el ) {
|
63 |
-
$( el ).select2({
|
64 |
-
allowClear: true
|
65 |
-
});
|
66 |
-
});
|
67 |
-
|
68 |
-
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role' ).each( function( k, el ) {
|
69 |
-
$input_user = $( el );
|
70 |
-
|
71 |
-
$input_user.select2({
|
72 |
-
ajax: {
|
73 |
-
type: 'POST',
|
74 |
-
url: ajaxurl,
|
75 |
-
dataType: 'json',
|
76 |
-
quietMillis: 500,
|
77 |
-
data: function( term, page ) {
|
78 |
-
return {
|
79 |
-
find: term,
|
80 |
-
limit: 10,
|
81 |
-
pager: page,
|
82 |
-
action: 'stream_get_users',
|
83 |
-
nonce: $input_user.data( 'nonce' )
|
84 |
-
};
|
85 |
-
},
|
86 |
-
processResults: function( response ) {
|
87 |
-
var answer = {
|
88 |
-
results: [
|
89 |
-
{ text: '', id: '' },
|
90 |
-
{ text: 'Roles', children: [] },
|
91 |
-
{ text: 'Users', children: [] }
|
92 |
-
]
|
93 |
-
};
|
94 |
-
|
95 |
-
if ( true !== response.success || undefined === response.data || true !== response.data.status ) {
|
96 |
-
return answer;
|
97 |
-
}
|
98 |
Â
|
99 |
-
if (
|
100 |
-
|
Â
|
|
101 |
Â
}
|
102 |
-
|
103 |
-
var roles = [];
|
104 |
-
|
105 |
-
$.each( response.data.roles, function( id, text ) {
|
106 |
-
roles.push({
|
107 |
-
'id' : id,
|
108 |
-
'text' : text
|
109 |
-
});
|
110 |
-
});
|
111 |
-
|
112 |
-
answer.results[ 1 ].children = roles;
|
113 |
-
answer.results[ 2 ].children = response.data.users;
|
114 |
-
|
115 |
-
// Return the value of more so Select2 knows if more results can be loaded
|
116 |
-
return answer;
|
117 |
Â
}
|
118 |
-
|
119 |
-
templateResult: function( object ) {
|
120 |
-
var $result = $( '<div>' ).text( object.text );
|
121 |
Â
|
122 |
-
|
123 |
-
|
Â
|
|
124 |
Â
|
125 |
-
|
126 |
-
$result.attr( 'title', object.tooltip );
|
127 |
-
}
|
128 |
Â
|
129 |
-
|
130 |
-
|
131 |
-
$result.attr( 'title', object.tooltip );
|
132 |
-
} else if ( 'undefined' !== typeof object.user_count ) {
|
133 |
-
$result.attr( 'title', object.user_count );
|
134 |
Â
}
|
Â
|
|
Â
|
|
135 |
Â
|
136 |
-
|
137 |
-
},
|
138 |
-
templateSelection: function( object ) {
|
139 |
-
var $result = $( '<div>' ).text( object.text );
|
140 |
Â
|
141 |
-
|
142 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
143 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
144 |
Â
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
placeholder: $input_user.data( 'placeholder' )
|
149 |
-
}).on( 'change', function() {
|
150 |
-
var value = $( this ).select2( 'data' );
|
151 |
-
|
152 |
-
$( this ).data( 'selected-id', value.id );
|
153 |
-
$( this ).data( 'selected-text', value.text );
|
154 |
-
});
|
155 |
-
});
|
156 |
-
|
157 |
-
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.ip_address' ).each( function( k, el ) {
|
158 |
-
var $input_ip = $( el ),
|
159 |
-
searchTerm = '';
|
160 |
-
|
161 |
-
$input_ip.select2({
|
162 |
-
ajax: {
|
163 |
-
type: 'POST',
|
164 |
-
url: ajaxurl,
|
165 |
-
dataType: 'json',
|
166 |
-
quietMillis: 500,
|
167 |
-
data: function( term ) {
|
168 |
-
searchTerm = term.term;
|
169 |
-
return {
|
170 |
-
find: term,
|
171 |
-
limit: 10,
|
172 |
-
action: 'stream_get_ips',
|
173 |
-
nonce: $input_ip.data( 'nonce' )
|
174 |
-
};
|
175 |
-
},
|
176 |
-
processResults: function( response ) {
|
177 |
-
var answer = { results: [] },
|
178 |
-
ip_chunks = [];
|
179 |
-
|
180 |
-
if ( true === response.success && undefined !== response.data ) {
|
181 |
-
$.each( response.data, function( key, ip ) {
|
182 |
-
answer.results.push({
|
183 |
-
id: ip,
|
184 |
-
text: ip
|
185 |
-
});
|
186 |
-
});
|
187 |
-
}
|
188 |
-
|
189 |
-
if ( undefined === searchTerm ) {
|
190 |
-
return answer;
|
191 |
-
}
|
192 |
-
|
193 |
-
ip_chunks = searchTerm.match( /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ );
|
194 |
Â
|
195 |
-
|
196 |
-
|
Â
|
|
197 |
Â
}
|
Â
|
|
198 |
Â
|
199 |
-
|
200 |
-
|
201 |
Â
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
var numeric = parseInt( chunk, 10 );
|
206 |
-
return numeric <= 255 && numeric.toString() === chunk;
|
207 |
-
}
|
208 |
-
);
|
209 |
Â
|
210 |
-
|
211 |
-
answer.results.push({
|
212 |
-
id: searchTerm,
|
213 |
-
text: searchTerm
|
214 |
-
});
|
215 |
-
}
|
216 |
Â
|
217 |
-
|
218 |
-
}
|
219 |
-
},
|
220 |
-
allowClear: false,
|
221 |
-
multiple: true,
|
222 |
-
maximumSelectionSize: 1,
|
223 |
-
placeholder: $input_ip.data( 'placeholder' ),
|
224 |
-
tags: true
|
225 |
-
});
|
226 |
-
}).on( 'change', function() {
|
227 |
-
$( this ).prev( '.select2-container' ).find( 'input.select2-input' ).blur();
|
228 |
-
});
|
229 |
-
|
230 |
-
$( 'ul.select2-choices, ul.select2-choices li, input.select2-input', '.stream-exclude-list tr:not(.hidden) .ip_address' ).on( 'mousedown click focus', function() {
|
231 |
-
var $container = $( this ).closest( '.select2-container' ),
|
232 |
-
$input = $container.find( 'input.select2-input' ),
|
233 |
-
value = $container.select2( 'data' );
|
234 |
-
|
235 |
-
if ( value.length >= 1 ) {
|
236 |
-
$input.blur();
|
237 |
-
return false;
|
238 |
-
}
|
239 |
-
});
|
240 |
Â
|
241 |
-
|
242 |
-
|
Â
|
|
Â
|
|
243 |
Â
|
244 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
245 |
Â
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
Â
|
|
Â
|
|
Â
|
|
250 |
Â
|
251 |
-
|
252 |
Â
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
Â
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
268 |
Â
|
269 |
-
|
270 |
-
var $excludeList = $( 'table.stream-exclude-list' );
|
271 |
Â
|
272 |
-
|
273 |
-
|
274 |
-
|
Â
|
|
Â
|
|
275 |
Â
|
276 |
-
|
277 |
-
|
Â
|
|
278 |
Â
|
279 |
-
|
280 |
-
|
281 |
-
$( ':input', $newRow ).off().val( '' );
|
282 |
Â
|
283 |
-
|
Â
|
|
284 |
Â
|
285 |
-
|
Â
|
|
Â
|
|
Â
|
|
286 |
Â
|
287 |
-
|
288 |
-
|
289 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
290 |
Â
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
Â
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
$( '.select2-select', selectedRows ).select2( 'val', '' );
|
301 |
Â
}
|
302 |
Â
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
$
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
$
|
316 |
-
$( this ).siblings( '.context' ).val( parts[1] );
|
317 |
-
$( this ).removeAttr( 'name' );
|
318 |
-
});
|
319 |
-
$( '.stream-exclude-list tbody tr:not(.hidden) select.select2-select.ip_address', this ).each( function() {
|
320 |
-
var firstSelected = $( 'option:selected', this ).first();
|
321 |
-
$( 'option:selected:not(:first)', this ).each( function() {
|
322 |
-
firstSelected.attr( 'value', firstSelected.attr( 'value' ) + ',' + $( this ).attr( 'value' ) );
|
323 |
-
$( this ).removeAttr( 'selected' );
|
324 |
-
});
|
325 |
-
});
|
326 |
-
});
|
327 |
-
|
328 |
-
$( '.stream-exclude-list' ).closest( 'td' ).prev( 'th' ).hide();
|
329 |
-
|
330 |
-
$( 'table.stream-exclude-list' ).on( 'click', 'input.cb-select', function() {
|
331 |
-
recalculate_rules_selected();
|
332 |
-
});
|
333 |
-
|
334 |
-
function getActions( row, connector ) {
|
335 |
-
var trigger_action = $( '.select2-select.action', row ),
|
336 |
-
action_value = trigger_action.val();
|
337 |
-
|
338 |
-
trigger_action.empty();
|
339 |
-
trigger_action.prop( 'disabled', true );
|
340 |
-
|
341 |
-
var placeholder = $( '<option/>', {value: '', text: ''} );
|
342 |
-
trigger_action.append( placeholder );
|
343 |
-
|
344 |
-
var data = {
|
345 |
-
'action' : 'get_actions',
|
346 |
-
'connector' : connector
|
347 |
-
};
|
348 |
-
|
349 |
-
$.post( window.ajaxurl, data, function( response ) {
|
350 |
-
var success = response.success,
|
351 |
-
actions = response.data;
|
352 |
-
if ( ! success ) {
|
353 |
-
return;
|
354 |
-
}
|
355 |
-
for ( var key in actions ) {
|
356 |
-
if ( actions.hasOwnProperty( key ) ) {
|
357 |
-
var value = actions[key];
|
358 |
-
var option = $( '<option/>', {value: key, text: value} );
|
359 |
-
trigger_action.append( option );
|
360 |
-
}
|
361 |
Â
}
|
362 |
-
trigger_action.val( action_value );
|
363 |
-
trigger_action.prop( 'disabled', false );
|
364 |
-
$( document ).trigger( 'alert-actions-updated' );
|
365 |
-
});
|
366 |
-
}
|
367 |
-
|
368 |
-
function recalculate_rules_selected() {
|
369 |
-
var $selectedRows = $( 'table.stream-exclude-list tbody tr:not( .hidden ) input.cb-select:checked' ),
|
370 |
-
$deleteButton = $( '#exclude_rules_remove_rules' );
|
371 |
Â
|
372 |
-
|
373 |
-
$deleteButton.prop( 'disabled', true );
|
374 |
-
} else {
|
375 |
-
$deleteButton.prop( 'disabled', false );
|
376 |
Â
}
|
377 |
-
}
|
378 |
Â
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
if ( 0 === $allRows.length ) {
|
386 |
-
$noRulesFound.show();
|
387 |
-
$selectAll.prop( 'disabled', true );
|
388 |
-
$deleteButton.prop( 'disabled', true );
|
389 |
-
} else {
|
390 |
-
$noRulesFound.hide();
|
391 |
-
$selectAll.prop( 'disabled', false );
|
392 |
-
}
|
393 |
-
|
394 |
-
wp_stream_regenerate_alt_rows( $allRows );
|
395 |
Â
}
|
396 |
-
|
397 |
-
$( document ).ready( function() {
|
398 |
-
recalculate_rules_found();
|
399 |
-
recalculate_rules_selected();
|
400 |
-
});
|
401 |
-
});
|
1 |
Â
/* globals ajaxurl, wp_stream_regenerate_alt_rows */
|
2 |
+
jQuery(
|
3 |
+
function( $ ) {
|
4 |
+
var initSettingsSelect2 = function() {
|
5 |
+
var $input_user;
|
6 |
+
|
7 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.connector_or_context' ).each(
|
8 |
+
function( k, el ) {
|
9 |
+
$( el ).select2(
|
10 |
+
{
|
11 |
+
allowClear: true,
|
12 |
+
templateResult : function( item ) {
|
13 |
+
if ( typeof item.id === 'undefined' ) {
|
14 |
+
return item.text;
|
15 |
+
}
|
16 |
+
if ( item.id.indexOf( '-' ) === -1 ) {
|
17 |
+
return $( '<span class="parent">' + item.text + '</span>' );
|
18 |
+
} else {
|
19 |
+
return $( '<span class="child">' + item.text + '</span>' );
|
20 |
+
}
|
21 |
+
},
|
22 |
+
matcher: function( params, data ) {
|
23 |
+
var match = $.extend( true, {}, data );
|
24 |
+
|
25 |
+
if ( params.term == null || $.trim( params.term ) === '') {
|
26 |
+
return match;
|
27 |
+
}
|
28 |
+
|
29 |
+
var term = params.term.toLowerCase();
|
30 |
+
|
31 |
+
match.id = match.id.replace( 'blogs', 'sites' );
|
32 |
+
if ( match.id.toLowerCase().indexOf( term ) >= 0 ) {
|
33 |
+
return match;
|
34 |
+
}
|
35 |
+
|
36 |
+
if ( match.children ) {
|
37 |
+
|
38 |
+
for ( var i = match.children.length - 1; i >= 0; i--) {
|
39 |
+
var child = match.children[i];
|
40 |
+
|
41 |
+
// Remove term from results if it doesn't match.
|
42 |
+
if ( child.id.toLowerCase().indexOf( term ) === -1 ) {
|
43 |
+
match.children.splice( i, 1 );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
if ( match.children.length > 0 ) {
|
48 |
+
return match;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
return null;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
).on(
|
56 |
+
'change', function() {
|
57 |
+
var row = $( this ).closest( 'tr' ),
|
58 |
+
connector = $( this ).val();
|
59 |
+
if ( connector && 0 < connector.indexOf( '-' ) ) {
|
60 |
+
var connector_split = connector.split( '-' );
|
61 |
+
connector = connector_split[0];
|
62 |
+
}
|
63 |
+
getActions( row, connector );
|
64 |
+
}
|
65 |
+
);
|
66 |
Â
}
|
67 |
+
);
|
Â
|
|
Â
|
|
68 |
Â
|
69 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.action' ).each(
|
70 |
+
function( k, el ) {
|
71 |
+
$( el ).select2(
|
72 |
+
{
|
73 |
+
allowClear: true
|
74 |
+
}
|
75 |
+
);
|
76 |
Â
}
|
77 |
+
);
|
78 |
+
|
79 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role' ).each(
|
80 |
+
function( k, el ) {
|
81 |
+
$input_user = $( el );
|
82 |
+
|
83 |
+
$input_user.select2(
|
84 |
+
{
|
85 |
+
ajax: {
|
86 |
+
type: 'POST',
|
87 |
+
url: ajaxurl,
|
88 |
+
dataType: 'json',
|
89 |
+
quietMillis: 500,
|
90 |
+
data: function( term, page ) {
|
91 |
+
return {
|
92 |
+
find: term,
|
93 |
+
limit: 10,
|
94 |
+
pager: page,
|
95 |
+
action: 'stream_get_users',
|
96 |
+
nonce: $input_user.data( 'nonce' )
|
97 |
+
};
|
98 |
+
},
|
99 |
+
processResults: function( response ) {
|
100 |
+
var answer = {
|
101 |
+
results: [
|
102 |
+
{ text: '', id: '' },
|
103 |
+
{ text: 'Roles', children: [] },
|
104 |
+
{ text: 'Users', children: [] }
|
105 |
+
]
|
106 |
+
};
|
107 |
+
|
108 |
+
if ( true !== response.success || undefined === response.data || true !== response.data.status ) {
|
109 |
+
return answer;
|
110 |
+
}
|
111 |
+
|
112 |
+
if ( undefined === response.data.users || undefined === response.data.roles ) {
|
113 |
+
return answer;
|
114 |
+
}
|
115 |
+
|
116 |
+
var roles = [];
|
117 |
+
|
118 |
+
$.each(
|
119 |
+
response.data.roles, function( id, text ) {
|
120 |
+
roles.push(
|
121 |
+
{
|
122 |
+
'id' : id,
|
123 |
+
'text' : text
|
124 |
+
}
|
125 |
+
);
|
126 |
+
}
|
127 |
+
);
|
128 |
+
|
129 |
+
answer.results[ 1 ].children = roles;
|
130 |
+
answer.results[ 2 ].children = response.data.users;
|
131 |
+
|
132 |
+
// Return the value of more so Select2 knows if more results can be loaded
|
133 |
+
return answer;
|
134 |
+
}
|
135 |
+
},
|
136 |
+
templateResult: function( object ) {
|
137 |
+
var $result = $( '<div>' ).text( object.text );
|
138 |
+
|
139 |
+
if ( 'undefined' !== typeof object.icon && object.icon ) {
|
140 |
+
$result.prepend( $( '<img src="' + object.icon + '" class="wp-stream-select2-icon">' ) );
|
141 |
+
|
142 |
+
// Add more info to the container
|
143 |
+
$result.attr( 'title', object.tooltip );
|
144 |
+
}
|
145 |
+
|
146 |
+
// Add more info to the container
|
147 |
+
if ( 'undefined' !== typeof object.tooltip ) {
|
148 |
+
$result.attr( 'title', object.tooltip );
|
149 |
+
} else if ( 'undefined' !== typeof object.user_count ) {
|
150 |
+
$result.attr( 'title', object.user_count );
|
151 |
+
}
|
152 |
+
|
153 |
+
return $result;
|
154 |
+
},
|
155 |
+
templateSelection: function( object ) {
|
156 |
+
var $result = $( '<div>' ).text( object.text );
|
157 |
+
|
158 |
+
if ( $.isNumeric( object.id ) && object.text.indexOf( 'icon-users' ) < 0 ) {
|
159 |
+
$result.append( $( '<i class="icon16 icon-users"></i>' ) );
|
160 |
+
}
|
161 |
+
|
162 |
+
return $result;
|
163 |
+
},
|
164 |
+
allowClear: true,
|
165 |
+
placeholder: $input_user.data( 'placeholder' )
|
166 |
+
}
|
167 |
+
).on(
|
168 |
+
'change', function() {
|
169 |
+
var value = $( this ).select2( 'data' );
|
170 |
Â
|
171 |
+
$( this ).data( 'selected-id', value.id );
|
172 |
+
$( this ).data( 'selected-text', value.text );
|
173 |
+
}
|
174 |
+
);
|
Â
|
|
175 |
Â
}
|
176 |
+
);
|
177 |
+
|
178 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.ip_address' ).each(
|
179 |
+
function( k, el ) {
|
180 |
+
var $input_ip = $( el ),
|
181 |
+
searchTerm = '';
|
182 |
+
|
183 |
+
$input_ip.select2(
|
184 |
+
{
|
185 |
+
ajax: {
|
186 |
+
type: 'POST',
|
187 |
+
url: ajaxurl,
|
188 |
+
dataType: 'json',
|
189 |
+
quietMillis: 500,
|
190 |
+
data: function( term ) {
|
191 |
+
searchTerm = term.term;
|
192 |
+
return {
|
193 |
+
find: term,
|
194 |
+
limit: 10,
|
195 |
+
action: 'stream_get_ips',
|
196 |
+
nonce: $input_ip.data( 'nonce' )
|
197 |
+
};
|
198 |
+
},
|
199 |
+
processResults: function( response ) {
|
200 |
+
var answer = { results: [] },
|
201 |
+
ip_chunks = [];
|
202 |
+
|
203 |
+
if ( true === response.success && undefined !== response.data ) {
|
204 |
+
$.each(
|
205 |
+
response.data, function( key, ip ) {
|
206 |
+
answer.results.push(
|
207 |
+
{
|
208 |
+
id: ip,
|
209 |
+
text: ip
|
210 |
+
}
|
211 |
+
);
|
212 |
+
}
|
213 |
+
);
|
214 |
+
}
|
215 |
+
|
216 |
+
if ( undefined === searchTerm ) {
|
217 |
+
return answer;
|
218 |
+
}
|
219 |
+
|
220 |
+
ip_chunks = searchTerm.match( /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ );
|
221 |
+
|
222 |
+
if ( null === ip_chunks ) {
|
223 |
+
return answer;
|
224 |
+
}
|
225 |
+
|
226 |
+
// remove whole match
|
227 |
+
ip_chunks.shift();
|
228 |
+
|
229 |
+
ip_chunks = $.grep(
|
230 |
+
ip_chunks,
|
231 |
+
function( chunk ) {
|
232 |
+
var numeric = parseInt( chunk, 10 );
|
233 |
+
return numeric <= 255 && numeric.toString() === chunk;
|
234 |
+
}
|
235 |
+
);
|
236 |
+
|
237 |
+
if ( ip_chunks.length >= 4 ) {
|
238 |
+
answer.results.push(
|
239 |
+
{
|
240 |
+
id: searchTerm,
|
241 |
+
text: searchTerm
|
242 |
+
}
|
243 |
+
);
|
244 |
+
}
|
245 |
+
|
246 |
+
return answer;
|
247 |
+
}
|
248 |
+
},
|
249 |
+
allowClear: false,
|
250 |
+
multiple: true,
|
251 |
+
maximumSelectionSize: 1,
|
252 |
+
placeholder: $input_ip.data( 'placeholder' ),
|
253 |
+
tags: true
|
254 |
Â
}
|
255 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
256 |
Â
}
|
257 |
+
).on(
|
258 |
+
'change', function() {
|
259 |
+
$( this ).prev( '.select2-container' ).find( 'input.select2-input' ).blur();
|
260 |
+
}
|
261 |
+
);
|
262 |
Â
|
263 |
+
$( 'ul.select2-choices, ul.select2-choices li, input.select2-input', '.stream-exclude-list tr:not(.hidden) .ip_address' ).on(
|
264 |
+
'mousedown click focus', function() {
|
265 |
+
var $container = $( this ).closest( '.select2-container' ),
|
266 |
+
$input = $container.find( 'input.select2-input' ),
|
267 |
+
value = $container.select2( 'data' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
268 |
Â
|
269 |
+
if ( value.length >= 1 ) {
|
270 |
+
$input.blur();
|
271 |
+
return false;
|
272 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
273 |
Â
}
|
274 |
+
);
|
Â
|
|
Â
|
|
275 |
Â
|
276 |
+
$( '.stream-exclude-list tr:not(.hidden) .exclude_rules_remove_rule_row' ).on(
|
277 |
+
'click', function() {
|
278 |
+
var $thisRow = $( this ).closest( 'tr' );
|
279 |
Â
|
280 |
+
$thisRow.remove();
|
Â
|
|
Â
|
|
281 |
Â
|
282 |
+
recalculate_rules_found();
|
283 |
+
recalculate_rules_selected();
|
Â
|
|
Â
|
|
Â
|
|
284 |
Â
}
|
285 |
+
);
|
286 |
+
};
|
287 |
Â
|
288 |
+
initSettingsSelect2();
|
Â
|
|
Â
|
|
Â
|
|
289 |
Â
|
290 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role' ).each(
|
291 |
+
function() {
|
292 |
+
var $option = $( '<option selected>' + $( this ).data( 'selected-text' ) + '</option>' ).val( $( this ).data( 'selected-id' ) );
|
293 |
+
$( this ).append( $option ).trigger( 'change' );
|
294 |
+
}
|
295 |
+
);
|
296 |
+
|
297 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.connector_or_context' ).each(
|
298 |
+
function() {
|
299 |
+
var parts = [
|
300 |
+
$( this ).siblings( '.connector' ).val(),
|
301 |
+
$( this ).siblings( '.context' ).val()
|
302 |
+
];
|
303 |
+
if ( parts[1] === '' ) {
|
304 |
+
parts.splice( 1, 1 );
|
305 |
Â
}
|
306 |
+
$( this ).val( parts.join( '-' ) ).trigger( 'change' );
|
307 |
+
}
|
308 |
+
);
|
309 |
Â
|
310 |
+
$( '#exclude_rules_new_rule' ).on(
|
311 |
+
'click', function() {
|
312 |
+
var $excludeList = $( 'table.stream-exclude-list' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
313 |
Â
|
314 |
+
$( 'tr:not(.hidden) select.select2-select', $excludeList ).each(
|
315 |
+
function() {
|
316 |
+
$( this ).select2( 'destroy' );
|
317 |
Â
}
|
318 |
+
);
|
319 |
Â
|
320 |
+
var $lastRow = $( 'tr', $excludeList ).last(),
|
321 |
+
$newRow = $lastRow.clone();
|
322 |
Â
|
323 |
+
$newRow.removeAttr( 'class' );
|
324 |
+
$( '.stream-exclude-list tbody :input' ).off();
|
325 |
+
$( ':input', $newRow ).off().val( '' );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
326 |
Â
|
327 |
+
$lastRow.after( $newRow );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
328 |
Â
|
329 |
+
initSettingsSelect2();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
330 |
Â
|
331 |
+
recalculate_rules_found();
|
332 |
+
recalculate_rules_selected();
|
333 |
+
}
|
334 |
+
);
|
335 |
Â
|
336 |
+
$( '#exclude_rules_remove_rules' ).on(
|
337 |
+
'click', function() {
|
338 |
+
var $excludeList = $( 'table.stream-exclude-list' ),
|
339 |
+
selectedRows = $( 'tbody input.cb-select:checked', $excludeList ).closest( 'tr' );
|
340 |
Â
|
341 |
+
if ( ( $( 'tbody tr', $excludeList ).length - selectedRows.length ) >= 2 ) {
|
342 |
+
selectedRows.remove();
|
343 |
+
} else {
|
344 |
+
$( ':input', selectedRows ).val( '' );
|
345 |
+
$( selectedRows ).not( ':first' ).remove();
|
346 |
+
$( '.select2-select', selectedRows ).select2( 'val', '' );
|
347 |
+
}
|
348 |
Â
|
349 |
+
$excludeList.find( 'input.cb-select' ).prop( 'checked', false );
|
350 |
Â
|
351 |
+
recalculate_rules_found();
|
352 |
+
recalculate_rules_selected();
|
353 |
+
}
|
354 |
+
);
|
355 |
Â
|
356 |
+
$( '.stream-exclude-list' ).closest( 'form' ).submit(
|
357 |
+
function() {
|
358 |
+
$( '.stream-exclude-list tbody tr.hidden', this ).each(
|
359 |
+
function() {
|
360 |
+
$( this ).find( ':input' ).removeAttr( 'name' );
|
361 |
+
}
|
362 |
+
);
|
363 |
+
$( '.stream-exclude-list tbody tr:not(.hidden) select.select2-select.connector_or_context', this ).each(
|
364 |
+
function() {
|
365 |
+
var parts = $( this ).val().split( '-' );
|
366 |
+
$( this ).siblings( '.connector' ).val( parts[0] );
|
367 |
+
$( this ).siblings( '.context' ).val( parts[1] );
|
368 |
+
$( this ).removeAttr( 'name' );
|
369 |
+
}
|
370 |
+
);
|
371 |
+
$( '.stream-exclude-list tbody tr:not(.hidden) select.select2-select.ip_address', this ).each(
|
372 |
+
function() {
|
373 |
+
var firstSelected = $( 'option:selected', this ).first();
|
374 |
+
$( 'option:selected:not(:first)', this ).each(
|
375 |
+
function() {
|
376 |
+
firstSelected.attr( 'value', firstSelected.attr( 'value' ) + ',' + $( this ).attr( 'value' ) );
|
377 |
+
$( this ).removeAttr( 'selected' );
|
378 |
+
}
|
379 |
+
);
|
380 |
+
}
|
381 |
+
);
|
382 |
+
}
|
383 |
+
);
|
384 |
Â
|
385 |
+
$( '.stream-exclude-list' ).closest( 'td' ).prev( 'th' ).hide();
|
Â
|
|
386 |
Â
|
387 |
+
$( 'table.stream-exclude-list' ).on(
|
388 |
+
'click', 'input.cb-select', function() {
|
389 |
+
recalculate_rules_selected();
|
390 |
+
}
|
391 |
+
);
|
392 |
Â
|
393 |
+
function getActions( row, connector ) {
|
394 |
+
var trigger_action = $( '.select2-select.action', row ),
|
395 |
+
action_value = trigger_action.val();
|
396 |
Â
|
397 |
+
trigger_action.empty();
|
398 |
+
trigger_action.prop( 'disabled', true );
|
Â
|
|
399 |
Â
|
400 |
+
var placeholder = $( '<option/>', {value: '', text: ''} );
|
401 |
+
trigger_action.append( placeholder );
|
402 |
Â
|
403 |
+
var data = {
|
404 |
+
'action' : 'get_actions',
|
405 |
+
'connector' : connector
|
406 |
+
};
|
407 |
Â
|
408 |
+
$.post(
|
409 |
+
window.ajaxurl, data, function( response ) {
|
410 |
+
var success = response.success,
|
411 |
+
actions = response.data;
|
412 |
+
if ( ! success ) {
|
413 |
+
return;
|
414 |
+
}
|
415 |
+
for ( var key in actions ) {
|
416 |
+
if ( actions.hasOwnProperty( key ) ) {
|
417 |
+
var value = actions[key];
|
418 |
+
var option = $( '<option/>', {value: key, text: value} );
|
419 |
+
trigger_action.append( option );
|
420 |
+
}
|
421 |
+
}
|
422 |
+
trigger_action.val( action_value );
|
423 |
+
trigger_action.prop( 'disabled', false );
|
424 |
+
$( document ).trigger( 'alert-actions-updated' );
|
425 |
+
}
|
426 |
+
);
|
427 |
+
}
|
428 |
Â
|
429 |
+
function recalculate_rules_selected() {
|
430 |
+
var $selectedRows = $( 'table.stream-exclude-list tbody tr:not( .hidden ) input.cb-select:checked' ),
|
431 |
+
$deleteButton = $( '#exclude_rules_remove_rules' );
|
432 |
Â
|
433 |
+
if ( 0 === $selectedRows.length ) {
|
434 |
+
$deleteButton.prop( 'disabled', true );
|
435 |
+
} else {
|
436 |
+
$deleteButton.prop( 'disabled', false );
|
437 |
+
}
|
Â
|
|
438 |
Â
}
|
439 |
Â
|
440 |
+
function recalculate_rules_found() {
|
441 |
+
var $allRows = $( 'table.stream-exclude-list tbody tr:not( .hidden )' ),
|
442 |
+
$noRulesFound = $( 'table.stream-exclude-list tbody tr.no-items' ),
|
443 |
+
$selectAll = $( '.check-column.manage-column input.cb-select' ),
|
444 |
+
$deleteButton = $( '#exclude_rules_remove_rules' );
|
445 |
+
|
446 |
+
if ( 0 === $allRows.length ) {
|
447 |
+
$noRulesFound.show();
|
448 |
+
$selectAll.prop( 'disabled', true );
|
449 |
+
$deleteButton.prop( 'disabled', true );
|
450 |
+
} else {
|
451 |
+
$noRulesFound.hide();
|
452 |
+
$selectAll.prop( 'disabled', false );
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
453 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
454 |
Â
|
455 |
+
wp_stream_regenerate_alt_rows( $allRows );
|
Â
|
|
Â
|
|
Â
|
|
456 |
Â
}
|
Â
|
|
457 |
Â
|
458 |
+
$( document ).ready(
|
459 |
+
function() {
|
460 |
+
recalculate_rules_found();
|
461 |
+
recalculate_rules_selected();
|
462 |
+
}
|
463 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
464 |
Â
}
|
465 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
ui/js/exclude.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
jQuery(function(e){function t(t,s){var n=e(".select2-select.action",t),l=n.val();n.empty(),n.prop("disabled",!0);var i=e("<option/>",{value:"",text:""});n.append(i);var c={action:"get_actions",connector:s};e.post(window.ajaxurl,c,function(t){var s=t.success,i=t.data;if(s){for(var c in i)if(i.hasOwnProperty(c)){var r=i[c],a=e("<option/>",{value:c,text:r});n.append(a)}n.val(l),n.prop("disabled",!1),e(document).trigger("alert-actions-updated")}})}function s(){var t=e("table.stream-exclude-list tbody tr:not( .hidden ) input.cb-select:checked"),s=e("#exclude_rules_remove_rules");0===t.length?s.prop("disabled",!0):s.prop("disabled",!1)}function n(){var t=e("table.stream-exclude-list tbody tr:not( .hidden )"),s=e("table.stream-exclude-list tbody tr.no-items"),n=e(".check-column.manage-column input.cb-select"),l=e("#exclude_rules_remove_rules");0===t.length?(s.show(),n.prop("disabled",!0),l.prop("disabled",!0)):(s.hide(),n.prop("disabled",!1)),wp_stream_regenerate_alt_rows(t)}var l=function(){var l;e(".stream-exclude-list tr:not(.hidden) select.select2-select.connector_or_context").each(function(s,n){e(n).select2({allowClear:!0,templateResult:function(t){return void 0===t.id?t.text:e(-1===t.id.indexOf("-")?'<span class="parent">'+t.text+"</span>":'<span class="child">'+t.text+"</span>")},matcher:function(t,s){var n=e.extend(!0,{},s);if(null==t.term||""===e.trim(t.term))return n;var l=t.term.toLowerCase();if(n.id=n.id.replace("blogs","sites"),n.id.toLowerCase().indexOf(l)>=0)return n;if(n.children){for(var i=n.children.length-1;i>=0;i--)-1===n.children[i].id.toLowerCase().indexOf(l)&&n.children.splice(i,1);if(n.children.length>0)return n}return null}}).on("change",function(){var s=e(this).closest("tr"),n=e(this).val();n&&0<n.indexOf("-")&&(n=n.split("-")[0]),t(s,n)})}),e(".stream-exclude-list tr:not(.hidden) select.select2-select.action").each(function(t,s){e(s).select2({allowClear:!0})}),e(".stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role").each(function(t,s){(l=e(s)).select2({ajax:{type:"POST",url:ajaxurl,dataType:"json",quietMillis:500,data:function(e,t){return{find:e,limit:10,pager:t,action:"stream_get_users",nonce:l.data("nonce")}},processResults:function(t){var s={results:[{text:"",id:""},{text:"Roles",children:[]},{text:"Users",children:[]}]};if(!0!==t.success||void 0===t.data||!0!==t.data.status)return s;if(void 0===t.data.users||void 0===t.data.roles)return s;var n=[];return e.each(t.data.roles,function(e,t){n.push({id:e,text:t})}),s.results[1].children=n,s.results[2].children=t.data.users,s}},templateResult:function(t){var s=e("<div>").text(t.text);return void 0!==t.icon&&t.icon&&(s.prepend(e('<img src="'+t.icon+'" class="wp-stream-select2-icon">')),s.attr("title",t.tooltip)),void 0!==t.tooltip?s.attr("title",t.tooltip):void 0!==t.user_count&&s.attr("title",t.user_count),s},templateSelection:function(t){var s=e("<div>").text(t.text);return e.isNumeric(t.id)&&t.text.indexOf("icon-users")<0&&s.append(e('<i class="icon16 icon-users"></i>')),s},allowClear:!0,placeholder:l.data("placeholder")}).on("change",function(){var t=e(this).select2("data");e(this).data("selected-id",t.id),e(this).data("selected-text",t.text)})}),e(".stream-exclude-list tr:not(.hidden) select.select2-select.ip_address").each(function(t,s){var n=e(s),l="";n.select2({ajax:{type:"POST",url:ajaxurl,dataType:"json",quietMillis:500,data:function(e){return l=e.term,{find:e,limit:10,action:"stream_get_ips",nonce:n.data("nonce")}},processResults:function(t){var s={results:[]},n=[];return!0===t.success&&void 0!==t.data&&e.each(t.data,function(e,t){s.results.push({id:t,text:t})}),void 0===l?s:null===(n=l.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/))?s:(n.shift(),(n=e.grep(n,function(e){var t=parseInt(e,10);return t<=255&&t.toString()===e})).length>=4&&s.results.push({id:l,text:l}),s)}},allowClear:!1,multiple:!0,maximumSelectionSize:1,placeholder:n.data("placeholder"),tags:!0})}).on("change",function(){e(this).prev(".select2-container").find("input.select2-input").blur()}),e("ul.select2-choices, ul.select2-choices li, input.select2-input",".stream-exclude-list tr:not(.hidden) .ip_address").on("mousedown click focus",function(){var t=e(this).closest(".select2-container"),s=t.find("input.select2-input");if(t.select2("data").length>=1)return s.blur(),!1}),e(".stream-exclude-list tr:not(.hidden) .exclude_rules_remove_rule_row").on("click",function(){e(this).closest("tr").remove(),n(),s()})};l(),e(".stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role").each(function(){var t=e("<option selected>"+e(this).data("selected-text")+"</option>").val(e(this).data("selected-id"));e(this).append(t).trigger("change")}),e(".stream-exclude-list tr:not(.hidden) select.select2-select.connector_or_context").each(function(){var t=[e(this).siblings(".connector").val(),e(this).siblings(".context").val()];""===t[1]&&t.splice(1,1),e(this).val(t.join("-")).trigger("change")}),e("#exclude_rules_new_rule").on("click",function(){var t=e("table.stream-exclude-list");e("tr:not(.hidden) select.select2-select",t).each(function(){e(this).select2("destroy")});var i=e("tr",t).last(),c=i.clone();c.removeAttr("class"),e(".stream-exclude-list tbody :input").off(),e(":input",c).off().val(""),i.after(c),l(),n(),s()}),e("#exclude_rules_remove_rules").on("click",function(){var t=e("table.stream-exclude-list"),l=e("tbody input.cb-select:checked",t).closest("tr");e("tbody tr",t).length-l.length>=2?l.remove():(e(":input",l).val(""),e(l).not(":first").remove(),e(".select2-select",l).select2("val","")),t.find("input.cb-select").prop("checked",!1),n(),s()}),e(".stream-exclude-list").closest("form").submit(function(){e(".stream-exclude-list tbody tr.hidden",this).each(function(){e(this).find(":input").removeAttr("name")}),e(".stream-exclude-list tbody tr:not(.hidden) select.select2-select.connector_or_context",this).each(function(){var t=e(this).val().split("-");e(this).siblings(".connector").val(t[0]),e(this).siblings(".context").val(t[1]),e(this).removeAttr("name")}),e(".stream-exclude-list tbody tr:not(.hidden) select.select2-select.ip_address",this).each(function(){var t=e("option:selected",this).first();e("option:selected:not(:first)",this).each(function(){t.attr("value",t.attr("value")+","+e(this).attr("value")),e(this).removeAttr("selected")})})}),e(".stream-exclude-list").closest("td").prev("th").hide(),e("table.stream-exclude-list").on("click","input.cb-select",function(){s()}),e(document).ready(function(){n(),s()})});
|
ui/js/global.js
CHANGED
@@ -1,30 +1,36 @@
|
|
1 |
Â
/* globals wp_stream_global */
|
2 |
Â
/* exported wp_stream_regenerate_alt_rows */
|
3 |
-
jQuery(
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
18 |
Â
}
|
19 |
-
});
|
20 |
Â
|
21 |
-
function warning_message( e ) {
|
22 |
-
if ( ! window.confirm( wp_stream_global.bulk_actions.i18n.confirm_action ) ) {
|
23 |
-
e.preventDefault();
|
24 |
-
}
|
25 |
Â
}
|
26 |
-
|
27 |
-
});
|
28 |
Â
|
29 |
Â
// Regenerate alternating row classes
|
30 |
Â
var wp_stream_regenerate_alt_rows = function( $rows ) {
|
@@ -34,7 +40,9 @@ var wp_stream_regenerate_alt_rows = function( $rows ) {
|
|
34 |
Â
|
35 |
Â
$rows.removeClass( 'alternate' );
|
36 |
Â
|
37 |
-
$rows.each(
|
38 |
-
|
39 |
-
|
Â
|
|
Â
|
|
40 |
Â
};
|
1 |
Â
/* globals wp_stream_global */
|
2 |
Â
/* exported wp_stream_regenerate_alt_rows */
|
3 |
+
jQuery(
|
4 |
+
function( $ ) {
|
5 |
+
|
6 |
+
// List table actions, ignores filtering
|
7 |
+
$( '.actions :submit:not([name="filter_action"])' ).on(
|
8 |
+
'click', function( e ) {
|
9 |
+
if ( $( 'table.widefat tbody :checkbox:checked' ).length > wp_stream_global.bulk_actions.threshold ) {
|
10 |
+
warning_message( e );
|
11 |
+
}
|
12 |
+
}
|
13 |
+
);
|
14 |
+
|
15 |
+
// Post type empty trash
|
16 |
+
$( '#delete_all' ).on(
|
17 |
+
'click', function( e ) {
|
18 |
+
var trash_count = parseInt( $( 'ul.subsubsub li.trash .count' ).text().replace( /\D/g, '' ), 10 );
|
19 |
+
|
20 |
+
if ( trash_count > wp_stream_global.bulk_actions.threshold ) {
|
21 |
+
warning_message( e );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
);
|
25 |
+
|
26 |
+
function warning_message( e ) {
|
27 |
+
if ( ! window.confirm( wp_stream_global.bulk_actions.i18n.confirm_action ) ) {
|
28 |
+
e.preventDefault();
|
29 |
+
}
|
30 |
Â
}
|
Â
|
|
31 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
32 |
Â
}
|
33 |
+
);
|
Â
|
|
34 |
Â
|
35 |
Â
// Regenerate alternating row classes
|
36 |
Â
var wp_stream_regenerate_alt_rows = function( $rows ) {
|
40 |
Â
|
41 |
Â
$rows.removeClass( 'alternate' );
|
42 |
Â
|
43 |
+
$rows.each(
|
44 |
+
function( index ) {
|
45 |
+
jQuery( this ).addClass( index % 2 ? '' : 'alternate' );
|
46 |
+
}
|
47 |
+
);
|
48 |
Â
};
|
ui/js/global.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
jQuery(function(t){function e(t){window.confirm(wp_stream_global.bulk_actions.i18n.confirm_action)||t.preventDefault()}t('.actions :submit:not([name="filter_action"])').on("click",function(n){t("table.widefat tbody :checkbox:checked").length>wp_stream_global.bulk_actions.threshold&&e(n)}),t("#delete_all").on("click",function(n){parseInt(t("ul.subsubsub li.trash .count").text().replace(/\D/g,""),10)>wp_stream_global.bulk_actions.threshold&&e(n)})});var wp_stream_regenerate_alt_rows=function(t){if(!t.length)return!1;t.removeClass("alternate"),t.each(function(t){jQuery(this).addClass(t%2?"":"alternate")})};
|
ui/js/live-updates.js
CHANGED
@@ -1,112 +1,125 @@
|
|
1 |
Â
/* globals wp_stream_live_updates, wp_stream_regenerate_alt_rows */
|
2 |
-
jQuery(
|
Â
|
|
3 |
Â
|
4 |
-
|
Â
|
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
10 |
Â
|
11 |
-
// Do not run if there are filters in use
|
12 |
-
if ( parseInt( wp_stream_live_updates.current_query_count, 10 ) > 1 ) {
|
13 |
-
return;
|
14 |
-
}
|
15 |
-
|
16 |
-
var list_sel = '.toplevel_page_wp_stream #the-list';
|
17 |
-
|
18 |
-
// Set initial beat to fast. WP is designed to slow this to 15 seconds after 2.5 minutes.
|
19 |
-
wp.heartbeat.interval( 'fast' );
|
20 |
-
|
21 |
-
$( document ).on( 'heartbeat-send.stream', function( e, data ) {
|
22 |
-
|
23 |
-
data['wp-stream-heartbeat'] = 'live-update';
|
24 |
-
|
25 |
-
var last_item = $( list_sel + ' tr:first .column-date time' ),
|
26 |
-
last_time = 1;
|
27 |
-
|
28 |
-
if ( 0 !== last_item.length ) {
|
29 |
-
last_time = ( '' === last_item.attr( 'datetime' ) ) ? 1 : last_item.attr( 'datetime' );
|
30 |
-
}
|
31 |
-
|
32 |
-
data['wp-stream-heartbeat-last-time'] = last_time;
|
33 |
-
data['wp-stream-heartbeat-query'] = wp_stream_live_updates.current_query;
|
34 |
-
});
|
35 |
-
|
36 |
-
// Listen for "heartbeat-tick" on $(document).
|
37 |
-
$( document ).on( 'heartbeat-tick.stream', function( e, data ) {
|
38 |
-
|
39 |
-
// If this no rows return then we kill the script
|
40 |
-
if ( ! data['wp-stream-heartbeat'] || 0 === data['wp-stream-heartbeat'].length ) {
|
41 |
-
return;
|
42 |
-
}
|
43 |
-
|
44 |
-
var show_on_screen = $( '#edit_stream_per_page' ).val(),
|
45 |
-
$current_items = $( list_sel + ' tr' ),
|
46 |
-
$new_items = $( data['wp-stream-heartbeat'] );
|
47 |
-
|
48 |
-
// Remove all default classes and add class to highlight new rows
|
49 |
-
$new_items.addClass( 'new-row' );
|
50 |
-
|
51 |
-
|
52 |
-
// Check if first tr has the alternate class
|
53 |
-
var has_class = ( $current_items.first().hasClass( 'alternate' ) );
|
54 |
-
|
55 |
-
// Apply the good class to the list
|
56 |
-
if ( 1 === $new_items.length && ! has_class ) {
|
57 |
-
$new_items.addClass( 'alternate' );
|
58 |
-
} else {
|
59 |
-
var even_or_odd = ( 0 === $new_items.length % 2 && ! has_class ) ? 'even' : 'odd';
|
60 |
-
// Add class to nth child because there is more than one element
|
61 |
-
$new_items.filter( ':nth-child(' + even_or_odd + ')' ).addClass( 'alternate' );
|
62 |
-
}
|
63 |
-
|
64 |
-
// Add element to the dom
|
65 |
-
$( list_sel ).prepend( $new_items );
|
66 |
-
|
67 |
-
$( '.metabox-prefs input' ).each( function() {
|
68 |
-
if ( true !== $( this ).prop( 'checked' ) ) {
|
69 |
-
var label = $( this ).val();
|
70 |
-
$( 'td.column-' + label ).hide();
|
71 |
Â
}
|
72 |
-
|
73 |
-
|
74 |
-
// Remove the number of element added to the end of the list table
|
75 |
-
var slice_rows = show_on_screen - ( $new_items.length + $current_items.length );
|
76 |
-
|
77 |
-
if ( slice_rows < 0 ) {
|
78 |
-
$( list_sel + ' tr' ).slice( slice_rows ).remove();
|
79 |
-
}
|
80 |
-
|
81 |
-
// Remove the no items row
|
82 |
-
$( list_sel + ' tr.no-items' ).remove();
|
83 |
-
|
84 |
-
// Update pagination
|
85 |
-
var total_items_i18n = data.total_items_i18n || '';
|
86 |
-
|
87 |
-
if ( total_items_i18n ) {
|
88 |
-
$( '.displaying-num' ).text( total_items_i18n );
|
89 |
-
$( '.total-pages' ).text( data.total_pages_i18n );
|
90 |
-
$( '.tablenav-pages' ).find( '.next-page, .last-page' ).toggleClass( 'disabled', data.total_pages === $( '.current-page' ).val() );
|
91 |
-
$( '.tablenav-pages .last-page' ).attr( 'href', data.last_page_link );
|
92 |
-
}
|
93 |
-
|
94 |
-
// Allow others to hook in, ie: timeago
|
95 |
-
$( list_sel ).parent().trigger( 'updated' );
|
96 |
-
|
97 |
-
// Regenerate alternating row classes
|
98 |
-
wp_stream_regenerate_alt_rows( $( list_sel + ' tr' ) );
|
99 |
-
|
100 |
-
// Remove background after a certain amount of time
|
101 |
-
setTimeout( function() {
|
102 |
-
$( '.new-row' ).addClass( 'fadeout' );
|
103 |
-
setTimeout( function() {
|
104 |
-
$( list_sel + ' tr' ).removeClass( 'new-row fadeout' );
|
105 |
-
}, 500 );
|
106 |
-
}, 3000 );
|
107 |
-
|
108 |
-
});
|
109 |
-
|
110 |
-
});
|
111 |
Â
|
112 |
-
}
|
Â
|
1 |
Â
/* globals wp_stream_live_updates, wp_stream_regenerate_alt_rows */
|
2 |
+
jQuery(
|
3 |
+
function( $ ) {
|
4 |
Â
|
5 |
+
$( document ).ready(
|
6 |
+
function() {
|
7 |
Â
|
8 |
+
// Only run on wp_stream when page is 1 and the order is desc
|
9 |
+
if ( 'toplevel_page_wp_stream' !== wp_stream_live_updates.current_screen || '1' !== wp_stream_live_updates.current_page || 'asc' === wp_stream_live_updates.current_order ) {
|
10 |
+
return;
|
11 |
+
}
|
12 |
+
|
13 |
+
// Do not run if there are filters in use
|
14 |
+
if ( parseInt( wp_stream_live_updates.current_query_count, 10 ) > 1 ) {
|
15 |
+
return;
|
16 |
+
}
|
17 |
+
|
18 |
+
var list_sel = '.toplevel_page_wp_stream #the-list';
|
19 |
+
|
20 |
+
// Set initial beat to fast. WP is designed to slow this to 15 seconds after 2.5 minutes.
|
21 |
+
wp.heartbeat.interval( 'fast' );
|
22 |
+
|
23 |
+
$( document ).on(
|
24 |
+
'heartbeat-send.stream', function( e, data ) {
|
25 |
+
|
26 |
+
data['wp-stream-heartbeat'] = 'live-update';
|
27 |
+
|
28 |
+
var last_item = $( list_sel + ' tr:first .column-date time' ),
|
29 |
+
last_time = 1;
|
30 |
+
|
31 |
+
if ( 0 !== last_item.length ) {
|
32 |
+
last_time = ( '' === last_item.attr( 'datetime' ) ) ? 1 : last_item.attr( 'datetime' );
|
33 |
+
}
|
34 |
+
|
35 |
+
data['wp-stream-heartbeat-last-time'] = last_time;
|
36 |
+
data['wp-stream-heartbeat-query'] = wp_stream_live_updates.current_query;
|
37 |
+
}
|
38 |
+
);
|
39 |
+
|
40 |
+
// Listen for "heartbeat-tick" on $(document).
|
41 |
+
$( document ).on(
|
42 |
+
'heartbeat-tick.stream', function( e, data ) {
|
43 |
+
|
44 |
+
// If this no rows return then we kill the script
|
45 |
+
if ( ! data['wp-stream-heartbeat'] || 0 === data['wp-stream-heartbeat'].length ) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
+
|
49 |
+
var show_on_screen = $( '#edit_stream_per_page' ).val(),
|
50 |
+
$current_items = $( list_sel + ' tr' ),
|
51 |
+
$new_items = $( data['wp-stream-heartbeat'] );
|
52 |
+
|
53 |
+
// Remove all default classes and add class to highlight new rows
|
54 |
+
$new_items.addClass( 'new-row' );
|
55 |
+
|
56 |
+
// Check if first tr has the alternate class
|
57 |
+
var has_class = ( $current_items.first().hasClass( 'alternate' ) );
|
58 |
+
|
59 |
+
// Apply the good class to the list
|
60 |
+
if ( 1 === $new_items.length && ! has_class ) {
|
61 |
+
$new_items.addClass( 'alternate' );
|
62 |
+
} else {
|
63 |
+
var even_or_odd = ( 0 === $new_items.length % 2 && ! has_class ) ? 'even' : 'odd';
|
64 |
+
// Add class to nth child because there is more than one element
|
65 |
+
$new_items.filter( ':nth-child(' + even_or_odd + ')' ).addClass( 'alternate' );
|
66 |
+
}
|
67 |
+
|
68 |
+
// Add element to the dom
|
69 |
+
$( list_sel ).prepend( $new_items );
|
70 |
+
|
71 |
+
$( '.metabox-prefs input' ).each(
|
72 |
+
function() {
|
73 |
+
if ( true !== $( this ).prop( 'checked' ) ) {
|
74 |
+
var label = $( this ).val();
|
75 |
+
$( 'td.column-' + label ).hide();
|
76 |
+
}
|
77 |
+
}
|
78 |
+
);
|
79 |
+
|
80 |
+
// Remove the number of element added to the end of the list table
|
81 |
+
var slice_rows = show_on_screen - ( $new_items.length + $current_items.length );
|
82 |
+
|
83 |
+
if ( slice_rows < 0 ) {
|
84 |
+
$( list_sel + ' tr' ).slice( slice_rows ).remove();
|
85 |
+
}
|
86 |
+
|
87 |
+
// Remove the no items row
|
88 |
+
$( list_sel + ' tr.no-items' ).remove();
|
89 |
+
|
90 |
+
// Update pagination
|
91 |
+
var total_items_i18n = data.total_items_i18n || '';
|
92 |
+
|
93 |
+
if ( total_items_i18n ) {
|
94 |
+
$( '.displaying-num' ).text( total_items_i18n );
|
95 |
+
$( '.total-pages' ).text( data.total_pages_i18n );
|
96 |
+
$( '.tablenav-pages' ).find( '.next-page, .last-page' ).toggleClass( 'disabled', data.total_pages === $( '.current-page' ).val() );
|
97 |
+
$( '.tablenav-pages .last-page' ).attr( 'href', data.last_page_link );
|
98 |
+
}
|
99 |
+
|
100 |
+
// Allow others to hook in, ie: timeago
|
101 |
+
$( list_sel ).parent().trigger( 'updated' );
|
102 |
+
|
103 |
+
// Regenerate alternating row classes
|
104 |
+
wp_stream_regenerate_alt_rows( $( list_sel + ' tr' ) );
|
105 |
+
|
106 |
+
// Remove background after a certain amount of time
|
107 |
+
setTimeout(
|
108 |
+
function() {
|
109 |
+
$( '.new-row' ).addClass( 'fadeout' );
|
110 |
+
setTimeout(
|
111 |
+
function() {
|
112 |
+
$( list_sel + ' tr' ).removeClass( 'new-row fadeout' );
|
113 |
+
}, 500
|
114 |
+
);
|
115 |
+
}, 3000
|
116 |
+
);
|
117 |
+
|
118 |
+
}
|
119 |
+
);
|
120 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
121 |
Â
}
|
122 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
123 |
Â
|
124 |
+
}
|
125 |
+
);
|
ui/js/live-updates.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
jQuery(function(e){e(document).ready(function(){if("toplevel_page_wp_stream"===wp_stream_live_updates.current_screen&&"1"===wp_stream_live_updates.current_page&&"asc"!==wp_stream_live_updates.current_order&&!(parseInt(wp_stream_live_updates.current_query_count,10)>1)){var t=".toplevel_page_wp_stream #the-list";wp.heartbeat.interval("fast"),e(document).on("heartbeat-send.stream",function(a,r){r["wp-stream-heartbeat"]="live-update";var s=e(t+" tr:first .column-date time"),n=1;0!==s.length&&(n=""===s.attr("datetime")?1:s.attr("datetime")),r["wp-stream-heartbeat-last-time"]=n,r["wp-stream-heartbeat-query"]=wp_stream_live_updates.current_query}),e(document).on("heartbeat-tick.stream",function(a,r){if(r["wp-stream-heartbeat"]&&0!==r["wp-stream-heartbeat"].length){var s=e("#edit_stream_per_page").val(),n=e(t+" tr"),l=e(r["wp-stream-heartbeat"]);l.addClass("new-row");var p=n.first().hasClass("alternate");if(1!==l.length||p){var i=0!=l.length%2||p?"odd":"even";l.filter(":nth-child("+i+")").addClass("alternate")}else l.addClass("alternate");e(t).prepend(l),e(".metabox-prefs input").each(function(){if(!0!==e(this).prop("checked")){var t=e(this).val();e("td.column-"+t).hide()}});var _=s-(l.length+n.length);_<0&&e(t+" tr").slice(_).remove(),e(t+" tr.no-items").remove();var d=r.total_items_i18n||"";d&&(e(".displaying-num").text(d),e(".total-pages").text(r.total_pages_i18n),e(".tablenav-pages").find(".next-page, .last-page").toggleClass("disabled",r.total_pages===e(".current-page").val()),e(".tablenav-pages .last-page").attr("href",r.last_page_link)),e(t).parent().trigger("updated"),wp_stream_regenerate_alt_rows(e(t+" tr")),setTimeout(function(){e(".new-row").addClass("fadeout"),setTimeout(function(){e(t+" tr").removeClass("new-row fadeout")},500)},3e3)}})}})});
|
ui/js/settings.js
CHANGED
@@ -1,75 +1,82 @@
|
|
1 |
-
/* globals confirm, wp_stream
|
2 |
-
jQuery(
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
network_affix = '';
|
8 |
-
}
|
9 |
-
var keepRecordsIndefinitely = $( '#wp_stream' + network_affix + '\\[general_keep_records_indefinitely\\]' ),
|
10 |
-
keepRecordsFor = $( '#wp_stream' + network_affix + '_general_records_ttl' ),
|
11 |
-
keepRecordsForRow = keepRecordsFor.closest( 'tr' );
|
12 |
-
|
13 |
-
function toggleKeepRecordsFor() {
|
14 |
-
if ( keepRecordsIndefinitely.is( ':checked' ) ) {
|
15 |
-
keepRecordsForRow.addClass( 'hidden' );
|
16 |
-
keepRecordsFor.addClass( 'hidden' );
|
17 |
Â
} else {
|
18 |
-
|
19 |
-
keepRecordsFor.removeClass( 'hidden' );
|
20 |
Â
}
|
21 |
-
|
Â
|
|
Â
|
|
22 |
Â
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
e.preventDefault();
|
32 |
Â
}
|
33 |
-
});
|
34 |
Â
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
$activeTab = $tabs.find( '.nav-tab-active' ),
|
39 |
-
defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
|
40 |
-
hashIndex = window.location.hash.match( /^#(\d+)$/ ),
|
41 |
-
currentHash = ( null !== hashIndex ? hashIndex[ 1 ] : defaultIndex ),
|
42 |
-
syncFormAction = function( index ) {
|
43 |
-
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
44 |
-
if ( $optionsForm.length === 0 ) {
|
45 |
-
return;
|
46 |
Â
}
|
47 |
-
|
48 |
Â
|
49 |
-
|
50 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
51 |
Â
|
52 |
-
|
53 |
-
var
|
54 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
55 |
Â
|
56 |
-
|
Â
|
|
57 |
Â
|
58 |
-
$tabs
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
.addClass( 'nav-tab-active' );
|
63 |
Â
|
64 |
-
|
65 |
-
window.location.hash = index;
|
66 |
-
}
|
67 |
Â
|
68 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
69 |
Â
|
70 |
-
|
71 |
-
|
Â
|
|
72 |
Â
|
73 |
-
|
74 |
Â
|
75 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
/* globals confirm, wp_stream */
|
2 |
+
jQuery(
|
3 |
+
function( $ ) {
|
4 |
+
var network_affix;
|
5 |
+
if ( 'wp_stream_network' === $( 'input[name="option_page"]' ).val() ) {
|
6 |
+
network_affix = '_network_affix';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
7 |
Â
} else {
|
8 |
+
network_affix = '';
|
Â
|
|
9 |
Â
}
|
10 |
+
var keepRecordsIndefinitely = $( '#wp_stream' + network_affix + '\\[general_keep_records_indefinitely\\]' ),
|
11 |
+
keepRecordsFor = $( '#wp_stream' + network_affix + '_general_records_ttl' ),
|
12 |
+
keepRecordsForRow = keepRecordsFor.closest( 'tr' );
|
13 |
Â
|
14 |
+
function toggleKeepRecordsFor() {
|
15 |
+
if ( keepRecordsIndefinitely.is( ':checked' ) ) {
|
16 |
+
keepRecordsForRow.addClass( 'hidden' );
|
17 |
+
keepRecordsFor.addClass( 'hidden' );
|
18 |
+
} else {
|
19 |
+
keepRecordsForRow.removeClass( 'hidden' );
|
20 |
+
keepRecordsFor.removeClass( 'hidden' );
|
21 |
+
}
|
Â
|
|
22 |
Â
}
|
Â
|
|
23 |
Â
|
24 |
+
keepRecordsIndefinitely.on(
|
25 |
+
'change', function() {
|
26 |
+
toggleKeepRecordsFor();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
}
|
28 |
+
);
|
29 |
Â
|
30 |
+
toggleKeepRecordsFor();
|
31 |
+
// Confirmation on some important actions
|
32 |
+
$( '#wp_stream_general_reset_site_settings' ).click(
|
33 |
+
function( e ) {
|
34 |
+
if ( ! confirm( wp_stream.i18n.confirm_defaults ) ) {
|
35 |
+
e.preventDefault();
|
36 |
+
}
|
37 |
+
}
|
38 |
+
);
|
39 |
Â
|
40 |
+
// Settings page tabs
|
41 |
+
var $tabs = $( '.nav-tab-wrapper' ),
|
42 |
+
$panels = $( '.nav-tab-content table.form-table' ),
|
43 |
+
$activeTab = $tabs.find( '.nav-tab-active' ),
|
44 |
+
defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
|
45 |
+
hashIndex = window.location.hash.match( /^#(\d+)$/ ),
|
46 |
+
currentHash = ( null !== hashIndex ? hashIndex[ 1 ] : defaultIndex ),
|
47 |
+
syncFormAction = function( index ) {
|
48 |
+
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
49 |
+
if ( $optionsForm.length === 0 ) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
var currentAction = $optionsForm.attr( 'action' );
|
53 |
Â
|
54 |
+
$optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
|
55 |
+
};
|
56 |
Â
|
57 |
+
$tabs.on(
|
58 |
+
'click', 'a', function() {
|
59 |
+
var index = $tabs.find( 'a' ).index( $( this ) ),
|
60 |
+
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
Â
|
|
61 |
Â
|
62 |
+
$panels.hide().eq( index ).show();
|
Â
|
|
Â
|
|
63 |
Â
|
64 |
+
$tabs
|
65 |
+
.find( 'a' )
|
66 |
+
.removeClass( 'nav-tab-active' )
|
67 |
+
.filter( $( this ) )
|
68 |
+
.addClass( 'nav-tab-active' );
|
69 |
Â
|
70 |
+
if ( '' === window.location.hash || null !== hashIndex ) {
|
71 |
+
window.location.hash = index;
|
72 |
+
}
|
73 |
Â
|
74 |
+
syncFormAction( index );
|
75 |
Â
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
);
|
79 |
+
|
80 |
+
$tabs.children().eq( currentHash ).trigger( 'click' );
|
81 |
+
}
|
82 |
+
);
|
ui/js/settings.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
jQuery(function(e){function a(){t.is(":checked")?(r.addClass("hidden"),i.addClass("hidden")):(r.removeClass("hidden"),i.removeClass("hidden"))}var n;n="wp_stream_network"===e('input[name="option_page"]').val()?"_network_affix":"";var t=e("#wp_stream"+n+"\\[general_keep_records_indefinitely\\]"),i=e("#wp_stream"+n+"_general_records_ttl"),r=i.closest("tr");t.on("change",function(){a()}),a(),e("#wp_stream_general_reset_site_settings").click(function(e){confirm(wp_stream.i18n.confirm_defaults)||e.preventDefault()});var o=e(".nav-tab-wrapper"),s=e(".nav-tab-content table.form-table"),c=o.find(".nav-tab-active"),l=c.length>0?o.find("a").index(c):0,d=window.location.hash.match(/^#(\d+)$/),h=null!==d?d[1]:l,_=function(a){var n=e('input[name="option_page"][value^="wp_stream"]').closest("form");if(0!==n.length){var t=n.attr("action");n.prop("action",t.replace(/(^[^#]*).*$/,"$1#"+a))}};o.on("click","a",function(){var a=o.find("a").index(e(this)),n=window.location.hash.match(/^#(\d+)$/);return s.hide().eq(a).show(),o.find("a").removeClass("nav-tab-active").filter(e(this)).addClass("nav-tab-active"),""!==window.location.hash&&null===n||(window.location.hash=a),_(a),!1}),o.children().eq(h).trigger("click")});
|
ui/js/wpseo-admin.js
CHANGED
@@ -1,32 +1,38 @@
|
|
1 |
Â
// globals jQuery, $
|
2 |
-
jQuery(
|
Â
|
|
3 |
Â
|
4 |
-
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
Â
|
10 |
-
|
11 |
Â
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
Â
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
}
|
30 |
-
}
|
31 |
Â
|
32 |
-
}
|
Â
|
1 |
Â
// globals jQuery, $
|
2 |
+
jQuery(
|
3 |
+
function( $ ) {
|
4 |
Â
|
5 |
+
var highlight, input, tab;
|
6 |
Â
|
7 |
+
if ( window.location.hash.substr( 'stream-highlight-' ) ) {
|
8 |
+
highlight = window.location.hash.replace( 'stream-highlight-', '' );
|
9 |
+
input = $( ':input' + highlight );
|
10 |
Â
|
11 |
+
window.location.hash = '';
|
12 |
Â
|
13 |
+
if ( input.length ) {
|
14 |
+
if ( $( '#wpseo-tabs' ).length ) {
|
15 |
+
tab = input.parents( '.wpseotab' ).first().attr( 'id' );
|
16 |
+
window.location.hash = '#top#' + tab;
|
17 |
+
}
|
18 |
Â
|
19 |
+
jQuery( document ).ready(
|
20 |
+
function() {
|
21 |
+
setTimeout(
|
22 |
+
function() {
|
23 |
+
$( 'body,html' ).animate(
|
24 |
+
{ scrollTop: input.offset().top - 50 },
|
25 |
+
'slow',
|
26 |
+
function() {
|
27 |
+
input.animate( { backgroundColor: 'yellow' }, 'slow' );
|
28 |
+
}
|
29 |
+
);
|
30 |
+
}, 500
|
31 |
+
);
|
32 |
+
}
|
33 |
+
);
|
34 |
+
}
|
35 |
Â
}
|
Â
|
|
36 |
Â
|
37 |
+
}
|
38 |
+
);
|
ui/js/wpseo-admin.min.js
ADDED
@@ -0,0 +1 @@
|
|
Â
|
1 |
+
jQuery(function(o){var t,n,a;window.location.hash.substr("stream-highlight-")&&(t=window.location.hash.replace("stream-highlight-",""),n=o(":input"+t),window.location.hash="",n.length&&(o("#wpseo-tabs").length&&(a=n.parents(".wpseotab").first().attr("id"),window.location.hash="#top#"+a),jQuery(document).ready(function(){setTimeout(function(){o("body,html").animate({scrollTop:n.offset().top-50},"slow",function(){n.animate({backgroundColor:"yellow"},"slow")})},500)})))});
|
ui/lib/select2/css/select2.css
CHANGED
File without changes
|
ui/lib/select2/css/select2.min.css
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ar.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/az.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/bg.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ca.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/cs.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/da.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/de.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/el.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/en.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/es.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/et.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/eu.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/fa.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/fi.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/fr.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/gl.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/he.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/hi.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/hr.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/hu.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/id.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/is.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/it.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ja.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/km.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ko.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/lt.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/lv.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/mk.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ms.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/nb.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/nl.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/pl.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/pt-BR.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/pt.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ro.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/ru.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/sk.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/sr-Cyrl.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/sr.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/sv.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/th.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/tr.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/uk.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/vi.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/zh-CN.js
CHANGED
File without changes
|
ui/lib/select2/js/i18n/zh-TW.js
CHANGED
File without changes
|
ui/lib/select2/js/select2.full.js
CHANGED
File without changes
|
ui/lib/select2/js/select2.full.min.js
CHANGED
File without changes
|
ui/lib/select2/js/select2.js
CHANGED
File without changes
|
ui/lib/select2/js/select2.min.js
CHANGED
File without changes
|
ui/lib/timeago/jquery.timeago.js
CHANGED
File without changes
|
ui/lib/timeago/locales/README.md
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.ar.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.bg.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.bs.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.ca.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.cs.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.cy.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.da.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.de.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.el.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.en-short.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.en.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.es-short.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.es.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.et.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.fa.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.fi.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.fr-short.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.fr.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.gl.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.he.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.hr.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.hu.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.hy.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.id.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.is.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.it.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.ja.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.jv.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.ko.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.lt.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.mk.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.nl.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.no.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.pl.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.pt-br-short.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.pt-br.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.pt.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.ro.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.rs.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.ru.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.sk.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.sl.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.sv.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.th.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.tr.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.uk.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.uz.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.vi.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.zh-CN.js
CHANGED
File without changes
|
ui/lib/timeago/locales/jquery.timeago.zh-TW.js
CHANGED
File without changes
|
ui/stream-icons/font/stream.eot
CHANGED
File without changes
|
ui/stream-icons/font/stream.svg
CHANGED
File without changes
|
ui/stream-icons/font/stream.ttf
CHANGED
File without changes
|
ui/stream-icons/font/stream.woff
CHANGED
File without changes
|
ui/stream-icons/style.css
CHANGED
File without changes
|