summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/stats.php')
-rw-r--r--plugins/jetpack/modules/stats.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/plugins/jetpack/modules/stats.php b/plugins/jetpack/modules/stats.php
index 4210f7c6..a0a1f7d4 100644
--- a/plugins/jetpack/modules/stats.php
+++ b/plugins/jetpack/modules/stats.php
@@ -655,6 +655,19 @@ function stats_convert_image_urls( $html ) {
}
/**
+ * Callback for preg_replace_callback used in stats_convert_chart_urls()
+ *
+ * @since 5.6.0
+ *
+ * @param array $matches The matches resulting from the preg_replace_callback call.
+ * @return string The admin url for the chart.
+ */
+function jetpack_stats_convert_chart_urls_callback( $matches ) {
+ // If there is a query string, change the beginning '?' to a '&' so it fits into the middle of this query string.
+ return 'admin.php?page=stats&noheader&chart=' . $matches[1] . str_replace( '?', '&', $matches[2] );
+}
+
+/**
* Stats Convert Chart URLs.
*
* @access public
@@ -662,13 +675,11 @@ function stats_convert_image_urls( $html ) {
* @return string
*/
function stats_convert_chart_urls( $html ) {
- $html = preg_replace_callback( '|https?://[-.a-z0-9]+/wp-includes/charts/([-.a-z0-9]+).php(\??)|',
- create_function(
- '$matches',
- // If there is a query string, change the beginning '?' to a '&' so it fits into the middle of this query string.
- 'return "admin.php?page=stats&noheader&chart=" . $matches[1] . str_replace( "?", "&", $matches[2] );'
- ),
- $html );
+ $html = preg_replace_callback(
+ '|https?://[-.a-z0-9]+/wp-includes/charts/([-.a-z0-9]+).php(\??)|',
+ 'jetpack_stats_convert_chart_urls_callback',
+ $html
+ );
return $html;
}