Version Description
Download this release
Release Info
Developer | mohammed_kaludi |
Plugin | AMP for WP – Accelerated Mobile Pages |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- accelerated-moblie-pages.php +42 -0
- admin/ampwp-check.php +128 -0
- admin/ampwp-core.php +60 -0
- admin/ampwp-render.php +57 -0
- readme.txt +32 -0
- themes/default/footer.php +11 -0
- themes/default/functions.php +273 -0
- themes/default/header.php +68 -0
- themes/default/index.php +45 -0
- themes/default/page.php +26 -0
- themes/default/single.php +34 -0
accelerated-moblie-pages.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Accelerated Mobile Pages
|
4 |
+
Plugin URI: www.theskin.io
|
5 |
+
Description: Accelerated Mobile Pages for WordPress
|
6 |
+
Version: 0.1
|
7 |
+
Author: Mohammed Kaludi, Ahmed Kaludi
|
8 |
+
Author URI: http://theskin.io/amp/
|
9 |
+
License: GPL2
|
10 |
+
*/
|
11 |
+
|
12 |
+
// Exit if accessed directly.
|
13 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
14 |
+
|
15 |
+
// Load the core class
|
16 |
+
require_once( dirname( __FILE__ ) . '/admin/ampwp-core.php' );
|
17 |
+
|
18 |
+
|
19 |
+
if ( class_exists( 'Ampwp_core' ) ) {
|
20 |
+
// New AmpWP object
|
21 |
+
$ampwp_core = new Ampwp_core;
|
22 |
+
|
23 |
+
// Shut down the plugin on deactivation for old versions of WordPress
|
24 |
+
register_deactivation_hook( __FILE__, array( &$ampwp_core, 'ampwp_load_deactivation' ) );
|
25 |
+
|
26 |
+
// Start a session if not started already
|
27 |
+
if ( ! session_id() ) {
|
28 |
+
@session_start();
|
29 |
+
}
|
30 |
+
// Initialize the AmpWP check logic and rendering
|
31 |
+
$ampwp_core->ampwp_load_site();
|
32 |
+
|
33 |
+
}
|
34 |
+
/*
|
35 |
+
* Add "amphtml" in the main theme to target it to the AMP page
|
36 |
+
*/
|
37 |
+
|
38 |
+
function add_rel_info() { ?>
|
39 |
+
<link rel="amphtml" href="<?php the_permalink(); ?>/?mobile" />
|
40 |
+
<?php }
|
41 |
+
add_action( 'wp_head', 'add_rel_info' );
|
42 |
+
?>
|
admin/ampwp-check.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly.
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
if ( ! class_exists( 'AmpWP_check' ) ) {
|
6 |
+
/**
|
7 |
+
* Class that does all the checks to determine if we are dealing with a Mobile browser
|
8 |
+
*
|
9 |
+
* @package AmpWP
|
10 |
+
* @since 1.0
|
11 |
+
*/
|
12 |
+
class AmpWP_check {
|
13 |
+
|
14 |
+
private $browser = '';
|
15 |
+
private $activated = FALSE;
|
16 |
+
private $theme = '';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Initialize the checking for a mobile browser
|
20 |
+
*
|
21 |
+
* @package AmpWP
|
22 |
+
* @since 1.0
|
23 |
+
*/
|
24 |
+
public function ampwp_detect_device() {
|
25 |
+
// ?mobile will render the selected non-touch mobile theme
|
26 |
+
// ?nomobile renders the standard selected WordPress theme
|
27 |
+
if ( isset( $_GET['mobile'] ) ) {
|
28 |
+
$this->browser = 'mobile';
|
29 |
+
$this->activated = TRUE;
|
30 |
+
$this->theme = 'default';
|
31 |
+
} else if ( isset( $_GET['nomobile'] ) ) {
|
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'] ) ) {
|
35 |
+
$this->browser = 'mobile';
|
36 |
+
$this->activated = TRUE;
|
37 |
+
$this->theme = 'default';
|
38 |
+
} else {
|
39 |
+
$this->browser = 'mobile';
|
40 |
+
$this->activated = TRUE;
|
41 |
+
$this->theme = 'default';
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
if ( $_SESSION['AMPWP_MOBILE_BROWSER'] != $this->browser && isset( $_SESSION['AMPWP_MOBILE_BROWSER'] ) ) {
|
46 |
+
session_unset();
|
47 |
+
session_destroy();
|
48 |
+
}
|
49 |
+
|
50 |
+
$_SESSION['AMPWP_MOBILE_BROWSER'] = $this->browser;
|
51 |
+
$_SESSION['AMPWP_MOBILE_ACTIVE'] = $this->activated;
|
52 |
+
$_SESSION['AMPWP_MOBILE_THEME'] = $this->theme;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Checks if the browser / device is a search engine spider
|
57 |
+
*
|
58 |
+
* @package AmpWP
|
59 |
+
* @since 1.0
|
60 |
+
*/
|
61 |
+
private function is_bot( $user_agent ) {
|
62 |
+
if ( preg_match( '/(askjeeves|baiduspider|baiduspider-mobile|baiduspider-mobile-gate|fastcrawler|fastmobilecrawl|gigabot|googlebot|googlebot-mobile|ia_archiver|infoseek|larbin|lmspider|lycos|lycos_spider|mediapartners-google|msnbot|msnbot-mobile|muscatferret|naverbot|nutch|omniexplorer_bot|pompos|roboobot|scooter|slurp|teoma|turnitinbot|yahoo|yahooseeker|youdaobot|yodaoBot-mobile|zyborg)/i', $user_agent ) ) {
|
63 |
+
return TRUE;
|
64 |
+
}
|
65 |
+
|
66 |
+
return FALSE;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Checks if the browser / device is a mobile device
|
71 |
+
*
|
72 |
+
* @package AmpWP
|
73 |
+
* @since 1.0
|
74 |
+
*/
|
75 |
+
private function is_mobile( $user_agent, $http_accept = NULL, $http_profile = NULL, $wap_profile = NULL ) {
|
76 |
+
if ( preg_match( '/(alcatel|android|avantgo|bada|benq|blackberry|configuration\/cldc|docomo|ericsson|hp |hp-|hpwos|htc |htc_|htc-|iemobile|iphone|ipod|kddi|kindle|maemo|meego|midp|mmp|motorola|mobi|mobile|netfront|nokia|opera mini|opera mobi|openweb|palm|palmos|pocket|portalmmm|ppc;|sagem|sharp|series60|series70|series80|series90|smartphone|sonyericsson|spv|symbian|teleca q|telus|treo|up.browser|up.link|vodafone|webos|windows ce|windows phone os 7|xda|zte)/i', $user_agent ) ) {
|
77 |
+
return TRUE;
|
78 |
+
} else if ( in_array( strtolower( substr( $user_agent, 0, 3 ) ), array( 'lg ' => 'lg ', 'lg-' => 'lg-', 'lg_' => 'lg_', 'lge' => 'lge' ) ) ) {
|
79 |
+
return TRUE;
|
80 |
+
} else if ( in_array( strtolower( substr( $user_agent , 0, 4 ) ), array( 'acs-' => 'acs-', 'amoi' => 'amoi', 'doco' => 'doco', 'eric' => 'eric', 'huaw' => 'huaw', 'lct_' => 'lct_', 'leno' => 'leno', 'mobi' => 'mobi', 'mot-' => 'mot-', 'moto' => 'moto', 'nec-' => 'nec-', 'phil' => 'phil', 'sams' => 'sams', 'sch-' => 'sch-', 'shar' => 'shar', 'sie-' => 'sie-', 'wap_' => 'wap_', 'zte-' => 'zte-' ) ) ) {
|
81 |
+
return TRUE;
|
82 |
+
} else if ( ( ( stripos( strtolower( $http_accept ), 'text/vnd.wap.wml' ) > 0 ) || ( stripos( strtolower( $http_accept ), 'application/vnd.wap.xhtml+xml' ) > 0 ) ) || ( ( isset( $wap_profile ) || isset( $http_profile ) ) ) ) {
|
83 |
+
return TRUE;
|
84 |
+
}
|
85 |
+
|
86 |
+
return FALSE;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Checks if the browser / device is a tablet (constantly being updated)
|
91 |
+
*
|
92 |
+
* @package AmpWP
|
93 |
+
* @since 1.0
|
94 |
+
*/
|
95 |
+
private function is_tablet( $user_agent ) {
|
96 |
+
if ( preg_match( '/(a100|a500|a501|a510|a700|dell streak|et-701|ipad|gt-n7000|gt-p1000|gt-p6200|gt-p6800|gt-p7100|gt-p7310|gt-p7510|lg-v905h|lg-v905r|kindle|rim tablet|sch-i800|silk|sl101|tablet|tf101|tf201|xoom)/i', $user_agent ) ) {
|
97 |
+
return TRUE;
|
98 |
+
}
|
99 |
+
|
100 |
+
return FALSE;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Checks if the browser / device is a touch screen / smart phone (constantly being updated)
|
105 |
+
*
|
106 |
+
* @package AmpWP
|
107 |
+
* @since 1.0
|
108 |
+
*/
|
109 |
+
private function is_touch( $user_agent ) {
|
110 |
+
if ( preg_match( '/(ipod|iphone)/i', $user_agent ) ) {
|
111 |
+
return TRUE;
|
112 |
+
} else if ( preg_match( '/android (\d+\.\d+(\.\d+)*)/i', $user_agent, $version ) ) {
|
113 |
+
if ( $version[1] >= '2.1' ) {
|
114 |
+
return TRUE;
|
115 |
+
}
|
116 |
+
} else if ( preg_match( '/(bada|blackberry9670|blackberry 9670|blackberry9800|blackberry 9800|blackberry9810|blackberry 9810|dolfin|maemo|meego|s8000|windows phone os 7)/i', $user_agent ) ) {
|
117 |
+
return TRUE;
|
118 |
+
} else if ( preg_match( '/webos\/(\d+\.\d+(\.\d+)*)/i', $user_agent, $version ) ) {
|
119 |
+
if ( $version[1] >= '1.4' ) {
|
120 |
+
return TRUE;
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
return FALSE;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
?>
|
admin/ampwp-core.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly.
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
if ( ! class_exists( 'Ampwp_core' ) ) {
|
6 |
+
/**
|
7 |
+
* The core AmpWP class where the magic happens
|
8 |
+
*
|
9 |
+
* @package AmpWP
|
10 |
+
* @since 1.0
|
11 |
+
*/
|
12 |
+
class Ampwp_core {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Deactivates the plugin
|
16 |
+
*
|
17 |
+
* @package AmpWP
|
18 |
+
* @since 1.0
|
19 |
+
*/
|
20 |
+
public function ampwp_load_deactivation() {
|
21 |
+
// Shutdown this plugin (nothing here for now)
|
22 |
+
}
|
23 |
+
/**
|
24 |
+
* Does the checks and decides whether to render a mobile or normal website
|
25 |
+
*
|
26 |
+
* @package AmpWP
|
27 |
+
* @since 1.0
|
28 |
+
*/
|
29 |
+
public function ampwp_load_site() {
|
30 |
+
|
31 |
+
if ( ( isset( $_GET['killsession'] ) ) ) {
|
32 |
+
session_unset();
|
33 |
+
session_destroy();
|
34 |
+
$_SESSION['AMPWP_MOBILE_ACTIVE'] = '';
|
35 |
+
$_SESSION['AMPWP_MOBILE_BROWSER'] = '';
|
36 |
+
$_SESSION['AMPWP_MOBILE_THEME'] = '';
|
37 |
+
}
|
38 |
+
|
39 |
+
// Check if mobile sesison var exists
|
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 |
+
if ( $_SESSION['AMPWP_MOBILE_ACTIVE'] === TRUE ) {
|
48 |
+
// Double check session var for theme, fall back on default if any problems
|
49 |
+
if ( ! isset( $_SESSION['AMPWP_MOBILE_THEME'] ) || ( trim( $_SESSION['AMPWP_MOBILE_THEME'] ) == '') ) {
|
50 |
+
$_SESSION['AMPWP_MOBILE_THEME'] = 'default';
|
51 |
+
}
|
52 |
+
|
53 |
+
require_once( dirname( __FILE__ ) . '/ampwp-render.php' );
|
54 |
+
|
55 |
+
$ampwp_render = new AmpWP_render();
|
56 |
+
$ampwp_render->ampwp_render_theme();
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
}
|
admin/ampwp-render.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly.
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
if ( ! class_exists( 'AmpWP_render' ) ) {
|
6 |
+
/**
|
7 |
+
* Class that deals with all aspects of rendering the mobile website
|
8 |
+
*
|
9 |
+
* @package AmpWP
|
10 |
+
* @since 1.0
|
11 |
+
*/
|
12 |
+
class AmpWP_render {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Initialize the rendering of the mobile website
|
16 |
+
*
|
17 |
+
* @package AmpWP
|
18 |
+
* @since 1.0
|
19 |
+
*/
|
20 |
+
public function ampwp_render_theme() {
|
21 |
+
// Apply theme filters
|
22 |
+
add_filter( 'theme_root', array( &$this, 'ampwp_set_theme_root' ) );
|
23 |
+
add_filter( 'theme_root_uri', array (&$this, 'ampwp_set_theme_uri' ) );
|
24 |
+
add_filter( 'template', array( &$this, 'ampwp_set_template' ) );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Sets the blogs template to the AmpWP template
|
29 |
+
*
|
30 |
+
* @package AmpWP
|
31 |
+
* @since 1.0
|
32 |
+
*/
|
33 |
+
public function ampwp_set_template() {
|
34 |
+
return $_SESSION['AMPWP_MOBILE_THEME'];
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Sets the theme root to the AmpWP theme directory
|
39 |
+
*
|
40 |
+
* @package AmpWP
|
41 |
+
* @since 1.0
|
42 |
+
*/
|
43 |
+
public function ampwp_set_theme_root() {
|
44 |
+
return WP_CONTENT_DIR . '/plugins/accelerated-mobile-page/themes/' ;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Sets the path to the themes directory
|
49 |
+
*
|
50 |
+
* @package AmpWP
|
51 |
+
* @since 1.0
|
52 |
+
*/
|
53 |
+
public function ampwp_set_theme_uri() {
|
54 |
+
return WP_CONTENT_DIR . '/wp-content' . '/plugins/accelerated-mobile-page/themes/';
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
readme.txt
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Accelerated Mobile Pages ===
|
2 |
+
Contributors: mohammed_kaludi, ahmedkaludi
|
3 |
+
Tags: accelerated mobile pages, amp, mobile, amp project, google amp
|
4 |
+
Requires at least: 4.0
|
5 |
+
Tested up to: 4.3
|
6 |
+
Stable tag: 1.0
|
7 |
+
License: GPLv2 or later
|
8 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
+
Automatically add Accelerated Mobile Pages (Google AMP Project) functionality on your WordPress site.
|
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 ?mobile 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 /?mobile at the end of your website url and you will get amp version of your website.
|
28 |
+
|
29 |
+
== Changelog ==
|
30 |
+
|
31 |
+
= 1.0 =
|
32 |
+
* Initial version
|
themes/default/footer.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
</main>
|
2 |
+
|
3 |
+
<footer class="container">
|
4 |
+
<div id="footer">
|
5 |
+
<p><a href="#header">Top</a> | <a href="?nomobile">View Desktop Version</a></p>
|
6 |
+
<p>Copyright © <?php echo date("Y"); ?> </p>
|
7 |
+
</div>
|
8 |
+
</footer>
|
9 |
+
<?php wp_footer(); ?>
|
10 |
+
</body>
|
11 |
+
</html>
|
themes/default/functions.php
ADDED
@@ -0,0 +1,273 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Added the style through the custom Hook called "amp_custom_style" and not used wp_enqueue, because of the strict rules of AMP.
|
4 |
+
*
|
5 |
+
* Check the url for the STRICT Markup required
|
6 |
+
* https://github.com/ampproject/amphtml/blob/master/spec/amp-html-format.md#required-markup
|
7 |
+
*/
|
8 |
+
|
9 |
+
function amp_custom_style() { ?>
|
10 |
+
<style>body {opacity: 0}</style><noscript><style>body {opacity: 1}</style></noscript>
|
11 |
+
<style amp-custom>
|
12 |
+
body{
|
13 |
+
font: 16px/1.4 Sans-serif;
|
14 |
+
}
|
15 |
+
main{
|
16 |
+
padding: 15px
|
17 |
+
}
|
18 |
+
a { color: #312C7E; text-decoration: none}
|
19 |
+
#header{
|
20 |
+
text-align: center;
|
21 |
+
}
|
22 |
+
#header h1{
|
23 |
+
text-align: center;
|
24 |
+
font-size: 20px;
|
25 |
+
font-weight: bold;
|
26 |
+
line-height: 1;
|
27 |
+
margin: 15px;
|
28 |
+
}
|
29 |
+
nav{
|
30 |
+
padding: 15px;
|
31 |
+
background: #312C7E;
|
32 |
+
color: #fff;
|
33 |
+
text-align: center
|
34 |
+
}
|
35 |
+
main{
|
36 |
+
background: #f1f1f1;
|
37 |
+
margin-top: 0;
|
38 |
+
padding: 25px 15% 25px 15%;
|
39 |
+
}
|
40 |
+
.post{
|
41 |
+
margin-bottom: 12px;
|
42 |
+
background: #fefefe;
|
43 |
+
-moz-border-radius: 2px;
|
44 |
+
-webkit-border-radius: 2px;
|
45 |
+
border-radius: 2px;
|
46 |
+
-moz-box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
47 |
+
-webkit-box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
48 |
+
box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
49 |
+
padding: 15px;
|
50 |
+
}
|
51 |
+
#home .post{
|
52 |
+
margin-bottom: 12px;
|
53 |
+
background: #fefefe;
|
54 |
+
-moz-border-radius: 2px;
|
55 |
+
-webkit-border-radius: 2px;
|
56 |
+
border-radius: 2px;
|
57 |
+
-moz-box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
58 |
+
-webkit-box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
59 |
+
box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
60 |
+
padding: 15px;
|
61 |
+
min-height: 75px;
|
62 |
+
}
|
63 |
+
.post_image{
|
64 |
+
float: right;
|
65 |
+
margin-left: 15px;
|
66 |
+
width: 100px;
|
67 |
+
height: 75px;
|
68 |
+
}
|
69 |
+
.post h2{
|
70 |
+
line-height: 30px;
|
71 |
+
}
|
72 |
+
.post h2 a{
|
73 |
+
font-weight: 300;
|
74 |
+
color: #000;
|
75 |
+
font-size: 20px;
|
76 |
+
}
|
77 |
+
.post h2, .post p{
|
78 |
+
margin: 0 0 0 5px;
|
79 |
+
}
|
80 |
+
#home .post p{
|
81 |
+
font-size: 12px;
|
82 |
+
color: #999;
|
83 |
+
line-height: 20px;
|
84 |
+
margin: 3px 0 0 5px;
|
85 |
+
}
|
86 |
+
.post p{
|
87 |
+
margin-top: 5px;
|
88 |
+
color: #333;
|
89 |
+
font-size: 15px;
|
90 |
+
line-height: 26px;
|
91 |
+
margin-bottom: 15px;
|
92 |
+
}
|
93 |
+
.subtitle{
|
94 |
+
font-size: 12px;
|
95 |
+
}
|
96 |
+
nav ul{
|
97 |
+
list-style-type: none;
|
98 |
+
margin: 0;
|
99 |
+
padding: 0;
|
100 |
+
display: inline-block;
|
101 |
+
width: 100%
|
102 |
+
}
|
103 |
+
.menu-all-pages-container:after{
|
104 |
+
content: "";
|
105 |
+
clear: both
|
106 |
+
}
|
107 |
+
nav ul li{
|
108 |
+
font-size: 13px;
|
109 |
+
border-bottom: 1px solid rgba(0, 0, 0, 0.11);
|
110 |
+
padding: 11px 0px;
|
111 |
+
width: 25%;
|
112 |
+
float: left;
|
113 |
+
}
|
114 |
+
nav ul ul{
|
115 |
+
display: none
|
116 |
+
}
|
117 |
+
nav ul li a{
|
118 |
+
color: #eee
|
119 |
+
}
|
120 |
+
.toggle-text{
|
121 |
+
color: #DCDCDC;
|
122 |
+
font-size: 12px;
|
123 |
+
text-transform: uppercase;
|
124 |
+
letter-spacing: 3px;
|
125 |
+
}
|
126 |
+
.toggle-text:before{
|
127 |
+
content: "...";
|
128 |
+
font-size: 32px;
|
129 |
+
position: absolute;
|
130 |
+
font-family: georgia;
|
131 |
+
line-height: 5px;
|
132 |
+
margin-left: -40px;
|
133 |
+
letter-spacing: 1px;
|
134 |
+
}
|
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
|
148 |
+
}
|
149 |
+
#pagination .next a, #pagination .prev a{
|
150 |
+
margin-bottom: 12px;
|
151 |
+
background: #fefefe;
|
152 |
+
-moz-border-radius: 2px;
|
153 |
+
-webkit-border-radius: 2px;
|
154 |
+
border-radius: 2px;
|
155 |
+
-moz-box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
156 |
+
-webkit-box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
157 |
+
box-shadow: 0 2px 3px rgba(0,0,0,.05);
|
158 |
+
padding: 11px 15px;
|
159 |
+
font-size: 12px;
|
160 |
+
text-transform: uppercase;
|
161 |
+
color: #666;
|
162 |
+
}
|
163 |
+
#footer{
|
164 |
+
font-size: 13px;
|
165 |
+
text-align: center;
|
166 |
+
letter-spacing: 0.2px;
|
167 |
+
padding: 20px 0;
|
168 |
+
}
|
169 |
+
#footer p:first-child{
|
170 |
+
margin-bottom: 12px;
|
171 |
+
}
|
172 |
+
#footer p{
|
173 |
+
margin: 0
|
174 |
+
}
|
175 |
+
.single_img img{
|
176 |
+
width: 100%;
|
177 |
+
height: 100%
|
178 |
+
}
|
179 |
+
#title h2{
|
180 |
+
margin: 20px 0px 18px 0px;
|
181 |
+
text-align: center;
|
182 |
+
}
|
183 |
+
.postmeta{
|
184 |
+
font-size: 12px;
|
185 |
+
padding-bottom: 10px;
|
186 |
+
color: #555;
|
187 |
+
border-bottom: 1px solid #DADADA;
|
188 |
+
}
|
189 |
+
.postmeta p{
|
190 |
+
margin: 0
|
191 |
+
}
|
192 |
+
.postmeta span{
|
193 |
+
float: right
|
194 |
+
}
|
195 |
+
.single_img{
|
196 |
+
text-align: center
|
197 |
+
}
|
198 |
+
img, iframe, object, video {
|
199 |
+
max-width: 100%;
|
200 |
+
height: auto;
|
201 |
+
}
|
202 |
+
@media screen and (min-width: 700px) {
|
203 |
+
/*header, footer, main, footer {
|
204 |
+
margin: 0 10%;
|
205 |
+
}*/
|
206 |
+
.container{
|
207 |
+
padding: 0 15%;
|
208 |
+
|
209 |
+
}
|
210 |
+
footer{
|
211 |
+
padding: 0
|
212 |
+
}
|
213 |
+
main{
|
214 |
+
padding: 25px 15% 25px 15%;
|
215 |
+
}
|
216 |
+
nav ul li{
|
217 |
+
width: 20%
|
218 |
+
}
|
219 |
+
|
220 |
+
}
|
221 |
+
@media screen and (max-width: 767px) {
|
222 |
+
.post p{
|
223 |
+
display: block
|
224 |
+
}
|
225 |
+
#home .post p{
|
226 |
+
display: none
|
227 |
+
}
|
228 |
+
|
229 |
+
main{
|
230 |
+
padding: 25px 18px 25px 18px;
|
231 |
+
}
|
232 |
+
nav ul li{
|
233 |
+
width: 50%
|
234 |
+
}
|
235 |
+
}
|
236 |
+
@media screen and (max-width: 495px) {
|
237 |
+
.post h2 a{
|
238 |
+
font-size: 17px;
|
239 |
+
line-height: 26px;
|
240 |
+
}
|
241 |
+
#home .post p{
|
242 |
+
display: none
|
243 |
+
}
|
244 |
+
}
|
245 |
+
@media screen and (min-width: 900px) {
|
246 |
+
/*header, footer, main, footer {
|
247 |
+
margin: 0 18%;
|
248 |
+
}*/
|
249 |
+
.container{
|
250 |
+
padding: 0 15%;
|
251 |
+
}
|
252 |
+
main{
|
253 |
+
padding: 25px 15% 25px 15%;
|
254 |
+
}
|
255 |
+
header, footer{
|
256 |
+
padding: 0
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
#something {
|
261 |
+
display: none;
|
262 |
+
}
|
263 |
+
|
264 |
+
#something:target {
|
265 |
+
display: block;
|
266 |
+
}
|
267 |
+
</style>
|
268 |
+
<script async src="https://cdn.ampproject.org/v0.js"></script>
|
269 |
+
<?php }
|
270 |
+
|
271 |
+
add_action('amp_custom_style','amp_custom_style');
|
272 |
+
|
273 |
+
?>
|
themes/default/header.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!doctype html>
|
2 |
+
<html amp>
|
3 |
+
<head>
|
4 |
+
|
5 |
+
<title>
|
6 |
+
<?php
|
7 |
+
global $query_string;
|
8 |
+
|
9 |
+
if ( is_home() )
|
10 |
+
bloginfo( 'name' );
|
11 |
+
|
12 |
+
if ( get_search_query() )
|
13 |
+
echo 'Results for: "' . get_search_query() .'"';
|
14 |
+
|
15 |
+
if ( is_month() )
|
16 |
+
the_time('F Y');
|
17 |
+
|
18 |
+
if ( is_category() )
|
19 |
+
single_cat_title();
|
20 |
+
|
21 |
+
if ( is_single() )
|
22 |
+
the_title();
|
23 |
+
|
24 |
+
if ( is_page() )
|
25 |
+
the_title();
|
26 |
+
|
27 |
+
if ( is_tag() )
|
28 |
+
single_tag_title();
|
29 |
+
|
30 |
+
if ( is_404() )
|
31 |
+
echo 'Page Not Found!';
|
32 |
+
?>
|
33 |
+
</title>
|
34 |
+
|
35 |
+
<link rel="canonical" href="<?php the_permalink(); ?>?nomobile">
|
36 |
+
<meta charset="utf-8">
|
37 |
+
<meta name="viewport" content="width=device-width,minimum-scale=1">
|
38 |
+
|
39 |
+
<?php
|
40 |
+
/*
|
41 |
+
* Added the custom style through the custom Hook called "amp_custom_style" and not used wp_enqueue, because of the strict rules of AMP.
|
42 |
+
*
|
43 |
+
*/
|
44 |
+
do_action('amp_custom_style'); ?>
|
45 |
+
|
46 |
+
</head>
|
47 |
+
|
48 |
+
<body id="<?php if ( !is_single() && !is_page() ) { ?>home<?php } ?>">
|
49 |
+
|
50 |
+
<header class="container">
|
51 |
+
<div id="headerwrap">
|
52 |
+
<div id="header">
|
53 |
+
<h1><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
|
54 |
+
</div>
|
55 |
+
</div>
|
56 |
+
</header>
|
57 |
+
|
58 |
+
<nav>
|
59 |
+
<a href="#" class="toggle-text">Navigate</a>
|
60 |
+
<div id="toggle-navigation"><?php wp_nav_menu( array( 'theme_location' => 'amp-menu' ) ); ?>
|
61 |
+
</div>
|
62 |
+
</nav>
|
63 |
+
|
64 |
+
<?php if ( is_single() ) {
|
65 |
+
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. ?>
|
66 |
+
<?php }
|
67 |
+
} ?>
|
68 |
+
<main role="main">
|
themes/default/index.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php get_header(); ?>
|
2 |
+
<div id="contentwrap">
|
3 |
+
<div id="title">
|
4 |
+
<h2>
|
5 |
+
<?php if ( is_category() ) : ?>
|
6 |
+
<?php single_cat_title(); ?> Archives
|
7 |
+
<?php elseif ( is_day() ) : ?>
|
8 |
+
Archive for <?php the_time( 'F jS, Y' ); ?>
|
9 |
+
<?php elseif ( is_month() ) : ?>
|
10 |
+
Archive for <?php the_time( 'F, Y' ); ?>
|
11 |
+
<?php elseif ( is_year() ) : ?>
|
12 |
+
Archive for <?php the_time('Y'); ?>
|
13 |
+
<?php endif; ?>
|
14 |
+
</h2>
|
15 |
+
</div>
|
16 |
+
|
17 |
+
<?php $access_key = 1; ?>
|
18 |
+
<?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>
|
19 |
+
|
20 |
+
<div class="post">
|
21 |
+
<?php
|
22 |
+
$thumb_id = get_post_thumbnail_id();
|
23 |
+
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail', true);
|
24 |
+
$thumb_url = $thumb_url_array[0];
|
25 |
+
?>
|
26 |
+
|
27 |
+
<div class="post_image"><a href="<?php the_permalink(); ?>"><amp-img src=<?php echo $thumb_url ?> width=100 height=75></amp-img></a></div>
|
28 |
+
|
29 |
+
|
30 |
+
<h2 class="title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" accesskey="<?php echo $access_key; $access_key++; ?>"><?php the_title(); ?></a></h2>
|
31 |
+
<?php $content = get_the_content();?>
|
32 |
+
<p><?php echo wp_trim_words( $content , '15' ); ?></p>
|
33 |
+
</div>
|
34 |
+
|
35 |
+
<?php endwhile; ?>
|
36 |
+
<?php endif; ?>
|
37 |
+
|
38 |
+
<div id="pagination">
|
39 |
+
<div class="next"><?php next_posts_link( 'Next »', 0 ) ?></div>
|
40 |
+
<div class="prev"><?php previous_posts_link( '« Previous' ); ?></div>
|
41 |
+
<div class="clearfix"></div>
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
|
45 |
+
<?php get_footer(); ?>
|
themes/default/page.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php get_header(); ?>
|
2 |
+
|
3 |
+
<div id="contentwrap">
|
4 |
+
|
5 |
+
|
6 |
+
<?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>
|
7 |
+
|
8 |
+
<div id="title">
|
9 |
+
<h2><?php the_title(); ?></h2>
|
10 |
+
</div>
|
11 |
+
|
12 |
+
<div class="post">
|
13 |
+
<?php if ( has_post_thumbnail() ) : $thumbnail_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); ?>
|
14 |
+
<a href="<?php the_permalink(); ?>" class="thumbnail"> </a>
|
15 |
+
<?php endif; ?>
|
16 |
+
|
17 |
+
<?php the_content(); ?>
|
18 |
+
<?php wp_link_pages( 'before=<p>&after=</p>&next_or_number=number&pagelink=Page %' ); ?>
|
19 |
+
</div>
|
20 |
+
|
21 |
+
<?php endwhile; ?>
|
22 |
+
<?php endif;?>
|
23 |
+
|
24 |
+
</div>
|
25 |
+
|
26 |
+
<?php get_footer(); ?>
|
themes/default/single.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php get_header(); ?>
|
2 |
+
|
3 |
+
<div id="contentwrap">
|
4 |
+
<?php if ( have_posts() ): while ( have_posts() ): the_post(); ?>
|
5 |
+
|
6 |
+
<div class="postmeta">
|
7 |
+
<p>By <a href="#"><?php the_author_meta( 'display_name' ); ?></a> on <?php the_time( get_option( 'date_format' ) ) ?> <span>Posted in <?php the_category( ', ' ) ?></span></p>
|
8 |
+
</div>
|
9 |
+
|
10 |
+
<div id="title">
|
11 |
+
<h2><?php the_title(); ?></h2>
|
12 |
+
</div>
|
13 |
+
|
14 |
+
<div class="post">
|
15 |
+
|
16 |
+
<?php the_content(); ?>
|
17 |
+
<?php wp_link_pages( 'before=<p>&after=</p>&next_or_number=number&pagelink=Page %' ); ?>
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<div id="posttags">
|
21 |
+
<p><?php the_tags( 'Tags: ', ', ' ); ?></p>
|
22 |
+
</div>
|
23 |
+
|
24 |
+
<div id="pagination">
|
25 |
+
<div class="next"><?php next_post_link(); ?></div>
|
26 |
+
<div class="prev"><?php previous_post_link(); ?></div>
|
27 |
+
<div class="clearfix"></div>
|
28 |
+
</div>
|
29 |
+
|
30 |
+
<?php endwhile; ?>
|
31 |
+
<?php endif;?>
|
32 |
+
</div>
|
33 |
+
|
34 |
+
<?php get_footer(); ?>
|