AnsPress_Rewrite::shortlink()

Description #

Handles shortlink redirects.

Changelog #

VersionDescription
unknownunknown
4.1.6Introduced.

Source #

File: includes/rewrite.php

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
public static function shortlink() {
    global $wp_query;
    $page = get_query_var( 'ap_page' );
 
    if ( empty( $page ) || 'shortlink' !== $page ) {
        return;
    }
 
    $post_id = ap_isset_post_value( 'ap_q', ap_isset_post_value( 'ap_a', false ) );
    $post_id = ap_isset_post_value( 'ap_p', $post_id );
 
    // Post redirect.
    if ( $post_id ) {
        $permalink = get_permalink( $post_id );
        wp_redirect( $permalink, 302 ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
        exit;
    }
 
    // Comment redirect.
    if ( ap_isset_post_value( 'ap_c', false ) ) {
        $permalink = get_comment_link( ap_isset_post_value( 'ap_c' ) );
        wp_redirect( $permalink, 302 ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
        exit;
    }
 
    // User redirect.
    if ( ap_isset_post_value( 'ap_u', false ) ) {
        $permalink = ap_user_link( ap_isset_post_value( 'ap_u' ), ap_isset_post_value( 'sub' ) );
        wp_redirect( $permalink, 302 ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect
        exit;
    }
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment