mercredi 9 mars 2016

WP ThirstyAffiliates plugin hook

I'm using ThirstyAffiliates plugin and I need to do some changes in function thirstyRedirectUrl(). The trouble is after update plugin my changes will disappear. How and where can I make some hook?

My change is

if (isset($_GET['token']) && $_GET['token'] != '')
  $redirectUrl = apply_filters('thirstyFilterRedirectUrlToken', $redirectUrl, $_GET['token']);
else
  $redirectUrl = apply_filters('thirstyFilterRedirectUrl', $redirectUrl);

Here is all code of the function

function thirstyRedirectUrl() {
global $post;

if (get_post_type($post) == 'thirstylink') {
    // Get link data and set the redirect url
    $linkData = unserialize(get_post_meta($post->ID, 'thirstyData', true));
    $thirstyOptions = get_option('thirstyOptions');

    // Set redirect URL
    $redirectUrl = htmlspecialchars_decode($linkData['linkurl'], ENT_COMPAT);

    // Set redirect type
    $redirectType = $linkData['linkredirecttype'];
    if (empty($redirectType))
        $redirectType = $thirstyOptions['linkredirecttype'];

    // Apply any filters to the url before redirecting
    if (isset($_GET['token']) && $_GET['token'] != '')
        $redirectUrl = apply_filters('thirstyFilterRedirectUrlToken', $redirectUrl, $_GET['token']);
    else
        $redirectUrl = apply_filters('thirstyFilterRedirectUrl', $redirectUrl);
    $redirectType = apply_filters('thirstyFilterRedirectType', $redirectType);

    // Perform any actions before redirecting
    do_action('thirstyBeforeLinkRedirect', $post->ID, $redirectUrl, $redirectType);

    if (empty($redirectType))
        $redirectType = 301; // default to 301 redirect

    // Redirect the page
    if (!empty($redirectUrl))
        wp_redirect($redirectUrl, intval($redirectType));
    exit();
}
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire