This page short URL: x4

weeblrAMP exposes a few methods so that other extensions can possibly alter the way they render their content when on an AMP page. Those methods can be used through an autoloaded static proxy class Weeblramp_Api.


1.bool isAMPRequest()

Returns true if the current request is an AMP request.

echo 'AMP request: ' . (Weeblramp_Api::isAMPRequest() ? 'yes' : 'no');

2.string getCanonicalUrl()

If the current request is an AMP one, returns the fully qualified canonical URL of the corresponding regular HTML page.

echo '<br />Canonical: ' . Weeblramp_Api::getCanonicalUrl();

3.string getAMPUrl($path = '', $full = true)

Gets the URL of the AMP version of a regular HTML page URL.

  • string $path
    if empty, the AMP URL for the current requested page is returned (whether an AMP page or a regular HTML page). Otherwise, the path of the URL you want to query the AMP URL for, ie /path/to/my/regular-html-page (without domain name)

  • bool $full
    if true, a fully qualified URL is returned (ie: for instance), if false an URL relative to the site is returned (ie: /path/to/page.amp.html)
echo '<br />AMP: ' . Weeblramp_Api::getAMPUrl();
  1. string wrapForm($content)

This method will take an arbitrary piece of content including a form element and will wrap it with mark it so that weeblrAMP later knows it must be converted to an AMP form instead of stripping form and input elements as it would normally do.

$content = <<<<<AMP
Your content with form and input fields

$content = WeeblrampFactory::getThe( 'weeblramp.content.protector' )
                                       $content ,
                                           WeeblrampFactory::getA(  // amp converter, with forms
                                                   'amp_config' => WeeblrampFactory::getA( 'weeblramp.config.ampform' )
echo $content;

In addition to this simple API, weeblrAMP has a large numbers of WordPress hooks (actions and filters) to customize its operation, and it gives your the ability to override all of its output through a variety of template overrides.