Пример #1
1
function amp_maybe_add_actions()
{
    if (!is_singular() || is_feed()) {
        return;
    }
    $is_amp_endpoint = is_amp_endpoint();
    // Cannot use `get_queried_object` before canonical redirect; see https://core.trac.wordpress.org/ticket/35344
    global $wp_query;
    $post = $wp_query->post;
    $supports = post_supports_amp($post);
    if (!$supports) {
        if ($is_amp_endpoint) {
            wp_safe_redirect(get_permalink($post->ID));
            exit;
        }
        return;
    }
    if ($is_amp_endpoint) {
        amp_prepare_render();
    } else {
        amp_add_frontend_actions();
    }
}
function ampforwp_add_endpoint_actions()
{
    if (is_home() || is_archive()) {
        $is_amp_endpoint = is_amp_endpoint();
        if ($is_amp_endpoint) {
            amp_prepare_render();
        } else {
            add_action('wp_head', 'ampforwp_home_archive_rel_canonical');
        }
    }
}
Пример #3
0
function amp_maybe_add_actions()
{
    if (!is_singular()) {
        return;
    }
    $is_amp_endpoint = is_amp_endpoint();
    $post = get_queried_object();
    $supports = does_this_post_support_amp($post);
    if (!$supports) {
        if ($is_amp_endpoint) {
            wp_safe_redirect(get_permalink($post->ID));
            exit;
        }
        return;
    }
    if ($is_amp_endpoint) {
        amp_prepare_render();
    } else {
        amp_add_template_actions();
    }
}