Human Injection Laboratories

Textpattern Twitter Cards Plugin

Description

This is a plugin for Textpattern 4.6. This plugin implements the Twitter Cards format. Twitter Cards is a meta data format to improve the user experience sharing websites on Twitter.

The only tag defined in this plugin is <txp:shs_twittercards>. It works only inside a single article scope. In article lists you need to implement Twitter Cards manually.

Download

Manual

Basic Usage

The basic usage of <txp:shs_twittercards /> creates some basic Meta-Elements filled width coressponding Textpattern fields:

<meta name="twitter:card" content="summary">
<meta name="twitter:url" content="{Permalink of the article}">
<meta name="twitter:title" content="{Title of the article}">
<meta name="twitter:description" content="{excerpt of the article (HTML element are striped out)}">
<meta name="twitter:image" content="{Article image (if exists)}">

Attributes

Each Property in Twitter Cards corresponds with an Attribute for <txp:shs_twittercards>:

Property Attribute Values Defaults
twitter:card cardtype summary, summary_large_image, photo, app or player summary
twitter:site site a twitter Name empty
twitter:site:id siteid a twitter user ID empty
twitter:creator creator a twitter Name empty
twitter:creator:id creatorid a twitter user ID empty
twitter:title title a raw text article title
twitter:description description a text description or excerpt of the article ( HTML element are striped out)
twitter:image image a picture url article picture if exitst
twitter:image:width imagewidth a integer empty
twitter:image:height imageheight a integer emtpy
twitter:app:id:iphone appidiphone App Store ID empty
twitter:app:name:iphone appnameiphone a string empty
twitter:app:url:iphone appurliphone u url empty
twitter:app:id:ipad appidipad App Store ID empty
twitter:app:name:ipad appnameipad a string empty
twitter:app:url:ipad appurlipad a url empty
twitter:app:id:googleplay appidgoogleplay Google Play ID empty
twitter:app:name:googleplay appnamegoogleplay a string empty
twitter:app:url:googleplay appurlgoogleplay a url empty
twitter:player player a url empty
twitter:player:width playerwidth a integer empty
twitter:player:height playerheight a integer emtpy
twitter:player:stream playerstream a video url emtpy
twitter:player:stream:content_type playerstreamcontenttype a MIME type emtpy

Special Attributes

Attribute Values Defaults Description
onlytwitteragent 0 or 1 1 if set to 1 renders meta elements only for HTTP user agent “Twitterbot”
imagedefault a picture url empty if ther is no article image the given url is used for twitter:image

License

Own Source Code

This software (without included parts, see below) is licensed under the following GPL license:

 * Copyright 2012, 2014, 2016 Sebastian Spautz
 *
 * Textpattern Twitter Cards Plugin is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * see http://www.gnu.org/licenses/.

Inserted Source Codes

This software includes the PHP library UrlToAbsolute.
The library is licensed under the following BSD license:

 * Copyright (c) 2008, David R. Nadeau, NadeauSoftware.com.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *	* Redistributions of source code must retain the above copyright
 *	  notice, this list of conditions and the following disclaimer.
 *
 *	* Redistributions in binary form must reproduce the above
 *	  copyright notice, this list of conditions and the following
 *	  disclaimer in the documentation and/or other materials provided
 *	  with the distribution.
 *
 *	* Neither the names of David R. Nadeau or NadeauSoftware.com, nor
 *	  the names of its contributors may be used to endorse or promote
 *	  products derived from this software without specific prior
 *	  written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 *
 * This is a BSD License approved by the Open Source Initiative (OSI).
 * See:  http://www.opensource.org/licenses/bsd-license.php

ChangeLog