Giter VIP home page Giter VIP logo

open-graph-control's Introduction

open-graph-control

This is a simple singleton class that allows you to set custom fields on posts that fill in utm, open graph, and twitter parameters that can be wired into custom tweet buttons. This plugin differs from others in that it leaves actual implementation of the tweet button: styling, graphics, etc. to the theme.

Installation:

Like any WordPress plugin: download, upload to your server, activate.

Requirements:

Tested on WordPress version 3.8.3. No guarantees on versions earlier or newer, though unless WordPress core removes the_title_attribute, or the plugins_loaded and wp_enqueue_scripts action hooks, it should continue working.

This plugin uses PHP namespaces and will only work on systems with PHP 5.3 and later. Sorry, 5.2.x users, but you should really just upgrade already.

Facebook

The facebook implementation is relatively straightforward. You have the option of wiring up two custom fields: og_title and og_image that, if set, are inserted into a <meta> tag. To make this more convenient, you may decide to add a custom meta box for this. That is not included here, for now.

UTM Data

If you specify some utm-related custom fields these will be appended to any urls generated for the share buttons. Possible fields are:

  • utm_campaign
  • utm_term
  • utm_content

The UTM variables 'utm_medium' and 'utm_source' are set dynamically. The former is set by the facebook and twitter methods respecitvely. The latter is set to either the UTM_SOURCE constant defined by you or to bloginfo('url').

Twitter

The tweet button is a bit lighter weight in that it doesn't reach back to the page for any data, it's just all in the URL parameters. Thus, the twitter url can be used by invoking the tweet_url method out of this class which will echo the full url for a tweet button. To set the 'via' URL parameter, define a constant called TWITTER_USER somewhere in your install (like wp-config.php with all the other constants). It also uses the following custom fields:

  • twtr_txt for the text parameter, falls back on the_title_attribute by default.
  • twtr_rel for the related parameter, falls back to the defined user if empty
  • twtr_hash for the hashtags parameter, does not set if empty
  • twtr_lang if you want to set a different language from english

See Twitter's documentation for the tweet button for more information on what these parameters are and how to use them.

open-graph-control's People

Contributors

gboone avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.