PHP code example of bonnier / wp-bonnier-redirect

1. Go to this page and download the library: Download bonnier/wp-bonnier-redirect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bonnier / wp-bonnier-redirect example snippets


/**
 * @param bool $isLive The plugins evaluation of whether the url is live or not
 * @param string $url The 'from'-url being saved
 * @param string $locale The locale of the redirect being saved
 * @param WP_Post|WP_Term|null $object The object found by the redirect plugin - null if $isLive == false
 *
 * @return bool
 */
add_filter('redirect/slug-is-live', function (bool $isLive, string $url, string $locale, $object) {
    return $isLive;
}, 10, 4);

/**
 * @param Redirect $redirect The newly created redirect
 */
add_filter('redirect/redirect-saved', function (Redirect $redirect) {
    // Do stuff with the newly created Redirect
}, 10);