Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "View Full Site" and "View Mobile Site" for WordPress Subdirectory Installations #12414

Merged
merged 6 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion modules/minileven/minileven.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,20 @@ function jetpack_mobile_template( $theme ) {
}

function jetpack_mobile_available() {
echo '<div class="jetpack-mobile-link" style="text-align:center;margin:10px 0;"><a href="'. esc_url( home_url( add_query_arg('ak_action', 'accept_mobile') ) ) . '">' . __( 'View Mobile Site', 'jetpack' ) . '</a></div>';
/*
* Create HTML markup with a link to "View Mobile Site".
* The link adds "ak_action=accept_mobile" to the current URL.
*/
global $wp;
$url_params = array(
'ak_action' => 'accept_mobile',
);
if ( is_array( $_GET ) && ! empty( $_GET ) ) {
$url_params[] = $_GET;
}
$target_url = home_url( add_query_arg( $url_params, $wp->request ) );
$anchor = '<a href="' . esc_url( $target_url ) . '">' . __( 'View Mobile Site', 'jetpack' ) . '</a>';
echo '<div class="jetpack-mobile-link" style="text-align:center;margin:10px 0;">' . $anchor . '</div>';
}

function jetpack_mobile_request_handler() {
Expand Down
19 changes: 18 additions & 1 deletion modules/minileven/theme/pub/minileven/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,24 @@

<footer id="colophon" role="contentinfo">
<div id="site-generator">
<a href="<?php echo esc_url( home_url( add_query_arg('ak_action', 'reject_mobile') ) ); ?>"><?php _e( 'View Full Site', 'jetpack' ); ?></a><br />

<?php
/*
* Construct "$target_url", which adds "ak_action=reject_mobile"
* to the current URL.
*/
global $wp;
$url_params = array(
'ak_action' => 'reject_mobile',
);
if ( is_array( $_GET ) && ! empty( $_GET ) ) {
$url_params[] = $_GET;
}
$target_url = home_url( add_query_arg( $url_params, $wp->request ) );
?>

<a href="<?php echo esc_url( $target_url ); ?>"><?php _e( 'View Full Site', 'jetpack' ); ?></a>
<br />

<?php
/**
Expand Down