Version Description
- Minor bugs fixed
- ?mobile & ?nomobile is now ?amp & ?noamp
Download this release
Release Info
Developer | mohammed_kaludi |
Plugin | AMP for WP – Accelerated Mobile Pages |
Version | 0.2.5 |
Comparing to | |
See all releases |
Code changes from version 0.2 to 0.2.5
- accelerated-moblie-pages.php +2 -2
- admin/ampwp-check.php +4 -4
- admin/ampwp-core.php +30 -17
- readme.txt +14 -5
- themes/default/footer.php +1 -1
- themes/default/functions.php +6 -3
- themes/default/header.php +1 -1
accelerated-moblie-pages.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Accelerated Mobile Pages
|
4 |
Plugin URI: http://theskin.io/amp/
|
5 |
Description: Accelerated Mobile Pages for WordPress
|
6 |
-
Version: 0.2
|
7 |
Author: Mohammed Kaludi, Ahmed Kaludi
|
8 |
Author URI: http://theskin.io/amp/
|
9 |
License: GPL2
|
@@ -36,7 +36,7 @@ if ( class_exists( 'Ampwp_core' ) ) {
|
|
36 |
*/
|
37 |
|
38 |
function add_rel_info() { ?>
|
39 |
-
<link rel="amphtml" href="<?php the_permalink(); ?>/?
|
40 |
<?php }
|
41 |
add_action( 'wp_head', 'add_rel_info' );
|
42 |
?>
|
3 |
Plugin Name: Accelerated Mobile Pages
|
4 |
Plugin URI: http://theskin.io/amp/
|
5 |
Description: Accelerated Mobile Pages for WordPress
|
6 |
+
Version: 0.2.5
|
7 |
Author: Mohammed Kaludi, Ahmed Kaludi
|
8 |
Author URI: http://theskin.io/amp/
|
9 |
License: GPL2
|
36 |
*/
|
37 |
|
38 |
function add_rel_info() { ?>
|
39 |
+
<link rel="amphtml" href="<?php the_permalink(); ?>/?amp" />
|
40 |
<?php }
|
41 |
add_action( 'wp_head', 'add_rel_info' );
|
42 |
?>
|
admin/ampwp-check.php
CHANGED
@@ -22,13 +22,13 @@ if ( ! class_exists( 'AmpWP_check' ) ) {
|
|
22 |
* @since 1.0
|
23 |
*/
|
24 |
public function ampwp_detect_device() {
|
25 |
-
// ?
|
26 |
-
// ?
|
27 |
-
if ( isset( $_GET['
|
28 |
$this->browser = 'mobile';
|
29 |
$this->activated = TRUE;
|
30 |
$this->theme = 'default';
|
31 |
-
} else if ( isset( $_GET['
|
32 |
$this->activated = FALSE;
|
33 |
} else if ( $this->is_mobile( $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_ACCEPT'] ) ) {
|
34 |
if ( $this->is_bot( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
22 |
* @since 1.0
|
23 |
*/
|
24 |
public function ampwp_detect_device() {
|
25 |
+
// ?amp will render the selected non-touch mobile theme
|
26 |
+
// ?noamp renders the standard selected WordPress theme
|
27 |
+
if ( isset( $_GET['amp'] ) ) {
|
28 |
$this->browser = 'mobile';
|
29 |
$this->activated = TRUE;
|
30 |
$this->theme = 'default';
|
31 |
+
} else if ( isset( $_GET['noamp'] ) ) {
|
32 |
$this->activated = FALSE;
|
33 |
} else if ( $this->is_mobile( $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_ACCEPT'] ) ) {
|
34 |
if ( $this->is_bot( $_SERVER['HTTP_USER_AGENT'] ) ) {
|
admin/ampwp-core.php
CHANGED
@@ -28,32 +28,45 @@ if ( ! class_exists( 'Ampwp_core' ) ) {
|
|
28 |
*/
|
29 |
public function ampwp_load_site() {
|
30 |
|
31 |
-
|
|
|
|
|
|
|
32 |
session_unset();
|
33 |
session_destroy();
|
34 |
$_SESSION['AMPWP_MOBILE_ACTIVE'] = '';
|
35 |
$_SESSION['AMPWP_MOBILE_BROWSER'] = '';
|
36 |
$_SESSION['AMPWP_MOBILE_THEME'] = '';
|
37 |
-
}
|
38 |
|
39 |
-
|
40 |
-
// Also, check if ?mobile or ?nomobile is set. If so, establish the session var so that subsequent page calls will render in the desired mode.
|
41 |
-
if ( ( ! isset( $_SESSION['AMPWP_MOBILE_ACTIVE'] ) || ( trim( $_SESSION['AMPWP_MOBILE_ACTIVE'] ) == '') ) || ( isset( $_GET['mobile'] ) ) || ( isset( $_GET['nomobile'] ) ) ) {
|
42 |
-
require_once( dirname( __FILE__ ) . '/ampwp-check.php' );
|
43 |
-
$ampwp_check = new AmpWP_check;
|
44 |
-
$ampwp_check->ampwp_detect_device();
|
45 |
-
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
$_SESSION['
|
|
|
|
|
51 |
}
|
52 |
-
|
53 |
-
require_once( dirname( __FILE__ ) . '/ampwp-render.php' );
|
54 |
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
}
|
59 |
}
|
28 |
*/
|
29 |
public function ampwp_load_site() {
|
30 |
|
31 |
+
// Check whether to show the AMP version or not.
|
32 |
+
// Checks if the user is in the dashboard, then reset the layout to normal view and Deactivates AMP layout.
|
33 |
+
if ( is_admin() ) {
|
34 |
+
|
35 |
session_unset();
|
36 |
session_destroy();
|
37 |
$_SESSION['AMPWP_MOBILE_ACTIVE'] = '';
|
38 |
$_SESSION['AMPWP_MOBILE_BROWSER'] = '';
|
39 |
$_SESSION['AMPWP_MOBILE_THEME'] = '';
|
|
|
40 |
|
41 |
+
} else {
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
+
if ( ( isset( $_GET['killsession'] ) ) ) {
|
44 |
+
session_unset();
|
45 |
+
session_destroy();
|
46 |
+
$_SESSION['AMPWP_MOBILE_ACTIVE'] = '';
|
47 |
+
$_SESSION['AMPWP_MOBILE_BROWSER'] = '';
|
48 |
+
$_SESSION['AMPWP_MOBILE_THEME'] = '';
|
49 |
}
|
|
|
|
|
50 |
|
51 |
+
// Check if mobile sesison var exists
|
52 |
+
// Also, check if ?amp or ?noamp is set. If so, establish the session var so that subsequent page calls will render in the desired mode.
|
53 |
+
if ( ( ! isset( $_SESSION['AMPWP_MOBILE_ACTIVE'] ) || ( trim( $_SESSION['AMPWP_MOBILE_ACTIVE'] ) == '') ) || ( isset( $_GET['amp'] ) ) || ( isset( $_GET['noamp'] ) ) ) {
|
54 |
+
require_once( dirname( __FILE__ ) . '/ampwp-check.php' );
|
55 |
+
$ampwp_check = new AmpWP_check;
|
56 |
+
$ampwp_check->ampwp_detect_device();
|
57 |
+
}
|
58 |
+
|
59 |
+
if ( $_SESSION['AMPWP_MOBILE_ACTIVE'] === TRUE ) {
|
60 |
+
// Double check session var for theme, fall back on default if any problems
|
61 |
+
if ( ! isset( $_SESSION['AMPWP_MOBILE_THEME'] ) || ( trim( $_SESSION['AMPWP_MOBILE_THEME'] ) == '') ) {
|
62 |
+
$_SESSION['AMPWP_MOBILE_THEME'] = 'default';
|
63 |
+
}
|
64 |
+
|
65 |
+
require_once( dirname( __FILE__ ) . '/ampwp-render.php' );
|
66 |
+
|
67 |
+
$ampwp_render = new AmpWP_render();
|
68 |
+
$ampwp_render->ampwp_render_theme();
|
69 |
+
}
|
70 |
}
|
71 |
}
|
72 |
}
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Accelerated Mobile Pages ===
|
2 |
Contributors: mohammed_kaludi, ahmedkaludi
|
3 |
-
Tags: accelerated mobile pages, amp, mobile, amp project, google amp
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.4.2
|
6 |
-
Stable tag:
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -11,20 +11,25 @@ Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on
|
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. This is the first AMP for WP plugin.
|
15 |
|
16 |
== Installation ==
|
17 |
|
18 |
1. Upload the folder to the `/wp-content/plugins/` directory
|
19 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
20 |
-
3. You can access your amp enabled website by adding ?
|
21 |
|
22 |
|
23 |
== Frequently Asked Questions ==
|
24 |
|
25 |
= How do I know that my site is AMP enabled? =
|
26 |
|
27 |
-
Add /?
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
== Changelog ==
|
30 |
|
@@ -34,3 +39,7 @@ Add /?mobile at the end of your website url and you will get amp version of your
|
|
34 |
= 0.2 =
|
35 |
* White Screen of death issue fixed
|
36 |
* Plugin URI updated
|
|
|
|
|
|
|
|
1 |
=== Accelerated Mobile Pages ===
|
2 |
Contributors: mohammed_kaludi, ahmedkaludi
|
3 |
+
Tags: accelerated mobile pages, amp, mobile, amp project, google amp, amp wp
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.4.2
|
6 |
+
Stable tag: 0.2.5
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site. This is the first AMP for WP plugin. AMP WP is a plugin that needs to no configuration, just activate it and you are done.
|
15 |
|
16 |
== Installation ==
|
17 |
|
18 |
1. Upload the folder to the `/wp-content/plugins/` directory
|
19 |
2. Activate the plugin through the 'Plugins' menu in WordPress
|
20 |
+
3. You can access your amp enabled website by adding ?amp at the end of the url.
|
21 |
|
22 |
|
23 |
== Frequently Asked Questions ==
|
24 |
|
25 |
= How do I know that my site is AMP enabled? =
|
26 |
|
27 |
+
Add /?amp at the end of your website url and you will get amp version of your website.
|
28 |
+
|
29 |
+
= I have addded /?amp at the end of the url and still I'm not able to see the AMP version of my site? =
|
30 |
+
|
31 |
+
Please check if you have "Pretty Permalinks" enabled. If not then activate it. For more details about Pretty Permalinks check out this wonderful article https://codex.wordpress.org/Using_Permalinks
|
32 |
+
|
33 |
|
34 |
== Changelog ==
|
35 |
|
39 |
= 0.2 =
|
40 |
* White Screen of death issue fixed
|
41 |
* Plugin URI updated
|
42 |
+
|
43 |
+
= 0.2.5 =
|
44 |
+
* Minor bugs fixed
|
45 |
+
* ?mobile & ?nomobile is now ?amp & ?noamp
|
themes/default/footer.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
<footer class="container">
|
4 |
<div id="footer">
|
5 |
-
<p><a href="#header">Top</a> | <a href="?
|
6 |
<p>Copyright © <?php echo date("Y"); ?> </p>
|
7 |
</div>
|
8 |
</footer>
|
2 |
|
3 |
<footer class="container">
|
4 |
<div id="footer">
|
5 |
+
<p><a href="#header">Top</a> | <a href="?noamp">View Desktop Version</a></p>
|
6 |
<p>Copyright © <?php echo date("Y"); ?> </p>
|
7 |
</div>
|
8 |
</footer>
|
themes/default/functions.php
CHANGED
@@ -135,13 +135,13 @@ function amp_custom_style() { ?>
|
|
135 |
.clearfix{
|
136 |
clear: both
|
137 |
}
|
138 |
-
#pagination{
|
139 |
-
display: inline-block;
|
140 |
width: 100%;
|
141 |
margin-top: 5px;
|
142 |
}
|
143 |
#pagination .next{
|
144 |
-
float: right
|
|
|
145 |
}
|
146 |
#pagination .prev{
|
147 |
float: left
|
@@ -199,6 +199,9 @@ function amp_custom_style() { ?>
|
|
199 |
max-width: 100%;
|
200 |
height: auto;
|
201 |
}
|
|
|
|
|
|
|
202 |
@media screen and (min-width: 700px) {
|
203 |
/*header, footer, main, footer {
|
204 |
margin: 0 10%;
|
135 |
.clearfix{
|
136 |
clear: both
|
137 |
}
|
138 |
+
#pagination{
|
|
|
139 |
width: 100%;
|
140 |
margin-top: 5px;
|
141 |
}
|
142 |
#pagination .next{
|
143 |
+
float: right;
|
144 |
+
margin-bottom: 22px;
|
145 |
}
|
146 |
#pagination .prev{
|
147 |
float: left
|
199 |
max-width: 100%;
|
200 |
height: auto;
|
201 |
}
|
202 |
+
.wp-caption {
|
203 |
+
max-width: 100% !important;
|
204 |
+
}
|
205 |
@media screen and (min-width: 700px) {
|
206 |
/*header, footer, main, footer {
|
207 |
margin: 0 10%;
|
themes/default/header.php
CHANGED
@@ -32,7 +32,7 @@
|
|
32 |
?>
|
33 |
</title>
|
34 |
|
35 |
-
<link rel="canonical" href="<?php the_permalink(); ?>?
|
36 |
<meta charset="utf-8">
|
37 |
<meta name="viewport" content="width=device-width,minimum-scale=1">
|
38 |
|
32 |
?>
|
33 |
</title>
|
34 |
|
35 |
+
<link rel="canonical" href="<?php the_permalink(); ?>?noamp">
|
36 |
<meta charset="utf-8">
|
37 |
<meta name="viewport" content="width=device-width,minimum-scale=1">
|
38 |
|