| 1 |
<?php |
| 2 |
/** |
| 3 |
* Helper functions. |
| 4 |
* |
| 5 |
* @package Search_Replace_WPCode |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Get a URL with UTM parameters. |
| 10 |
* |
| 11 |
* @param string $url The URL to add the params to. |
| 12 |
* @param string $medium The marketing medium. |
| 13 |
* @param string $campaign The campaign. |
| 14 |
* @param string $ad_content The utm_content param. |
| 15 |
* |
| 16 |
* @return string |
| 17 |
*/ |
| 18 |
function wsrw_utm_url( $url, $medium = '', $campaign = '', $ad_content = '' ) { |
| 19 |
$args = array( |
| 20 |
'utm_source' => class_exists( 'WSRW_License' ) ? 'wsrwpro' : 'wsrwlite', |
| 21 |
'utm_medium' => sanitize_key( $medium ), |
| 22 |
'utm_campaign' => sanitize_key( $campaign ), |
| 23 |
); |
| 24 |
|
| 25 |
if ( ! empty( $ad_content ) ) { |
| 26 |
$args['utm_content'] = sanitize_key( $ad_content ); |
| 27 |
} |
| 28 |
|
| 29 |
return add_query_arg( |
| 30 |
$args, |
| 31 |
$url |
| 32 |
); |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* Check WP version and include the compatible upgrader skin. |
| 38 |
*/ |
| 39 |
function wsrw_require_upgrader() { |
| 40 |
|
| 41 |
global $wp_version; |
| 42 |
|
| 43 |
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 44 |
|
| 45 |
// WP 5.3 changes the upgrader skin. |
| 46 |
if ( version_compare( $wp_version, '5.3', '<' ) ) { |
| 47 |
require_once WSRW_PLUGIN_PATH . 'includes/admin/class-wsrw-skin-legacy.php'; |
| 48 |
} else { |
| 49 |
require_once WSRW_PLUGIN_PATH . 'includes/admin/class-wsrw-skin.php'; |
| 50 |
} |
| 51 |
} |
| 52 |
|