diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..108329d --- /dev/null +++ b/readme.txt @@ -0,0 +1,46 @@ +=== Rel Publisher === +Contributors: chrisguitarguy, agencypmg +Donate link: http://www.pwsausa.org/give.htm +Tags: google+, google plus, social, rel publisher +Requires at least: 3.4 +Tested up to: 3.4.1 +Stable tag: 1.0 +License: GPLv2 +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Rel Publisher is a simple plugin that lets you easily add <link rel="publisher" /> to your site. + +== Description == + +Google+ pages can verify their URLs by adding `` to the `` section of a website. + +This plugin lets you do that. + +[More information](http://support.google.com/plus/bin/answer.py?hl=en&answer=1713826) on the Google+ help pages. + +== Installation == + +Use the built in installer or + +1. Click the big button to download the latest version +2. Unzip the file and place the `rel-publisher` folder in your plugin directory +3. Login and activate the plugin + +== Frequently Asked Questions == + += Where is the options page? = + +There isn't one. Just a single field and section on the general options page. + +== Screenshots == + +1. The field on the admin page. + +== Changelog == + += 1.0 = +* First version. + +== Upgrade Notice == + +n/a diff --git a/rel-publisher.php b/rel-publisher.php new file mode 100644 index 0000000..23c6186 --- /dev/null +++ b/rel-publisher.php @@ -0,0 +1,165 @@ + to your section -- userful for Google+ +Version: 1.0 +Text Domain: rel-publisher +Domain Path: /lang +Author: Christopher Davis +Author URI: http://pmg.co/people/chris +License: GPL2 + + Copyright 2012 Performance Media Group + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, as + published by the Free Software Foundation. + + 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. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +PMG_Rel_Publisher::init(); + +class PMG_Rel_Publisher +{ + /** + * Our option name + * + * @since 1.0 + */ + const OPTION = 'pmg_rel_publisher'; + + /** + * Page on which this option will reside. + * + * @since 1.0 + */ + const PAGE = 'general'; + + /** + * Secton for this option. + * + * @since 1.0 + */ + const SECT = 'rel_publisher'; + + /** + * Adds actions and such. + * + * @since 1.0 + * @access public + * @uses add_action + * @return null + */ + public static function init() + { + add_action( + 'admin_init', + array(__CLASS__, 'settings') + ); + + add_action( + 'wp_head', + array(__CLASS__, 'head'), + 3 + ); + } + + /** + * Hooked into `admin_init`. Registers the settings and adds settings + * fields and sections. + * + * @since 1.0 + * @access public + * @uses register_setting + * @uses add_settings_section + * @uses add_settings_field + * @return null + */ + public static function settings() + { + register_setting( + self::PAGE, + self::OPTION, + array(__CLASS__, 'validate') + ); + + add_settings_section( + self::SECT, + __('Rel Publisher', 'rel-publisher'), + '__return_false', + self::PAGE + ); + + add_settings_field( + 'rel-publisher-gplus', + __('Google+ URL', 'rel-publisher'), + array(__CLASS__, 'field'), + self::PAGE, + self::SECT, + array('label_for' => self::OPTION) + ); + } + + /** + * Callback function for the settings field. + * + * @since 1.0 + * @access public + * @uses get_option + * @uses esc_attr + * @return null + */ + public static function field() + { + printf( + '', + esc_attr(self::OPTION), + esc_attr(get_option(self::OPTION, '')) + ); + } + + /** + * Settings validation callback. Escapes the URL if it happens to be there. + * + * @since 1.0 + * @access public + * @uses esc_url_raw + * @return string Empty or the escaped URL. + */ + public static function validate($dirty) + { + $clean = ''; + if($dirty) + $clean = esc_url_raw($dirty); + + return $clean; + } + + /** + * Hooked into `wp_head`. Spits out the rel="publish" link if we have a + * google+ url. + * + * @since 1.0 + * @access public + * @uses get_option + * @return null + */ + public static function head() + { + $gplus = get_option(self::OPTION); + + if(!$gplus) + return; + + printf("\n", esc_url($gplus)); + } +} // end class diff --git a/screenshot-1.png b/screenshot-1.png new file mode 100644 index 0000000..86dc402 Binary files /dev/null and b/screenshot-1.png differ