Version Description
July 13, 2019 =
New: Add development environment and documentation, update tooling #1016.
New: Add Mercator connector #993, props @spacedmonkey).
Fix: Respect the
DISALLOW_FILE_MODS
constant and prevent plugin uninstall, if set. #997 fixes #988, props @lukecarbis and @josephfusco.
Download this release
Release Info
Developer | kasparsd |
Plugin | Stream |
Version | 3.4.0 |
Comparing to | |
See all releases |
Code changes from version 3.3.0 to 3.4.0
- alerts/class-alert-trigger-context.php +6 -3
- alerts/class-alert-type-email.php +13 -6
- alerts/class-alert-type-highlight.php +33 -11
- alerts/class-alert-type-ifttt.php +14 -7
- alerts/class-alert-type-menu-alert.php +4 -2
- alerts/class-alert-type-slack.php +23 -11
- alerts/js/alert-type-highlight.js +47 -53
- classes/class-admin.php +46 -24
- classes/class-alerts-list.php +21 -3
- classes/class-alerts.php +68 -35
- classes/class-author.php +10 -2
- classes/class-connector.php +6 -6
- classes/class-connectors.php +2 -0
- classes/class-db.php +2 -1
- classes/class-form-generator.php +4 -2
- classes/class-install.php +7 -2
- classes/class-list-table.php +22 -10
- classes/class-live-update.php +4 -2
- classes/class-log.php +4 -2
- classes/class-network.php +3 -1
- classes/class-plugin.php +4 -2
- classes/class-record.php +2 -2
- classes/class-settings.php +34 -15
- classes/class-uninstall.php +7 -2
- connectors/class-connector-acf.php +14 -14
- connectors/class-connector-bbpress.php +4 -4
- connectors/class-connector-blogs.php +1 -1
- connectors/class-connector-buddypress.php +8 -4
- connectors/class-connector-comments.php +3 -3
- connectors/class-connector-edd.php +35 -17
- connectors/class-connector-gravityforms.php +6 -6
- connectors/class-connector-installer.php +3 -2
- connectors/class-connector-jetpack.php +1 -1
- connectors/class-connector-media.php +1 -1
- connectors/class-connector-menus.php +5 -4
- connectors/class-connector-mercator.php +221 -0
- connectors/class-connector-posts.php +4 -4
- connectors/class-connector-settings.php +9 -10
- connectors/class-connector-taxonomies.php +5 -5
- connectors/class-connector-user-switching.php +0 -1
- connectors/class-connector-users.php +7 -7
- connectors/class-connector-widgets.php +4 -3
- connectors/class-connector-woocommerce.php +15 -12
- connectors/class-connector-wordpress-seo.php +93 -93
- contributing.md +158 -0
- includes/db-updates.php +8 -4
- includes/functions.php +6 -4
- readme.md +23 -0
- readme.txt +28 -14
- stream.php +4 -3
- ui/js/admin.js +409 -412
- ui/js/alerts-list.js +8 -8
- ui/js/alerts.js +241 -243
- ui/js/exclude.js +335 -337
- ui/js/exclude.min.js +1 -1
- ui/js/global.js +17 -19
- ui/js/live-updates.js +91 -98
- ui/js/settings.js +15 -14
- ui/js/wpseo-admin.js +4 -6
alerts/class-alert-trigger-context.php
CHANGED
@@ -76,7 +76,8 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
76 |
$context_values = array();
|
77 |
|
78 |
$form->add_field(
|
79 |
-
'select2',
|
|
|
80 |
'name' => 'wp_stream_trigger_connector_or_context',
|
81 |
'options' => $this->get_values(),
|
82 |
'classes' => 'wp_stream_ajax_forward connector_or_context',
|
@@ -87,7 +88,8 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
87 |
);
|
88 |
|
89 |
$form->add_field(
|
90 |
-
'hidden',
|
|
|
91 |
'name' => 'wp_stream_trigger_connector',
|
92 |
'value' => $connector,
|
93 |
'classes' => 'connector wp_stream_ajax_forward',
|
@@ -95,7 +97,8 @@ class Alert_Trigger_Context extends Alert_Trigger {
|
|
95 |
);
|
96 |
|
97 |
$form->add_field(
|
98 |
-
'hidden',
|
|
|
99 |
'name' => 'wp_stream_trigger_context',
|
100 |
'value' => $context,
|
101 |
'classes' => 'context wp_stream_ajax_forward',
|
76 |
$context_values = array();
|
77 |
|
78 |
$form->add_field(
|
79 |
+
'select2',
|
80 |
+
array(
|
81 |
'name' => 'wp_stream_trigger_connector_or_context',
|
82 |
'options' => $this->get_values(),
|
83 |
'classes' => 'wp_stream_ajax_forward connector_or_context',
|
88 |
);
|
89 |
|
90 |
$form->add_field(
|
91 |
+
'hidden',
|
92 |
+
array(
|
93 |
'name' => 'wp_stream_trigger_connector',
|
94 |
'value' => $connector,
|
95 |
'classes' => 'connector wp_stream_ajax_forward',
|
97 |
);
|
98 |
|
99 |
$form->add_field(
|
100 |
+
'hidden',
|
101 |
+
array(
|
102 |
'name' => 'wp_stream_trigger_context',
|
103 |
'value' => $context,
|
104 |
'classes' => 'context wp_stream_ajax_forward',
|
alerts/class-alert-type-email.php
CHANGED
@@ -43,10 +43,13 @@ class Alert_Type_Email extends Alert_Type {
|
|
43 |
return;
|
44 |
}
|
45 |
add_filter(
|
46 |
-
'wp_stream_alerts_save_meta',
|
|
|
47 |
$this,
|
48 |
'add_alert_meta',
|
49 |
-
),
|
|
|
|
|
50 |
);
|
51 |
}
|
52 |
|
@@ -60,7 +63,8 @@ class Alert_Type_Email extends Alert_Type {
|
|
60 |
*/
|
61 |
public function alert( $record_id, $recordarr, $alert ) {
|
62 |
$options = wp_parse_args(
|
63 |
-
$alert->alert_meta,
|
|
|
64 |
'email_recipient' => '',
|
65 |
'email_subject' => '',
|
66 |
'trigger_action' => '',
|
@@ -131,7 +135,8 @@ class Alert_Type_Email extends Alert_Type {
|
|
131 |
$alert_meta = $alert->alert_meta;
|
132 |
}
|
133 |
$options = wp_parse_args(
|
134 |
-
$alert_meta,
|
|
|
135 |
'email_recipient' => '',
|
136 |
'email_subject' => '',
|
137 |
)
|
@@ -142,7 +147,8 @@ class Alert_Type_Email extends Alert_Type {
|
|
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',
|
|
|
146 |
'name' => 'wp_stream_email_recipient',
|
147 |
'title' => esc_attr( __( 'Email Recipient', 'stream' ) ),
|
148 |
'value' => $options['email_recipient'],
|
@@ -153,7 +159,8 @@ class Alert_Type_Email extends Alert_Type {
|
|
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',
|
|
|
157 |
'name' => 'wp_stream_email_subject',
|
158 |
'title' => esc_attr( __( 'Email Subject', 'stream' ) ),
|
159 |
'value' => $options['email_subject'],
|
43 |
return;
|
44 |
}
|
45 |
add_filter(
|
46 |
+
'wp_stream_alerts_save_meta',
|
47 |
+
array(
|
48 |
$this,
|
49 |
'add_alert_meta',
|
50 |
+
),
|
51 |
+
10,
|
52 |
+
2
|
53 |
);
|
54 |
}
|
55 |
|
63 |
*/
|
64 |
public function alert( $record_id, $recordarr, $alert ) {
|
65 |
$options = wp_parse_args(
|
66 |
+
$alert->alert_meta,
|
67 |
+
array(
|
68 |
'email_recipient' => '',
|
69 |
'email_subject' => '',
|
70 |
'trigger_action' => '',
|
135 |
$alert_meta = $alert->alert_meta;
|
136 |
}
|
137 |
$options = wp_parse_args(
|
138 |
+
$alert_meta,
|
139 |
+
array(
|
140 |
'email_recipient' => '',
|
141 |
'email_subject' => '',
|
142 |
)
|
147 |
echo '<label for="wp_stream_email_recipient"><span class="title">' . esc_html__( 'Recipient', 'stream' ) . '</span>';
|
148 |
echo '<span class="input-text-wrap">';
|
149 |
echo $form->render_field(
|
150 |
+
'text',
|
151 |
+
array(
|
152 |
'name' => 'wp_stream_email_recipient',
|
153 |
'title' => esc_attr( __( 'Email Recipient', 'stream' ) ),
|
154 |
'value' => $options['email_recipient'],
|
159 |
echo '<label for="wp_stream_email_subject"><span class="title">' . esc_html__( 'Subject', 'stream' ) . '</span>';
|
160 |
echo '<span class="input-text-wrap">';
|
161 |
echo $form->render_field(
|
162 |
+
'text',
|
163 |
+
array(
|
164 |
'name' => 'wp_stream_email_subject',
|
165 |
'title' => esc_attr( __( 'Email Subject', 'stream' ) ),
|
166 |
'value' => $options['email_subject'],
|
alerts/class-alert-type-highlight.php
CHANGED
@@ -70,19 +70,24 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
70 |
return;
|
71 |
}
|
72 |
add_filter(
|
73 |
-
'wp_stream_record_classes',
|
|
|
74 |
$this,
|
75 |
'post_class',
|
76 |
-
),
|
|
|
|
|
77 |
);
|
78 |
add_action(
|
79 |
-
'admin_enqueue_scripts',
|
|
|
80 |
$this,
|
81 |
'enqueue_scripts',
|
82 |
)
|
83 |
);
|
84 |
add_action(
|
85 |
-
'wp_ajax_' . self::REMOVE_ACTION,
|
|
|
86 |
$this,
|
87 |
'ajax_remove_highlight',
|
88 |
)
|
@@ -91,19 +96,25 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
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,
|
|
|
95 |
$this,
|
96 |
'action_link_remove_highlight',
|
97 |
-
),
|
|
|
|
|
98 |
);
|
99 |
}
|
100 |
}
|
101 |
|
102 |
add_filter(
|
103 |
-
'wp_stream_alerts_save_meta',
|
|
|
104 |
$this,
|
105 |
'add_alert_meta',
|
106 |
-
),
|
|
|
|
|
107 |
);
|
108 |
}
|
109 |
|
@@ -141,7 +152,8 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
141 |
$alert_meta = $alert->alert_meta;
|
142 |
}
|
143 |
$options = wp_parse_args(
|
144 |
-
$alert_meta,
|
|
|
145 |
'color' => 'yellow',
|
146 |
)
|
147 |
);
|
@@ -151,7 +163,8 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
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',
|
|
|
155 |
'name' => 'wp_stream_highlight_color',
|
156 |
'title' => esc_attr( __( 'Highlight Color', 'stream' ) ),
|
157 |
'options' => $this->get_highlight_options(),
|
@@ -295,7 +308,16 @@ class Alert_Type_Highlight extends Alert_Type {
|
|
295 |
public function enqueue_scripts( $page ) {
|
296 |
if ( 'toplevel_page_wp_stream' === $page ) {
|
297 |
$min = wp_stream_min_suffix();
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
$exports = array(
|
301 |
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
70 |
return;
|
71 |
}
|
72 |
add_filter(
|
73 |
+
'wp_stream_record_classes',
|
74 |
+
array(
|
75 |
$this,
|
76 |
'post_class',
|
77 |
+
),
|
78 |
+
10,
|
79 |
+
2
|
80 |
);
|
81 |
add_action(
|
82 |
+
'admin_enqueue_scripts',
|
83 |
+
array(
|
84 |
$this,
|
85 |
'enqueue_scripts',
|
86 |
)
|
87 |
);
|
88 |
add_action(
|
89 |
+
'wp_ajax_' . self::REMOVE_ACTION,
|
90 |
+
array(
|
91 |
$this,
|
92 |
'ajax_remove_highlight',
|
93 |
)
|
96 |
if ( ! empty( $this->plugin->connectors->connectors ) && is_array( $this->plugin->connectors->connectors ) ) {
|
97 |
foreach ( $this->plugin->connectors->connectors as $connector ) {
|
98 |
add_filter(
|
99 |
+
'wp_stream_action_links_' . $connector->name,
|
100 |
+
array(
|
101 |
$this,
|
102 |
'action_link_remove_highlight',
|
103 |
+
),
|
104 |
+
10,
|
105 |
+
2
|
106 |
);
|
107 |
}
|
108 |
}
|
109 |
|
110 |
add_filter(
|
111 |
+
'wp_stream_alerts_save_meta',
|
112 |
+
array(
|
113 |
$this,
|
114 |
'add_alert_meta',
|
115 |
+
),
|
116 |
+
10,
|
117 |
+
2
|
118 |
);
|
119 |
}
|
120 |
|
152 |
$alert_meta = $alert->alert_meta;
|
153 |
}
|
154 |
$options = wp_parse_args(
|
155 |
+
$alert_meta,
|
156 |
+
array(
|
157 |
'color' => 'yellow',
|
158 |
)
|
159 |
);
|
163 |
echo '<label for="wp_stream_highlight_color"><span class="title">' . esc_html__( 'Color', 'stream' ) . '</span>';
|
164 |
echo '<span class="input-text-wrap">';
|
165 |
echo $form->render_field(
|
166 |
+
'select',
|
167 |
+
array(
|
168 |
'name' => 'wp_stream_highlight_color',
|
169 |
'title' => esc_attr( __( 'Highlight Color', 'stream' ) ),
|
170 |
'options' => $this->get_highlight_options(),
|
308 |
public function enqueue_scripts( $page ) {
|
309 |
if ( 'toplevel_page_wp_stream' === $page ) {
|
310 |
$min = wp_stream_min_suffix();
|
311 |
+
|
312 |
+
wp_register_script(
|
313 |
+
self::SCRIPT_HANDLE,
|
314 |
+
$this->plugin->locations['url'] . 'alerts/js/alert-type-highlight.' . $min . 'js',
|
315 |
+
array(
|
316 |
+
'jquery',
|
317 |
+
),
|
318 |
+
$this->plugin->get_version(),
|
319 |
+
false
|
320 |
+
);
|
321 |
|
322 |
$exports = array(
|
323 |
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
alerts/class-alert-type-ifttt.php
CHANGED
@@ -76,10 +76,13 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
76 |
return;
|
77 |
}
|
78 |
add_filter(
|
79 |
-
'wp_stream_alerts_save_meta',
|
|
|
80 |
$this,
|
81 |
'add_alert_meta',
|
82 |
-
),
|
|
|
|
|
83 |
);
|
84 |
}
|
85 |
|
@@ -111,7 +114,8 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
111 |
$alert_meta = $alert->alert_meta;
|
112 |
}
|
113 |
$options = wp_parse_args(
|
114 |
-
$alert_meta,
|
|
|
115 |
'maker_key' => '',
|
116 |
'event_name' => '',
|
117 |
)
|
@@ -126,7 +130,8 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
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',
|
|
|
130 |
'name' => 'wp_stream_ifttt_maker_key',
|
131 |
'title' => esc_attr( __( 'Maker Key', 'stream' ) ),
|
132 |
'value' => $options['maker_key'],
|
@@ -144,7 +149,8 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
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',
|
|
|
148 |
'name' => 'wp_stream_ifttt_event_name',
|
149 |
'title' => esc_attr( __( 'Event Name', 'stream' ) ),
|
150 |
'value' => $options['event_name'],
|
@@ -200,7 +206,8 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
200 |
}
|
201 |
|
202 |
$record_data = wp_parse_args(
|
203 |
-
$recordarr,
|
|
|
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(),
|
@@ -251,7 +258,7 @@ class Alert_Type_IFTTT extends Alert_Type {
|
|
251 |
*
|
252 |
* value3 = Record Date
|
253 |
* (see the wp_stream_alert_ifttt_date_format filter above)
|
254 |
-
|
255 |
* The filters below allow complete customization of these data values.
|
256 |
*/
|
257 |
$args = array(
|
76 |
return;
|
77 |
}
|
78 |
add_filter(
|
79 |
+
'wp_stream_alerts_save_meta',
|
80 |
+
array(
|
81 |
$this,
|
82 |
'add_alert_meta',
|
83 |
+
),
|
84 |
+
10,
|
85 |
+
2
|
86 |
);
|
87 |
}
|
88 |
|
114 |
$alert_meta = $alert->alert_meta;
|
115 |
}
|
116 |
$options = wp_parse_args(
|
117 |
+
$alert_meta,
|
118 |
+
array(
|
119 |
'maker_key' => '',
|
120 |
'event_name' => '',
|
121 |
)
|
130 |
echo '<label for="wp_stream_ifttt_maker_key"><span class="title">' . esc_html__( 'Maker Key', 'stream' ) . '</span>';
|
131 |
echo '<span class="input-text-wrap">';
|
132 |
echo $form->render_field(
|
133 |
+
'text',
|
134 |
+
array(
|
135 |
'name' => 'wp_stream_ifttt_maker_key',
|
136 |
'title' => esc_attr( __( 'Maker Key', 'stream' ) ),
|
137 |
'value' => $options['maker_key'],
|
149 |
echo '<label for="wp_stream_ifttt_event_name"><span class="title">' . esc_html__( 'Event Name', 'stream' ) . '</span>';
|
150 |
echo '<span class="input-text-wrap">';
|
151 |
echo $form->render_field(
|
152 |
+
'text',
|
153 |
+
array(
|
154 |
'name' => 'wp_stream_ifttt_event_name',
|
155 |
'title' => esc_attr( __( 'Event Name', 'stream' ) ),
|
156 |
'value' => $options['event_name'],
|
206 |
}
|
207 |
|
208 |
$record_data = wp_parse_args(
|
209 |
+
$recordarr,
|
210 |
+
array(
|
211 |
// translators: Placeholder refers to the Event Name of the Alert (e.g. "Update a post")
|
212 |
'summary' => sprintf( __( 'The event %s was triggered' ), $alert->alert_meta['event_name'] ),
|
213 |
'user_id' => get_current_user_id(),
|
258 |
*
|
259 |
* value3 = Record Date
|
260 |
* (see the wp_stream_alert_ifttt_date_format filter above)
|
261 |
+
*
|
262 |
* The filters below allow complete customization of these data values.
|
263 |
*/
|
264 |
$args = array(
|
alerts/class-alert-type-menu-alert.php
CHANGED
@@ -63,14 +63,16 @@ class Alert_Type_Menu_Alert extends Alert_Type {
|
|
63 |
$alert_meta = $alert->alert_meta;
|
64 |
}
|
65 |
$options = wp_parse_args(
|
66 |
-
$alert_meta,
|
|
|
67 |
'clear_immediate' => false,
|
68 |
)
|
69 |
);
|
70 |
|
71 |
$form = new Form_Generator();
|
72 |
$form->add_field(
|
73 |
-
'checkbox',
|
|
|
74 |
'name' => 'wp_stream_menu_alert_clear_immediate',
|
75 |
'text' => esc_attr( __( 'Clear alerts after seen.', 'stream' ) ),
|
76 |
'value' => $options['clear_immediate'],
|
63 |
$alert_meta = $alert->alert_meta;
|
64 |
}
|
65 |
$options = wp_parse_args(
|
66 |
+
$alert_meta,
|
67 |
+
array(
|
68 |
'clear_immediate' => false,
|
69 |
)
|
70 |
);
|
71 |
|
72 |
$form = new Form_Generator();
|
73 |
$form->add_field(
|
74 |
+
'checkbox',
|
75 |
+
array(
|
76 |
'name' => 'wp_stream_menu_alert_clear_immediate',
|
77 |
'text' => esc_attr( __( 'Clear alerts after seen.', 'stream' ) ),
|
78 |
'value' => $options['clear_immediate'],
|
alerts/class-alert-type-slack.php
CHANGED
@@ -40,10 +40,13 @@ class Alert_Type_Slack extends Alert_Type {
|
|
40 |
return;
|
41 |
}
|
42 |
add_filter(
|
43 |
-
'wp_stream_alerts_save_meta',
|
|
|
44 |
$this,
|
45 |
'add_alert_meta',
|
46 |
-
),
|
|
|
|
|
47 |
);
|
48 |
}
|
49 |
|
@@ -57,7 +60,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
57 |
*/
|
58 |
public function alert( $record_id, $recordarr, $alert ) {
|
59 |
$options = wp_parse_args(
|
60 |
-
$alert->alert_meta,
|
|
|
61 |
'webhook' => '',
|
62 |
'channel' => '',
|
63 |
'username' => '',
|
@@ -115,7 +119,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
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,
|
|
|
119 |
'title' => 'Edit ' . $post_type->labels->singular_name,
|
120 |
'value' => "<$edit_post_link>",
|
121 |
'short' => false,
|
@@ -125,7 +130,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
125 |
|
126 |
$edit_alert_link = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $alert->ID );
|
127 |
array_push(
|
128 |
-
$fields,
|
|
|
129 |
'title' => 'Edit Alert',
|
130 |
'value' => "<$edit_alert_link>",
|
131 |
'short' => false,
|
@@ -165,7 +171,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
165 |
}
|
166 |
}
|
167 |
wp_remote_post(
|
168 |
-
$options['webhook'],
|
|
|
169 |
'body' => wp_json_encode( $data ),
|
170 |
'headers' => array( 'Content-Type' => 'application/json' ),
|
171 |
)
|
@@ -184,7 +191,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
184 |
$alert_meta = $alert->alert_meta;
|
185 |
}
|
186 |
$options = wp_parse_args(
|
187 |
-
$alert_meta,
|
|
|
188 |
'webhook' => '',
|
189 |
'channel' => '',
|
190 |
'username' => '',
|
@@ -196,7 +204,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
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',
|
|
|
200 |
'name' => 'wp_stream_slack_webhook',
|
201 |
'title' => esc_attr( __( 'Webhook URL', 'stream' ) ),
|
202 |
'value' => $options['webhook'],
|
@@ -208,7 +217,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
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',
|
|
|
212 |
'name' => 'wp_stream_slack_channel',
|
213 |
'title' => esc_attr( __( 'Channel', 'stream' ) ),
|
214 |
'value' => $options['channel'],
|
@@ -220,7 +230,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
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',
|
|
|
224 |
'name' => 'wp_stream_slack_username',
|
225 |
'title' => esc_attr( __( 'Username', 'stream' ) ),
|
226 |
'value' => $options['username'],
|
@@ -232,7 +243,8 @@ class Alert_Type_Slack extends Alert_Type {
|
|
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',
|
|
|
236 |
'name' => 'wp_stream_slack_icon',
|
237 |
'title' => esc_attr( __( 'Icon', 'stream' ) ),
|
238 |
'value' => $options['icon'],
|
40 |
return;
|
41 |
}
|
42 |
add_filter(
|
43 |
+
'wp_stream_alerts_save_meta',
|
44 |
+
array(
|
45 |
$this,
|
46 |
'add_alert_meta',
|
47 |
+
),
|
48 |
+
10,
|
49 |
+
2
|
50 |
);
|
51 |
}
|
52 |
|
60 |
*/
|
61 |
public function alert( $record_id, $recordarr, $alert ) {
|
62 |
$options = wp_parse_args(
|
63 |
+
$alert->alert_meta,
|
64 |
+
array(
|
65 |
'webhook' => '',
|
66 |
'channel' => '',
|
67 |
'username' => '',
|
119 |
$post_type = get_post_type_object( $post->post_type );
|
120 |
$edit_post_link = get_edit_post_link( $post->ID, 'raw' );
|
121 |
array_push(
|
122 |
+
$fields,
|
123 |
+
array(
|
124 |
'title' => 'Edit ' . $post_type->labels->singular_name,
|
125 |
'value' => "<$edit_post_link>",
|
126 |
'short' => false,
|
130 |
|
131 |
$edit_alert_link = admin_url( 'edit.php?post_type=wp_stream_alerts#post-' . $alert->ID );
|
132 |
array_push(
|
133 |
+
$fields,
|
134 |
+
array(
|
135 |
'title' => 'Edit Alert',
|
136 |
'value' => "<$edit_alert_link>",
|
137 |
'short' => false,
|
171 |
}
|
172 |
}
|
173 |
wp_remote_post(
|
174 |
+
$options['webhook'],
|
175 |
+
array(
|
176 |
'body' => wp_json_encode( $data ),
|
177 |
'headers' => array( 'Content-Type' => 'application/json' ),
|
178 |
)
|
191 |
$alert_meta = $alert->alert_meta;
|
192 |
}
|
193 |
$options = wp_parse_args(
|
194 |
+
$alert_meta,
|
195 |
+
array(
|
196 |
'webhook' => '',
|
197 |
'channel' => '',
|
198 |
'username' => '',
|
204 |
echo '<label for="wp_stream_slack_webhook"><span class="title">' . esc_html__( 'Webhook URL', 'stream' ) . '</span>';
|
205 |
echo '<span class="input-text-wrap">';
|
206 |
echo $form->render_field(
|
207 |
+
'text',
|
208 |
+
array(
|
209 |
'name' => 'wp_stream_slack_webhook',
|
210 |
'title' => esc_attr( __( 'Webhook URL', 'stream' ) ),
|
211 |
'value' => $options['webhook'],
|
217 |
echo '<label for="wp_stream_slack_channel"><span class="title">' . esc_html__( 'Channel', 'stream' ) . '</span>';
|
218 |
echo '<span class="input-text-wrap">';
|
219 |
echo $form->render_field(
|
220 |
+
'text',
|
221 |
+
array(
|
222 |
'name' => 'wp_stream_slack_channel',
|
223 |
'title' => esc_attr( __( 'Channel', 'stream' ) ),
|
224 |
'value' => $options['channel'],
|
230 |
echo '<label for="wp_stream_slack_username"><span class="title">' . esc_html__( 'Username', 'stream' ) . '</span>';
|
231 |
echo '<span class="input-text-wrap">';
|
232 |
echo $form->render_field(
|
233 |
+
'text',
|
234 |
+
array(
|
235 |
'name' => 'wp_stream_slack_username',
|
236 |
'title' => esc_attr( __( 'Username', 'stream' ) ),
|
237 |
'value' => $options['username'],
|
243 |
echo '<label for="wp_stream_slack_icon"><span class="title">' . esc_html__( 'Icon', 'stream' ) . '</span>';
|
244 |
echo '<span class="input-text-wrap">';
|
245 |
echo $form->render_field(
|
246 |
+
'text',
|
247 |
+
array(
|
248 |
'name' => 'wp_stream_slack_icon',
|
249 |
'title' => esc_attr( __( 'Icon', 'stream' ) ),
|
250 |
'value' => $options['icon'],
|
alerts/js/alert-type-highlight.js
CHANGED
@@ -4,7 +4,7 @@ var streamAlertTypeHighlight = ( function( $ ) {
|
|
4 |
var self = {
|
5 |
ajaxUrl: '',
|
6 |
removeAction: '',
|
7 |
-
security: ''
|
8 |
};
|
9 |
|
10 |
if ( 'undefined' !== typeof _streamAlertTypeHighlightExports ) {
|
@@ -13,77 +13,71 @@ var streamAlertTypeHighlight = ( function( $ ) {
|
|
13 |
|
14 |
/**
|
15 |
* The primary function for this file.
|
16 |
-
*
|
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 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
}
|
55 |
}
|
56 |
-
|
|
|
57 |
|
58 |
-
|
59 |
* Fires when Ajax complete.
|
60 |
*/
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
}
|
77 |
-
actionLink.remove();
|
78 |
}
|
|
|
79 |
}
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
83 |
}
|
84 |
); // End document.ready().
|
85 |
};
|
86 |
|
87 |
return self;
|
88 |
-
|
89 |
-
})( jQuery );
|
4 |
var self = {
|
5 |
ajaxUrl: '',
|
6 |
removeAction: '',
|
7 |
+
security: '',
|
8 |
};
|
9 |
|
10 |
if ( 'undefined' !== typeof _streamAlertTypeHighlightExports ) {
|
13 |
|
14 |
/**
|
15 |
* The primary function for this file.
|
|
|
|
|
16 |
*/
|
17 |
self.init = function() {
|
18 |
$( document ).ready(
|
19 |
function() {
|
20 |
+
/**
|
21 |
+
* Remove highlights on Record list screen.
|
22 |
+
*/
|
23 |
+
$( '.alert-highlight .action-link[href="#"]' ).each(
|
24 |
+
function() {
|
25 |
+
var actionLink = $( this );
|
26 |
|
27 |
+
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
* Ajax call to remove the highlight.
|
29 |
*
|
30 |
* @returns void.
|
31 |
*/
|
32 |
+
actionLink.click(
|
33 |
+
function( e ) {
|
34 |
+
var recordId, data;
|
35 |
+
e.preventDefault();
|
36 |
+
recordId = actionLink.parents( '.alert-highlight' ).attr( 'class' ).match( /record\-id\-[\w-]*\b/ );
|
37 |
+
recordId = recordId[0].replace( 'record-id-', '' );
|
38 |
|
39 |
+
data = {
|
40 |
+
action: self.removeAction,
|
41 |
+
security: self.security,
|
42 |
+
recordId: recordId,
|
43 |
+
};
|
44 |
|
45 |
+
$.post(
|
46 |
+
self.ajaxUrl, data, function( response ) {
|
47 |
+
if ( true === response.success ) {
|
48 |
+
ajaxDone();
|
|
|
49 |
}
|
50 |
+
}
|
51 |
+
);
|
52 |
|
53 |
+
/**
|
54 |
* Fires when Ajax complete.
|
55 |
*/
|
56 |
+
function ajaxDone() {
|
57 |
+
var row = actionLink.parents( '.alert-highlight' ),
|
58 |
+
odd = $( '.striped > tbody > :nth-child( odd )' );
|
59 |
+
if ( row.is( odd ) ) {
|
60 |
+
row.animate(
|
61 |
+
{ backgroundColor: '#f9f9f9' }, 300, function() {
|
62 |
+
row.removeClass( 'alert-highlight' );
|
63 |
+
}
|
64 |
+
);
|
65 |
+
} else {
|
66 |
+
row.animate(
|
67 |
+
{ backgroundColor: '' }, 300, function() {
|
68 |
+
row.removeClass( 'alert-highlight' );
|
69 |
+
}
|
70 |
+
);
|
|
|
|
|
71 |
}
|
72 |
+
actionLink.remove();
|
73 |
}
|
74 |
+
}
|
75 |
+
);
|
76 |
+
}
|
77 |
+
);
|
78 |
}
|
79 |
); // End document.ready().
|
80 |
};
|
81 |
|
82 |
return self;
|
83 |
+
}( jQuery ) );
|
|
classes/class-admin.php
CHANGED
@@ -155,15 +155,19 @@ class Admin {
|
|
155 |
|
156 |
// Plugin action links.
|
157 |
add_filter(
|
158 |
-
'plugin_action_links',
|
|
|
159 |
$this,
|
160 |
'plugin_action_links',
|
161 |
-
),
|
|
|
|
|
162 |
);
|
163 |
|
164 |
// Load admin scripts and styles.
|
165 |
add_action(
|
166 |
-
'admin_enqueue_scripts',
|
|
|
167 |
$this,
|
168 |
'admin_enqueue_scripts',
|
169 |
)
|
@@ -172,7 +176,8 @@ class Admin {
|
|
172 |
|
173 |
// Reset Streams database.
|
174 |
add_action(
|
175 |
-
'wp_ajax_wp_stream_reset',
|
|
|
176 |
$this,
|
177 |
'wp_ajax_reset',
|
178 |
)
|
@@ -184,7 +189,8 @@ class Admin {
|
|
184 |
// Auto purge setup.
|
185 |
add_action( 'wp_loaded', array( $this, 'purge_schedule_setup' ) );
|
186 |
add_action(
|
187 |
-
'wp_stream_auto_purge',
|
|
|
188 |
$this,
|
189 |
'purge_scheduled_action',
|
190 |
)
|
@@ -192,7 +198,8 @@ class Admin {
|
|
192 |
|
193 |
// Ajax users list.
|
194 |
add_action(
|
195 |
-
'wp_ajax_wp_stream_filters',
|
|
|
196 |
$this,
|
197 |
'ajax_filters',
|
198 |
)
|
@@ -359,7 +366,8 @@ class Admin {
|
|
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'],
|
|
|
363 |
$this,
|
364 |
'register_list_table',
|
365 |
)
|
@@ -403,22 +411,31 @@ class Admin {
|
|
403 |
wp_enqueue_script( 'wp-stream-timeago-locale' );
|
404 |
|
405 |
wp_enqueue_script(
|
406 |
-
'wp-stream-admin',
|
|
|
|
|
407 |
'jquery',
|
408 |
'wp-stream-select2',
|
409 |
-
),
|
|
|
410 |
);
|
411 |
wp_enqueue_script(
|
412 |
-
'wp-stream-admin-exclude',
|
|
|
|
|
413 |
'jquery',
|
414 |
'wp-stream-select2',
|
415 |
-
),
|
|
|
416 |
);
|
417 |
wp_enqueue_script(
|
418 |
-
'wp-stream-live-updates',
|
|
|
|
|
419 |
'jquery',
|
420 |
'heartbeat',
|
421 |
-
),
|
|
|
422 |
);
|
423 |
|
424 |
wp_localize_script(
|
@@ -734,27 +751,31 @@ class Admin {
|
|
734 |
$admin_page_url = add_query_arg(
|
735 |
array(
|
736 |
'page' => $this->network->network_settings_page_slug,
|
737 |
-
),
|
|
|
738 |
);
|
739 |
} else {
|
740 |
$admin_page_url = add_query_arg(
|
741 |
array(
|
742 |
'page' => $this->settings_page_slug,
|
743 |
-
),
|
|
|
744 |
);
|
745 |
}
|
746 |
|
747 |
$links[] = sprintf( '<a href="%s">%s</a>', esc_url( $admin_page_url ), esc_html__( 'Settings', 'default' ) );
|
748 |
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
|
|
756 |
|
757 |
-
|
|
|
758 |
|
759 |
return $links;
|
760 |
}
|
@@ -837,7 +858,8 @@ class Admin {
|
|
837 |
*/
|
838 |
public function register_list_table() {
|
839 |
$this->list_table = new List_Table(
|
840 |
-
$this->plugin,
|
|
|
841 |
'screen' => $this->screen_id['main'],
|
842 |
)
|
843 |
);
|
155 |
|
156 |
// Plugin action links.
|
157 |
add_filter(
|
158 |
+
'plugin_action_links',
|
159 |
+
array(
|
160 |
$this,
|
161 |
'plugin_action_links',
|
162 |
+
),
|
163 |
+
10,
|
164 |
+
2
|
165 |
);
|
166 |
|
167 |
// Load admin scripts and styles.
|
168 |
add_action(
|
169 |
+
'admin_enqueue_scripts',
|
170 |
+
array(
|
171 |
$this,
|
172 |
'admin_enqueue_scripts',
|
173 |
)
|
176 |
|
177 |
// Reset Streams database.
|
178 |
add_action(
|
179 |
+
'wp_ajax_wp_stream_reset',
|
180 |
+
array(
|
181 |
$this,
|
182 |
'wp_ajax_reset',
|
183 |
)
|
189 |
// Auto purge setup.
|
190 |
add_action( 'wp_loaded', array( $this, 'purge_schedule_setup' ) );
|
191 |
add_action(
|
192 |
+
'wp_stream_auto_purge',
|
193 |
+
array(
|
194 |
$this,
|
195 |
'purge_scheduled_action',
|
196 |
)
|
198 |
|
199 |
// Ajax users list.
|
200 |
add_action(
|
201 |
+
'wp_ajax_wp_stream_filters',
|
202 |
+
array(
|
203 |
$this,
|
204 |
'ajax_filters',
|
205 |
)
|
366 |
|
367 |
// Register the list table early, so it associates the column headers with 'Screen settings'.
|
368 |
add_action(
|
369 |
+
'load-' . $this->screen_id['main'],
|
370 |
+
array(
|
371 |
$this,
|
372 |
'register_list_table',
|
373 |
)
|
411 |
wp_enqueue_script( 'wp-stream-timeago-locale' );
|
412 |
|
413 |
wp_enqueue_script(
|
414 |
+
'wp-stream-admin',
|
415 |
+
$this->plugin->locations['url'] . 'ui/js/admin.' . $min . 'js',
|
416 |
+
array(
|
417 |
'jquery',
|
418 |
'wp-stream-select2',
|
419 |
+
),
|
420 |
+
$this->plugin->get_version()
|
421 |
);
|
422 |
wp_enqueue_script(
|
423 |
+
'wp-stream-admin-exclude',
|
424 |
+
$this->plugin->locations['url'] . 'ui/js/exclude.' . $min . 'js',
|
425 |
+
array(
|
426 |
'jquery',
|
427 |
'wp-stream-select2',
|
428 |
+
),
|
429 |
+
$this->plugin->get_version()
|
430 |
);
|
431 |
wp_enqueue_script(
|
432 |
+
'wp-stream-live-updates',
|
433 |
+
$this->plugin->locations['url'] . 'ui/js/live-updates.' . $min . 'js',
|
434 |
+
array(
|
435 |
'jquery',
|
436 |
'heartbeat',
|
437 |
+
),
|
438 |
+
$this->plugin->get_version()
|
439 |
);
|
440 |
|
441 |
wp_localize_script(
|
751 |
$admin_page_url = add_query_arg(
|
752 |
array(
|
753 |
'page' => $this->network->network_settings_page_slug,
|
754 |
+
),
|
755 |
+
network_admin_url( $this->admin_parent_page )
|
756 |
);
|
757 |
} else {
|
758 |
$admin_page_url = add_query_arg(
|
759 |
array(
|
760 |
'page' => $this->settings_page_slug,
|
761 |
+
),
|
762 |
+
admin_url( $this->admin_parent_page )
|
763 |
);
|
764 |
}
|
765 |
|
766 |
$links[] = sprintf( '<a href="%s">%s</a>', esc_url( $admin_page_url ), esc_html__( 'Settings', 'default' ) );
|
767 |
|
768 |
+
if ( ! defined( 'DISALLOW_FILE_MODS' ) || false === DISALLOW_FILE_MODS ) {
|
769 |
+
$url = add_query_arg(
|
770 |
+
array(
|
771 |
+
'action' => 'wp_stream_uninstall',
|
772 |
+
'wp_stream_nonce' => wp_create_nonce( 'stream_nonce' ),
|
773 |
+
),
|
774 |
+
admin_url( 'admin-ajax.php' )
|
775 |
+
);
|
776 |
|
777 |
+
$links[] = sprintf( '<span id="wp_stream_uninstall" class="delete"><a href="%s">%s</a></span>', esc_url( $url ), esc_html__( 'Uninstall', 'stream' ) );
|
778 |
+
}
|
779 |
|
780 |
return $links;
|
781 |
}
|
858 |
*/
|
859 |
public function register_list_table() {
|
860 |
$this->list_table = new List_Table(
|
861 |
+
$this->plugin,
|
862 |
+
array(
|
863 |
'screen' => $this->screen_id['main'],
|
864 |
)
|
865 |
);
|
classes/class-alerts-list.php
CHANGED
@@ -316,7 +316,7 @@ class Alerts_List {
|
|
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';
|
@@ -339,10 +339,28 @@ class Alerts_List {
|
|
339 |
if ( 'edit-wp_stream_alerts' !== $screen->id ) {
|
340 |
return;
|
341 |
}
|
|
|
342 |
$min = wp_stream_min_suffix();
|
343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
}
|
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';
|
339 |
if ( 'edit-wp_stream_alerts' !== $screen->id ) {
|
340 |
return;
|
341 |
}
|
342 |
+
|
343 |
$min = wp_stream_min_suffix();
|
344 |
+
|
345 |
+
wp_register_script(
|
346 |
+
'wp-stream-alerts-list-js',
|
347 |
+
$this->plugin->locations['url'] . 'ui/js/alerts-list.' . $min . 'js',
|
348 |
+
array(
|
349 |
+
'wp-stream-alerts',
|
350 |
+
'jquery',
|
351 |
+
),
|
352 |
+
$this->plugin->get_version(),
|
353 |
+
false
|
354 |
+
);
|
355 |
+
|
356 |
+
wp_register_style(
|
357 |
+
'wp-stream-alerts-list-css',
|
358 |
+
$this->plugin->locations['url'] . 'ui/css/alerts-list.' . $min . 'css',
|
359 |
+
[],
|
360 |
+
$this->plugin->get_version()
|
361 |
+
);
|
362 |
+
|
363 |
wp_enqueue_script( 'wp-stream-alerts-list-js' );
|
|
|
364 |
wp_enqueue_style( 'wp-stream-alerts-list-css' );
|
365 |
wp_enqueue_style( 'wp-stream-select2' );
|
366 |
}
|
classes/class-alerts.php
CHANGED
@@ -67,32 +67,51 @@ class Alerts {
|
|
67 |
add_action( 'wp_stream_admin_menu', array( $this, 'register_menu' ) );
|
68 |
|
69 |
// Add scripts to post screens.
|
70 |
-
add_action(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
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 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
$this,
|
97 |
'get_new_alert_triggers_notifications',
|
98 |
)
|
@@ -101,10 +120,15 @@ class Alerts {
|
|
101 |
$this->load_alert_types();
|
102 |
$this->load_alert_triggers();
|
103 |
|
104 |
-
add_filter(
|
105 |
-
|
106 |
-
|
107 |
-
|
|
|
|
|
|
|
|
|
|
|
108 |
|
109 |
}
|
110 |
|
@@ -278,14 +302,22 @@ class Alerts {
|
|
278 |
if ( 'edit-wp_stream_alerts' === $screen->id ) {
|
279 |
|
280 |
$min = wp_stream_min_suffix();
|
281 |
-
|
282 |
-
|
283 |
-
'
|
284 |
-
'
|
285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
wp_localize_script(
|
288 |
-
'wp-stream-alerts',
|
|
|
289 |
array(
|
290 |
'any' => __( 'Any', 'stream' ),
|
291 |
'anyContext' => __( 'Any Context', 'stream' ),
|
@@ -485,7 +517,8 @@ class Alerts {
|
|
485 |
$form = new Form_Generator();
|
486 |
|
487 |
$field_html = $form->render_field(
|
488 |
-
'select',
|
|
|
489 |
'id' => 'wp_stream_alert_type',
|
490 |
'name' => 'wp_stream_alert_type',
|
491 |
'value' => $alert_type,
|
67 |
add_action( 'wp_stream_admin_menu', array( $this, 'register_menu' ) );
|
68 |
|
69 |
// Add scripts to post screens.
|
70 |
+
add_action(
|
71 |
+
'admin_enqueue_scripts',
|
72 |
+
array(
|
73 |
+
$this,
|
74 |
+
'register_scripts',
|
75 |
+
)
|
76 |
+
);
|
77 |
+
|
78 |
+
add_action(
|
79 |
+
'network_admin_menu',
|
80 |
+
array(
|
81 |
+
$this,
|
82 |
+
'change_menu_link_url',
|
83 |
+
),
|
84 |
+
99
|
85 |
+
);
|
86 |
+
|
87 |
+
add_filter(
|
88 |
+
'wp_stream_record_inserted',
|
89 |
+
array(
|
90 |
+
$this,
|
91 |
+
'check_records',
|
92 |
+
),
|
93 |
+
10,
|
94 |
+
2
|
95 |
+
);
|
96 |
+
|
97 |
+
add_action(
|
98 |
+
'wp_ajax_load_alerts_settings',
|
99 |
+
array(
|
100 |
+
$this,
|
101 |
+
'load_alerts_settings',
|
102 |
+
)
|
103 |
+
);
|
104 |
add_action( 'wp_ajax_get_actions', array( $this, 'get_actions' ) );
|
|
|
|
|
|
|
|
|
105 |
add_action(
|
106 |
+
'wp_ajax_save_new_alert',
|
107 |
+
array(
|
108 |
+
$this,
|
109 |
+
'save_new_alert',
|
110 |
+
)
|
111 |
+
);
|
112 |
+
add_action(
|
113 |
+
'wp_ajax_get_new_alert_triggers_notifications',
|
114 |
+
array(
|
115 |
$this,
|
116 |
'get_new_alert_triggers_notifications',
|
117 |
)
|
120 |
$this->load_alert_types();
|
121 |
$this->load_alert_triggers();
|
122 |
|
123 |
+
add_filter(
|
124 |
+
'wp_stream_action_links_posts',
|
125 |
+
array(
|
126 |
+
$this,
|
127 |
+
'change_alert_action_links',
|
128 |
+
),
|
129 |
+
11,
|
130 |
+
2
|
131 |
+
);
|
132 |
|
133 |
}
|
134 |
|
302 |
if ( 'edit-wp_stream_alerts' === $screen->id ) {
|
303 |
|
304 |
$min = wp_stream_min_suffix();
|
305 |
+
|
306 |
+
wp_register_script(
|
307 |
+
'wp-stream-alerts',
|
308 |
+
$this->plugin->locations['url'] . 'ui/js/alerts.' . $min . 'js',
|
309 |
+
array(
|
310 |
+
'wp-stream-select2',
|
311 |
+
'jquery',
|
312 |
+
'inline-edit-post',
|
313 |
+
),
|
314 |
+
$this->plugin->get_version(),
|
315 |
+
false
|
316 |
+
);
|
317 |
|
318 |
wp_localize_script(
|
319 |
+
'wp-stream-alerts',
|
320 |
+
'streamAlerts',
|
321 |
array(
|
322 |
'any' => __( 'Any', 'stream' ),
|
323 |
'anyContext' => __( 'Any Context', 'stream' ),
|
517 |
$form = new Form_Generator();
|
518 |
|
519 |
$field_html = $form->render_field(
|
520 |
+
'select',
|
521 |
+
array(
|
522 |
'id' => 'wp_stream_alert_type',
|
523 |
'name' => 'wp_stream_alert_type',
|
524 |
'value' => $alert_type,
|
classes/class-author.php
CHANGED
@@ -186,8 +186,16 @@ class Author {
|
|
186 |
$user_role = $wp_roles->role_names[ $this->meta['user_role'] ];
|
187 |
} elseif ( ! empty( $this->meta['user_role_label'] ) ) {
|
188 |
$user_role = $this->meta['user_role_label'];
|
189 |
-
} elseif (
|
190 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
} elseif ( is_multisite() && is_super_admin( $this->id ) ) {
|
192 |
$user_role = $wp_roles->role_names['administrator'];
|
193 |
}
|
186 |
$user_role = $wp_roles->role_names[ $this->meta['user_role'] ];
|
187 |
} elseif ( ! empty( $this->meta['user_role_label'] ) ) {
|
188 |
$user_role = $this->meta['user_role_label'];
|
189 |
+
} elseif ( ! empty( $this->user->roles ) ) {
|
190 |
+
$roles = array_map(
|
191 |
+
function( $role ) use ( $wp_roles ) {
|
192 |
+
return $wp_roles->role_names[ $role ];
|
193 |
+
},
|
194 |
+
$this->user->roles
|
195 |
+
);
|
196 |
+
|
197 |
+
$separator = apply_filters( 'wp_stream_get_role_list_separator', ' - ' );
|
198 |
+
$user_role = implode( $separator, $roles );
|
199 |
} elseif ( is_multisite() && is_super_admin( $this->id ) ) {
|
200 |
$user_role = $wp_roles->role_names['administrator'];
|
201 |
}
|
classes/class-connector.php
CHANGED
@@ -82,7 +82,7 @@ abstract class Connector {
|
|
82 |
/**
|
83 |
* Add action links to Stream drop row in admin list screen
|
84 |
*
|
85 |
-
* @param array
|
86 |
* @param object $record Stream record
|
87 |
*
|
88 |
* @filter wp_stream_action_links_{connector}
|
@@ -98,11 +98,11 @@ abstract class Connector {
|
|
98 |
* Log handler
|
99 |
*
|
100 |
* @param string $message sprintf-ready error message string
|
101 |
-
* @param array
|
102 |
-
* @param int
|
103 |
* @param string $context Context of the event
|
104 |
* @param string $action Action of the event
|
105 |
-
* @param int
|
106 |
*
|
107 |
* @return bool
|
108 |
*/
|
@@ -158,8 +158,8 @@ abstract class Connector {
|
|
158 |
/**
|
159 |
* Compare two values and return changed keys if they are arrays
|
160 |
*
|
161 |
-
* @param mixed
|
162 |
-
* @param mixed
|
163 |
* @param bool|int $deep Get array children changes keys as well, not just parents
|
164 |
*
|
165 |
* @return array
|
82 |
/**
|
83 |
* Add action links to Stream drop row in admin list screen
|
84 |
*
|
85 |
+
* @param array $links Previous links registered
|
86 |
* @param object $record Stream record
|
87 |
*
|
88 |
* @filter wp_stream_action_links_{connector}
|
98 |
* Log handler
|
99 |
*
|
100 |
* @param string $message sprintf-ready error message string
|
101 |
+
* @param array $args sprintf (and extra) arguments to use
|
102 |
+
* @param int $object_id Target object id
|
103 |
* @param string $context Context of the event
|
104 |
* @param string $action Action of the event
|
105 |
+
* @param int $user_id User responsible for the event
|
106 |
*
|
107 |
* @return bool
|
108 |
*/
|
158 |
/**
|
159 |
* Compare two values and return changed keys if they are arrays
|
160 |
*
|
161 |
+
* @param mixed $old_value Value before change
|
162 |
+
* @param mixed $new_value Value after change
|
163 |
* @param bool|int $deep Get array children changes keys as well, not just parents
|
164 |
*
|
165 |
* @return array
|
classes/class-connectors.php
CHANGED
@@ -4,6 +4,7 @@ namespace WP_Stream;
|
|
4 |
class Connectors {
|
5 |
/**
|
6 |
* Hold Plugin class
|
|
|
7 |
* @var Plugin
|
8 |
*/
|
9 |
public $plugin;
|
@@ -76,6 +77,7 @@ class Connectors {
|
|
76 |
'edd',
|
77 |
'gravityforms',
|
78 |
'jetpack',
|
|
|
79 |
'user-switching',
|
80 |
'woocommerce',
|
81 |
'wordpress-seo',
|
4 |
class Connectors {
|
5 |
/**
|
6 |
* Hold Plugin class
|
7 |
+
*
|
8 |
* @var Plugin
|
9 |
*/
|
10 |
public $plugin;
|
77 |
'edd',
|
78 |
'gravityforms',
|
79 |
'jetpack',
|
80 |
+
'mercator',
|
81 |
'user-switching',
|
82 |
'woocommerce',
|
83 |
'wordpress-seo',
|
classes/class-db.php
CHANGED
@@ -47,7 +47,8 @@ class DB {
|
|
47 |
$record = apply_filters( 'wp_stream_record_array', $record );
|
48 |
|
49 |
array_walk(
|
50 |
-
$record,
|
|
|
51 |
if ( ! is_array( $value ) ) {
|
52 |
$value = strip_tags( $value );
|
53 |
}
|
47 |
$record = apply_filters( 'wp_stream_record_array', $record );
|
48 |
|
49 |
array_walk(
|
50 |
+
$record,
|
51 |
+
function( &$value, &$key ) {
|
52 |
if ( ! is_array( $value ) ) {
|
53 |
$value = strip_tags( $value );
|
54 |
}
|
classes/class-form-generator.php
CHANGED
@@ -65,7 +65,8 @@ class Form_Generator {
|
|
65 |
*/
|
66 |
public function render_field( $field_type, $args ) {
|
67 |
$args = wp_parse_args(
|
68 |
-
$args,
|
|
|
69 |
'name' => '',
|
70 |
'value' => '',
|
71 |
'options' => array(),
|
@@ -131,7 +132,8 @@ class Form_Generator {
|
|
131 |
|
132 |
foreach ( $args['options'] as $parent ) {
|
133 |
$parent = wp_parse_args(
|
134 |
-
$parent,
|
|
|
135 |
'value' => '',
|
136 |
'text' => '',
|
137 |
'children' => array(),
|
65 |
*/
|
66 |
public function render_field( $field_type, $args ) {
|
67 |
$args = wp_parse_args(
|
68 |
+
$args,
|
69 |
+
array(
|
70 |
'name' => '',
|
71 |
'value' => '',
|
72 |
'options' => array(),
|
132 |
|
133 |
foreach ( $args['options'] as $parent ) {
|
134 |
$parent = wp_parse_args(
|
135 |
+
$parent,
|
136 |
+
array(
|
137 |
'value' => '',
|
138 |
'text' => '',
|
139 |
'children' => array(),
|
classes/class-install.php
CHANGED
@@ -4,6 +4,7 @@ namespace WP_Stream;
|
|
4 |
class Install {
|
5 |
/**
|
6 |
* Hold Plugin class
|
|
|
7 |
* @var Plugin
|
8 |
*/
|
9 |
public $plugin;
|
@@ -97,7 +98,9 @@ class Install {
|
|
97 |
if ( ! $update ) {
|
98 |
$this->update_required = true;
|
99 |
$this->success_db = $this->update(
|
100 |
-
$this->db_version,
|
|
|
|
|
101 |
'type' => 'auto',
|
102 |
)
|
103 |
);
|
@@ -105,7 +108,9 @@ class Install {
|
|
105 |
|
106 |
if ( 'update_and_continue' === $update ) {
|
107 |
$this->success_db = $this->update(
|
108 |
-
$this->db_version,
|
|
|
|
|
109 |
'type' => 'user',
|
110 |
)
|
111 |
);
|
4 |
class Install {
|
5 |
/**
|
6 |
* Hold Plugin class
|
7 |
+
*
|
8 |
* @var Plugin
|
9 |
*/
|
10 |
public $plugin;
|
98 |
if ( ! $update ) {
|
99 |
$this->update_required = true;
|
100 |
$this->success_db = $this->update(
|
101 |
+
$this->db_version,
|
102 |
+
$this->plugin->get_version(),
|
103 |
+
array(
|
104 |
'type' => 'auto',
|
105 |
)
|
106 |
);
|
108 |
|
109 |
if ( 'update_and_continue' === $update ) {
|
110 |
$this->success_db = $this->update(
|
111 |
+
$this->db_version,
|
112 |
+
$this->plugin->get_version(),
|
113 |
+
array(
|
114 |
'type' => 'user',
|
115 |
)
|
116 |
);
|
classes/class-list-table.php
CHANGED
@@ -49,14 +49,24 @@ class List_Table extends \WP_List_Table {
|
|
49 |
// Check for default hidden columns
|
50 |
$this->get_hidden_columns();
|
51 |
|
52 |
-
add_filter(
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
set_screen_options();
|
62 |
}
|
@@ -513,7 +523,8 @@ class List_Table extends \WP_List_Table {
|
|
513 |
}
|
514 |
|
515 |
$users[] = new Author(
|
516 |
-
0,
|
|
|
517 |
'is_wp_cli' => true,
|
518 |
)
|
519 |
);
|
@@ -618,7 +629,8 @@ class List_Table extends \WP_List_Table {
|
|
618 |
foreach ( $filters as $name => $data ) {
|
619 |
|
620 |
$data = wp_parse_args(
|
621 |
-
$data,
|
|
|
622 |
'title' => '',
|
623 |
'items' => array(),
|
624 |
'ajax' => false,
|
49 |
// Check for default hidden columns
|
50 |
$this->get_hidden_columns();
|
51 |
|
52 |
+
add_filter(
|
53 |
+
'screen_settings',
|
54 |
+
array(
|
55 |
+
$this,
|
56 |
+
'screen_controls',
|
57 |
+
),
|
58 |
+
10,
|
59 |
+
2
|
60 |
+
);
|
61 |
+
add_filter(
|
62 |
+
'set-screen-option',
|
63 |
+
array(
|
64 |
+
$this,
|
65 |
+
'set_screen_option',
|
66 |
+
),
|
67 |
+
10,
|
68 |
+
3
|
69 |
+
);
|
70 |
|
71 |
set_screen_options();
|
72 |
}
|
523 |
}
|
524 |
|
525 |
$users[] = new Author(
|
526 |
+
0,
|
527 |
+
array(
|
528 |
'is_wp_cli' => true,
|
529 |
)
|
530 |
);
|
629 |
foreach ( $filters as $name => $data ) {
|
630 |
|
631 |
$data = wp_parse_args(
|
632 |
+
$data,
|
633 |
+
array(
|
634 |
'title' => '',
|
635 |
'items' => array(),
|
636 |
'ajax' => false,
|
classes/class-live-update.php
CHANGED
@@ -4,6 +4,7 @@ namespace WP_Stream;
|
|
4 |
class Live_Update {
|
5 |
/**
|
6 |
* Hold Plugin class
|
|
|
7 |
* @var Plugin
|
8 |
*/
|
9 |
public $plugin;
|
@@ -128,7 +129,7 @@ class Live_Update {
|
|
128 |
/**
|
129 |
* Sends Updated Actions to the List Table View
|
130 |
*
|
131 |
-
* @param int
|
132 |
* @param array $args Query args
|
133 |
*
|
134 |
* @return array Array of recently updated items
|
@@ -177,7 +178,8 @@ class Live_Update {
|
|
177 |
|
178 |
// Register list table
|
179 |
$this->list_table = new List_Table(
|
180 |
-
$this->plugin,
|
|
|
181 |
'screen' => 'toplevel_page_' . $this->plugin->admin->records_page_slug,
|
182 |
)
|
183 |
);
|
4 |
class Live_Update {
|
5 |
/**
|
6 |
* Hold Plugin class
|
7 |
+
*
|
8 |
* @var Plugin
|
9 |
*/
|
10 |
public $plugin;
|
129 |
/**
|
130 |
* Sends Updated Actions to the List Table View
|
131 |
*
|
132 |
+
* @param int $last_time Timestamp of last update
|
133 |
* @param array $args Query args
|
134 |
*
|
135 |
* @return array Array of recently updated items
|
178 |
|
179 |
// Register list table
|
180 |
$this->list_table = new List_Table(
|
181 |
+
$this->plugin,
|
182 |
+
array(
|
183 |
'screen' => 'toplevel_page_' . $this->plugin->admin->records_page_slug,
|
184 |
)
|
185 |
);
|
classes/class-log.php
CHANGED
@@ -291,7 +291,8 @@ class Log {
|
|
291 |
|
292 |
if ( $stream_meta ) {
|
293 |
array_walk(
|
294 |
-
$stream_meta,
|
|
|
295 |
$value = sprintf( '%s: %s', $key, ( '' === $value ) ? 'null' : $value );
|
296 |
}
|
297 |
);
|
@@ -303,7 +304,8 @@ class Log {
|
|
303 |
|
304 |
if ( $user_meta ) {
|
305 |
array_walk(
|
306 |
-
$user_meta,
|
|
|
307 |
$value = sprintf( '%s: %s', $key, ( '' === $value ) ? 'null' : $value );
|
308 |
}
|
309 |
);
|
291 |
|
292 |
if ( $stream_meta ) {
|
293 |
array_walk(
|
294 |
+
$stream_meta,
|
295 |
+
function ( &$value, $key ) {
|
296 |
$value = sprintf( '%s: %s', $key, ( '' === $value ) ? 'null' : $value );
|
297 |
}
|
298 |
);
|
304 |
|
305 |
if ( $user_meta ) {
|
306 |
array_walk(
|
307 |
+
$user_meta,
|
308 |
+
function ( &$value, $key ) {
|
309 |
$value = sprintf( '%s: %s', $key, ( '' === $value ) ? 'null' : $value );
|
310 |
}
|
311 |
);
|
classes/class-network.php
CHANGED
@@ -4,6 +4,7 @@ namespace WP_Stream;
|
|
4 |
class Network {
|
5 |
/**
|
6 |
* Hold Plugin class
|
|
|
7 |
* @var Plugin
|
8 |
*/
|
9 |
public $plugin;
|
@@ -177,7 +178,8 @@ class Network {
|
|
177 |
$action = add_query_arg(
|
178 |
array(
|
179 |
'action' => $current_page,
|
180 |
-
),
|
|
|
181 |
);
|
182 |
}
|
183 |
|
4 |
class Network {
|
5 |
/**
|
6 |
* Hold Plugin class
|
7 |
+
*
|
8 |
* @var Plugin
|
9 |
*/
|
10 |
public $plugin;
|
178 |
$action = add_query_arg(
|
179 |
array(
|
180 |
'action' => $current_page,
|
181 |
+
),
|
182 |
+
'edit.php'
|
183 |
);
|
184 |
}
|
185 |
|
classes/class-plugin.php
CHANGED
@@ -3,11 +3,13 @@ namespace WP_Stream;
|
|
3 |
|
4 |
class Plugin {
|
5 |
/**
|
6 |
-
* Plugin version number
|
|
|
|
|
7 |
*
|
8 |
* @const string
|
9 |
*/
|
10 |
-
const VERSION = '3.
|
11 |
|
12 |
/**
|
13 |
* WP-CLI command
|
3 |
|
4 |
class Plugin {
|
5 |
/**
|
6 |
+
* Plugin version number.
|
7 |
+
*
|
8 |
+
* TODO Maybe pass this as a constructor dependency?
|
9 |
*
|
10 |
* @const string
|
11 |
*/
|
12 |
+
const VERSION = '3.4.0';
|
13 |
|
14 |
/**
|
15 |
* WP-CLI command
|
classes/class-record.php
CHANGED
@@ -74,8 +74,8 @@ class Record {
|
|
74 |
* Update record meta
|
75 |
*
|
76 |
* @param string $meta_key
|
77 |
-
* @param mixed
|
78 |
-
* @param mixed
|
79 |
*
|
80 |
* @return bool
|
81 |
*/
|
74 |
* Update record meta
|
75 |
*
|
76 |
* @param string $meta_key
|
77 |
+
* @param mixed $meta_value
|
78 |
+
* @param mixed $prev_value (optional)
|
79 |
*
|
80 |
* @return bool
|
81 |
*/
|
classes/class-settings.php
CHANGED
@@ -10,6 +10,7 @@ class Settings {
|
|
10 |
|
11 |
/**
|
12 |
* Hold Plugin class
|
|
|
13 |
* @var Plugin
|
14 |
*/
|
15 |
public $plugin;
|
@@ -58,15 +59,19 @@ class Settings {
|
|
58 |
|
59 |
// Remove records when records TTL is shortened
|
60 |
add_action(
|
61 |
-
'update_option_' . $this->option_key,
|
|
|
62 |
$this,
|
63 |
'updated_option_ttl_remove_records',
|
64 |
-
),
|
|
|
|
|
65 |
);
|
66 |
|
67 |
// Apply label translations for settings
|
68 |
add_filter(
|
69 |
-
'wp_stream_serialized_labels',
|
|
|
70 |
$this,
|
71 |
'get_settings_translations',
|
72 |
)
|
@@ -108,10 +113,13 @@ class Settings {
|
|
108 |
);
|
109 |
|
110 |
add_filter(
|
111 |
-
'user_search_columns',
|
|
|
112 |
$this,
|
113 |
'add_display_name_search_columns',
|
114 |
-
),
|
|
|
|
|
115 |
);
|
116 |
|
117 |
$users = new WP_User_Query(
|
@@ -129,10 +137,12 @@ class Settings {
|
|
129 |
);
|
130 |
|
131 |
remove_filter(
|
132 |
-
'user_search_columns',
|
|
|
133 |
$this,
|
134 |
'add_display_name_search_columns',
|
135 |
-
),
|
|
|
136 |
);
|
137 |
|
138 |
if ( 0 === $users->get_total() ) {
|
@@ -465,7 +475,9 @@ class Settings {
|
|
465 |
$sections = $this->get_fields();
|
466 |
|
467 |
register_setting(
|
468 |
-
$this->option_key,
|
|
|
|
|
469 |
$this,
|
470 |
'sanitize_settings',
|
471 |
)
|
@@ -541,7 +553,8 @@ class Settings {
|
|
541 |
|
542 |
// Support all values in multidimentional arrays too.
|
543 |
array_walk_recursive(
|
544 |
-
$output[ $name ],
|
|
|
545 |
$v = trim( $v );
|
546 |
}
|
547 |
);
|
@@ -878,7 +891,8 @@ class Settings {
|
|
878 |
}
|
879 |
|
880 |
$author_or_role_input = $form->render_field(
|
881 |
-
'select2',
|
|
|
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',
|
@@ -923,7 +937,8 @@ class Settings {
|
|
923 |
}
|
924 |
|
925 |
$connector_or_context_input = $form->render_field(
|
926 |
-
'select2',
|
|
|
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',
|
@@ -935,7 +950,8 @@ class Settings {
|
|
935 |
);
|
936 |
|
937 |
$connector_input = $form->render_field(
|
938 |
-
'hidden',
|
|
|
939 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector' ) ),
|
940 |
'value' => $connector,
|
941 |
'classes' => 'connector',
|
@@ -943,7 +959,8 @@ class Settings {
|
|
943 |
);
|
944 |
|
945 |
$context_input = $form->render_field(
|
946 |
-
'hidden',
|
|
|
947 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'context' ) ),
|
948 |
'value' => $context,
|
949 |
'classes' => 'context',
|
@@ -961,7 +978,8 @@ class Settings {
|
|
961 |
}
|
962 |
|
963 |
$action_input = $form->render_field(
|
964 |
-
'select2',
|
|
|
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,
|
@@ -974,7 +992,8 @@ class Settings {
|
|
974 |
|
975 |
// IP Address input
|
976 |
$ip_address_input = $form->render_field(
|
977 |
-
'select2',
|
|
|
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',
|
10 |
|
11 |
/**
|
12 |
* Hold Plugin class
|
13 |
+
*
|
14 |
* @var Plugin
|
15 |
*/
|
16 |
public $plugin;
|
59 |
|
60 |
// Remove records when records TTL is shortened
|
61 |
add_action(
|
62 |
+
'update_option_' . $this->option_key,
|
63 |
+
array(
|
64 |
$this,
|
65 |
'updated_option_ttl_remove_records',
|
66 |
+
),
|
67 |
+
10,
|
68 |
+
2
|
69 |
);
|
70 |
|
71 |
// Apply label translations for settings
|
72 |
add_filter(
|
73 |
+
'wp_stream_serialized_labels',
|
74 |
+
array(
|
75 |
$this,
|
76 |
'get_settings_translations',
|
77 |
)
|
113 |
);
|
114 |
|
115 |
add_filter(
|
116 |
+
'user_search_columns',
|
117 |
+
array(
|
118 |
$this,
|
119 |
'add_display_name_search_columns',
|
120 |
+
),
|
121 |
+
10,
|
122 |
+
3
|
123 |
);
|
124 |
|
125 |
$users = new WP_User_Query(
|
137 |
);
|
138 |
|
139 |
remove_filter(
|
140 |
+
'user_search_columns',
|
141 |
+
array(
|
142 |
$this,
|
143 |
'add_display_name_search_columns',
|
144 |
+
),
|
145 |
+
10
|
146 |
);
|
147 |
|
148 |
if ( 0 === $users->get_total() ) {
|
475 |
$sections = $this->get_fields();
|
476 |
|
477 |
register_setting(
|
478 |
+
$this->option_key,
|
479 |
+
$this->option_key,
|
480 |
+
array(
|
481 |
$this,
|
482 |
'sanitize_settings',
|
483 |
)
|
553 |
|
554 |
// Support all values in multidimentional arrays too.
|
555 |
array_walk_recursive(
|
556 |
+
$output[ $name ],
|
557 |
+
function ( &$v, $k ) {
|
558 |
$v = trim( $v );
|
559 |
}
|
560 |
);
|
891 |
}
|
892 |
|
893 |
$author_or_role_input = $form->render_field(
|
894 |
+
'select2',
|
895 |
+
array(
|
896 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'author_or_role' ) ),
|
897 |
'options' => $author_or_role_values,
|
898 |
'classes' => 'author_or_role',
|
937 |
}
|
938 |
|
939 |
$connector_or_context_input = $form->render_field(
|
940 |
+
'select2',
|
941 |
+
array(
|
942 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector_or_context' ) ),
|
943 |
'options' => $context_values,
|
944 |
'classes' => 'connector_or_context',
|
950 |
);
|
951 |
|
952 |
$connector_input = $form->render_field(
|
953 |
+
'hidden',
|
954 |
+
array(
|
955 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'connector' ) ),
|
956 |
'value' => $connector,
|
957 |
'classes' => 'connector',
|
959 |
);
|
960 |
|
961 |
$context_input = $form->render_field(
|
962 |
+
'hidden',
|
963 |
+
array(
|
964 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'context' ) ),
|
965 |
'value' => $context,
|
966 |
'classes' => 'context',
|
978 |
}
|
979 |
|
980 |
$action_input = $form->render_field(
|
981 |
+
'select2',
|
982 |
+
array(
|
983 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'action' ) ),
|
984 |
'value' => $action,
|
985 |
'options' => $action_values,
|
992 |
|
993 |
// IP Address input
|
994 |
$ip_address_input = $form->render_field(
|
995 |
+
'select2',
|
996 |
+
array(
|
997 |
'name' => esc_attr( sprintf( '%1$s[%2$s_%3$s][%4$s][]', $option_key, $section, $name, 'ip_address' ) ),
|
998 |
'value' => $ip_address,
|
999 |
'classes' => 'ip_address',
|
classes/class-uninstall.php
CHANGED
@@ -4,6 +4,7 @@ namespace WP_Stream;
|
|
4 |
class Uninstall {
|
5 |
/**
|
6 |
* Hold Plugin class
|
|
|
7 |
* @var Plugin
|
8 |
*/
|
9 |
public $plugin;
|
@@ -37,8 +38,6 @@ class Uninstall {
|
|
37 |
* Uninstall Stream by deleting its data
|
38 |
*/
|
39 |
public function uninstall() {
|
40 |
-
//check_ajax_referer( 'stream_nonce', 'wp_stream_nonce' );
|
41 |
-
|
42 |
$this->options = array(
|
43 |
$this->plugin->install->option_key,
|
44 |
$this->plugin->settings->option_key,
|
@@ -52,6 +51,12 @@ class Uninstall {
|
|
52 |
);
|
53 |
}
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
// Prevent this action from firing
|
56 |
remove_action( 'deactivate_plugin', array( 'Connector_Installer', 'callback' ), null );
|
57 |
|
4 |
class Uninstall {
|
5 |
/**
|
6 |
* Hold Plugin class
|
7 |
+
*
|
8 |
* @var Plugin
|
9 |
*/
|
10 |
public $plugin;
|
38 |
* Uninstall Stream by deleting its data
|
39 |
*/
|
40 |
public function uninstall() {
|
|
|
|
|
41 |
$this->options = array(
|
42 |
$this->plugin->install->option_key,
|
43 |
$this->plugin->settings->option_key,
|
51 |
);
|
52 |
}
|
53 |
|
54 |
+
if ( defined( 'DISALLOW_FILE_MODS' ) && true === DISALLOW_FILE_MODS ) {
|
55 |
+
wp_die(
|
56 |
+
esc_html__( "You don't have sufficient file permissions to do this action.", 'stream' )
|
57 |
+
);
|
58 |
+
}
|
59 |
+
|
60 |
// Prevent this action from firing
|
61 |
remove_action( 'deactivate_plugin', array( 'Connector_Installer', 'callback' ), null );
|
62 |
|
connectors/class-connector-acf.php
CHANGED
@@ -55,7 +55,7 @@ class Connector_ACF extends Connector {
|
|
55 |
* @return bool
|
56 |
*/
|
57 |
public function is_dependency_satisfied() {
|
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;
|
@@ -126,7 +126,7 @@ class Connector_ACF extends Connector {
|
|
126 |
*
|
127 |
* @filter wp_stream_action_links_{connector}
|
128 |
*
|
129 |
-
* @param array
|
130 |
* @param object $record Stream record
|
131 |
*
|
132 |
* @return array Action links
|
@@ -201,11 +201,11 @@ class Connector_ACF extends Connector {
|
|
201 |
/**
|
202 |
* Track addition of post/user meta
|
203 |
*
|
204 |
-
* @param string
|
205 |
-
* @param string
|
206 |
-
* @param integer
|
207 |
-
* @param integer
|
208 |
-
* @param string
|
209 |
* @param mixed|null $meta_value
|
210 |
*/
|
211 |
public function check_meta( $type, $action, $meta_id, $object_id, $meta_key, $meta_value = null ) {
|
@@ -339,11 +339,11 @@ class Connector_ACF extends Connector {
|
|
339 |
/**
|
340 |
* Track changes to ACF values within rendered post meta forms
|
341 |
*
|
342 |
-
* @param string
|
343 |
-
* @param string
|
344 |
-
* @param integer
|
345 |
-
* @param integer
|
346 |
-
* @param string
|
347 |
* @param mixed|null $value
|
348 |
*
|
349 |
* @return bool
|
@@ -484,7 +484,7 @@ class Connector_ACF extends Connector {
|
|
484 |
* processed by callback_updated_post_meta
|
485 |
*
|
486 |
* @param string $value
|
487 |
-
* @param int
|
488 |
* @param string $field
|
489 |
*
|
490 |
* @return string
|
@@ -497,7 +497,7 @@ class Connector_ACF extends Connector {
|
|
497 |
/**
|
498 |
* Track changes to post main attributes, ie: Order No.
|
499 |
*
|
500 |
-
* @param int
|
501 |
* @param array $data Array with the updated post data
|
502 |
*/
|
503 |
public function callback_pre_post_update( $post_id, $data ) {
|
55 |
* @return bool
|
56 |
*/
|
57 |
public function is_dependency_satisfied() {
|
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;
|
126 |
*
|
127 |
* @filter wp_stream_action_links_{connector}
|
128 |
*
|
129 |
+
* @param array $links Previous links registered
|
130 |
* @param object $record Stream record
|
131 |
*
|
132 |
* @return array Action links
|
201 |
/**
|
202 |
* Track addition of post/user meta
|
203 |
*
|
204 |
+
* @param string $type Type of object, post or user
|
205 |
+
* @param string $action Added, updated, deleted
|
206 |
+
* @param integer $meta_id
|
207 |
+
* @param integer $object_id
|
208 |
+
* @param string $meta_key
|
209 |
* @param mixed|null $meta_value
|
210 |
*/
|
211 |
public function check_meta( $type, $action, $meta_id, $object_id, $meta_key, $meta_value = null ) {
|
339 |
/**
|
340 |
* Track changes to ACF values within rendered post meta forms
|
341 |
*
|
342 |
+
* @param string $type Type of object, post or user
|
343 |
+
* @param string $action Added, updated, deleted
|
344 |
+
* @param integer $meta_id
|
345 |
+
* @param integer $object_id
|
346 |
+
* @param string $key
|
347 |
* @param mixed|null $value
|
348 |
*
|
349 |
* @return bool
|
484 |
* processed by callback_updated_post_meta
|
485 |
*
|
486 |
* @param string $value
|
487 |
+
* @param int $post_id
|
488 |
* @param string $field
|
489 |
*
|
490 |
* @return string
|
497 |
/**
|
498 |
* Track changes to post main attributes, ie: Order No.
|
499 |
*
|
500 |
+
* @param int $post_id
|
501 |
* @param array $data Array with the updated post data
|
502 |
*/
|
503 |
public function callback_pre_post_update( $post_id, $data ) {
|
connectors/class-connector-bbpress.php
CHANGED
@@ -120,7 +120,7 @@ class Connector_BbPress extends Connector {
|
|
120 |
*
|
121 |
* @filter wp_stream_action_links_{connector}
|
122 |
*
|
123 |
-
* @param array
|
124 |
* @param object $record Stream record
|
125 |
*
|
126 |
* @return array Action links
|
@@ -206,10 +206,10 @@ class Connector_BbPress extends Connector {
|
|
206 |
/**
|
207 |
* Tracks togging the forum topics
|
208 |
*
|
209 |
-
* @param bool
|
210 |
* @param \WP_Post $post_data
|
211 |
-
* @param string
|
212 |
-
* @param string
|
213 |
*
|
214 |
* @return array|bool
|
215 |
*/
|
120 |
*
|
121 |
* @filter wp_stream_action_links_{connector}
|
122 |
*
|
123 |
+
* @param array $links Previous links registered
|
124 |
* @param object $record Stream record
|
125 |
*
|
126 |
* @return array Action links
|
206 |
/**
|
207 |
* Tracks togging the forum topics
|
208 |
*
|
209 |
+
* @param bool $success
|
210 |
* @param \WP_Post $post_data
|
211 |
+
* @param string $action
|
212 |
+
* @param string $message
|
213 |
*
|
214 |
* @return array|bool
|
215 |
*/
|
connectors/class-connector-blogs.php
CHANGED
@@ -87,7 +87,7 @@ class Connector_Blogs extends Connector {
|
|
87 |
*
|
88 |
* @filter wp_stream_action_links_{connector}
|
89 |
*
|
90 |
-
* @param array
|
91 |
* @param Record $record
|
92 |
*
|
93 |
* @return array
|
87 |
*
|
88 |
* @filter wp_stream_action_links_{connector}
|
89 |
*
|
90 |
+
* @param array $links
|
91 |
* @param Record $record
|
92 |
*
|
93 |
* @return array
|
connectors/class-connector-buddypress.php
CHANGED
@@ -367,10 +367,14 @@ class Connector_BuddyPress extends Connector {
|
|
367 |
$replacement = str_replace( '-', '_', $option );
|
368 |
|
369 |
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
370 |
-
call_user_func(
|
371 |
-
|
372 |
-
|
373 |
-
|
|
|
|
|
|
|
|
|
374 |
} else {
|
375 |
$data = $this->options[ $option ];
|
376 |
$option_title = $data['label'];
|
367 |
$replacement = str_replace( '-', '_', $option );
|
368 |
|
369 |
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
370 |
+
call_user_func(
|
371 |
+
array(
|
372 |
+
$this,
|
373 |
+
'check_' . $replacement,
|
374 |
+
),
|
375 |
+
$old_value,
|
376 |
+
$new_value
|
377 |
+
);
|
378 |
} else {
|
379 |
$data = $this->options[ $option ];
|
380 |
$option_title = $data['label'];
|
connectors/class-connector-comments.php
CHANGED
@@ -120,7 +120,7 @@ class Connector_Comments extends Connector {
|
|
120 |
*
|
121 |
* @filter wp_stream_action_links_{connector}
|
122 |
*
|
123 |
-
* @param array
|
124 |
* @param object $record Stream record
|
125 |
*
|
126 |
* @return array Action links
|
@@ -164,7 +164,7 @@ class Connector_Comments extends Connector {
|
|
164 |
* will try to see if the e-mail provided does belong to a registered user.
|
165 |
*
|
166 |
* @param object|int $comment A comment object or comment ID
|
167 |
-
* @param string
|
168 |
*
|
169 |
* @return int|string $output User ID or user display name
|
170 |
*/
|
@@ -241,7 +241,7 @@ class Connector_Comments extends Connector {
|
|
241 |
*
|
242 |
* @action wp_insert_comment
|
243 |
*
|
244 |
-
* @param int
|
245 |
* @param object $comment
|
246 |
*/
|
247 |
public function callback_wp_insert_comment( $comment_id, $comment ) {
|
120 |
*
|
121 |
* @filter wp_stream_action_links_{connector}
|
122 |
*
|
123 |
+
* @param array $links Previous links registered
|
124 |
* @param object $record Stream record
|
125 |
*
|
126 |
* @return array Action links
|
164 |
* will try to see if the e-mail provided does belong to a registered user.
|
165 |
*
|
166 |
* @param object|int $comment A comment object or comment ID
|
167 |
+
* @param string $field What field you want to return
|
168 |
*
|
169 |
* @return int|string $output User ID or user display name
|
170 |
*/
|
241 |
*
|
242 |
* @action wp_insert_comment
|
243 |
*
|
244 |
+
* @param int $comment_id
|
245 |
* @param object $comment
|
246 |
*/
|
247 |
public function callback_wp_insert_comment( $comment_id, $comment ) {
|
connectors/class-connector-edd.php
CHANGED
@@ -68,12 +68,14 @@ class Connector_EDD extends Connector {
|
|
68 |
|
69 |
/**
|
70 |
* Flag status changes to not create duplicate entries
|
|
|
71 |
* @var bool
|
72 |
*/
|
73 |
public $is_discount_status_change = false;
|
74 |
|
75 |
/**
|
76 |
* Flag status changes to not create duplicate entries
|
|
|
77 |
* @var bool
|
78 |
*/
|
79 |
public $is_payment_status_change = false;
|
@@ -133,7 +135,7 @@ class Connector_EDD extends Connector {
|
|
133 |
'discounts' => esc_html_x( 'Discounts', 'edd', 'stream' ),
|
134 |
'reports' => esc_html_x( 'Reports', 'edd', 'stream' ),
|
135 |
'api_keys' => esc_html_x( 'API Keys', 'edd', 'stream' ),
|
136 |
-
//'payments' => esc_html_x( 'Payments', 'edd', 'stream' ),
|
137 |
);
|
138 |
}
|
139 |
|
@@ -183,10 +185,14 @@ class Connector_EDD extends Connector {
|
|
183 |
$base
|
184 |
);
|
185 |
}
|
186 |
-
} elseif ( in_array(
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
|
|
|
|
|
|
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 ) );
|
@@ -201,7 +207,8 @@ class Connector_EDD extends Connector {
|
|
201 |
'page' => 'edd-reports',
|
202 |
'tab' => 'logs',
|
203 |
's' => $user->user_email,
|
204 |
-
),
|
|
|
205 |
);
|
206 |
}
|
207 |
|
@@ -211,7 +218,8 @@ class Connector_EDD extends Connector {
|
|
211 |
'user_id' => $record->object_id,
|
212 |
'edd_action' => 'process_api_key',
|
213 |
'edd_api_process' => 'revoke',
|
214 |
-
),
|
|
|
215 |
);
|
216 |
$links[ esc_html__( 'Reissue', 'stream' ) ] = add_query_arg(
|
217 |
array(
|
@@ -219,7 +227,8 @@ class Connector_EDD extends Connector {
|
|
219 |
'user_id' => $record->object_id,
|
220 |
'edd_action' => 'process_api_key',
|
221 |
'edd_api_process' => 'regenerate',
|
222 |
-
),
|
|
|
223 |
);
|
224 |
}
|
225 |
|
@@ -268,10 +277,14 @@ class Connector_EDD extends Connector {
|
|
268 |
$replacement = str_replace( '-', '_', $option );
|
269 |
|
270 |
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
271 |
-
call_user_func(
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
275 |
} else {
|
276 |
$data = $this->options[ $option ];
|
277 |
$option_title = $data['label'];
|
@@ -299,7 +312,7 @@ class Connector_EDD extends Connector {
|
|
299 |
$options[ $field_key ] = $field_value;
|
300 |
}
|
301 |
|
302 |
-
//TODO: Check this exists first
|
303 |
$settings = \edd_get_registered_settings();
|
304 |
|
305 |
foreach ( $options as $option => $option_value ) {
|
@@ -505,10 +518,15 @@ class Connector_EDD extends Connector {
|
|
505 |
return false;
|
506 |
}
|
507 |
|
508 |
-
return call_user_func(
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
|
|
|
|
|
|
512 |
}
|
513 |
|
514 |
private function meta_edd_user_public_key( $user_id, $value, $is_add = false ) {
|
68 |
|
69 |
/**
|
70 |
* Flag status changes to not create duplicate entries
|
71 |
+
*
|
72 |
* @var bool
|
73 |
*/
|
74 |
public $is_discount_status_change = false;
|
75 |
|
76 |
/**
|
77 |
* Flag status changes to not create duplicate entries
|
78 |
+
*
|
79 |
* @var bool
|
80 |
*/
|
81 |
public $is_payment_status_change = false;
|
135 |
'discounts' => esc_html_x( 'Discounts', 'edd', 'stream' ),
|
136 |
'reports' => esc_html_x( 'Reports', 'edd', 'stream' ),
|
137 |
'api_keys' => esc_html_x( 'API Keys', 'edd', 'stream' ),
|
138 |
+
// 'payments' => esc_html_x( 'Payments', 'edd', 'stream' ),
|
139 |
);
|
140 |
}
|
141 |
|
185 |
$base
|
186 |
);
|
187 |
}
|
188 |
+
} elseif ( in_array(
|
189 |
+
$record->context,
|
190 |
+
array(
|
191 |
+
'download_category',
|
192 |
+
'download_tag',
|
193 |
+
),
|
194 |
+
true
|
195 |
+
) ) {
|
196 |
$tax_label = get_taxonomy_labels( get_taxonomy( $record->context ) )->singular_name;
|
197 |
// translators: Placeholder refers to a taxonomy (e.g. "Category")
|
198 |
$links[ sprintf( esc_html__( 'Edit %s', 'stream' ), $tax_label ) ] = get_edit_term_link( $record->object_id, $record->get_meta( 'taxonomy', true ) );
|
207 |
'page' => 'edd-reports',
|
208 |
'tab' => 'logs',
|
209 |
's' => $user->user_email,
|
210 |
+
),
|
211 |
+
'edit.php'
|
212 |
);
|
213 |
}
|
214 |
|
218 |
'user_id' => $record->object_id,
|
219 |
'edd_action' => 'process_api_key',
|
220 |
'edd_api_process' => 'revoke',
|
221 |
+
),
|
222 |
+
'edit.php'
|
223 |
);
|
224 |
$links[ esc_html__( 'Reissue', 'stream' ) ] = add_query_arg(
|
225 |
array(
|
227 |
'user_id' => $record->object_id,
|
228 |
'edd_action' => 'process_api_key',
|
229 |
'edd_api_process' => 'regenerate',
|
230 |
+
),
|
231 |
+
'edit.php'
|
232 |
);
|
233 |
}
|
234 |
|
277 |
$replacement = str_replace( '-', '_', $option );
|
278 |
|
279 |
if ( method_exists( $this, 'check_' . $replacement ) ) {
|
280 |
+
call_user_func(
|
281 |
+
array(
|
282 |
+
$this,
|
283 |
+
'check_' . $replacement,
|
284 |
+
),
|
285 |
+
$old_value,
|
286 |
+
$new_value
|
287 |
+
);
|
288 |
} else {
|
289 |
$data = $this->options[ $option ];
|
290 |
$option_title = $data['label'];
|
312 |
$options[ $field_key ] = $field_value;
|
313 |
}
|
314 |
|
315 |
+
// TODO: Check this exists first
|
316 |
$settings = \edd_get_registered_settings();
|
317 |
|
318 |
foreach ( $options as $option => $option_value ) {
|
518 |
return false;
|
519 |
}
|
520 |
|
521 |
+
return call_user_func(
|
522 |
+
array(
|
523 |
+
$this,
|
524 |
+
'meta_' . $key,
|
525 |
+
),
|
526 |
+
$object_id,
|
527 |
+
$value,
|
528 |
+
$is_add
|
529 |
+
);
|
530 |
}
|
531 |
|
532 |
private function meta_edd_user_public_key( $user_id, $value, $is_add = false ) {
|
connectors/class-connector-gravityforms.php
CHANGED
@@ -206,7 +206,7 @@ class Connector_GravityForms extends Connector {
|
|
206 |
* Track Create/Update actions on Forms
|
207 |
*
|
208 |
* @param array $form
|
209 |
-
* @param bool
|
210 |
* @return void
|
211 |
*/
|
212 |
public function callback_gform_after_save_form( $form, $is_new ) {
|
@@ -236,7 +236,7 @@ class Connector_GravityForms extends Connector {
|
|
236 |
*
|
237 |
* @param array $confirmation
|
238 |
* @param array $form
|
239 |
-
* @param bool
|
240 |
* @return array
|
241 |
*/
|
242 |
public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_new = true ) {
|
@@ -269,7 +269,7 @@ class Connector_GravityForms extends Connector {
|
|
269 |
*
|
270 |
* @param array $notification
|
271 |
* @param array $form
|
272 |
-
* @param bool
|
273 |
* @return array
|
274 |
*/
|
275 |
public function callback_gform_pre_notification_save( $notification, $form, $is_new = true ) {
|
@@ -352,7 +352,7 @@ class Connector_GravityForms extends Connector {
|
|
352 |
*
|
353 |
* @param array $confirmation
|
354 |
* @param array $form
|
355 |
-
* @param bool
|
356 |
* @return void
|
357 |
*/
|
358 |
public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
|
@@ -380,7 +380,7 @@ class Connector_GravityForms extends Connector {
|
|
380 |
*
|
381 |
* @param array $notification
|
382 |
* @param array $form
|
383 |
-
* @param bool
|
384 |
* @return void
|
385 |
*/
|
386 |
public function callback_gform_notification_status( $notification, $form, $is_active ) {
|
@@ -782,7 +782,7 @@ class Connector_GravityForms extends Connector {
|
|
782 |
/**
|
783 |
* Track status change of forms
|
784 |
*
|
785 |
-
* @param int
|
786 |
* @param string $action
|
787 |
* @return void
|
788 |
*/
|
206 |
* Track Create/Update actions on Forms
|
207 |
*
|
208 |
* @param array $form
|
209 |
+
* @param bool $is_new
|
210 |
* @return void
|
211 |
*/
|
212 |
public function callback_gform_after_save_form( $form, $is_new ) {
|
236 |
*
|
237 |
* @param array $confirmation
|
238 |
* @param array $form
|
239 |
+
* @param bool $is_new
|
240 |
* @return array
|
241 |
*/
|
242 |
public function callback_gform_pre_confirmation_save( $confirmation, $form, $is_new = true ) {
|
269 |
*
|
270 |
* @param array $notification
|
271 |
* @param array $form
|
272 |
+
* @param bool $is_new
|
273 |
* @return array
|
274 |
*/
|
275 |
public function callback_gform_pre_notification_save( $notification, $form, $is_new = true ) {
|
352 |
*
|
353 |
* @param array $confirmation
|
354 |
* @param array $form
|
355 |
+
* @param bool $is_active
|
356 |
* @return void
|
357 |
*/
|
358 |
public function callback_gform_confirmation_status( $confirmation, $form, $is_active ) {
|
380 |
*
|
381 |
* @param array $notification
|
382 |
* @param array $form
|
383 |
+
* @param bool $is_active
|
384 |
* @return void
|
385 |
*/
|
386 |
public function callback_gform_notification_status( $notification, $form, $is_active ) {
|
782 |
/**
|
783 |
* Track status change of forms
|
784 |
*
|
785 |
+
* @param int $form_id
|
786 |
* @param string $action
|
787 |
* @return void
|
788 |
*/
|
connectors/class-connector-installer.php
CHANGED
@@ -115,7 +115,7 @@ class Connector_Installer extends Connector {
|
|
115 |
* @action transition_post_status
|
116 |
*
|
117 |
* @param \WP_Upgrader $upgrader
|
118 |
-
* @param array
|
119 |
*
|
120 |
* @return bool
|
121 |
*/
|
@@ -214,7 +214,8 @@ class Connector_Installer extends Connector {
|
|
214 |
$theme = wp_get_theme( $slug );
|
215 |
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
|
216 |
$theme_data = get_file_data(
|
217 |
-
$stylesheet,
|
|
|
218 |
'Version' => 'Version',
|
219 |
)
|
220 |
);
|
115 |
* @action transition_post_status
|
116 |
*
|
117 |
* @param \WP_Upgrader $upgrader
|
118 |
+
* @param array $extra
|
119 |
*
|
120 |
* @return bool
|
121 |
*/
|
214 |
$theme = wp_get_theme( $slug );
|
215 |
$stylesheet = $theme['Stylesheet Dir'] . '/style.css';
|
216 |
$theme_data = get_file_data(
|
217 |
+
$stylesheet,
|
218 |
+
array(
|
219 |
'Version' => 'Version',
|
220 |
)
|
221 |
);
|
connectors/class-connector-jetpack.php
CHANGED
@@ -133,7 +133,7 @@ class Connector_Jetpack extends Connector {
|
|
133 |
*
|
134 |
* @filter wp_stream_action_links_{connector}
|
135 |
*
|
136 |
-
* @param array
|
137 |
* @param object $record Stream record
|
138 |
*
|
139 |
* @return array Action links
|
133 |
*
|
134 |
* @filter wp_stream_action_links_{connector}
|
135 |
*
|
136 |
+
* @param array $links Previous links registered
|
137 |
* @param object $record Stream record
|
138 |
*
|
139 |
* @return array Action links
|
connectors/class-connector-media.php
CHANGED
@@ -214,7 +214,7 @@ class Connector_Media extends Connector {
|
|
214 |
* @param string $filename
|
215 |
* @param string $image
|
216 |
* @param string $mime_type
|
217 |
-
* @param int
|
218 |
*/
|
219 |
public function callback_wp_save_image_editor_file( $dummy, $filename, $image, $mime_type, $post_id ) {
|
220 |
unset( $dummy );
|
214 |
* @param string $filename
|
215 |
* @param string $image
|
216 |
* @param string $mime_type
|
217 |
+
* @param int $post_id
|
218 |
*/
|
219 |
public function callback_wp_save_image_editor_file( $dummy, $filename, $image, $mime_type, $post_id ) {
|
220 |
unset( $dummy );
|
connectors/class-connector-menus.php
CHANGED
@@ -59,7 +59,8 @@ class Connector_Menus extends Connector {
|
|
59 |
public function get_context_labels() {
|
60 |
$labels = array();
|
61 |
$menus = get_terms(
|
62 |
-
'nav_menu',
|
|
|
63 |
'hide_empty' => false,
|
64 |
)
|
65 |
);
|
@@ -106,7 +107,7 @@ class Connector_Menus extends Connector {
|
|
106 |
*
|
107 |
* @action wp_create_nav_menu
|
108 |
*
|
109 |
-
* @param int
|
110 |
* @param array $menu_data
|
111 |
*/
|
112 |
public function callback_wp_create_nav_menu( $menu_id, $menu_data ) {
|
@@ -127,7 +128,7 @@ class Connector_Menus extends Connector {
|
|
127 |
*
|
128 |
* @action wp_update_nav_menu
|
129 |
*
|
130 |
-
* @param int
|
131 |
* @param array $menu_data
|
132 |
*/
|
133 |
public function callback_wp_update_nav_menu( $menu_id, $menu_data = array() ) {
|
@@ -153,7 +154,7 @@ class Connector_Menus extends Connector {
|
|
153 |
* @action delete_nav_menu
|
154 |
*
|
155 |
* @param object $term
|
156 |
-
* @param int
|
157 |
* @param object $deleted_term
|
158 |
*/
|
159 |
public function callback_delete_nav_menu( $term, $tt_id, $deleted_term ) {
|
59 |
public function get_context_labels() {
|
60 |
$labels = array();
|
61 |
$menus = get_terms(
|
62 |
+
'nav_menu',
|
63 |
+
array(
|
64 |
'hide_empty' => false,
|
65 |
)
|
66 |
);
|
107 |
*
|
108 |
* @action wp_create_nav_menu
|
109 |
*
|
110 |
+
* @param int $menu_id
|
111 |
* @param array $menu_data
|
112 |
*/
|
113 |
public function callback_wp_create_nav_menu( $menu_id, $menu_data ) {
|
128 |
*
|
129 |
* @action wp_update_nav_menu
|
130 |
*
|
131 |
+
* @param int $menu_id
|
132 |
* @param array $menu_data
|
133 |
*/
|
134 |
public function callback_wp_update_nav_menu( $menu_id, $menu_data = array() ) {
|
154 |
* @action delete_nav_menu
|
155 |
*
|
156 |
* @param object $term
|
157 |
+
* @param int $tt_id
|
158 |
* @param object $deleted_term
|
159 |
*/
|
160 |
public function callback_delete_nav_menu( $term, $tt_id, $deleted_term ) {
|
connectors/class-connector-mercator.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WP_Stream;
|
4 |
+
|
5 |
+
class Connector_Mercator extends Connector {
|
6 |
+
/**
|
7 |
+
* Connector slug
|
8 |
+
*
|
9 |
+
* @var string
|
10 |
+
*/
|
11 |
+
public $name = 'mercator';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Actions registered for this connector
|
15 |
+
*
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
public $actions = array(
|
19 |
+
'mercator.mapping.updated',
|
20 |
+
'mercator.mapping.deleted',
|
21 |
+
'mercator.mapping.created',
|
22 |
+
'mercator.mapping.made_primary',
|
23 |
+
);
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Register connector in the WP Frontend
|
27 |
+
*
|
28 |
+
* @var bool
|
29 |
+
*/
|
30 |
+
public $register_frontend = false;
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Return translated connector label
|
34 |
+
*
|
35 |
+
* @return string
|
36 |
+
*/
|
37 |
+
public function get_label() {
|
38 |
+
return esc_html__( 'Mercator' );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Return translated action labels
|
43 |
+
*
|
44 |
+
* @return array
|
45 |
+
*/
|
46 |
+
public function get_action_labels() {
|
47 |
+
return array(
|
48 |
+
'made_primary' => esc_html__( 'Make primary domain', 'stream' ),
|
49 |
+
'created' => esc_html__( 'Created', 'stream' ),
|
50 |
+
'deleted' => esc_html__( 'Deleted', 'stream' ),
|
51 |
+
'updated' => esc_html__( 'Updated', 'stream' ),
|
52 |
+
);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Return translated context labels
|
57 |
+
*
|
58 |
+
* @return array
|
59 |
+
*/
|
60 |
+
public function get_context_labels() {
|
61 |
+
$labels = array();
|
62 |
+
|
63 |
+
if ( is_multisite() && ! wp_is_large_network() ) {
|
64 |
+
$blogs = wp_stream_get_sites();
|
65 |
+
|
66 |
+
foreach ( $blogs as $blog ) {
|
67 |
+
$blog_details = get_site( $blog->blog_id );
|
68 |
+
$key = sanitize_key( $blog_details->blogname );
|
69 |
+
$labels[ $key ] = $blog_details->blogname;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
return $labels;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Add action links to Stream drop row in admin list screen
|
78 |
+
*
|
79 |
+
* @filter wp_stream_action_links_{connector}
|
80 |
+
*
|
81 |
+
* @param array $links
|
82 |
+
* @param Record $record
|
83 |
+
*
|
84 |
+
* @return array
|
85 |
+
*/
|
86 |
+
public function action_links( $links, $record ) {
|
87 |
+
$links [ esc_html__( 'Site Admin' ) ] = get_admin_url( $record->object_id );
|
88 |
+
|
89 |
+
if ( $record->object_id ) {
|
90 |
+
$site_admin_link = get_admin_url( $record->object_id );
|
91 |
+
|
92 |
+
if ( $site_admin_link ) {
|
93 |
+
$links [ esc_html__( 'Site Admin' ) ] = $site_admin_link;
|
94 |
+
}
|
95 |
+
|
96 |
+
$site_settings_link = add_query_arg(
|
97 |
+
array(
|
98 |
+
'id' => $record->object_id,
|
99 |
+
'action' => 'mercator-aliases',
|
100 |
+
),
|
101 |
+
network_admin_url( 'admin.php' )
|
102 |
+
);
|
103 |
+
|
104 |
+
if ( $site_settings_link ) {
|
105 |
+
$links [ esc_html__( 'Domain mapping Settings', 'stream' ) ] = $site_settings_link;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
return $links;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Log if domain is made primary.
|
114 |
+
*
|
115 |
+
* @param $mapping
|
116 |
+
*/
|
117 |
+
public function callback_mercator_mapping_made_primary( $mapping ) {
|
118 |
+
$blog_id = $mapping->get_site_id();
|
119 |
+
$blog = get_site( $blog_id );
|
120 |
+
|
121 |
+
$this->log(
|
122 |
+
// translators: Placeholder refers to site name (e.g. "FooBar Blog")
|
123 |
+
_x(
|
124 |
+
'"%1$s" domain alias was make primary for "%2$s"',
|
125 |
+
'1. Domain alias 2. Site name',
|
126 |
+
'stream'
|
127 |
+
),
|
128 |
+
array(
|
129 |
+
'domain' => $mapping->get_domain(),
|
130 |
+
'site_name' => $blog->blogname,
|
131 |
+
),
|
132 |
+
$blog_id,
|
133 |
+
sanitize_key( $blog->blogname ),
|
134 |
+
'made_primary'
|
135 |
+
);
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Log if domain alias is updated.
|
140 |
+
*
|
141 |
+
* @param $mapping
|
142 |
+
* @param $old_mapping
|
143 |
+
*/
|
144 |
+
public function callback_mercator_mapping_updated( $mapping, $old_mapping ) {
|
145 |
+
|
146 |
+
$blog_id = $mapping->get_site_id();
|
147 |
+
$blog = get_site( $blog_id );
|
148 |
+
|
149 |
+
$this->log(
|
150 |
+
// translators: Placeholder refers to site name (e.g. "FooBar Blog")
|
151 |
+
_x(
|
152 |
+
'The domain alias "%1$s" was updated to "%2$s" for site "%3$s"',
|
153 |
+
'1. Old Domain alias 2. Domain alias 2. Site name',
|
154 |
+
'stream'
|
155 |
+
),
|
156 |
+
array(
|
157 |
+
'old_domain' => $old_mapping->get_domain(),
|
158 |
+
'domain' => $mapping->get_domain(),
|
159 |
+
'site_name' => $blog->blogname,
|
160 |
+
),
|
161 |
+
$blog_id,
|
162 |
+
sanitize_key( $blog->blogname ),
|
163 |
+
'updated'
|
164 |
+
);
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Log if domain alias is deleted.
|
170 |
+
*
|
171 |
+
* @param $mapping
|
172 |
+
*/
|
173 |
+
public function callback_mercator_mapping_deleted( $mapping ) {
|
174 |
+
|
175 |
+
$blog_id = $mapping->get_site_id();
|
176 |
+
$blog = get_site( $blog_id );
|
177 |
+
|
178 |
+
$this->log(
|
179 |
+
// translators: Placeholder refers to site name (e.g. "FooBar Blog")
|
180 |
+
_x(
|
181 |
+
'"%1$s" domain alias was deleted for "%2$s"',
|
182 |
+
'1. Domain alias 2. Site name',
|
183 |
+
'stream'
|
184 |
+
),
|
185 |
+
array(
|
186 |
+
'domain' => $mapping->get_domain(),
|
187 |
+
'site_name' => $blog->blogname,
|
188 |
+
),
|
189 |
+
$blog_id,
|
190 |
+
sanitize_key( $blog->blogname ),
|
191 |
+
'deleted'
|
192 |
+
);
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Log if domain alias is created.
|
198 |
+
*
|
199 |
+
* @param $mapping
|
200 |
+
*/
|
201 |
+
public function callback_mercator_mapping_created( $mapping ) {
|
202 |
+
$blog_id = $mapping->get_site_id();
|
203 |
+
$blog = get_site( $blog_id );
|
204 |
+
|
205 |
+
$this->log(
|
206 |
+
// translators: Placeholder refers to site name (e.g. "FooBar Blog")
|
207 |
+
_x(
|
208 |
+
'"%1$s" domain alias was created for "%2$s"',
|
209 |
+
'1. Domain alias 2. Site name',
|
210 |
+
'stream'
|
211 |
+
),
|
212 |
+
array(
|
213 |
+
'domain' => $mapping->get_domain(),
|
214 |
+
'site_name' => $blog->blogname,
|
215 |
+
),
|
216 |
+
$blog_id,
|
217 |
+
sanitize_key( $blog->blogname ),
|
218 |
+
'created'
|
219 |
+
);
|
220 |
+
}
|
221 |
+
}
|
connectors/class-connector-posts.php
CHANGED
@@ -71,7 +71,7 @@ class Connector_Posts extends Connector {
|
|
71 |
*
|
72 |
* @filter wp_stream_action_links_{connector}
|
73 |
*
|
74 |
-
* @param array
|
75 |
* @param Record $record Stream record
|
76 |
*
|
77 |
* @return array Action links
|
@@ -152,8 +152,8 @@ class Connector_Posts extends Connector {
|
|
152 |
*
|
153 |
* @action transition_post_status
|
154 |
*
|
155 |
-
* @param mixed
|
156 |
-
* @param mixed
|
157 |
* @param \WP_Post $post
|
158 |
*/
|
159 |
public function callback_transition_post_status( $new, $old, $post ) {
|
@@ -369,7 +369,7 @@ class Connector_Posts extends Connector {
|
|
369 |
/**
|
370 |
* Get an adjacent post revision ID
|
371 |
*
|
372 |
-
* @param int
|
373 |
* @param bool $previous
|
374 |
*
|
375 |
* @return int $revision_id
|
71 |
*
|
72 |
* @filter wp_stream_action_links_{connector}
|
73 |
*
|
74 |
+
* @param array $links Previous links registered
|
75 |
* @param Record $record Stream record
|
76 |
*
|
77 |
* @return array Action links
|
152 |
*
|
153 |
* @action transition_post_status
|
154 |
*
|
155 |
+
* @param mixed $new
|
156 |
+
* @param mixed $old
|
157 |
* @param \WP_Post $post
|
158 |
*/
|
159 |
public function callback_transition_post_status( $new, $old, $post ) {
|
369 |
/**
|
370 |
* Get an adjacent post revision ID
|
371 |
*
|
372 |
+
* @param int $revision_id
|
373 |
* @param bool $previous
|
374 |
*
|
375 |
* @return int $revision_id
|
connectors/class-connector-settings.php
CHANGED
@@ -451,7 +451,7 @@ class Connector_Settings extends Connector {
|
|
451 |
*
|
452 |
* @filter wp_stream_action_links_{connector}
|
453 |
*
|
454 |
-
* @param array
|
455 |
* @param Record $record Stream record
|
456 |
*
|
457 |
* @return array Action links
|
@@ -593,8 +593,8 @@ class Connector_Settings extends Connector {
|
|
593 |
* @action update_option
|
594 |
*
|
595 |
* @param string $option
|
596 |
-
* @param mixed
|
597 |
-
* @param mixed
|
598 |
*/
|
599 |
public function callback_update_option( $option, $value, $old_value ) {
|
600 |
if ( ( defined( '\WP_CLI' ) && \WP_CLI || did_action( 'customize_save' ) ) && array_key_exists( $option, $this->labels ) ) {
|
@@ -624,7 +624,6 @@ class Connector_Settings extends Connector {
|
|
624 |
*
|
625 |
* @param mixed $old_value
|
626 |
* @param mixed $value
|
627 |
-
*
|
628 |
*/
|
629 |
public function callback_update_option_permalink_structure( $old_value, $value ) {
|
630 |
$this->callback_updated_option( 'permalink_structure', $old_value, $value );
|
@@ -636,8 +635,8 @@ class Connector_Settings extends Connector {
|
|
636 |
* @action update_site_option
|
637 |
*
|
638 |
* @param string $option
|
639 |
-
* @param mixed
|
640 |
-
* @param mixed
|
641 |
*/
|
642 |
public function callback_update_site_option( $option, $value, $old_value ) {
|
643 |
$this->callback_updated_option( $option, $value, $old_value );
|
@@ -673,8 +672,8 @@ class Connector_Settings extends Connector {
|
|
673 |
* @action updated_option
|
674 |
*
|
675 |
* @param string $option
|
676 |
-
* @param mixed
|
677 |
-
* @param mixed
|
678 |
*/
|
679 |
public function callback_updated_option( $option, $old_value, $value ) {
|
680 |
global $whitelist_options, $new_whitelist_options;
|
@@ -820,8 +819,8 @@ class Connector_Settings extends Connector {
|
|
820 |
* @see is_option_group()
|
821 |
*
|
822 |
* @param string $key
|
823 |
-
* @param mixed
|
824 |
-
* @param mixed
|
825 |
*
|
826 |
* @return bool Whether the option should be treated as a group
|
827 |
*/
|
451 |
*
|
452 |
* @filter wp_stream_action_links_{connector}
|
453 |
*
|
454 |
+
* @param array $links Previous links registered
|
455 |
* @param Record $record Stream record
|
456 |
*
|
457 |
* @return array Action links
|
593 |
* @action update_option
|
594 |
*
|
595 |
* @param string $option
|
596 |
+
* @param mixed $old_value
|
597 |
+
* @param mixed $value
|
598 |
*/
|
599 |
public function callback_update_option( $option, $value, $old_value ) {
|
600 |
if ( ( defined( '\WP_CLI' ) && \WP_CLI || did_action( 'customize_save' ) ) && array_key_exists( $option, $this->labels ) ) {
|
624 |
*
|
625 |
* @param mixed $old_value
|
626 |
* @param mixed $value
|
|
|
627 |
*/
|
628 |
public function callback_update_option_permalink_structure( $old_value, $value ) {
|
629 |
$this->callback_updated_option( 'permalink_structure', $old_value, $value );
|
635 |
* @action update_site_option
|
636 |
*
|
637 |
* @param string $option
|
638 |
+
* @param mixed $old_value
|
639 |
+
* @param mixed $value
|
640 |
*/
|
641 |
public function callback_update_site_option( $option, $value, $old_value ) {
|
642 |
$this->callback_updated_option( $option, $value, $old_value );
|
672 |
* @action updated_option
|
673 |
*
|
674 |
* @param string $option
|
675 |
+
* @param mixed $old_value
|
676 |
+
* @param mixed $value
|
677 |
*/
|
678 |
public function callback_updated_option( $option, $old_value, $value ) {
|
679 |
global $whitelist_options, $new_whitelist_options;
|
819 |
* @see is_option_group()
|
820 |
*
|
821 |
* @param string $key
|
822 |
+
* @param mixed $old_value
|
823 |
+
* @param mixed $value
|
824 |
*
|
825 |
* @return bool Whether the option should be treated as a group
|
826 |
*/
|
connectors/class-connector-taxonomies.php
CHANGED
@@ -118,7 +118,7 @@ class Connector_Taxonomies extends Connector {
|
|
118 |
*
|
119 |
* @action registered_taxonomy
|
120 |
*
|
121 |
-
* @param string
|
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 |
*/
|
@@ -140,7 +140,7 @@ class Connector_Taxonomies extends Connector {
|
|
140 |
*
|
141 |
* @param integer $term_id
|
142 |
* @param integer $tt_id
|
143 |
-
* @param string
|
144 |
*/
|
145 |
public function callback_created_term( $term_id, $tt_id, $taxonomy ) {
|
146 |
if ( in_array( $taxonomy, $this->get_excluded_taxonomies(), true ) ) {
|
@@ -173,8 +173,8 @@ class Connector_Taxonomies extends Connector {
|
|
173 |
*
|
174 |
* @param integer $term_id
|
175 |
* @param integer $tt_id
|
176 |
-
* @param string
|
177 |
-
* @param object
|
178 |
*/
|
179 |
public function callback_delete_term( $term_id, $tt_id, $taxonomy, $deleted_term ) {
|
180 |
if ( in_array( $taxonomy, $this->get_excluded_taxonomies(), true ) ) {
|
@@ -206,7 +206,7 @@ class Connector_Taxonomies extends Connector {
|
|
206 |
*
|
207 |
* @param integer $term_id
|
208 |
* @param integer $tt_id
|
209 |
-
* @param string
|
210 |
*/
|
211 |
public function callback_edit_term( $term_id, $tt_id, $taxonomy ) {
|
212 |
unset( $tt_id );
|
118 |
*
|
119 |
* @action registered_taxonomy
|
120 |
*
|
121 |
+
* @param string $taxonomy Taxonomy slug
|
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 |
*/
|
140 |
*
|
141 |
* @param integer $term_id
|
142 |
* @param integer $tt_id
|
143 |
+
* @param string $taxonomy
|
144 |
*/
|
145 |
public function callback_created_term( $term_id, $tt_id, $taxonomy ) {
|
146 |
if ( in_array( $taxonomy, $this->get_excluded_taxonomies(), true ) ) {
|
173 |
*
|
174 |
* @param integer $term_id
|
175 |
* @param integer $tt_id
|
176 |
+
* @param string $taxonomy
|
177 |
+
* @param object $deleted_term
|
178 |
*/
|
179 |
public function callback_delete_term( $term_id, $tt_id, $taxonomy, $deleted_term ) {
|
180 |
if ( in_array( $taxonomy, $this->get_excluded_taxonomies(), true ) ) {
|
206 |
*
|
207 |
* @param integer $term_id
|
208 |
* @param integer $tt_id
|
209 |
+
* @param string $taxonomy
|
210 |
*/
|
211 |
public function callback_edit_term( $term_id, $tt_id, $taxonomy ) {
|
212 |
unset( $tt_id );
|
connectors/class-connector-user-switching.php
CHANGED
@@ -66,7 +66,6 @@ class Connector_User_Switching extends Connector {
|
|
66 |
* Register this connector.
|
67 |
*
|
68 |
* Overrides the default `Connector::register()` method.
|
69 |
-
*
|
70 |
*/
|
71 |
public function register() {
|
72 |
parent::register();
|
66 |
* Register this connector.
|
67 |
*
|
68 |
* Overrides the default `Connector::register()` method.
|
|
|
69 |
*/
|
70 |
public function register() {
|
71 |
parent::register();
|
connectors/class-connector-users.php
CHANGED
@@ -79,7 +79,7 @@ class Connector_Users extends Connector {
|
|
79 |
*
|
80 |
* @filter wp_stream_action_links_{connector}
|
81 |
*
|
82 |
-
* @param array
|
83 |
* @param Record $record Stream record
|
84 |
*
|
85 |
* @return array Action links
|
@@ -167,7 +167,7 @@ class Connector_Users extends Connector {
|
|
167 |
*
|
168 |
* @action profile_update
|
169 |
*
|
170 |
-
* @param int
|
171 |
* @param \WP_User $user registered user object
|
172 |
*/
|
173 |
public function callback_profile_update( $user_id, $user ) {
|
@@ -190,9 +190,9 @@ class Connector_Users extends Connector {
|
|
190 |
*
|
191 |
* @action set_user_role
|
192 |
*
|
193 |
-
* @param int
|
194 |
* @param string $new_role
|
195 |
-
* @param array
|
196 |
*/
|
197 |
public function callback_set_user_role( $user_id, $new_role, $old_roles ) {
|
198 |
if ( empty( $old_roles ) ) {
|
@@ -273,9 +273,9 @@ class Connector_Users extends Connector {
|
|
273 |
* @action set_logged_in_cookie
|
274 |
*
|
275 |
* @param string $logged_in_cookie
|
276 |
-
* @param int
|
277 |
-
* @param int
|
278 |
-
* @param int
|
279 |
*/
|
280 |
public function callback_set_logged_in_cookie( $logged_in_cookie, $expire, $expiration, $user_id ) {
|
281 |
unset( $logged_in_cookie );
|
79 |
*
|
80 |
* @filter wp_stream_action_links_{connector}
|
81 |
*
|
82 |
+
* @param array $links Previous links registered
|
83 |
* @param Record $record Stream record
|
84 |
*
|
85 |
* @return array Action links
|
167 |
*
|
168 |
* @action profile_update
|
169 |
*
|
170 |
+
* @param int $user_id registered user ID
|
171 |
* @param \WP_User $user registered user object
|
172 |
*/
|
173 |
public function callback_profile_update( $user_id, $user ) {
|
190 |
*
|
191 |
* @action set_user_role
|
192 |
*
|
193 |
+
* @param int $user_id
|
194 |
* @param string $new_role
|
195 |
+
* @param array $old_roles
|
196 |
*/
|
197 |
public function callback_set_user_role( $user_id, $new_role, $old_roles ) {
|
198 |
if ( empty( $old_roles ) ) {
|
273 |
* @action set_logged_in_cookie
|
274 |
*
|
275 |
* @param string $logged_in_cookie
|
276 |
+
* @param int $expire
|
277 |
+
* @param int $expiration
|
278 |
+
* @param int $user_id
|
279 |
*/
|
280 |
public function callback_set_logged_in_cookie( $logged_in_cookie, $expire, $expiration, $user_id ) {
|
281 |
unset( $logged_in_cookie );
|
connectors/class-connector-widgets.php
CHANGED
@@ -90,7 +90,7 @@ class Connector_Widgets extends Connector {
|
|
90 |
*
|
91 |
* @filter wp_stream_action_links_{connector}
|
92 |
*
|
93 |
-
* @param array
|
94 |
* @param Record $record Stream record
|
95 |
*
|
96 |
* @return array Action links
|
@@ -516,8 +516,8 @@ class Connector_Widgets extends Connector {
|
|
516 |
* @action updated_option
|
517 |
*
|
518 |
* @param string $option_name
|
519 |
-
* @param array
|
520 |
-
* @param array
|
521 |
*/
|
522 |
public function callback_updated_option( $option_name, $old_value, $new_value ) {
|
523 |
if ( ! preg_match( '/^widget_(.+)$/', $option_name, $matches ) || ! is_array( $new_value ) ) {
|
@@ -817,6 +817,7 @@ class Connector_Widgets extends Connector {
|
|
817 |
public function get_sidebars_widgets() {
|
818 |
/**
|
819 |
* Filter allows for insertion of sidebar widgets
|
|
|
820 |
* @todo Do we need this filter?
|
821 |
*
|
822 |
* @param array Sidebar Widgets in Options table
|
90 |
*
|
91 |
* @filter wp_stream_action_links_{connector}
|
92 |
*
|
93 |
+
* @param array $links Previous links registered
|
94 |
* @param Record $record Stream record
|
95 |
*
|
96 |
* @return array Action links
|
516 |
* @action updated_option
|
517 |
*
|
518 |
* @param string $option_name
|
519 |
+
* @param array $old_value
|
520 |
+
* @param array $new_value
|
521 |
*/
|
522 |
public function callback_updated_option( $option_name, $old_value, $new_value ) {
|
523 |
if ( ! preg_match( '/^widget_(.+)$/', $option_name, $matches ) || ! is_array( $new_value ) ) {
|
817 |
public function get_sidebars_widgets() {
|
818 |
/**
|
819 |
* Filter allows for insertion of sidebar widgets
|
820 |
+
*
|
821 |
* @todo Do we need this filter?
|
822 |
*
|
823 |
* @param array Sidebar Widgets in Options table
|
connectors/class-connector-woocommerce.php
CHANGED
@@ -4,6 +4,7 @@ namespace WP_Stream;
|
|
4 |
class Connector_Woocommerce extends Connector {
|
5 |
/**
|
6 |
* Context name
|
|
|
7 |
* @var string
|
8 |
*/
|
9 |
public $name = 'woocommerce';
|
@@ -17,6 +18,7 @@ class Connector_Woocommerce extends Connector {
|
|
17 |
|
18 |
/**
|
19 |
* Actions registered for this context
|
|
|
20 |
* @var array
|
21 |
*/
|
22 |
public $actions = array(
|
@@ -206,7 +208,7 @@ class Connector_Woocommerce extends Connector {
|
|
206 |
*
|
207 |
* @filter wp_stream_action_links_{connector}
|
208 |
*
|
209 |
-
* @param array
|
210 |
* @param Record $record Stream record
|
211 |
*
|
212 |
* @return array Action links
|
@@ -288,8 +290,8 @@ class Connector_Woocommerce extends Connector {
|
|
288 |
*
|
289 |
* @action transition_post_status
|
290 |
*
|
291 |
-
* @param string
|
292 |
-
* @param string
|
293 |
* @param \WP_Post $post
|
294 |
*/
|
295 |
public function callback_transition_post_status( $new, $old, $post ) {
|
@@ -419,7 +421,7 @@ class Connector_Woocommerce extends Connector {
|
|
419 |
*
|
420 |
* @action woocommerce_order_status_changed
|
421 |
*
|
422 |
-
* @param int
|
423 |
* @param string $old
|
424 |
* @param string $new
|
425 |
*/
|
@@ -477,7 +479,7 @@ class Connector_Woocommerce extends Connector {
|
|
477 |
*
|
478 |
* @action woocommerce_attribute_added
|
479 |
*
|
480 |
-
* @param int
|
481 |
* @param array $attribute
|
482 |
*/
|
483 |
public function callback_woocommerce_attribute_added( $attribute_id, $attribute ) {
|
@@ -500,7 +502,7 @@ class Connector_Woocommerce extends Connector {
|
|
500 |
*
|
501 |
* @action woocommerce_attribute_updated
|
502 |
*
|
503 |
-
* @param int
|
504 |
* @param array $attribute
|
505 |
*/
|
506 |
public function callback_woocommerce_attribute_updated( $attribute_id, $attribute ) {
|
@@ -523,7 +525,7 @@ class Connector_Woocommerce extends Connector {
|
|
523 |
*
|
524 |
* @action woocommerce_attribute_updated
|
525 |
*
|
526 |
-
* @param int
|
527 |
* @param string $attribute_name
|
528 |
*/
|
529 |
public function callback_woocommerce_attribute_deleted( $attribute_id, $attribute_name ) {
|
@@ -548,7 +550,7 @@ class Connector_Woocommerce extends Connector {
|
|
548 |
*
|
549 |
* @action woocommerce_tax_rate_added
|
550 |
*
|
551 |
-
* @param int
|
552 |
* @param array $tax_rate
|
553 |
*/
|
554 |
public function callback_woocommerce_tax_rate_added( $tax_rate_id, $tax_rate ) {
|
@@ -571,7 +573,7 @@ class Connector_Woocommerce extends Connector {
|
|
571 |
*
|
572 |
* @action woocommerce_tax_rate_updated
|
573 |
*
|
574 |
-
* @param int
|
575 |
* @param array $tax_rate
|
576 |
*/
|
577 |
public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) {
|
@@ -680,8 +682,8 @@ class Connector_Woocommerce extends Connector {
|
|
680 |
'tab' => $this->settings[ $option ]['tab'],
|
681 |
'section' => $this->settings[ $option ]['section'],
|
682 |
'option' => $option,
|
683 |
-
'old_value' => $old_value,
|
684 |
-
'value' => $value,
|
685 |
),
|
686 |
null,
|
687 |
$this->settings[ $option ]['tab'],
|
@@ -754,7 +756,8 @@ class Connector_Woocommerce extends Connector {
|
|
754 |
|
755 |
// Provide additional context for each of the settings pages
|
756 |
array_walk(
|
757 |
-
$settings_pages,
|
|
|
758 |
$value .= ' ' . esc_html__( 'Settings', 'stream' );
|
759 |
}
|
760 |
);
|
4 |
class Connector_Woocommerce extends Connector {
|
5 |
/**
|
6 |
* Context name
|
7 |
+
*
|
8 |
* @var string
|
9 |
*/
|
10 |
public $name = 'woocommerce';
|
18 |
|
19 |
/**
|
20 |
* Actions registered for this context
|
21 |
+
*
|
22 |
* @var array
|
23 |
*/
|
24 |
public $actions = array(
|
208 |
*
|
209 |
* @filter wp_stream_action_links_{connector}
|
210 |
*
|
211 |
+
* @param array $links Previous links registered
|
212 |
* @param Record $record Stream record
|
213 |
*
|
214 |
* @return array Action links
|
290 |
*
|
291 |
* @action transition_post_status
|
292 |
*
|
293 |
+
* @param string $new
|
294 |
+
* @param string $old
|
295 |
* @param \WP_Post $post
|
296 |
*/
|
297 |
public function callback_transition_post_status( $new, $old, $post ) {
|
421 |
*
|
422 |
* @action woocommerce_order_status_changed
|
423 |
*
|
424 |
+
* @param int $order_id
|
425 |
* @param string $old
|
426 |
* @param string $new
|
427 |
*/
|
479 |
*
|
480 |
* @action woocommerce_attribute_added
|
481 |
*
|
482 |
+
* @param int $attribute_id
|
483 |
* @param array $attribute
|
484 |
*/
|
485 |
public function callback_woocommerce_attribute_added( $attribute_id, $attribute ) {
|
502 |
*
|
503 |
* @action woocommerce_attribute_updated
|
504 |
*
|
505 |
+
* @param int $attribute_id
|
506 |
* @param array $attribute
|
507 |
*/
|
508 |
public function callback_woocommerce_attribute_updated( $attribute_id, $attribute ) {
|
525 |
*
|
526 |
* @action woocommerce_attribute_updated
|
527 |
*
|
528 |
+
* @param int $attribute_id
|
529 |
* @param string $attribute_name
|
530 |
*/
|
531 |
public function callback_woocommerce_attribute_deleted( $attribute_id, $attribute_name ) {
|
550 |
*
|
551 |
* @action woocommerce_tax_rate_added
|
552 |
*
|
553 |
+
* @param int $tax_rate_id
|
554 |
* @param array $tax_rate
|
555 |
*/
|
556 |
public function callback_woocommerce_tax_rate_added( $tax_rate_id, $tax_rate ) {
|
573 |
*
|
574 |
* @action woocommerce_tax_rate_updated
|
575 |
*
|
576 |
+
* @param int $tax_rate_id
|
577 |
* @param array $tax_rate
|
578 |
*/
|
579 |
public function callback_woocommerce_tax_rate_updated( $tax_rate_id, $tax_rate ) {
|
682 |
'tab' => $this->settings[ $option ]['tab'],
|
683 |
'section' => $this->settings[ $option ]['section'],
|
684 |
'option' => $option,
|
685 |
+
'old_value' => maybe_serialize( $old_value ),
|
686 |
+
'value' => maybe_serialize( $value ),
|
687 |
),
|
688 |
null,
|
689 |
$this->settings[ $option ]['tab'],
|
756 |
|
757 |
// Provide additional context for each of the settings pages
|
758 |
array_walk(
|
759 |
+
$settings_pages,
|
760 |
+
function( &$value ) {
|
761 |
$value .= ' ' . esc_html__( 'Settings', 'stream' );
|
762 |
}
|
763 |
);
|
connectors/class-connector-wordpress-seo.php
CHANGED
@@ -213,13 +213,13 @@ class Connector_WordPress_SEO extends Connector {
|
|
213 |
*/
|
214 |
public function callback_wpseo_handle_import() {
|
215 |
$imports = array(
|
216 |
-
'importheadspace' => esc_html__( 'HeadSpace2', 'stream' ),
|
217 |
-
'importaioseo' => esc_html__( 'All-in-One SEO', 'stream' ),
|
218 |
-
'importaioseoold' => esc_html__( 'OLD All-in-One SEO', 'stream' ),
|
219 |
-
'importwoo' => esc_html__( 'WooThemes SEO framework', 'stream' ),
|
220 |
-
'importrobotsmeta' => esc_html__( 'Robots Meta (by Yoast)', 'stream' ),
|
221 |
-
'importrssfooter' => esc_html__( 'RSS Footer (by Yoast)', 'stream' ),
|
222 |
-
'importbreadcrumbs' => esc_html__( 'Yoast Breadcrumbs', 'stream' ),
|
223 |
);
|
224 |
|
225 |
$opts = wp_stream_filter_input( INPUT_POST, 'wpseo' );
|
@@ -401,94 +401,94 @@ class Connector_WordPress_SEO extends Connector {
|
|
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' ),
|
405 |
-
'disableadvanced_meta' => esc_html_x( 'Disable the Advanced part of the WordPress SEO meta box', 'wordpress-seo', 'stream' ),
|
406 |
-
'alexaverify' => esc_html_x( 'Alexa Verification ID', 'wordpress-seo', 'stream' ),
|
407 |
-
'msverify' => esc_html_x( 'Bing Webmaster Tools', 'wordpress-seo', 'stream' ),
|
408 |
-
'googleverify' => esc_html_x( 'Google Webmaster Tools', 'wordpress-seo', 'stream' ),
|
409 |
-
'pinterestverify' => esc_html_x( 'Pinterest', 'wordpress-seo', 'stream' ),
|
410 |
-
'yandexverify' => esc_html_x( 'Yandex Webmaster Tools', 'wordpress-seo', 'stream' ),
|
411 |
|
412 |
// wp-content/plugins/wordpress-seo/admin/pages/advanced.php:
|
413 |
-
'breadcrumbs-enable' => esc_html_x( 'Enable Breadcrumbs', 'wordpress-seo', 'stream' ),
|
414 |
-
'breadcrumbs-sep' => esc_html_x( 'Separator between breadcrumbs', 'wordpress-seo', 'stream' ),
|
415 |
-
'breadcrumbs-home' => esc_html_x( 'Anchor text for the Homepage', 'wordpress-seo', 'stream' ),
|
416 |
-
'breadcrumbs-prefix' => esc_html_x( 'Prefix for the breadcrumb path', 'wordpress-seo', 'stream' ),
|
417 |
-
'breadcrumbs-archiveprefix' => esc_html_x( 'Prefix for Archive breadcrumbs', 'wordpress-seo', 'stream' ),
|
418 |
-
'breadcrumbs-searchprefix' => esc_html_x( 'Prefix for Search Page breadcrumbs', 'wordpress-seo', 'stream' ),
|
419 |
-
'breadcrumbs-404crumb' => esc_html_x( 'Breadcrumb for 404 Page', 'wordpress-seo', 'stream' ),
|
420 |
-
'breadcrumbs-blog-remove' => esc_html_x( 'Remove Blog page from Breadcrumbs', 'wordpress-seo', 'stream' ),
|
421 |
-
'breadcrumbs-boldlast' => esc_html_x( 'Bold the last page in the breadcrumb', 'wordpress-seo', 'stream' ),
|
422 |
-
'post_types-post-maintax' => esc_html_x( 'Taxonomy to show in breadcrumbs for post types', 'wordpress-seo', 'stream' ),
|
423 |
|
424 |
// wp-content/plugins/wordpress-seo/admin/pages/metas.php:
|
425 |
-
'forcerewritetitle' => esc_html_x( 'Force rewrite titles', 'wordpress-seo', 'stream' ),
|
426 |
-
'noindex-subpages-wpseo' => esc_html_x( 'Noindex subpages of archives', 'wordpress-seo', 'stream' ),
|
427 |
-
'usemetakeywords' => _x( 'Use <code>meta</code> keywords tag?', 'wordpress-seo', 'stream' ),
|
428 |
-
'noodp' => _x( 'Add <code>noodp</code> meta robots tag sitewide', 'wordpress-seo', 'stream' ),
|
429 |
-
'noydir' => _x( 'Add <code>noydir</code> meta robots tag sitewide', 'wordpress-seo', 'stream' ),
|
430 |
-
'hide-rsdlink' => esc_html_x( 'Hide RSD Links', 'wordpress-seo', 'stream' ),
|
431 |
-
'hide-wlwmanifest' => esc_html_x( 'Hide WLW Manifest Links', 'wordpress-seo', 'stream' ),
|
432 |
-
'hide-shortlink' => esc_html_x( 'Hide Shortlink for posts', 'wordpress-seo', 'stream' ),
|
433 |
-
'hide-feedlinks' => esc_html_x( 'Hide RSS Links', 'wordpress-seo', 'stream' ),
|
434 |
-
'disable-author' => esc_html_x( 'Disable the author archives', 'wordpress-seo', 'stream' ),
|
435 |
-
'disable-date' => esc_html_x( 'Disable the date-based archives', 'wordpress-seo', 'stream' ),
|
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' ),
|
439 |
-
'defaultblog' => esc_html_x( 'New blogs get the SEO settings from this blog', 'wordpress-seo', 'stream' ),
|
440 |
-
'restoreblog' => esc_html_x( 'Blog ID', 'wordpress-seo', 'stream' ),
|
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' ),
|
444 |
-
'trailingslash' => esc_html_x( "Enforce a trailing slash on all category and tag URL's", 'wordpress-seo', 'stream' ),
|
445 |
-
'cleanslugs' => esc_html_x( 'Remove stop words from slugs.', 'wordpress-seo', 'stream' ),
|
446 |
-
'redirectattachment' => esc_html_x( "Redirect attachment URL's to parent post URL.", 'wordpress-seo', 'stream' ),
|
447 |
-
'cleanreplytocom' => _x( 'Remove the <code>?replytocom</code> variables.', 'wordpress-seo', 'stream' ),
|
448 |
-
'cleanpermalinks' => esc_html_x( "Redirect ugly URL's to clean permalinks. (Not recommended in many cases!)", 'wordpress-seo', 'stream' ),
|
449 |
-
'force_transport' => esc_html_x( 'Force Transport', 'wordpress-seo', 'stream' ),
|
450 |
-
'cleanpermalink-googlesitesearch' => esc_html_x( "Prevent cleaning out Google Site Search URL's.", 'wordpress-seo', 'stream' ),
|
451 |
-
'cleanpermalink-googlecampaign' => esc_html_x( 'Prevent cleaning out Google Analytics Campaign & Google AdWords Parameters.', 'wordpress-seo', 'stream' ),
|
452 |
-
'cleanpermalink-extravars' => esc_html_x( 'Other variables not to clean', 'wordpress-seo', 'stream' ),
|
453 |
|
454 |
// wp-content/plugins/wordpress-seo/admin/pages/social.php:
|
455 |
-
'opengraph' => esc_html_x( 'Add Open Graph meta data', 'wordpress-seo', 'stream' ),
|
456 |
-
'facebook_site' => esc_html_x( 'Facebook Page URL', 'wordpress-seo', 'stream' ),
|
457 |
-
'instagram_url' => esc_html_x( 'Instagram URL', 'wordpress-seo', 'stream' ),
|
458 |
-
'linkedin_url' => esc_html_x( 'LinkedIn URL', 'wordpress-seo', 'stream' ),
|
459 |
-
'myspace_url' => esc_html_x( 'MySpace URL', 'wordpress-seo', 'stream' ),
|
460 |
-
'pinterest_url' => esc_html_x( 'Pinterest URL', 'wordpress-seo', 'stream' ),
|
461 |
-
'youtube_url' => esc_html_x( 'YouTube URL', 'wordpress-seo', 'stream' ),
|
462 |
-
'google_plus_url' => esc_html_x( 'Google+ URL', 'wordpress-seo', 'stream' ),
|
463 |
-
'og_frontpage_image' => esc_html_x( 'Image URL', 'wordpress-seo', 'stream' ),
|
464 |
-
'og_frontpage_desc' => esc_html_x( 'Description', 'wordpress-seo', 'stream' ),
|
465 |
-
'og_frontpage_title' => esc_html_x( 'Title', 'wordpress-seo', 'stream' ),
|
466 |
-
'og_default_image' => esc_html_x( 'Image URL', 'wordpress-seo', 'stream' ),
|
467 |
-
'twitter' => esc_html_x( 'Add Twitter card meta data', 'wordpress-seo', 'stream' ),
|
468 |
-
'twitter_site' => esc_html_x( 'Site Twitter Username', 'wordpress-seo', 'stream' ),
|
469 |
-
'twitter_card_type' => esc_html_x( 'The default card type to use', 'wordpress-seo', 'stream' ),
|
470 |
-
'googleplus' => esc_html_x( 'Add Google+ specific post meta data (excluding author metadata)', 'wordpress-seo', 'stream' ),
|
471 |
-
'plus-publisher' => esc_html_x( 'Google Publisher Page', 'wordpress-seo', 'stream' ),
|
472 |
-
'fbadminapp' => esc_html_x( 'Facebook App ID', 'wordpress-seo', 'stream' ),
|
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' ),
|
476 |
-
'disable_author_sitemap' => esc_html_x( 'Disable author/user sitemap', 'wordpress-seo', 'stream' ),
|
477 |
-
'disable_author_noposts' => esc_html_x( 'Users with zero posts', 'wordpress-seo', 'stream' ),
|
478 |
-
'user_role-administrator-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Administrator', 'wordpress-seo', 'stream' ),
|
479 |
-
'user_role-editor-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Editor', 'wordpress-seo', 'stream' ),
|
480 |
-
'user_role-author-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Author', 'wordpress-seo', 'stream' ),
|
481 |
-
'user_role-contributor-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Contributor', 'wordpress-seo', 'stream' ),
|
482 |
-
'user_role-subscriber-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Subscriber', 'wordpress-seo', 'stream' ),
|
483 |
-
'xml_ping_yahoo' => esc_html_x( 'Ping Yahoo!', 'wordpress-seo', 'stream' ),
|
484 |
-
'xml_ping_ask' => esc_html_x( 'Ping Ask.com', 'wordpress-seo', 'stream' ),
|
485 |
-
'entries-per-page' => esc_html_x( 'Max entries per sitemap page', 'wordpress-seo', 'stream' ),
|
486 |
-
'excluded-posts' => esc_html_x( 'Posts to exclude', 'wordpress-seo', 'stream' ),
|
487 |
-
'post_types-post-not_in_sitemap' => _x( 'Post Types Posts (<code>post</code>)', 'wordpress-seo', 'stream' ),
|
488 |
-
'post_types-page-not_in_sitemap' => _x( 'Post Types Pages (<code>page</code>)', 'wordpress-seo', 'stream' ),
|
489 |
-
'post_types-attachment-not_in_sitemap' => _x( 'Post Types Media (<code>attachment</code>)', 'wordpress-seo', 'stream' ),
|
490 |
-
'taxonomies-category-not_in_sitemap' => _x( 'Taxonomies Categories (<code>category</code>)', 'wordpress-seo', 'stream' ),
|
491 |
-
'taxonomies-post_tag-not_in_sitemap' => _x( 'Taxonomies Tags (<code>post_tag</code>)', 'wordpress-seo', 'stream' ),
|
492 |
|
493 |
// Added manually
|
494 |
'rssbefore' => esc_html_x( 'Content to put before each post in the feed', 'wordpress-seo', 'stream' ),
|
@@ -496,16 +496,16 @@ class Connector_WordPress_SEO extends Connector {
|
|
496 |
);
|
497 |
|
498 |
$ast_labels = array(
|
499 |
-
'title-' => esc_html_x( 'Title template', 'wordpress-seo', 'stream' ),
|
500 |
-
'metadesc-' => esc_html_x( 'Meta description template', 'wordpress-seo', 'stream' ),
|
501 |
-
'metakey-' => esc_html_x( 'Meta keywords template', 'wordpress-seo', 'stream' ),
|
502 |
-
'noindex-' => esc_html_x( 'Meta Robots', 'wordpress-seo', 'stream' ),
|
503 |
-
'noauthorship-' => esc_html_x( 'Authorship', 'wordpress-seo', 'stream' ),
|
504 |
-
'showdate-' => esc_html_x( 'Show date in snippet preview?', 'wordpress-seo', 'stream' ),
|
505 |
-
'hideeditbox-' => esc_html_x( 'WordPress SEO Meta Box', 'wordpress-seo', 'stream' ),
|
506 |
-
'bctitle-' => esc_html_x( 'Breadcrumbs Title', 'wordpress-seo', 'stream' ),
|
507 |
-
'post_types-' => esc_html_x( 'Post types', 'wordpress-seo', 'stream' ),
|
508 |
-
'taxonomies-' => esc_html_x( 'Taxonomies', 'wordpress-seo', 'stream' ),
|
509 |
);
|
510 |
|
511 |
if ( $option ) {
|
213 |
*/
|
214 |
public function callback_wpseo_handle_import() {
|
215 |
$imports = array(
|
216 |
+
'importheadspace' => esc_html__( 'HeadSpace2', 'stream' ), // type = checkbox
|
217 |
+
'importaioseo' => esc_html__( 'All-in-One SEO', 'stream' ), // type = checkbox
|
218 |
+
'importaioseoold' => esc_html__( 'OLD All-in-One SEO', 'stream' ), // type = checkbox
|
219 |
+
'importwoo' => esc_html__( 'WooThemes SEO framework', 'stream' ), // type = checkbox
|
220 |
+
'importrobotsmeta' => esc_html__( 'Robots Meta (by Yoast)', 'stream' ), // type = checkbox
|
221 |
+
'importrssfooter' => esc_html__( 'RSS Footer (by Yoast)', 'stream' ), // type = checkbox
|
222 |
+
'importbreadcrumbs' => esc_html__( 'Yoast Breadcrumbs', 'stream' ), // type = checkbox
|
223 |
);
|
224 |
|
225 |
$opts = wp_stream_filter_input( INPUT_POST, 'wpseo' );
|
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
|
476 |
+
'disable_author_sitemap' => esc_html_x( 'Disable author/user sitemap', 'wordpress-seo', 'stream' ), // type = checkbox
|
477 |
+
'disable_author_noposts' => esc_html_x( 'Users with zero posts', 'wordpress-seo', 'stream' ), // type = checkbox
|
478 |
+
'user_role-administrator-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Administrator', 'wordpress-seo', 'stream' ), // type = checkbox
|
479 |
+
'user_role-editor-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Editor', 'wordpress-seo', 'stream' ), // type = checkbox
|
480 |
+
'user_role-author-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Author', 'wordpress-seo', 'stream' ), // type = checkbox
|
481 |
+
'user_role-contributor-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Contributor', 'wordpress-seo', 'stream' ), // type = checkbox
|
482 |
+
'user_role-subscriber-not_in_sitemap' => esc_html_x( 'Filter specific user roles - Subscriber', 'wordpress-seo', 'stream' ), // type = checkbox
|
483 |
+
'xml_ping_yahoo' => esc_html_x( 'Ping Yahoo!', 'wordpress-seo', 'stream' ), // type = checkbox
|
484 |
+
'xml_ping_ask' => esc_html_x( 'Ping Ask.com', 'wordpress-seo', 'stream' ), // type = checkbox
|
485 |
+
'entries-per-page' => esc_html_x( 'Max entries per sitemap page', 'wordpress-seo', 'stream' ), // type = textinput
|
486 |
+
'excluded-posts' => esc_html_x( 'Posts to exclude', 'wordpress-seo', 'stream' ), // type = textinput
|
487 |
+
'post_types-post-not_in_sitemap' => _x( 'Post Types Posts (<code>post</code>)', 'wordpress-seo', 'stream' ), // type = checkbox
|
488 |
+
'post_types-page-not_in_sitemap' => _x( 'Post Types Pages (<code>page</code>)', 'wordpress-seo', 'stream' ), // type = checkbox
|
489 |
+
'post_types-attachment-not_in_sitemap' => _x( 'Post Types Media (<code>attachment</code>)', 'wordpress-seo', 'stream' ), // type = checkbox
|
490 |
+
'taxonomies-category-not_in_sitemap' => _x( 'Taxonomies Categories (<code>category</code>)', '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' ),
|
496 |
);
|
497 |
|
498 |
$ast_labels = array(
|
499 |
+
'title-' => esc_html_x( 'Title template', 'wordpress-seo', 'stream' ), // type = textinput
|
500 |
+
'metadesc-' => esc_html_x( 'Meta description template', 'wordpress-seo', 'stream' ), // type = textarea
|
501 |
+
'metakey-' => esc_html_x( 'Meta keywords template', 'wordpress-seo', 'stream' ), // type = textinput
|
502 |
+
'noindex-' => esc_html_x( 'Meta Robots', 'wordpress-seo', 'stream' ), // type = checkbox
|
503 |
+
'noauthorship-' => esc_html_x( 'Authorship', 'wordpress-seo', 'stream' ), // type = checkbox
|
504 |
+
'showdate-' => esc_html_x( 'Show date in snippet preview?', 'wordpress-seo', 'stream' ), // type = checkbox
|
505 |
+
'hideeditbox-' => esc_html_x( 'WordPress SEO Meta Box', 'wordpress-seo', 'stream' ), // type = checkbox
|
506 |
+
'bctitle-' => esc_html_x( 'Breadcrumbs Title', 'wordpress-seo', 'stream' ), // type = textinput
|
507 |
+
'post_types-' => esc_html_x( 'Post types', 'wordpress-seo', 'stream' ), // type = checkbox
|
508 |
+
'taxonomies-' => esc_html_x( 'Taxonomies', 'wordpress-seo', 'stream' ), // type = checkbox
|
509 |
);
|
510 |
|
511 |
if ( $option ) {
|
contributing.md
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contribute to Stream
|
2 |
+
|
3 |
+
|
4 |
+
## Development Environment
|
5 |
+
|
6 |
+
Stream uses [npm](https://npmjs.com) for javascript dependencies, [Composer](https://getcomposer.org) for PHP dependencies and the [Grunt](https://gruntjs.com) task runner to minimize and compile scripts and styles and to deploy to the WordPress.org plugin repository.
|
7 |
+
|
8 |
+
Included is a local development environment built with [Docker](https://www.docker.com) which can be optionally run inside [Vagrant](https://www.vagrantup.com) for network isolation and better performance.
|
9 |
+
|
10 |
+
|
11 |
+
### Requirements
|
12 |
+
|
13 |
+
- [VirtualBox](https://www.virtualbox.org)
|
14 |
+
- [Vagrant](https://www.vagrantup.com)
|
15 |
+
- [Node.js](https://nodejs.org)
|
16 |
+
- [Composer](https://getcomposer.org)
|
17 |
+
|
18 |
+
We suggest using the [Homebrew package manager](https://brew.sh) on macOS to install the dependencies:
|
19 |
+
|
20 |
+
brew install node composer
|
21 |
+
brew cask install virtualbox vagrant
|
22 |
+
|
23 |
+
For setups with local Docker environment you don't need Vagrant and VirtualBox.
|
24 |
+
|
25 |
+
|
26 |
+
### Environment Setup
|
27 |
+
|
28 |
+
1. See the [Git Flow](#git-flow) section below for how to fork the repository.
|
29 |
+
2. Run `npm install` to install all project dependencies.
|
30 |
+
3. Run `vagrant up` to start the development environment.
|
31 |
+
4. Visit [stream.local](https://stream.local) and login using `admin` / `password`.
|
32 |
+
5. Activate the Stream plugin.
|
33 |
+
|
34 |
+
|
35 |
+
### Scripts and Commands
|
36 |
+
|
37 |
+
We use npm as the canonical task runner for the project. The following commands are available:
|
38 |
+
|
39 |
+
- `npm run build` to build the plugin JS and CSS files.
|
40 |
+
|
41 |
+
- `npm run lint` to check JS and PHP files for syntax and style issues.
|
42 |
+
|
43 |
+
- `npm run deploy` to deploy the plugin to the WordPress.org repository.
|
44 |
+
|
45 |
+
- `npm run cli -- wp info` where `wp info` is the CLI command to run inside the WordPress container. For example, use `npm run cli -- ls -lah` to list all files in the root of the WordPress installation.
|
46 |
+
|
47 |
+
- `npm run compose -- up -d` where `up -d` is the `docker-compose` command for the WordPress container. For example, use `npm run compose -- down` and `npm run compose -- up -d` to restart the WordPres container.
|
48 |
+
|
49 |
+
- `npm run phpunit` to run PHPunit tests inside the WordPress container.
|
50 |
+
|
51 |
+
All `npm` commands running inside Vagrant are prefixed with `v`, for example, `npm run vcli` and `npm run vcompose`.
|
52 |
+
|
53 |
+
|
54 |
+
## Issues Tracker
|
55 |
+
|
56 |
+
Support issues or usage questions should be posted on the [Plugin Support Forum](https://wordpress.org/support/plugin/stream).
|
57 |
+
|
58 |
+
The [issue tracker on GitHub](https://github.com/xwp/stream/issues) is the preferred channel for [bug reports](#bugs), [features requests](#features) and [submitting pull requests](#pull-requests).
|
59 |
+
|
60 |
+
|
61 |
+
<a name="bugs"></a>
|
62 |
+
|
63 |
+
## Reporting Bugs
|
64 |
+
|
65 |
+
A bug is a _demonstrable problem_ that is caused by the code in the repository. Good bug reports with complete error messages, environment details and screenshots are extremely helpful — thank you!
|
66 |
+
|
67 |
+
Guidelines for bug reports:
|
68 |
+
|
69 |
+
1. **Check if the bug has already been fixed** — Someone may already be on top of it, so try to reproduce it using the latest from the `master` branch.
|
70 |
+
|
71 |
+
2. **Use the [GitHub issue search](https://github.com/xwp/stream/search?type=Issues)** — Someone might already know about it, so please check if the issue has already been reported.
|
72 |
+
|
73 |
+
3. **Isolate the problem** — The better you can determine exactly what behavior(s) cause the issue, the faster and more effectively it can be resolved. “I’m getting an error message.” is not a good bug report. A good bug report shouldn't leave others needing to contact you for more information.
|
74 |
+
|
75 |
+
Please try to be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) experience the problem? What outcome did you expect, and how did it differ from what you actually saw? All these details will help people to fix any potential bugs.
|
76 |
+
|
77 |
+
Example:
|
78 |
+
|
79 |
+
> Short and descriptive example bug report title
|
80 |
+
>
|
81 |
+
> A summary of the issue and the environment/browser in which it occurs. If
|
82 |
+
> suitable, include the steps required to reproduce the bug.
|
83 |
+
>
|
84 |
+
> 1. This is the first step
|
85 |
+
> 2. This is the second step
|
86 |
+
> 3. Further steps, etc.
|
87 |
+
>
|
88 |
+
> Any other information you want to share that is relevant to the issue being reported. This might include the lines of code that you have identified as causing the bug, and potential solutions (and your opinions on their merits).
|
89 |
+
|
90 |
+
**Note:** In an effort to keep open issues to a manageable number, we will close any issues that do not provide enough information for us to be able to work on a solution. You will be encouraged to provide the necessary details, after which we will reopen the issue.
|
91 |
+
|
92 |
+
|
93 |
+
<a name="features"></a>
|
94 |
+
|
95 |
+
## Feature Requests
|
96 |
+
|
97 |
+
Feature requests are very welcome! But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
|
98 |
+
|
99 |
+
Building something great means choosing features carefully especially because it is much, much easier to add features than it is to take them away. Additions to Stream will be evaluated on a combination of scope (how well it fits into the project), maintenance burden and general usefulness to users.
|
100 |
+
|
101 |
+
|
102 |
+
<a name="pull-requests"></a>
|
103 |
+
|
104 |
+
## Pull Requests
|
105 |
+
|
106 |
+
Good pull requests — patches, improvements, new features — are a fantastic help.
|
107 |
+
They should remain focused in scope and avoid containing unrelated commits.
|
108 |
+
|
109 |
+
**Please ask first** before embarking on any significant pull request (e.g. implementing features, refactoring code), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project. You can solicit feedback and opinions in an open enhancement issue, or [create a new one](https://github.com/xwp/stream/issues/new).
|
110 |
+
|
111 |
+
Please use the [git flow for pull requests](#git-flow) and follow [WordPress Coding Standards](https://make.wordpress.org/core/handbook/coding-standards/) before submitting your work.
|
112 |
+
|
113 |
+
|
114 |
+
<a name="git-flow"></a>
|
115 |
+
|
116 |
+
### Git Flow for Pull Requests
|
117 |
+
|
118 |
+
1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
|
119 |
+
|
120 |
+
```bash
|
121 |
+
# Clone your fork of the repo into the current directory
|
122 |
+
git clone git@github.com:<YOUR_USERNAME>/stream.git
|
123 |
+
# Navigate to the newly cloned directory
|
124 |
+
cd stream
|
125 |
+
# Assign the original repo to a remote called "upstream"
|
126 |
+
git remote add upstream https://github.com/xwp/stream
|
127 |
+
```
|
128 |
+
|
129 |
+
2. If you cloned a while ago, get the latest changes from upstream:
|
130 |
+
|
131 |
+
```bash
|
132 |
+
git checkout master
|
133 |
+
git pull upstream master
|
134 |
+
```
|
135 |
+
|
136 |
+
3. Create a new topic branch (off the `master` branch) to contain your feature, change, or fix:
|
137 |
+
|
138 |
+
```bash
|
139 |
+
git checkout -b <topic-branch-name>
|
140 |
+
```
|
141 |
+
|
142 |
+
4. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html). Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public.
|
143 |
+
|
144 |
+
5. Locally merge (or rebase) the upstream development branch into your topic branch:
|
145 |
+
|
146 |
+
```bash
|
147 |
+
git pull [--rebase] upstream master
|
148 |
+
```
|
149 |
+
|
150 |
+
6. Push your topic branch up to your fork:
|
151 |
+
|
152 |
+
```bash
|
153 |
+
git push origin <topic-branch-name>
|
154 |
+
```
|
155 |
+
|
156 |
+
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) (with a clear title and description) to the `master` branch.
|
157 |
+
|
158 |
+
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to license your work under the [GPL v2 license](https://www.gnu.org/licenses/gpl-2.0.html).
|
includes/db-updates.php
CHANGED
@@ -33,17 +33,21 @@ function wp_stream_update_302( $db_version, $current_version ) {
|
|
33 |
if ( class_exists( $class ) ) {
|
34 |
$connector = new $class();
|
35 |
$wpdb->update(
|
36 |
-
$wpdb->base_prefix . 'stream',
|
|
|
37 |
'connector' => $connector->name,
|
38 |
-
),
|
|
|
39 |
'ID' => $entry->ID,
|
40 |
)
|
41 |
);
|
42 |
} else {
|
43 |
$wpdb->update(
|
44 |
-
$wpdb->base_prefix . 'stream',
|
|
|
45 |
'connector' => strtolower( $entry->connector ),
|
46 |
-
),
|
|
|
47 |
'ID' => $entry->ID,
|
48 |
)
|
49 |
);
|
33 |
if ( class_exists( $class ) ) {
|
34 |
$connector = new $class();
|
35 |
$wpdb->update(
|
36 |
+
$wpdb->base_prefix . 'stream',
|
37 |
+
array(
|
38 |
'connector' => $connector->name,
|
39 |
+
),
|
40 |
+
array(
|
41 |
'ID' => $entry->ID,
|
42 |
)
|
43 |
);
|
44 |
} else {
|
45 |
$wpdb->update(
|
46 |
+
$wpdb->base_prefix . 'stream',
|
47 |
+
array(
|
48 |
'connector' => strtolower( $entry->connector ),
|
49 |
+
),
|
50 |
+
array(
|
51 |
'ID' => $entry->ID,
|
52 |
)
|
53 |
);
|
includes/functions.php
CHANGED
@@ -36,7 +36,7 @@ function wp_stream_filter_var( $var, $filter = null, $options = array() ) {
|
|
36 |
* Converts a time into an ISO 8601 extended formatted string.
|
37 |
*
|
38 |
* @param int|bool $time Seconds since unix epoc
|
39 |
-
* @param int
|
40 |
*
|
41 |
* @return string an ISO 8601 extended formatted time
|
42 |
*/
|
@@ -65,8 +65,8 @@ function wp_stream_get_iso_8601_extended_date( $time = false, $offset = 0 ) {
|
|
65 |
* Encode to JSON in a way that is also backwards compatible
|
66 |
*
|
67 |
* @param mixed $data
|
68 |
-
* @param int
|
69 |
-
* @param int
|
70 |
*
|
71 |
* @return string
|
72 |
*/
|
@@ -131,7 +131,9 @@ function wp_stream_is_cron_enabled() {
|
|
131 |
*/
|
132 |
function wp_stream_min_suffix() {
|
133 |
$min = '';
|
134 |
-
|
|
|
|
|
135 |
$min = 'min.';
|
136 |
}
|
137 |
|
36 |
* Converts a time into an ISO 8601 extended formatted string.
|
37 |
*
|
38 |
* @param int|bool $time Seconds since unix epoc
|
39 |
+
* @param int $offset Hour offset
|
40 |
*
|
41 |
* @return string an ISO 8601 extended formatted time
|
42 |
*/
|
65 |
* Encode to JSON in a way that is also backwards compatible
|
66 |
*
|
67 |
* @param mixed $data
|
68 |
+
* @param int $options (optional)
|
69 |
+
* @param int $depth (optional)
|
70 |
*
|
71 |
* @return string
|
72 |
*/
|
131 |
*/
|
132 |
function wp_stream_min_suffix() {
|
133 |
$min = '';
|
134 |
+
$is_script_debugging = ! defined( 'SCRIPT_DEBUG' ) || false === SCRIPT_DEBUG;
|
135 |
+
|
136 |
+
if ( apply_filters( 'wp_stream_load_min_assets', $is_script_debugging ) ) {
|
137 |
$min = 'min.';
|
138 |
}
|
139 |
|
readme.md
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Stream for WordPress
|
2 |
+
|
3 |
+
[![Build Status](https://travis-ci.org/xwp/stream.svg?branch=master)](https://travis-ci.org/xwp/stream)
|
4 |
+
|
5 |
+
**Track WordPress user and system actions for debugging, logging and compliance purposes.**
|
6 |
+
|
7 |
+
- [Product Website](http://wp-stream.com)
|
8 |
+
- [Plugin on WordPress.org](https://wordpress.org/plugins/stream/)
|
9 |
+
|
10 |
+
|
11 |
+
## Documentation
|
12 |
+
|
13 |
+
View the [plugin description on WordPress.org](https://wordpress.org/plugins/stream/) for the list of features and screenshots.
|
14 |
+
|
15 |
+
|
16 |
+
## Contribute
|
17 |
+
|
18 |
+
All suggestions and contributions are welcome! View the [contributor documentation](contributing.md) for how to report issues and setup the local development environment.
|
19 |
+
|
20 |
+
|
21 |
+
## Credits
|
22 |
+
|
23 |
+
The plugin is owned and maintained by [XWP](https://xwp.co). View [all contributors](https://github.com/xwp/stream/graphs/contributors).
|
readme.txt
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
=== Stream ===
|
2 |
-
Contributors:
|
3 |
-
Tags:
|
4 |
-
Requires at least:
|
5 |
-
Tested up to:
|
6 |
-
Stable tag:
|
7 |
-
License:
|
8 |
-
License URI:
|
9 |
|
10 |
Planes have a black box, WordPress has Stream. When something goes wrong, you need to know how it happened.
|
11 |
|
|
|
12 |
== Description ==
|
13 |
|
14 |
With Stream, you're never left in the dark about WordPress Admin activity.
|
@@ -19,7 +20,7 @@ For advanced users, Stream also supports a Multisite view of all activity record
|
|
19 |
|
20 |
Stream is perfect for keeping tabs on your clients. When something breaks, Stream is there to help. See what changed and who changed it.
|
21 |
|
22 |
-
|
23 |
|
24 |
* Advanced Custom Fields
|
25 |
* bbPress
|
@@ -31,7 +32,7 @@ Stream is perfect for keeping tabs on your clients. When something breaks, Strea
|
|
31 |
* WooCommerce
|
32 |
* WordPress SEO by Yoast
|
33 |
|
34 |
-
|
35 |
|
36 |
* Posts
|
37 |
* Pages
|
@@ -52,7 +53,7 @@ Stream is perfect for keeping tabs on your clients. When something breaks, Strea
|
|
52 |
* Theme Editor
|
53 |
* WordPress Core Updates
|
54 |
|
55 |
-
|
56 |
|
57 |
* Multisite view of all activity records on a network
|
58 |
* Limit who can view user activity records by user role
|
@@ -61,24 +62,37 @@ Stream is perfect for keeping tabs on your clients. When something breaks, Strea
|
|
61 |
* Export your Activity Stream as a CSV or JSON file
|
62 |
* WP-CLI command for querying records
|
63 |
|
64 |
-
**See room for improvement?**
|
65 |
|
66 |
-
|
|
|
|
|
67 |
|
68 |
1. **Report Bugs:** If you find a bug, error or other problem, please report it! You can do this by [creating a new topic](https://wordpress.org/support/plugin/stream) in the plugin forum. Once a developer can verify the bug by reproducing it, they will create an official bug report in GitHub where the bug will be worked on.
|
69 |
-
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
|
72 |
Thank you for wanting to make Stream better for everyone!
|
73 |
|
|
|
74 |
== Screenshots ==
|
75 |
|
76 |
1. Every logged-in user action is displayed in an activity stream and organized for easy filtering and searching.
|
77 |
2. Enable live updates in Screen Options to watch your site activity appear in near real-time.
|
78 |
3. Create rules for excluding certain kinds of records from appearing in Stream.
|
79 |
|
|
|
80 |
== Changelog ==
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
= 3.3.0 - June 18, 2019 =
|
83 |
|
84 |
* New: Filter for allow WP network-like behaviour ([#1003](https://github.com/xwp/stream/pull/1003)).
|
1 |
=== Stream ===
|
2 |
+
Contributors: lukecarbis, fjarrett, stream, xwp
|
3 |
+
Tags: wp stream, stream, activity, logs, track
|
4 |
+
Requires at least: 4.5
|
5 |
+
Tested up to: 5.2
|
6 |
+
Stable tag: 3.4.0
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
Planes have a black box, WordPress has Stream. When something goes wrong, you need to know how it happened.
|
11 |
|
12 |
+
|
13 |
== Description ==
|
14 |
|
15 |
With Stream, you're never left in the dark about WordPress Admin activity.
|
20 |
|
21 |
Stream is perfect for keeping tabs on your clients. When something breaks, Stream is there to help. See what changed and who changed it.
|
22 |
|
23 |
+
= Built-In Tracking Integrations For Popular Plugins: =
|
24 |
|
25 |
* Advanced Custom Fields
|
26 |
* bbPress
|
32 |
* WooCommerce
|
33 |
* WordPress SEO by Yoast
|
34 |
|
35 |
+
= Built-In Tracking For Core Actions: =
|
36 |
|
37 |
* Posts
|
38 |
* Pages
|
53 |
* Theme Editor
|
54 |
* WordPress Core Updates
|
55 |
|
56 |
+
= Other Noteworthy Features: =
|
57 |
|
58 |
* Multisite view of all activity records on a network
|
59 |
* Limit who can view user activity records by user role
|
62 |
* Export your Activity Stream as a CSV or JSON file
|
63 |
* WP-CLI command for querying records
|
64 |
|
|
|
65 |
|
66 |
+
= Contribute =
|
67 |
+
|
68 |
+
There are several ways you can get involved to help make Stream better:
|
69 |
|
70 |
1. **Report Bugs:** If you find a bug, error or other problem, please report it! You can do this by [creating a new topic](https://wordpress.org/support/plugin/stream) in the plugin forum. Once a developer can verify the bug by reproducing it, they will create an official bug report in GitHub where the bug will be worked on.
|
71 |
+
|
72 |
+
2. **Translate into Your Language:** Use the official plugin translation tool to [translate Stream into your language](https://translate.wordpress.org/projects/wp-plugins/stream/).
|
73 |
+
|
74 |
+
3. **Suggest New Features:** Have an awesome idea? Please share it! Simply [create a new topic](https://wordpress.org/support/plugin/stream) in the plugin forum to express your thoughts on why the feature should be included and get a discussion going around your idea.
|
75 |
+
|
76 |
+
4. **Issue Pull Requests:** If you're a developer, the easiest way to get involved is to help out on [issues already reported](https://github.com/x-team/wp-stream/issues) in GitHub. Be sure to check out the [contributing guide](https://github.com/x-team/wp-stream/blob/master/contributing.md) for developers.
|
77 |
|
78 |
Thank you for wanting to make Stream better for everyone!
|
79 |
|
80 |
+
|
81 |
== Screenshots ==
|
82 |
|
83 |
1. Every logged-in user action is displayed in an activity stream and organized for easy filtering and searching.
|
84 |
2. Enable live updates in Screen Options to watch your site activity appear in near real-time.
|
85 |
3. Create rules for excluding certain kinds of records from appearing in Stream.
|
86 |
|
87 |
+
|
88 |
== Changelog ==
|
89 |
|
90 |
+
= 3.4.0 - July 13, 2019 =
|
91 |
+
|
92 |
+
* New: Add development environment and documentation, update tooling [#1016](https://github.com/xwp/stream/pull/1016).
|
93 |
+
* New: Add [Mercator](https://github.com/humanmade/Mercator) connector [#993](https://github.com/xwp/stream/pull/993), props [@spacedmonkey](https://github.com/spacedmonkey)).
|
94 |
+
* Fix: Respect the `DISALLOW_FILE_MODS` constant and prevent plugin uninstall, if set. [#997](https://github.com/xwp/stream/pull/997) fixes [#988](https://github.com/xwp/stream/issues/988), props [@lukecarbis](https://github.com/lukecarbis) and [@josephfusco](https://github.com/josephfusco).
|
95 |
+
|
96 |
= 3.3.0 - June 18, 2019 =
|
97 |
|
98 |
* New: Filter for allow WP network-like behaviour ([#1003](https://github.com/xwp/stream/pull/1003)).
|
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.
|
7 |
* Author: XWP
|
8 |
* Author URI: https://xwp.co/
|
9 |
* License: GPLv2+
|
@@ -41,7 +41,8 @@ if ( ! version_compare( PHP_VERSION, '5.3', '>=' ) ) {
|
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
* Invoked when the PHP version check fails
|
|
|
45 |
* Load up the translations and add the error message to the admin notices.
|
46 |
*/
|
47 |
function wp_stream_fail_php_version() {
|
@@ -54,7 +55,7 @@ function wp_stream_fail_php_version() {
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
* Helper for external plugins which wish to use Stream
|
58 |
*
|
59 |
* @return WP_Stream\Plugin
|
60 |
*/
|
3 |
* Plugin Name: Stream
|
4 |
* Plugin URI: https://wp-stream.com/
|
5 |
* Description: Stream tracks logged-in user activity so you can monitor every change made on your WordPress site in beautifully organized detail. All activity is organized by context, action and IP address for easy filtering. Developers can extend Stream with custom connectors to log any kind of action.
|
6 |
+
* Version: 3.4.0
|
7 |
* Author: XWP
|
8 |
* Author URI: https://xwp.co/
|
9 |
* License: GPLv2+
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
+
* Invoked when the PHP version check fails.
|
45 |
+
*
|
46 |
* Load up the translations and add the error message to the admin notices.
|
47 |
*/
|
48 |
function wp_stream_fail_php_version() {
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Helper for external plugins which wish to use Stream.
|
59 |
*
|
60 |
* @return WP_Stream\Plugin
|
61 |
*/
|
ui/js/admin.js
CHANGED
@@ -1,26 +1,25 @@
|
|
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
|
9 |
-
$.timeago.settings.strings.hour
|
10 |
-
$.timeago.settings.strings.hours
|
11 |
-
$.timeago.settings.strings.month
|
12 |
-
$.timeago.settings.strings.year
|
13 |
}
|
14 |
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
templateResult = function( record ) {
|
21 |
var $result = $( '<span>' ),
|
22 |
-
|
23 |
-
|
24 |
|
25 |
if ( '- ' === record.text.substring( 0, 2 ) ) {
|
26 |
record.text = record.text.substring( 2 );
|
@@ -54,131 +53,131 @@ jQuery(
|
|
54 |
return record.text;
|
55 |
};
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
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 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
-
);
|
107 |
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
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 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
$option
|
127 |
-
$connector
|
128 |
optionConnector = $option.data( 'group' ),
|
129 |
-
optionClass
|
130 |
-
$recordAction
|
131 |
-
|
132 |
-
if ( $( '#record-actions-submit' ).attr( 'clicked' ) !== 'true' ) {
|
133 |
-
$recordAction.val( '' );
|
134 |
-
}
|
135 |
|
136 |
-
|
137 |
-
|
138 |
-
if ( 'level-1' === optionClass ) {
|
139 |
-
$option.val( '' );
|
140 |
-
}
|
141 |
}
|
142 |
-
);
|
143 |
|
144 |
-
|
145 |
-
function() {
|
146 |
-
$( '.toplevel_page_wp_stream input[type="search"]' ).off( 'mousedown' );
|
147 |
-
}
|
148 |
-
);
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
-
|
|
|
158 |
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
}
|
164 |
}
|
165 |
-
|
|
|
166 |
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
}
|
172 |
}
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
$
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
182 |
syncFormAction = function( index ) {
|
183 |
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
184 |
if ( $optionsForm.length === 0 ) {
|
@@ -189,382 +188,380 @@ jQuery(
|
|
189 |
$optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
|
190 |
};
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
196 |
|
197 |
-
|
198 |
-
|
199 |
.find( 'a' )
|
200 |
.removeClass( 'nav-tab-active' )
|
201 |
.filter( $( this ) )
|
202 |
.addClass( 'nav-tab-active' );
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
}
|
207 |
-
|
208 |
-
syncFormAction( index );
|
209 |
-
|
210 |
-
return false;
|
211 |
}
|
212 |
-
);
|
213 |
|
214 |
-
|
215 |
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
226 |
heartbeat = 'true';
|
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 |
-
|
272 |
|
273 |
-
|
274 |
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
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 (
|
294 |
-
$( '
|
|
|
295 |
} else {
|
296 |
-
$( '
|
|
|
297 |
}
|
|
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
|
|
|
|
302 |
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
308 |
}
|
309 |
-
|
|
|
310 |
|
311 |
-
|
312 |
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
} else {
|
321 |
-
$( 'div.date-interval' ).hide();
|
322 |
-
}
|
323 |
} else {
|
324 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
334 |
}
|
335 |
-
);
|
336 |
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
|
|
|
|
|
|
|
|
350 |
.prependTo( timeEl.parent().parent() )
|
351 |
.find( 'time.timeago' )
|
352 |
.timeago();
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
dateinputs
|
367 |
-
from
|
368 |
-
to
|
369 |
-
to_remove
|
370 |
-
from_remove
|
371 |
-
predefined
|
372 |
-
datepickers
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
if ( localTime.
|
387 |
-
|
388 |
-
|
389 |
-
|
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 |
-
|
413 |
{
|
414 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
}
|
416 |
);
|
417 |
|
418 |
-
|
419 |
-
|
420 |
-
}
|
421 |
|
422 |
-
|
423 |
-
|
|
|
424 |
}
|
|
|
425 |
|
426 |
-
|
427 |
-
|
428 |
-
|
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 |
-
|
443 |
-
|
|
|
444 |
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
455 |
.find( 'option' )
|
456 |
.filter( '[data-to="' + to.val() + '"]' )
|
457 |
.filter( '[data-from="' + from.val() + '"]' );
|
458 |
-
|
459 |
-
|
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 |
-
|
479 |
}
|
|
|
|
|
|
|
480 |
|
481 |
-
|
482 |
-
|
483 |
-
|
|
|
|
|
|
|
|
|
|
|
484 |
|
485 |
-
|
|
|
486 |
}
|
487 |
-
);
|
488 |
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
to_remove.show();
|
493 |
-
from.datepicker( 'option', 'maxDate', to.val() );
|
494 |
-
} else {
|
495 |
-
to_remove.hide();
|
496 |
-
}
|
497 |
|
498 |
-
|
499 |
-
|
500 |
-
|
|
|
|
|
|
|
|
|
|
|
501 |
|
502 |
-
|
|
|
503 |
}
|
504 |
-
);
|
505 |
|
506 |
-
|
507 |
-
|
|
|
508 |
|
509 |
-
|
510 |
-
|
511 |
-
$( this ).next( 'input' ).val( '' ).trigger( 'change' );
|
512 |
-
}
|
513 |
-
);
|
514 |
-
}
|
515 |
-
);
|
516 |
-
},
|
517 |
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
};
|
534 |
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
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 ) {
|
568 |
-
|
|
|
|
|
569 |
}
|
570 |
);
|
1 |
+
/* globals wp_stream, ajaxurl, jQuery */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
+
// Shorter timeago strings for English locale
|
|
|
5 |
if ( 'en' === wp_stream.locale && 'undefined' !== typeof $.timeago ) {
|
6 |
$.timeago.settings.strings.seconds = 'seconds';
|
7 |
+
$.timeago.settings.strings.minute = 'a minute';
|
8 |
+
$.timeago.settings.strings.hour = 'an hour';
|
9 |
+
$.timeago.settings.strings.hours = '%d hours';
|
10 |
+
$.timeago.settings.strings.month = 'a month';
|
11 |
+
$.timeago.settings.strings.year = 'a year';
|
12 |
}
|
13 |
|
14 |
+
$( 'li.toplevel_page_wp_stream ul li.wp-first-item.current' ).parent().parent().find( '.update-plugins' ).remove();
|
15 |
|
16 |
+
$( '.toplevel_page_wp_stream :input.chosen-select' ).each(
|
17 |
+
function( i, el ) {
|
18 |
+
var args = {},
|
19 |
templateResult = function( record ) {
|
20 |
var $result = $( '<span>' ),
|
21 |
+
$elem = $( record.element ),
|
22 |
+
icon = '';
|
23 |
|
24 |
if ( '- ' === record.text.substring( 0, 2 ) ) {
|
25 |
record.text = record.text.substring( 2 );
|
53 |
return record.text;
|
54 |
};
|
55 |
|
56 |
+
if ( $( el ).find( 'option' ).not( ':selected' ).not( ':empty' ).length > 0 ) {
|
57 |
+
args = {
|
58 |
+
minimumResultsForSearch: 10,
|
59 |
+
templateResult: templateResult,
|
60 |
+
templateSelection: templateSelection,
|
61 |
+
allowClear: true,
|
62 |
+
width: '165px',
|
63 |
+
};
|
64 |
+
} else {
|
65 |
+
args = {
|
66 |
+
minimumInputLength: 3,
|
67 |
+
allowClear: true,
|
68 |
+
width: '165px',
|
69 |
+
ajax: {
|
70 |
+
url: ajaxurl,
|
71 |
+
dataType: 'json',
|
72 |
+
quietMillis: 100,
|
73 |
+
data: function( term ) {
|
74 |
+
return {
|
75 |
+
action: 'wp_stream_filters',
|
76 |
+
nonce: $( '#stream_filters_user_search_nonce' ).val(),
|
77 |
+
filter: $( el ).attr( 'name' ),
|
78 |
+
q: term.term,
|
79 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
},
|
81 |
+
processResults: function( data ) {
|
82 |
+
var results = [];
|
83 |
+
$.each(
|
84 |
+
data, function( index, item ) {
|
85 |
+
results.push(
|
86 |
+
{
|
87 |
+
id: item.id,
|
88 |
+
text: item.label,
|
89 |
+
}
|
90 |
+
);
|
91 |
+
}
|
92 |
+
);
|
93 |
+
return {
|
94 |
+
results: results,
|
95 |
+
};
|
96 |
+
},
|
97 |
+
},
|
98 |
+
templateResult: templateResult,
|
99 |
+
templateSelection: templateSelection,
|
100 |
+
};
|
101 |
}
|
|
|
102 |
|
103 |
+
$( el ).select2( args );
|
104 |
+
}
|
105 |
+
);
|
106 |
+
|
107 |
+
var $queryVars = $.streamGetQueryVars();
|
108 |
+
var $contextInput = $( '.toplevel_page_wp_stream select.chosen-select[name="context"]' );
|
109 |
|
110 |
if ( ( 'undefined' === typeof $queryVars.context || '' === $queryVars.context ) && 'undefined' !== typeof $queryVars.connector ) {
|
111 |
$contextInput.val( 'group-' + $queryVars.connector );
|
112 |
$contextInput.trigger( 'change' );
|
113 |
}
|
114 |
|
115 |
+
$( 'input[type=submit]', '#record-filter-form' ).click(
|
116 |
+
function() {
|
117 |
+
$( 'input[type=submit]', $( this ).parents( 'form' ) ).removeAttr( 'clicked' );
|
118 |
+
$( this ).attr( 'clicked', 'true' );
|
119 |
+
}
|
120 |
+
);
|
121 |
+
|
122 |
+
$( '#record-filter-form' ).submit(
|
123 |
+
function() {
|
124 |
+
var $context = $( '.toplevel_page_wp_stream :input.chosen-select[name="context"]' ),
|
125 |
+
$option = $context.find( 'option:selected' ),
|
126 |
+
$connector = $context.parent().find( '.record-filter-connector' ),
|
127 |
optionConnector = $option.data( 'group' ),
|
128 |
+
optionClass = $option.prop( 'class' ),
|
129 |
+
$recordAction = $( '.recordactions select' );
|
|
|
|
|
|
|
|
|
130 |
|
131 |
+
if ( $( '#record-actions-submit' ).attr( 'clicked' ) !== 'true' ) {
|
132 |
+
$recordAction.val( '' );
|
|
|
|
|
|
|
133 |
}
|
|
|
134 |
|
135 |
+
$connector.val( optionConnector );
|
|
|
|
|
|
|
|
|
136 |
|
137 |
+
if ( 'level-1' === optionClass ) {
|
138 |
+
$option.val( '' );
|
139 |
+
}
|
140 |
+
}
|
141 |
+
);
|
142 |
+
|
143 |
+
$( window ).load(
|
144 |
+
function() {
|
145 |
+
$( '.toplevel_page_wp_stream input[type="search"]' ).off( 'mousedown' );
|
146 |
+
}
|
147 |
+
);
|
148 |
+
|
149 |
+
// Confirmation on some important actions
|
150 |
+
$( 'body' ).on(
|
151 |
+
'click', '#wp_stream_advanced_delete_all_records, #wp_stream_network_advanced_delete_all_records', function( e ) {
|
152 |
+
if ( ! window.confirm( wp_stream.i18n.confirm_purge ) ) {
|
153 |
+
e.preventDefault();
|
154 |
}
|
155 |
+
}
|
156 |
+
);
|
157 |
|
158 |
+
$( 'body' ).on(
|
159 |
+
'click', '#wp_stream_advanced_reset_site_settings, #wp_stream_network_advanced_reset_site_settings', function( e ) {
|
160 |
+
if ( ! window.confirm( wp_stream.i18n.confirm_defaults ) ) {
|
161 |
+
e.preventDefault();
|
|
|
162 |
}
|
163 |
+
}
|
164 |
+
);
|
165 |
|
166 |
+
$( 'body' ).on(
|
167 |
+
'click', '#wp_stream_uninstall', function( e ) {
|
168 |
+
if ( ! window.confirm( wp_stream.i18n.confirm_uninstall ) ) {
|
169 |
+
e.preventDefault();
|
|
|
170 |
}
|
171 |
+
}
|
172 |
+
);
|
173 |
+
|
174 |
+
// Admin page tabs
|
175 |
+
var $tabs = $( '.wp_stream_screen .nav-tab-wrapper' ),
|
176 |
+
$panels = $( '.wp_stream_screen .nav-tab-content table.form-table' ),
|
177 |
+
$activeTab = $tabs.find( '.nav-tab-active' ),
|
178 |
+
defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
|
179 |
+
hashIndexStart = window.location.hash.match( /^#(\d+)$/ ),
|
180 |
+
currentHash = ( null !== hashIndexStart ? hashIndexStart[ 1 ] : defaultIndex ),
|
181 |
syncFormAction = function( index ) {
|
182 |
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
183 |
if ( $optionsForm.length === 0 ) {
|
188 |
$optionsForm.prop( 'action', currentAction.replace( /(^[^#]*).*$/, '$1#' + index ) );
|
189 |
};
|
190 |
|
191 |
+
$tabs.on(
|
192 |
+
'click', 'a', function() {
|
193 |
+
var index = $tabs.find( 'a' ).index( $( this ) ),
|
194 |
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
195 |
|
196 |
+
$panels.hide().eq( index ).show();
|
197 |
+
$tabs
|
198 |
.find( 'a' )
|
199 |
.removeClass( 'nav-tab-active' )
|
200 |
.filter( $( this ) )
|
201 |
.addClass( 'nav-tab-active' );
|
202 |
|
203 |
+
if ( '' === window.location.hash || null !== hashIndex ) {
|
204 |
+
window.location.hash = index;
|
|
|
|
|
|
|
|
|
|
|
205 |
}
|
|
|
206 |
|
207 |
+
syncFormAction( index );
|
208 |
|
209 |
+
return false;
|
210 |
+
}
|
211 |
+
);
|
212 |
|
213 |
+
$tabs.children().eq( currentHash ).trigger( 'click' );
|
214 |
+
|
215 |
+
// Live Updates screen option
|
216 |
+
$( document ).ready(
|
217 |
+
function() {
|
218 |
+
// Enable Live Updates checkbox ajax
|
219 |
+
$( '#enable_live_update' ).click(
|
220 |
+
function() {
|
221 |
+
var nonce = $( '#stream_live_update_nonce' ).val(),
|
222 |
+
user = $( '#enable_live_update_user' ).val(),
|
223 |
+
checked = 'unchecked',
|
224 |
heartbeat = 'true';
|
225 |
|
226 |
+
if ( $( '#enable_live_update' ).is( ':checked' ) ) {
|
227 |
+
checked = 'checked';
|
228 |
+
}
|
229 |
|
230 |
+
heartbeat = $( '#enable_live_update' ).data( 'heartbeat' );
|
231 |
|
232 |
+
$.ajax(
|
233 |
+
{
|
234 |
+
type: 'POST',
|
235 |
+
url: ajaxurl,
|
236 |
+
data: {
|
237 |
+
action: 'stream_enable_live_update',
|
238 |
+
nonce: nonce,
|
239 |
+
user: user,
|
240 |
+
checked: checked,
|
241 |
+
heartbeat: heartbeat,
|
242 |
+
},
|
243 |
+
dataType: 'json',
|
244 |
+
beforeSend: function() {
|
245 |
+
$( '.stream-live-update-checkbox .spinner' ).show().css( { display: 'inline-block' } );
|
246 |
+
},
|
247 |
+
success: function( response ) {
|
248 |
+
$( '.stream-live-update-checkbox .spinner' ).hide();
|
249 |
|
250 |
+
if ( false === response.success ) {
|
251 |
+
$( '#enable_live_update' ).prop( 'checked', false );
|
252 |
|
253 |
+
if ( response.data ) {
|
254 |
+
window.alert( response.data );
|
|
|
255 |
}
|
256 |
}
|
257 |
+
},
|
258 |
+
}
|
259 |
+
);
|
260 |
+
}
|
261 |
+
);
|
262 |
|
263 |
+
function toggle_filter_submit() {
|
264 |
+
var all_hidden = true;
|
265 |
|
266 |
+
// If all filters are hidden, hide the button
|
267 |
+
if ( $( 'div.metabox-prefs [name="date-hide"]' ).is( ':checked' ) ) {
|
268 |
+
all_hidden = false;
|
269 |
+
}
|
270 |
|
271 |
+
var divs = $( 'div.alignleft.actions div.select2-container' );
|
272 |
|
273 |
+
divs.each(
|
274 |
+
function() {
|
275 |
+
if ( ! $( this ).is( ':hidden' ) ) {
|
276 |
+
all_hidden = false;
|
277 |
+
return false;
|
|
|
278 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
280 |
+
);
|
281 |
|
282 |
+
if ( all_hidden ) {
|
283 |
+
$( 'input#record-query-submit' ).hide();
|
284 |
+
$( 'span.filter_info' ).show();
|
285 |
} else {
|
286 |
+
$( 'input#record-query-submit' ).show();
|
287 |
+
$( 'span.filter_info' ).hide();
|
288 |
}
|
289 |
+
}
|
290 |
|
291 |
+
if ( $( 'div.metabox-prefs [name="date-hide"]' ).is( ':checked' ) ) {
|
292 |
+
$( 'div.date-interval' ).show();
|
293 |
+
} else {
|
294 |
+
$( 'div.date-interval' ).hide();
|
295 |
+
}
|
296 |
|
297 |
+
$( 'div.actions select.chosen-select' ).each(
|
298 |
+
function() {
|
299 |
+
var name = $( this ).prop( 'name' );
|
300 |
+
|
301 |
+
if ( $( 'div.metabox-prefs [name="' + name + '-hide"]' ).is( ':checked' ) ) {
|
302 |
+
$( this ).prev( '.select2-container' ).show();
|
303 |
+
} else {
|
304 |
+
$( this ).prev( '.select2-container' ).hide();
|
305 |
}
|
306 |
+
}
|
307 |
+
);
|
308 |
|
309 |
+
toggle_filter_submit();
|
310 |
|
311 |
+
$( 'div.metabox-prefs [type="checkbox"]' ).click(
|
312 |
+
function() {
|
313 |
+
var id = $( this ).prop( 'id' );
|
314 |
|
315 |
+
if ( 'date-hide' === id ) {
|
316 |
+
if ( $( this ).is( ':checked' ) ) {
|
317 |
+
$( 'div.date-interval' ).show();
|
|
|
|
|
|
|
318 |
} else {
|
319 |
+
$( 'div.date-interval' ).hide();
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
}
|
321 |
+
} else {
|
322 |
+
id = id.replace( '-hide', '' );
|
323 |
|
324 |
+
if ( $( this ).is( ':checked' ) ) {
|
325 |
+
$( '[name="' + id + '"]' ).prev( '.select2-container' ).show();
|
326 |
+
} else {
|
327 |
+
$( '[name="' + id + '"]' ).prev( '.select2-container' ).hide();
|
328 |
+
}
|
329 |
}
|
|
|
330 |
|
331 |
+
toggle_filter_submit();
|
332 |
+
}
|
333 |
+
);
|
334 |
+
|
335 |
+
$( '#ui-datepicker-div' ).addClass( 'stream-datepicker' );
|
336 |
+
}
|
337 |
+
);
|
338 |
+
|
339 |
+
// Relative time
|
340 |
+
$( 'table.wp-list-table' ).on(
|
341 |
+
'updated', function() {
|
342 |
+
var timeObjects = $( this ).find( 'time.relative-time' );
|
343 |
+
timeObjects.each(
|
344 |
+
function( i, el ) {
|
345 |
+
var timeEl = $( el );
|
346 |
+
timeEl.removeClass( 'relative-time' );
|
347 |
+
$( '<strong><time datetime="' + timeEl.attr( 'datetime' ) + '" class="timeago"/></time></strong><br/>' )
|
348 |
.prependTo( timeEl.parent().parent() )
|
349 |
.find( 'time.timeago' )
|
350 |
.timeago();
|
351 |
+
}
|
352 |
+
);
|
353 |
+
}
|
354 |
+
).trigger( 'updated' );
|
355 |
+
|
356 |
+
var intervals = {
|
357 |
+
init: function( $wrapper ) {
|
358 |
+
this.wrapper = $wrapper;
|
359 |
+
this.save_interval( this.wrapper.find( '.button-primary' ), this.wrapper );
|
360 |
+
|
361 |
+
this.$ = this.wrapper.each(
|
362 |
+
function( i, val ) {
|
363 |
+
var container = $( val ),
|
364 |
+
dateinputs = container.find( '.date-inputs' ),
|
365 |
+
from = container.find( '.field-from' ),
|
366 |
+
to = container.find( '.field-to' ),
|
367 |
+
to_remove = to.prev( '.date-remove' ),
|
368 |
+
from_remove = from.prev( '.date-remove' ),
|
369 |
+
predefined = container.children( '.field-predefined' ),
|
370 |
+
datepickers = $( '' ).add( to ).add( from );
|
371 |
+
|
372 |
+
if ( jQuery.datepicker ) {
|
373 |
+
// Apply a GMT offset due to Date() using the visitor's local time
|
374 |
+
var siteGMTOffsetHours = parseFloat( wp_stream.gmt_offset ),
|
375 |
+
localGMTOffsetHours = new Date().getTimezoneOffset() / 60 * -1,
|
376 |
+
totalGMTOffsetHours = siteGMTOffsetHours - localGMTOffsetHours,
|
377 |
+
localTime = new Date(),
|
378 |
+
siteTime = new Date( localTime.getTime() + ( totalGMTOffsetHours * 60 * 60 * 1000 ) ),
|
379 |
+
maxOffset = 0,
|
380 |
+
minOffset = null;
|
381 |
+
|
382 |
+
// Check if the site date is different from the local date, and set a day offset
|
383 |
+
if ( localTime.getDate() !== siteTime.getDate() || localTime.getMonth() !== siteTime.getMonth() ) {
|
384 |
+
if ( localTime.getTime() < siteTime.getTime() ) {
|
385 |
+
maxOffset = '+1d';
|
386 |
+
} else {
|
387 |
+
maxOffset = '-1d';
|
|
|
|
|
388 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
}
|
390 |
|
391 |
+
datepickers.datepicker(
|
392 |
{
|
393 |
+
dateFormat: 'yy/mm/dd',
|
394 |
+
minDate: minOffset,
|
395 |
+
maxDate: maxOffset,
|
396 |
+
defaultDate: siteTime,
|
397 |
+
beforeShow: function() {
|
398 |
+
$( this ).prop( 'disabled', true );
|
399 |
+
},
|
400 |
+
onClose: function() {
|
401 |
+
$( this ).prop( 'disabled', false );
|
402 |
+
},
|
403 |
}
|
404 |
);
|
405 |
|
406 |
+
datepickers.datepicker( 'widget' ).addClass( 'stream-datepicker' );
|
407 |
+
}
|
|
|
408 |
|
409 |
+
predefined.select2(
|
410 |
+
{
|
411 |
+
allowClear: true,
|
412 |
}
|
413 |
+
);
|
414 |
|
415 |
+
if ( '' !== from.val() ) {
|
416 |
+
from_remove.show();
|
417 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
|
419 |
+
if ( '' !== to.val() ) {
|
420 |
+
to_remove.show();
|
421 |
+
}
|
422 |
|
423 |
+
predefined.on(
|
424 |
+
{
|
425 |
+
change: function() {
|
426 |
+
var value = $( this ).val(),
|
427 |
+
option = predefined.find( '[value="' + value + '"]' ),
|
428 |
+
to_val = option.data( 'to' ),
|
429 |
+
from_val = option.data( 'from' );
|
430 |
+
|
431 |
+
if ( 'custom' === value ) {
|
432 |
+
dateinputs.show();
|
433 |
+
return false;
|
434 |
+
}
|
435 |
+
dateinputs.hide();
|
436 |
+
datepickers.datepicker( 'hide' );
|
437 |
+
|
438 |
+
from.val( from_val ).trigger( 'change', [ true ] );
|
439 |
+
to.val( to_val ).trigger( 'change', [ true ] );
|
440 |
+
|
441 |
+
if ( jQuery.datepicker && datepickers.datepicker( 'widget' ).is( ':visible' ) ) {
|
442 |
+
datepickers.datepicker( 'refresh' ).datepicker( 'hide' );
|
443 |
+
}
|
444 |
+
},
|
445 |
+
'select2-removed': function() {
|
446 |
+
predefined.val( '' ).trigger( 'change' );
|
447 |
+
},
|
448 |
+
check_options: function() {
|
449 |
+
if ( '' !== to.val() && '' !== from.val() ) {
|
450 |
+
var option = predefined
|
451 |
.find( 'option' )
|
452 |
.filter( '[data-to="' + to.val() + '"]' )
|
453 |
.filter( '[data-from="' + from.val() + '"]' );
|
454 |
+
if ( 0 !== option.length ) {
|
455 |
+
predefined.val( option.attr( 'value' ) ).trigger( 'change', [ true ] );
|
|
|
|
|
|
|
|
|
|
|
456 |
} else {
|
457 |
predefined.val( 'custom' ).trigger( 'change', [ true ] );
|
458 |
}
|
459 |
+
} else if ( '' === to.val() && '' === from.val() ) {
|
460 |
+
predefined.val( '' ).trigger( 'change', [ true ] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
} else {
|
462 |
+
predefined.val( 'custom' ).trigger( 'change', [ true ] );
|
463 |
}
|
464 |
+
},
|
465 |
+
}
|
466 |
+
);
|
467 |
|
468 |
+
from.on(
|
469 |
+
'change', function() {
|
470 |
+
if ( '' !== from.val() ) {
|
471 |
+
from_remove.show();
|
472 |
+
to.datepicker( 'option', 'minDate', from.val() );
|
473 |
+
} else {
|
474 |
+
from_remove.hide();
|
475 |
+
}
|
476 |
|
477 |
+
if ( true === arguments[ arguments.length - 1 ] ) {
|
478 |
+
return false;
|
479 |
}
|
|
|
480 |
|
481 |
+
predefined.trigger( 'check_options' );
|
482 |
+
}
|
483 |
+
);
|
|
|
|
|
|
|
|
|
|
|
484 |
|
485 |
+
to.on(
|
486 |
+
'change', function() {
|
487 |
+
if ( '' !== to.val() ) {
|
488 |
+
to_remove.show();
|
489 |
+
from.datepicker( 'option', 'maxDate', to.val() );
|
490 |
+
} else {
|
491 |
+
to_remove.hide();
|
492 |
+
}
|
493 |
|
494 |
+
if ( true === arguments[ arguments.length - 1 ] ) {
|
495 |
+
return false;
|
496 |
}
|
|
|
497 |
|
498 |
+
predefined.trigger( 'check_options' );
|
499 |
+
}
|
500 |
+
);
|
501 |
|
502 |
+
// Trigger change on load
|
503 |
+
predefined.trigger( 'change' );
|
|
|
|
|
|
|
|
|
|
|
|
|
504 |
|
505 |
+
$( '' ).add( from_remove ).add( to_remove ).on(
|
506 |
+
'click', function() {
|
507 |
+
$( this ).next( 'input' ).val( '' ).trigger( 'change' );
|
508 |
+
}
|
509 |
+
);
|
510 |
+
}
|
511 |
+
);
|
512 |
+
},
|
513 |
+
|
514 |
+
save_interval: function( $btn ) {
|
515 |
+
var $wrapper = this.wrapper;
|
516 |
+
$btn.click(
|
517 |
+
function() {
|
518 |
+
var data = {
|
519 |
+
key: $wrapper.find( 'select.field-predefined' ).find( ':selected' ).val(),
|
520 |
+
start: $wrapper.find( '.date-inputs .field-from' ).val(),
|
521 |
+
end: $wrapper.find( '.date-inputs .field-to' ).val(),
|
522 |
+
};
|
523 |
+
|
524 |
+
// Add params to URL
|
525 |
+
$( this ).attr( 'href', $( this ).attr( 'href' ) + '&' + $.param( data ) );
|
526 |
+
}
|
527 |
+
);
|
528 |
+
},
|
529 |
};
|
530 |
|
531 |
+
$( document ).ready(
|
532 |
+
function() {
|
533 |
+
intervals.init( $( '.date-interval' ) );
|
534 |
|
535 |
+
// Disable option groups whose children are all disabled
|
536 |
+
$( 'select[name="context"] .level-1' ).each(
|
537 |
+
function() {
|
538 |
+
var all_disabled = true;
|
539 |
|
540 |
+
$( this ).nextUntil( '.level-1' ).each(
|
541 |
+
function() {
|
542 |
+
if ( $( this ).is( ':not(:disabled)' ) ) {
|
543 |
+
all_disabled = false;
|
544 |
+
return false;
|
|
|
545 |
}
|
|
|
|
|
|
|
|
|
546 |
}
|
547 |
+
);
|
|
|
|
|
|
|
548 |
|
549 |
+
if ( true === all_disabled ) {
|
550 |
+
$( this ).prop( 'disabled', true );
|
551 |
+
}
|
552 |
+
}
|
553 |
+
);
|
554 |
+
}
|
555 |
+
);
|
556 |
}
|
557 |
);
|
558 |
|
559 |
jQuery.extend(
|
560 |
{
|
561 |
streamGetQueryVars: function( str ) {
|
562 |
+
return ( str || document.location.search ).replace( /(^\?)/, '' ).split( '&' ).map( function( n ) {
|
563 |
+
return n = n.split( '=' ), this[n[0]] = n[1], this;
|
564 |
+
}.bind( {} ) )[0];
|
565 |
+
},
|
566 |
}
|
567 |
);
|
ui/js/alerts-list.js
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
( function( $ ) {
|
3 |
$( document ).ready(
|
4 |
function() {
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
}
|
14 |
);
|
15 |
-
}
|
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.js
CHANGED
@@ -1,306 +1,304 @@
|
|
1 |
/* globals jQuery, streamAlerts, inlineEditPost */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
-
|
5 |
-
|
6 |
$edit_row;
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
var match = $.extend( true, {}, data );
|
27 |
-
|
28 |
-
if (null === params.term || '' === $.trim( params.term )) {
|
29 |
-
return match;
|
30 |
-
}
|
31 |
|
32 |
-
|
|
|
|
|
33 |
|
34 |
-
|
35 |
-
if (match.id.toLowerCase().indexOf( term ) >= 0) {
|
36 |
-
return match;
|
37 |
-
}
|
38 |
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
}
|
47 |
-
}
|
48 |
|
49 |
-
if
|
50 |
-
|
|
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
|
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 |
-
|
69 |
$( el ).siblings( '.connector' ).val(),
|
70 |
-
$( el ).siblings( '.context' ).val()
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
}
|
75 |
-
$( el ).val( parts.join( '-' ) ).trigger( 'change' );
|
76 |
}
|
77 |
-
|
|
|
|
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
element_id_split[element_id_split.length - 1].slice( 1 );
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
};
|
93 |
-
var $alertSettingSelect = $( '#wp_stream_alert_type' );
|
94 |
|
95 |
-
var
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
var
|
107 |
-
|
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 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
-
getActions( connector );
|
127 |
}
|
|
|
|
|
128 |
}
|
129 |
);
|
|
|
130 |
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
var placeholder = $( '<option/>', {value: '', text: ''} );
|
137 |
-
trigger_action.append( placeholder );
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
var data = {
|
140 |
-
|
141 |
-
'connector' : connector
|
142 |
};
|
143 |
-
|
144 |
$.post(
|
145 |
window.ajaxurl, data, function( response ) {
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
}
|
158 |
-
trigger_action.prop( 'disabled', false );
|
159 |
-
$( document ).trigger( 'alert-actions-updated' );
|
160 |
}
|
161 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
};
|
163 |
-
|
164 |
-
$alertSettingSelect.change(
|
165 |
function() {
|
166 |
-
|
|
|
|
|
|
|
167 |
}
|
168 |
);
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
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 |
-
|
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 |
-
|
249 |
-
|
250 |
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
|
257 |
-
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
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 |
-
|
304 |
);
|
305 |
$target_post_row.find( '.row-actions a.editinline' ).trigger( 'click' );
|
306 |
}
|
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 |
+
}
|
22 |
+
return $( '<span class="child">' + item.text + '</span>' );
|
23 |
+
},
|
24 |
+
matcher: function( params, data ) {
|
25 |
+
var match = $.extend( true, {}, data );
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
if ( null === params.term || '' === $.trim( params.term ) ) {
|
28 |
+
return match;
|
29 |
+
}
|
30 |
|
31 |
+
var term = params.term.toLowerCase();
|
|
|
|
|
|
|
32 |
|
33 |
+
match.id = match.id.replace( 'blogs', 'sites' );
|
34 |
+
if ( match.id.toLowerCase().indexOf( term ) >= 0 ) {
|
35 |
+
return match;
|
36 |
+
}
|
37 |
|
38 |
+
if ( match.children ) {
|
39 |
+
for ( var i = match.children.length - 1; i >= 0; i-- ) {
|
40 |
+
var child = match.children[i];
|
|
|
|
|
41 |
|
42 |
+
// Remove term from results if it doesn't match.
|
43 |
+
if ( -1 === child.id.toLowerCase().indexOf( term ) ) {
|
44 |
+
match.children.splice( i, 1 );
|
45 |
}
|
46 |
}
|
47 |
|
48 |
+
if ( match.children.length > 0 ) {
|
49 |
+
return match;
|
50 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
+
|
53 |
+
return null;
|
54 |
+
},
|
55 |
+
}
|
56 |
+
).change(
|
57 |
+
function() {
|
58 |
+
var value = $( this ).val();
|
59 |
+
if ( value ) {
|
60 |
+
var parts = value.split( '-' );
|
61 |
+
$( this ).siblings( '.connector' ).val( parts[0] );
|
62 |
+
$( this ).siblings( '.context' ).val( parts[1] );
|
63 |
}
|
64 |
+
}
|
65 |
+
);
|
66 |
|
67 |
+
var parts = [
|
68 |
$( el ).siblings( '.connector' ).val(),
|
69 |
+
$( el ).siblings( '.context' ).val(),
|
70 |
+
];
|
71 |
+
if ( '' === parts[1] ) {
|
72 |
+
parts.splice( 1, 1 );
|
|
|
|
|
73 |
}
|
74 |
+
$( el ).val( parts.join( '-' ) ).trigger( 'change' );
|
75 |
+
}
|
76 |
+
);
|
77 |
|
78 |
+
$target.find( 'select.select2-select:not(.connector_or_context)' ).each(
|
79 |
+
function() {
|
80 |
+
var element_id_split = $( this ).attr( 'id' ).split( '_' );
|
81 |
+
var select_name = element_id_split[element_id_split.length - 1].charAt( 0 ).toUpperCase() +
|
82 |
element_id_split[element_id_split.length - 1].slice( 1 );
|
83 |
+
$( this ).select2(
|
84 |
+
{
|
85 |
+
allowClear: true,
|
86 |
+
placeholder: streamAlerts.any + ' ' + select_name,
|
87 |
+
}
|
88 |
+
);
|
89 |
+
}
|
90 |
+
);
|
91 |
+
};
|
92 |
+
var $alertSettingSelect = $( '#wp_stream_alert_type' );
|
93 |
+
|
94 |
+
var loadAlertSettings = function( alert_type ) {
|
95 |
+
var data = {
|
96 |
+
action: 'load_alerts_settings',
|
97 |
+
alert_type: alert_type,
|
98 |
};
|
|
|
99 |
|
100 |
+
var $alert_edit_row = $( '#wp_stream_alert_type' ).closest( 'tr' );
|
101 |
+
var row_id = $alert_edit_row.attr( 'id' );
|
102 |
+
data.post_id = row_id.split( '-' )[1];
|
103 |
+
$.post(
|
104 |
+
window.ajaxurl, data, function( response ) {
|
105 |
+
var $alert_type_settings = $( '#wp_stream_alert_type_form' );
|
106 |
+
var alert_type_value = $( '#wp_stream_alert_type' ).val();
|
107 |
+
if ( 'none' === alert_type_value ) {
|
108 |
+
$alert_type_settings.hide();
|
109 |
+
return;
|
110 |
+
}
|
111 |
+
$alert_type_settings.html( response.data.html );
|
112 |
+
$alert_type_settings.show();
|
113 |
+
}
|
114 |
+
);
|
115 |
+
};
|
116 |
|
117 |
+
$( '#the-list' ).on(
|
118 |
+
'change', '#wp_stream_trigger_connector_or_context', function() {
|
119 |
+
if ( 'wp_stream_trigger_connector_or_context' === $( this ).attr( 'id' ) ) {
|
120 |
+
var connector = $( this ).val();
|
121 |
+
if ( connector && 0 < connector.indexOf( '-' ) ) {
|
122 |
+
var connector_split = connector.split( '-' );
|
123 |
+
connector = connector_split[0];
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
+
getActions( connector );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
);
|
129 |
+
|
130 |
+
var getActions = function( connector ) {
|
131 |
+
var trigger_action = $( '#wp_stream_trigger_action' );
|
132 |
+
trigger_action.empty();
|
133 |
+
trigger_action.prop( 'disabled', true );
|
134 |
+
|
135 |
+
var placeholder = $( '<option/>', { value: '', text: '' } );
|
136 |
+
trigger_action.append( placeholder );
|
137 |
+
|
138 |
+
var data = {
|
139 |
+
action: 'get_actions',
|
140 |
+
connector: connector,
|
141 |
};
|
142 |
|
143 |
+
$.post(
|
144 |
+
window.ajaxurl, data, function( response ) {
|
145 |
+
var success = response.success,
|
146 |
+
actions = response.data;
|
147 |
+
if ( ! success ) {
|
148 |
+
return;
|
149 |
+
}
|
150 |
+
for ( var key in actions ) {
|
151 |
+
if ( actions.hasOwnProperty( key ) ) {
|
152 |
+
var value = actions[key];
|
153 |
+
var option = $( '<option/>', { value: key, text: value } );
|
154 |
+
trigger_action.append( option );
|
155 |
}
|
|
|
156 |
}
|
157 |
+
trigger_action.prop( 'disabled', false );
|
158 |
+
$( document ).trigger( 'alert-actions-updated' );
|
159 |
}
|
160 |
);
|
161 |
+
};
|
162 |
|
163 |
+
$alertSettingSelect.change(
|
164 |
+
function() {
|
165 |
+
loadAlertSettings( $( this ).val() );
|
166 |
+
}
|
167 |
+
);
|
|
|
|
|
168 |
|
169 |
+
$( '#wpbody-content' ).on(
|
170 |
+
'click', 'a.page-title-action', function( e ) {
|
171 |
+
e.preventDefault();
|
172 |
+
$( '#add-new-alert' ).remove();
|
173 |
+
if ( $( '.inline-edit-wp_stream_alerts' ).length > 0 ) {
|
174 |
+
$( '.inline-edit-wp_stream_alerts .inline-edit-save button.button-secondary.cancel' ).trigger( 'click' );
|
175 |
+
}
|
176 |
+
var alert_form_html = '';
|
177 |
var data = {
|
178 |
+
action: 'get_new_alert_triggers_notifications',
|
|
|
179 |
};
|
|
|
180 |
$.post(
|
181 |
window.ajaxurl, data, function( response ) {
|
182 |
+
if ( true === response.success ) {
|
183 |
+
alert_form_html = response.data.html;
|
184 |
+
$( '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>' );
|
185 |
+
var add_new_alert = $( '#add-new-alert' );
|
186 |
+
var current_bg_color = add_new_alert.css( 'background-color' );
|
187 |
+
|
188 |
+
// Color taken from /wp-admin/css/forms.css
|
189 |
+
// #pass-strength-result.strong
|
190 |
+
add_new_alert.css( 'background-color', '#C1E1B9' );
|
191 |
+
setTimeout(
|
192 |
+
function() {
|
193 |
+
add_new_alert.css( 'background-color', current_bg_color );
|
194 |
+
}, 250
|
195 |
+
);
|
196 |
+
|
197 |
+
$( '#wp_stream_alert_type' ).change(
|
198 |
+
function() {
|
199 |
+
loadAlertSettings( $( this ).val() );
|
200 |
+
}
|
201 |
+
);
|
202 |
+
add_new_alert.on(
|
203 |
+
'click', '.button-secondary.cancel', function() {
|
204 |
+
$( '#add-new-alert' ).remove();
|
205 |
+
}
|
206 |
+
);
|
207 |
+
add_new_alert.on( 'click', '.button-primary.save', save_new_alert );
|
208 |
+
|
209 |
+
setupSelectTwo( '#add-new-alert' );
|
210 |
}
|
|
|
|
|
211 |
}
|
212 |
);
|
213 |
+
}
|
214 |
+
);
|
215 |
+
var save_new_alert = function save_new_alert( e ) {
|
216 |
+
e.preventDefault();
|
217 |
+
$( '#add-new-alert' ).find( 'p.submit.inline-edit-save span.spinner' ).css( 'visibility', 'visible' );
|
218 |
+
var data = {
|
219 |
+
action: 'save_new_alert',
|
220 |
+
wp_stream_alerts_nonce: $( '#wp_stream_alerts_nonce' ).val(),
|
221 |
+
wp_stream_trigger_author: $( '#wp_stream_trigger_author' ).val(),
|
222 |
+
wp_stream_trigger_context: $( '#wp_stream_trigger_connector_or_context' ).val(),
|
223 |
+
wp_stream_trigger_action: $( '#wp_stream_trigger_action' ).val(),
|
224 |
+
wp_stream_alert_type: $( '#wp_stream_alert_type' ).val(),
|
225 |
+
wp_stream_alert_status: $( '#wp_stream_alert_status' ).val(),
|
226 |
};
|
227 |
+
$( '#wp_stream_alert_type_form' ).find( ':input' ).each(
|
|
|
228 |
function() {
|
229 |
+
var alert_type_data_id = $( this ).attr( 'id' );
|
230 |
+
if ( $( this ).val() ) {
|
231 |
+
data[alert_type_data_id] = $( this ).val();
|
232 |
+
}
|
233 |
}
|
234 |
);
|
235 |
|
236 |
+
$.post(
|
237 |
+
window.ajaxurl, data, function( response ) {
|
238 |
+
if ( true === response.success ) {
|
239 |
+
$( '#add-new-alert' ).find( 'p.submit.inline-edit-save span.spinner' ).css( 'visibility', 'hidden' );
|
240 |
+
location.reload();
|
|
|
241 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
);
|
244 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
+
// we create a copy of the WP inline edit post function
|
247 |
+
var $wp_inline_edit = inlineEditPost.edit;
|
248 |
|
249 |
+
// and then we overwrite the function with our own code
|
250 |
+
inlineEditPost.edit = function( id ) {
|
251 |
+
// "call" the original WP edit function
|
252 |
+
// we don't want to leave WordPress hanging
|
253 |
+
$wp_inline_edit.apply( this, arguments );
|
254 |
|
255 |
+
// now we take care of our business
|
256 |
|
257 |
+
// get the post ID
|
258 |
+
var post_id = 0;
|
259 |
+
if ( typeof ( id ) === 'object' ) {
|
260 |
+
post_id = parseInt( this.getId( id ), 10 );
|
261 |
+
}
|
262 |
|
263 |
+
if ( post_id > 0 ) {
|
264 |
+
// define the edit row
|
265 |
+
$edit_row = $( '#edit-' + post_id );
|
266 |
+
$post_row = $( '#post-' + post_id );
|
267 |
|
268 |
+
// get the data
|
269 |
+
var alert_trigger_connector = $post_row.find( 'input[name="wp_stream_trigger_connector"]' ).val();
|
270 |
+
var alert_trigger_context = $post_row.find( 'input[name="wp_stream_trigger_context"]' ).val();
|
271 |
+
var alert_trigger_connector_context = alert_trigger_connector + '-' + alert_trigger_context;
|
272 |
+
var alert_trigger_action = $post_row.find( 'input[name="wp_stream_trigger_action"]' ).val();
|
273 |
+
var alert_status = $post_row.find( 'input[name="wp_stream_alert_status"]' ).val();
|
274 |
|
275 |
+
// populate the data
|
276 |
+
$edit_row.find( 'input[name="wp_stream_trigger_connector"]' ).attr( 'value', alert_trigger_connector );
|
277 |
+
$edit_row.find( 'input[name="wp_stream_trigger_context"]' ).attr( 'value', alert_trigger_context );
|
278 |
+
$edit_row.find( 'select[name="wp_stream_trigger_connector_or_context"] option[value="' + alert_trigger_connector_context + '"]' ).attr( 'selected', 'selected' );
|
279 |
+
$( document ).one(
|
280 |
+
'alert-actions-updated', function() {
|
281 |
+
$edit_row.find( 'input[name="wp_stream_trigger_action"]' ).attr( 'value', alert_trigger_action );
|
282 |
+
$edit_row.find( 'select[name="wp_stream_trigger_action"] option[value="' + alert_trigger_action + '"]' ).attr( 'selected', 'selected' ).trigger( 'change' );
|
283 |
+
}
|
284 |
+
);
|
285 |
+
$edit_row.find( 'select[name="wp_stream_alert_status"] option[value="' + alert_status + '"]' ).attr( 'selected', 'selected' );
|
286 |
+
setupSelectTwo( '#edit-' + post_id );
|
287 |
|
288 |
+
// Alert type handling
|
289 |
+
$( '#wp_stream_alert_type_form' ).hide();
|
290 |
+
var alert_type = $post_row.find( 'input[name="wp_stream_alert_type"]' ).val();
|
291 |
+
$edit_row.find( 'select[name="wp_stream_alert_type"] option[value="' + alert_type + '"]' ).attr( 'selected', 'selected' ).trigger( 'change' );
|
292 |
+
}
|
293 |
+
};
|
294 |
if ( window.location.hash ) {
|
295 |
var $target_post_row = $( window.location.hash );
|
296 |
if ( $target_post_row.length ) {
|
297 |
var scroll_to_position = $target_post_row.offset().top - $( '#wpadminbar' ).height();
|
298 |
$( 'html, body' ).animate(
|
299 |
{
|
300 |
+
scrollTop: scroll_to_position,
|
301 |
+
}, 1000
|
302 |
);
|
303 |
$target_post_row.find( '.row-actions a.editinline' ).trigger( 'click' );
|
304 |
}
|
ui/js/exclude.js
CHANGED
@@ -1,421 +1,419 @@
|
|
1 |
-
/* globals ajaxurl, wp_stream_regenerate_alt_rows */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
-
|
5 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
connector = $( this ).val();
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
}
|
63 |
-
getActions( row, connector );
|
64 |
}
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
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 |
-
|
119 |
-
|
120 |
-
|
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 |
-
|
133 |
return answer;
|
134 |
}
|
135 |
-
},
|
136 |
-
templateResult: function( object ) {
|
137 |
-
var $result = $( '<div>' ).text( object.text );
|
138 |
|
139 |
-
|
140 |
-
$result.prepend( $( '<img src="' + object.icon + '" class="wp-stream-select2-icon">' ) );
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
$result.attr( 'title', object.tooltip );
|
149 |
-
} else if ( 'undefined' !== typeof object.user_count ) {
|
150 |
-
$result.attr( 'title', object.user_count );
|
151 |
-
}
|
152 |
|
153 |
-
|
|
|
154 |
},
|
155 |
-
|
156 |
-
|
|
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
}
|
161 |
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
placeholder: $input_user.data( 'placeholder' )
|
166 |
-
}
|
167 |
-
).on(
|
168 |
-
'change', function() {
|
169 |
-
var value = $( this ).select2( 'data' );
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
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 |
-
|
217 |
-
|
218 |
-
|
219 |
|
220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
|
|
|
|
|
|
|
225 |
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
function(
|
232 |
-
|
233 |
-
|
|
|
|
|
|
|
|
|
234 |
}
|
235 |
);
|
|
|
236 |
|
237 |
-
|
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 |
-
|
270 |
-
$input.blur();
|
271 |
-
return false;
|
272 |
-
}
|
273 |
-
}
|
274 |
-
);
|
275 |
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
|
280 |
-
|
|
|
281 |
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
|
|
|
|
287 |
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
}
|
295 |
);
|
296 |
|
297 |
-
$( '.stream-exclude-list tr:not(.hidden)
|
298 |
-
function() {
|
299 |
-
var
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
if (
|
304 |
-
|
|
|
305 |
}
|
306 |
-
$( this ).val( parts.join( '-' ) ).trigger( 'change' );
|
307 |
}
|
308 |
);
|
309 |
|
310 |
-
$( '
|
311 |
'click', function() {
|
312 |
-
var $
|
313 |
|
314 |
-
$(
|
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 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
350 |
|
351 |
-
|
352 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
353 |
}
|
354 |
-
|
|
|
|
|
355 |
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
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 |
-
|
|
|
386 |
|
387 |
-
|
388 |
-
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
}
|
391 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
function getActions( row, connector ) {
|
394 |
var trigger_action = $( '.select2-select.action', row ),
|
395 |
-
action_value
|
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 |
-
|
405 |
-
|
406 |
};
|
407 |
|
408 |
$.post(
|
409 |
window.ajaxurl, data, function( response ) {
|
410 |
var success = response.success,
|
411 |
-
|
412 |
if ( ! success ) {
|
413 |
return;
|
414 |
}
|
415 |
for ( var key in actions ) {
|
416 |
if ( actions.hasOwnProperty( key ) ) {
|
417 |
-
var value
|
418 |
-
var option = $( '<option/>', {value: key, text: value} );
|
419 |
trigger_action.append( option );
|
420 |
}
|
421 |
}
|
@@ -438,9 +436,9 @@ jQuery(
|
|
438 |
}
|
439 |
|
440 |
function recalculate_rules_found() {
|
441 |
-
var $allRows
|
442 |
$noRulesFound = $( 'table.stream-exclude-list tbody tr.no-items' ),
|
443 |
-
$selectAll
|
444 |
$deleteButton = $( '#exclude_rules_remove_rules' );
|
445 |
|
446 |
if ( 0 === $allRows.length ) {
|
@@ -455,11 +453,11 @@ jQuery(
|
|
455 |
wp_stream_regenerate_alt_rows( $allRows );
|
456 |
}
|
457 |
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
}
|
465 |
);
|
1 |
+
/* globals jQuery, 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 |
+
}
|
19 |
+
return $( '<span class="child">' + item.text + '</span>' );
|
20 |
+
},
|
21 |
+
matcher: function( params, data ) {
|
22 |
+
var match = $.extend( true, {}, data );
|
23 |
|
24 |
+
if ( null === params.term || $.trim( params.term ) === '' ) {
|
25 |
+
return match;
|
26 |
+
}
|
|
|
27 |
|
28 |
+
var term = params.term.toLowerCase();
|
29 |
|
30 |
+
match.id = match.id.replace( 'blogs', 'sites' );
|
31 |
+
if ( match.id.toLowerCase().indexOf( term ) >= 0 ) {
|
32 |
+
return match;
|
33 |
+
}
|
34 |
|
35 |
+
if ( match.children ) {
|
36 |
+
for ( var i = match.children.length - 1; i >= 0; i-- ) {
|
37 |
+
var child = match.children[i];
|
|
|
|
|
38 |
|
39 |
+
// Remove term from results if it doesn't match.
|
40 |
+
if ( child.id.toLowerCase().indexOf( term ) === -1 ) {
|
41 |
+
match.children.splice( i, 1 );
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
if ( match.children.length > 0 ) {
|
46 |
+
return match;
|
47 |
+
}
|
48 |
}
|
49 |
+
|
50 |
+
return null;
|
51 |
+
},
|
52 |
+
}
|
53 |
+
).on(
|
54 |
+
'change', function() {
|
55 |
+
var row = $( this ).closest( 'tr' ),
|
56 |
connector = $( this ).val();
|
57 |
+
if ( connector && 0 < connector.indexOf( '-' ) ) {
|
58 |
+
var connector_split = connector.split( '-' );
|
59 |
+
connector = connector_split[0];
|
|
|
|
|
60 |
}
|
61 |
+
getActions( row, connector );
|
62 |
+
}
|
63 |
+
);
|
64 |
+
}
|
65 |
+
);
|
66 |
|
67 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.action' ).each(
|
68 |
+
function( k, el ) {
|
69 |
+
$( el ).select2(
|
70 |
+
{
|
71 |
+
allowClear: true,
|
72 |
+
}
|
73 |
+
);
|
74 |
+
}
|
75 |
+
);
|
76 |
|
77 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role' ).each(
|
78 |
+
function( k, el ) {
|
79 |
+
$input_user = $( el );
|
80 |
+
|
81 |
+
$input_user.select2(
|
82 |
+
{
|
83 |
+
ajax: {
|
84 |
+
type: 'POST',
|
85 |
+
url: ajaxurl,
|
86 |
+
dataType: 'json',
|
87 |
+
quietMillis: 500,
|
88 |
+
data: function( term, page ) {
|
89 |
+
return {
|
90 |
+
find: term,
|
91 |
+
limit: 10,
|
92 |
+
pager: page,
|
93 |
+
action: 'stream_get_users',
|
94 |
+
nonce: $input_user.data( 'nonce' ),
|
95 |
+
};
|
96 |
+
},
|
97 |
+
processResults: function( response ) {
|
98 |
+
var answer = {
|
99 |
+
results: [
|
100 |
{ text: '', id: '' },
|
101 |
{ text: 'Roles', children: [] },
|
102 |
+
{ text: 'Users', children: [] },
|
103 |
+
],
|
104 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
+
if ( true !== response.success || undefined === response.data || true !== response.data.status ) {
|
107 |
+
return answer;
|
108 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
if ( undefined === response.data.users || undefined === response.data.roles ) {
|
111 |
return answer;
|
112 |
}
|
|
|
|
|
|
|
113 |
|
114 |
+
var roles = [];
|
|
|
115 |
|
116 |
+
$.each(
|
117 |
+
response.data.roles, function( id, text ) {
|
118 |
+
roles.push(
|
119 |
+
{
|
120 |
+
id: id,
|
121 |
+
text: text,
|
122 |
+
}
|
123 |
+
);
|
124 |
+
}
|
125 |
+
);
|
126 |
|
127 |
+
answer.results[ 1 ].children = roles;
|
128 |
+
answer.results[ 2 ].children = response.data.users;
|
|
|
|
|
|
|
|
|
129 |
|
130 |
+
// Return the value of more so Select2 knows if more results can be loaded
|
131 |
+
return answer;
|
132 |
},
|
133 |
+
},
|
134 |
+
templateResult: function( object ) {
|
135 |
+
var $result = $( '<div>' ).text( object.text );
|
136 |
|
137 |
+
if ( 'undefined' !== typeof object.icon && object.icon ) {
|
138 |
+
$result.prepend( $( '<img src="' + object.icon + '" class="wp-stream-select2-icon">' ) );
|
|
|
139 |
|
140 |
+
// Add more info to the container
|
141 |
+
$result.attr( 'title', object.tooltip );
|
142 |
+
}
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
+
// Add more info to the container
|
145 |
+
if ( 'undefined' !== typeof object.tooltip ) {
|
146 |
+
$result.attr( 'title', object.tooltip );
|
147 |
+
} else if ( 'undefined' !== typeof object.user_count ) {
|
148 |
+
$result.attr( 'title', object.user_count );
|
149 |
+
}
|
150 |
|
151 |
+
return $result;
|
152 |
+
},
|
153 |
+
templateSelection: function( object ) {
|
154 |
+
var $result = $( '<div>' ).text( object.text );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
+
if ( $.isNumeric( object.id ) && object.text.indexOf( 'icon-users' ) < 0 ) {
|
157 |
+
$result.append( $( '<i class="icon16 icon-users"></i>' ) );
|
158 |
+
}
|
159 |
|
160 |
+
return $result;
|
161 |
+
},
|
162 |
+
allowClear: true,
|
163 |
+
placeholder: $input_user.data( 'placeholder' ),
|
164 |
+
}
|
165 |
+
).on(
|
166 |
+
'change', function() {
|
167 |
+
var value = $( this ).select2( 'data' );
|
168 |
|
169 |
+
$( this ).data( 'selected-id', value.id );
|
170 |
+
$( this ).data( 'selected-text', value.text );
|
171 |
+
}
|
172 |
+
);
|
173 |
+
}
|
174 |
+
);
|
175 |
|
176 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.ip_address' ).each(
|
177 |
+
function( k, el ) {
|
178 |
+
var $input_ip = $( el ),
|
179 |
+
searchTerm = '';
|
180 |
+
|
181 |
+
$input_ip.select2(
|
182 |
+
{
|
183 |
+
ajax: {
|
184 |
+
type: 'POST',
|
185 |
+
url: ajaxurl,
|
186 |
+
dataType: 'json',
|
187 |
+
quietMillis: 500,
|
188 |
+
data: function( term ) {
|
189 |
+
searchTerm = term.term;
|
190 |
+
return {
|
191 |
+
find: term,
|
192 |
+
limit: 10,
|
193 |
+
action: 'stream_get_ips',
|
194 |
+
nonce: $input_ip.data( 'nonce' ),
|
195 |
+
};
|
196 |
+
},
|
197 |
+
processResults: function( response ) {
|
198 |
+
var answer = { results: [] },
|
199 |
+
ip_chunks = [];
|
200 |
|
201 |
+
if ( true === response.success && undefined !== response.data ) {
|
202 |
+
$.each(
|
203 |
+
response.data, function( key, ip ) {
|
204 |
+
answer.results.push(
|
205 |
+
{
|
206 |
+
id: ip,
|
207 |
+
text: ip,
|
208 |
+
}
|
209 |
+
);
|
210 |
}
|
211 |
);
|
212 |
+
}
|
213 |
|
214 |
+
if ( undefined === searchTerm ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
return answer;
|
216 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
+
ip_chunks = searchTerm.match( /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ );
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
+
if ( null === ip_chunks ) {
|
221 |
+
return answer;
|
222 |
+
}
|
223 |
|
224 |
+
// remove whole match
|
225 |
+
ip_chunks.shift();
|
226 |
|
227 |
+
ip_chunks = $.grep(
|
228 |
+
ip_chunks,
|
229 |
+
function( chunk ) {
|
230 |
+
var numeric = parseInt( chunk, 10 );
|
231 |
+
return numeric <= 255 && numeric.toString() === chunk;
|
232 |
+
}
|
233 |
+
);
|
234 |
|
235 |
+
if ( ip_chunks.length >= 4 ) {
|
236 |
+
answer.results.push(
|
237 |
+
{
|
238 |
+
id: searchTerm,
|
239 |
+
text: searchTerm,
|
240 |
+
}
|
241 |
+
);
|
242 |
+
}
|
243 |
|
244 |
+
return answer;
|
245 |
+
},
|
246 |
+
},
|
247 |
+
allowClear: false,
|
248 |
+
multiple: true,
|
249 |
+
maximumSelectionSize: 1,
|
250 |
+
placeholder: $input_ip.data( 'placeholder' ),
|
251 |
+
tags: true,
|
252 |
+
}
|
253 |
+
);
|
254 |
+
}
|
255 |
+
).on(
|
256 |
+
'change', function() {
|
257 |
+
$( this ).prev( '.select2-container' ).find( 'input.select2-input' ).blur();
|
258 |
}
|
259 |
);
|
260 |
|
261 |
+
$( 'ul.select2-choices, ul.select2-choices li, input.select2-input', '.stream-exclude-list tr:not(.hidden) .ip_address' ).on(
|
262 |
+
'mousedown click focus', function() {
|
263 |
+
var $container = $( this ).closest( '.select2-container' ),
|
264 |
+
$input = $container.find( 'input.select2-input' ),
|
265 |
+
value = $container.select2( 'data' );
|
266 |
+
|
267 |
+
if ( value.length >= 1 ) {
|
268 |
+
$input.blur();
|
269 |
+
return false;
|
270 |
}
|
|
|
271 |
}
|
272 |
);
|
273 |
|
274 |
+
$( '.stream-exclude-list tr:not(.hidden) .exclude_rules_remove_rule_row' ).on(
|
275 |
'click', function() {
|
276 |
+
var $thisRow = $( this ).closest( 'tr' );
|
277 |
|
278 |
+
$thisRow.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
|
280 |
recalculate_rules_found();
|
281 |
recalculate_rules_selected();
|
282 |
}
|
283 |
);
|
284 |
+
};
|
285 |
|
286 |
+
initSettingsSelect2();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.author_or_role' ).each(
|
289 |
+
function() {
|
290 |
+
var $option = $( '<option selected>' + $( this ).data( 'selected-text' ) + '</option>' ).val( $( this ).data( 'selected-id' ) );
|
291 |
+
$( this ).append( $option ).trigger( 'change' );
|
292 |
+
}
|
293 |
+
);
|
294 |
|
295 |
+
$( '.stream-exclude-list tr:not(.hidden) select.select2-select.connector_or_context' ).each(
|
296 |
+
function() {
|
297 |
+
var parts = [
|
298 |
+
$( this ).siblings( '.connector' ).val(),
|
299 |
+
$( this ).siblings( '.context' ).val(),
|
300 |
+
];
|
301 |
+
if ( parts[1] === '' ) {
|
302 |
+
parts.splice( 1, 1 );
|
303 |
}
|
304 |
+
$( this ).val( parts.join( '-' ) ).trigger( 'change' );
|
305 |
+
}
|
306 |
+
);
|
307 |
|
308 |
+
$( '#exclude_rules_new_rule' ).on(
|
309 |
+
'click', function() {
|
310 |
+
var $excludeList = $( 'table.stream-exclude-list' );
|
311 |
+
|
312 |
+
$( 'tr:not(.hidden) select.select2-select', $excludeList ).each(
|
313 |
+
function() {
|
314 |
+
$( this ).select2( 'destroy' );
|
315 |
+
}
|
316 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
+
var $lastRow = $( 'tr', $excludeList ).last(),
|
319 |
+
$newRow = $lastRow.clone();
|
320 |
|
321 |
+
$newRow.removeAttr( 'class' );
|
322 |
+
$( '.stream-exclude-list tbody :input' ).off();
|
323 |
+
$( ':input', $newRow ).off().val( '' );
|
324 |
+
|
325 |
+
$lastRow.after( $newRow );
|
326 |
+
|
327 |
+
initSettingsSelect2();
|
328 |
+
|
329 |
+
recalculate_rules_found();
|
330 |
+
recalculate_rules_selected();
|
331 |
+
}
|
332 |
+
);
|
333 |
+
|
334 |
+
$( '#exclude_rules_remove_rules' ).on(
|
335 |
+
'click', function() {
|
336 |
+
var $excludeList = $( 'table.stream-exclude-list' ),
|
337 |
+
selectedRows = $( 'tbody input.cb-select:checked', $excludeList ).closest( 'tr' );
|
338 |
+
|
339 |
+
if ( ( $( 'tbody tr', $excludeList ).length - selectedRows.length ) >= 2 ) {
|
340 |
+
selectedRows.remove();
|
341 |
+
} else {
|
342 |
+
$( ':input', selectedRows ).val( '' );
|
343 |
+
$( selectedRows ).not( ':first' ).remove();
|
344 |
+
$( '.select2-select', selectedRows ).select2( 'val', '' );
|
345 |
}
|
346 |
+
|
347 |
+
$excludeList.find( 'input.cb-select' ).prop( 'checked', false );
|
348 |
+
|
349 |
+
recalculate_rules_found();
|
350 |
+
recalculate_rules_selected();
|
351 |
+
}
|
352 |
+
);
|
353 |
+
|
354 |
+
$( '.stream-exclude-list' ).closest( 'form' ).submit(
|
355 |
+
function() {
|
356 |
+
$( '.stream-exclude-list tbody tr.hidden', this ).each(
|
357 |
+
function() {
|
358 |
+
$( this ).find( ':input' ).removeAttr( 'name' );
|
359 |
+
}
|
360 |
+
);
|
361 |
+
$( '.stream-exclude-list tbody tr:not(.hidden) select.select2-select.connector_or_context', this ).each(
|
362 |
+
function() {
|
363 |
+
var parts = $( this ).val().split( '-' );
|
364 |
+
$( this ).siblings( '.connector' ).val( parts[0] );
|
365 |
+
$( this ).siblings( '.context' ).val( parts[1] );
|
366 |
+
$( this ).removeAttr( 'name' );
|
367 |
+
}
|
368 |
+
);
|
369 |
+
$( '.stream-exclude-list tbody tr:not(.hidden) select.select2-select.ip_address', this ).each(
|
370 |
+
function() {
|
371 |
+
var firstSelected = $( 'option:selected', this ).first();
|
372 |
+
$( 'option:selected:not(:first)', this ).each(
|
373 |
+
function() {
|
374 |
+
firstSelected.attr( 'value', firstSelected.attr( 'value' ) + ',' + $( this ).attr( 'value' ) );
|
375 |
+
$( this ).removeAttr( 'selected' );
|
376 |
+
}
|
377 |
+
);
|
378 |
+
}
|
379 |
+
);
|
380 |
+
}
|
381 |
+
);
|
382 |
+
|
383 |
+
$( '.stream-exclude-list' ).closest( 'td' ).prev( 'th' ).hide();
|
384 |
+
|
385 |
+
$( 'table.stream-exclude-list' ).on(
|
386 |
+
'click', 'input.cb-select', function() {
|
387 |
+
recalculate_rules_selected();
|
388 |
+
}
|
389 |
+
);
|
390 |
|
391 |
function getActions( row, connector ) {
|
392 |
var trigger_action = $( '.select2-select.action', row ),
|
393 |
+
action_value = trigger_action.val();
|
394 |
|
395 |
trigger_action.empty();
|
396 |
trigger_action.prop( 'disabled', true );
|
397 |
|
398 |
+
var placeholder = $( '<option/>', { value: '', text: '' } );
|
399 |
trigger_action.append( placeholder );
|
400 |
|
401 |
var data = {
|
402 |
+
action: 'get_actions',
|
403 |
+
connector: connector,
|
404 |
};
|
405 |
|
406 |
$.post(
|
407 |
window.ajaxurl, data, function( response ) {
|
408 |
var success = response.success,
|
409 |
+
actions = response.data;
|
410 |
if ( ! success ) {
|
411 |
return;
|
412 |
}
|
413 |
for ( var key in actions ) {
|
414 |
if ( actions.hasOwnProperty( key ) ) {
|
415 |
+
var value = actions[key];
|
416 |
+
var option = $( '<option/>', { value: key, text: value } );
|
417 |
trigger_action.append( option );
|
418 |
}
|
419 |
}
|
436 |
}
|
437 |
|
438 |
function recalculate_rules_found() {
|
439 |
+
var $allRows = $( 'table.stream-exclude-list tbody tr:not( .hidden )' ),
|
440 |
$noRulesFound = $( 'table.stream-exclude-list tbody tr.no-items' ),
|
441 |
+
$selectAll = $( '.check-column.manage-column input.cb-select' ),
|
442 |
$deleteButton = $( '#exclude_rules_remove_rules' );
|
443 |
|
444 |
if ( 0 === $allRows.length ) {
|
453 |
wp_stream_regenerate_alt_rows( $allRows );
|
454 |
}
|
455 |
|
456 |
+
$( document ).ready(
|
457 |
+
function() {
|
458 |
+
recalculate_rules_found();
|
459 |
+
recalculate_rules_selected();
|
460 |
+
}
|
461 |
+
);
|
462 |
}
|
463 |
);
|
ui/js/exclude.min.js
CHANGED
@@ -1 +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
|
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,34 +1,32 @@
|
|
1 |
-
/* globals wp_stream_global */
|
2 |
/* exported wp_stream_regenerate_alt_rows */
|
3 |
jQuery(
|
4 |
function( $ ) {
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
'
|
9 |
-
|
10 |
-
warning_message( e );
|
11 |
-
}
|
12 |
}
|
13 |
-
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
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 |
|
@@ -42,7 +40,7 @@ var wp_stream_regenerate_alt_rows = function( $rows ) {
|
|
42 |
|
43 |
$rows.each(
|
44 |
function( index ) {
|
45 |
-
|
46 |
}
|
47 |
);
|
48 |
};
|
1 |
+
/* globals jQuery, wp_stream_global */
|
2 |
/* exported wp_stream_regenerate_alt_rows */
|
3 |
jQuery(
|
4 |
function( $ ) {
|
5 |
+
// List table actions, ignores filtering
|
6 |
+
$( '.actions :submit:not([name="filter_action"])' ).on(
|
7 |
+
'click', function( e ) {
|
8 |
+
if ( $( 'table.widefat tbody :checkbox:checked' ).length > wp_stream_global.bulk_actions.threshold ) {
|
9 |
+
warning_message( e );
|
|
|
|
|
10 |
}
|
11 |
+
}
|
12 |
+
);
|
13 |
|
14 |
+
// Post type empty trash
|
15 |
+
$( '#delete_all' ).on(
|
16 |
+
'click', function( e ) {
|
17 |
+
var trash_count = parseInt( $( 'ul.subsubsub li.trash .count' ).text().replace( /\D/g, '' ), 10 );
|
18 |
|
19 |
+
if ( trash_count > wp_stream_global.bulk_actions.threshold ) {
|
20 |
+
warning_message( e );
|
|
|
21 |
}
|
22 |
+
}
|
23 |
+
);
|
24 |
|
25 |
function warning_message( e ) {
|
26 |
if ( ! window.confirm( wp_stream_global.bulk_actions.i18n.confirm_action ) ) {
|
27 |
e.preventDefault();
|
28 |
}
|
29 |
}
|
|
|
30 |
}
|
31 |
);
|
32 |
|
40 |
|
41 |
$rows.each(
|
42 |
function( index ) {
|
43 |
+
jQuery( this ).addClass( index % 2 ? '' : 'alternate' );
|
44 |
}
|
45 |
);
|
46 |
};
|
ui/js/live-updates.js
CHANGED
@@ -1,125 +1,118 @@
|
|
1 |
-
/* globals wp_stream_live_updates, wp_stream_regenerate_alt_rows */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
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 |
-
|
24 |
-
'heartbeat-send.stream', function( e, data ) {
|
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 |
-
$current_items
|
51 |
-
$new_items
|
52 |
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
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 |
-
|
88 |
-
|
89 |
-
|
90 |
-
// Update pagination
|
91 |
-
var total_items_i18n = data.total_items_i18n || '';
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
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 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
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 |
);
|
1 |
+
/* globals jQuery, wp, wp_stream_live_updates, wp_stream_regenerate_alt_rows */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
+
$( document ).ready(
|
5 |
+
function() {
|
6 |
+
// Only run on wp_stream when page is 1 and the order is desc
|
7 |
+
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 ) {
|
8 |
+
return;
|
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(
|
22 |
+
'heartbeat-send.stream', function( e, data ) {
|
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 |
+
|
37 |
+
// Listen for "heartbeat-tick" on $(document).
|
38 |
+
$( document ).on(
|
39 |
+
'heartbeat-tick.stream', function( e, data ) {
|
40 |
+
// If this no rows return then we kill the script
|
41 |
+
if ( ! data['wp-stream-heartbeat'] || 0 === data['wp-stream-heartbeat'].length ) {
|
42 |
+
return;
|
43 |
+
}
|
44 |
|
45 |
+
var show_on_screen = $( '#edit_stream_per_page' ).val(),
|
46 |
+
$current_items = $( list_sel + ' tr' ),
|
47 |
+
$new_items = $( data['wp-stream-heartbeat'] );
|
48 |
|
49 |
+
// Remove all default classes and add class to highlight new rows
|
50 |
+
$new_items.addClass( 'new-row' );
|
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(
|
68 |
+
function() {
|
69 |
+
if ( true !== $( this ).prop( 'checked' ) ) {
|
70 |
+
var label = $( this ).val();
|
71 |
+
$( 'td.column-' + label ).hide();
|
|
|
72 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
+
);
|
75 |
|
76 |
+
// Remove the number of element added to the end of the list table
|
77 |
+
var slice_rows = show_on_screen - ( $new_items.length + $current_items.length );
|
|
|
|
|
|
|
78 |
|
79 |
+
if ( slice_rows < 0 ) {
|
80 |
+
$( list_sel + ' tr' ).slice( slice_rows ).remove();
|
81 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
+
// Remove the no items row
|
84 |
+
$( list_sel + ' tr.no-items' ).remove();
|
85 |
|
86 |
+
// Update pagination
|
87 |
+
var total_items_i18n = data.total_items_i18n || '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
+
if ( total_items_i18n ) {
|
90 |
+
$( '.displaying-num' ).text( total_items_i18n );
|
91 |
+
$( '.total-pages' ).text( data.total_pages_i18n );
|
92 |
+
$( '.tablenav-pages' ).find( '.next-page, .last-page' ).toggleClass( 'disabled', data.total_pages === $( '.current-page' ).val() );
|
93 |
+
$( '.tablenav-pages .last-page' ).attr( 'href', data.last_page_link );
|
94 |
}
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
// Allow others to hook in, ie: timeago
|
97 |
+
$( list_sel ).parent().trigger( 'updated' );
|
98 |
+
|
99 |
+
// Regenerate alternating row classes
|
100 |
+
wp_stream_regenerate_alt_rows( $( list_sel + ' tr' ) );
|
101 |
+
|
102 |
+
// Remove background after a certain amount of time
|
103 |
+
setTimeout(
|
104 |
+
function() {
|
105 |
+
$( '.new-row' ).addClass( 'fadeout' );
|
106 |
+
setTimeout(
|
107 |
+
function() {
|
108 |
+
$( list_sel + ' tr' ).removeClass( 'new-row fadeout' );
|
109 |
+
}, 500
|
110 |
+
);
|
111 |
+
}, 3000
|
112 |
+
);
|
113 |
+
}
|
114 |
+
);
|
115 |
+
}
|
116 |
+
);
|
117 |
}
|
118 |
);
|
ui/js/settings.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
/* globals
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
var network_affix;
|
@@ -8,8 +8,8 @@ jQuery(
|
|
8 |
network_affix = '';
|
9 |
}
|
10 |
var keepRecordsIndefinitely = $( '#wp_stream' + network_affix + '\\[general_keep_records_indefinitely\\]' ),
|
11 |
-
keepRecordsFor
|
12 |
-
keepRecordsForRow
|
13 |
|
14 |
function toggleKeepRecordsFor() {
|
15 |
if ( keepRecordsIndefinitely.is( ':checked' ) ) {
|
@@ -28,6 +28,7 @@ jQuery(
|
|
28 |
);
|
29 |
|
30 |
toggleKeepRecordsFor();
|
|
|
31 |
// Confirmation on some important actions
|
32 |
$( '#wp_stream_general_reset_site_settings' ).click(
|
33 |
function( e ) {
|
@@ -38,12 +39,12 @@ jQuery(
|
|
38 |
);
|
39 |
|
40 |
// Settings page tabs
|
41 |
-
var $tabs
|
42 |
-
$panels
|
43 |
-
$activeTab
|
44 |
-
defaultIndex
|
45 |
-
|
46 |
-
currentHash
|
47 |
syncFormAction = function( index ) {
|
48 |
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
49 |
if ( $optionsForm.length === 0 ) {
|
@@ -56,16 +57,16 @@ jQuery(
|
|
56 |
|
57 |
$tabs.on(
|
58 |
'click', 'a', function() {
|
59 |
-
var index
|
60 |
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
61 |
|
62 |
$panels.hide().eq( index ).show();
|
63 |
|
64 |
$tabs
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
|
70 |
if ( '' === window.location.hash || null !== hashIndex ) {
|
71 |
window.location.hash = index;
|
1 |
+
/* globals jQuery, wp_stream */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
var network_affix;
|
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' ) ) {
|
28 |
);
|
29 |
|
30 |
toggleKeepRecordsFor();
|
31 |
+
|
32 |
// Confirmation on some important actions
|
33 |
$( '#wp_stream_general_reset_site_settings' ).click(
|
34 |
function( e ) {
|
39 |
);
|
40 |
|
41 |
// Settings page tabs
|
42 |
+
var $tabs = $( '.nav-tab-wrapper' ),
|
43 |
+
$panels = $( '.nav-tab-content table.form-table' ),
|
44 |
+
$activeTab = $tabs.find( '.nav-tab-active' ),
|
45 |
+
defaultIndex = $activeTab.length > 0 ? $tabs.find( 'a' ).index( $activeTab ) : 0,
|
46 |
+
hashIndexStart = window.location.hash.match( /^#(\d+)$/ ),
|
47 |
+
currentHash = ( null !== hashIndexStart ? hashIndexStart[ 1 ] : defaultIndex ),
|
48 |
syncFormAction = function( index ) {
|
49 |
var $optionsForm = $( 'input[name="option_page"][value^="wp_stream"]' ).closest( 'form' );
|
50 |
if ( $optionsForm.length === 0 ) {
|
57 |
|
58 |
$tabs.on(
|
59 |
'click', 'a', function() {
|
60 |
+
var index = $tabs.find( 'a' ).index( $( this ) ),
|
61 |
hashIndex = window.location.hash.match( /^#(\d+)$/ );
|
62 |
|
63 |
$panels.hide().eq( index ).show();
|
64 |
|
65 |
$tabs
|
66 |
+
.find( 'a' )
|
67 |
+
.removeClass( 'nav-tab-active' )
|
68 |
+
.filter( $( this ) )
|
69 |
+
.addClass( 'nav-tab-active' );
|
70 |
|
71 |
if ( '' === window.location.hash || null !== hashIndex ) {
|
72 |
window.location.hash = index;
|
ui/js/wpseo-admin.js
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
-
|
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
|
10 |
|
11 |
window.location.hash = '';
|
12 |
|
13 |
if ( input.length ) {
|
14 |
if ( $( '#wpseo-tabs' ).length ) {
|
15 |
-
tab
|
16 |
window.location.hash = '#top#' + tab;
|
17 |
}
|
18 |
|
@@ -33,6 +32,5 @@ jQuery(
|
|
33 |
);
|
34 |
}
|
35 |
}
|
36 |
-
|
37 |
}
|
38 |
);
|
1 |
+
/* globals jQuery */
|
2 |
jQuery(
|
3 |
function( $ ) {
|
4 |
+
var highlight, input, tab;
|
|
|
5 |
|
6 |
if ( window.location.hash.substr( 'stream-highlight-' ) ) {
|
7 |
highlight = window.location.hash.replace( 'stream-highlight-', '' );
|
8 |
+
input = $( ':input' + highlight );
|
9 |
|
10 |
window.location.hash = '';
|
11 |
|
12 |
if ( input.length ) {
|
13 |
if ( $( '#wpseo-tabs' ).length ) {
|
14 |
+
tab = input.parents( '.wpseotab' ).first().attr( 'id' );
|
15 |
window.location.hash = '#top#' + tab;
|
16 |
}
|
17 |
|
32 |
);
|
33 |
}
|
34 |
}
|
|
|
35 |
}
|
36 |
);
|