Skip to content

Commit

Permalink
1.3.1:
Browse files Browse the repository at this point in the history
Added: option to add <link> in <real>

git-svn-id: http://plugins.svn.wordpress.org/yourls-wordpress-to-twitter/trunk@157228 b8457f37-d9ea-0310-8a92-e5e31aec5664
  • Loading branch information
ozh committed Sep 23, 2009
1 parent 7870977 commit 33fd9bd
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
18 changes: 12 additions & 6 deletions inc/core.php
@@ -1,5 +1,16 @@
<?php

// Add <link> in <head> if applicable
function wp_ozh_yourls_add_head_link() {
global $wp_ozh_yourls;
if(
( is_single() && $wp_ozh_yourls['link_on_post'] ) ||
( is_page() && $wp_ozh_yourls['link_on_page'] )
) {
wp_ozh_yourls_head_linkrel();
}
}

// Manual tweet from the Edit interface
function wp_ozh_yourls_promote() {
check_ajax_referer( 'yourls' );
Expand Down Expand Up @@ -48,8 +59,6 @@ function wp_ozh_yourls_reset_url() {
// Function called when new post. Expecting post object.
function wp_ozh_yourls_newpost( $post ) {
global $wp_ozh_yourls;
if (!$wp_ozh_yourls)
wp_ozh_yourls_admin_init();

$post_id = $post->ID;
$url = get_permalink( $post_id );
Expand Down Expand Up @@ -87,10 +96,7 @@ function wp_ozh_yourls_send_tweet( $tweet ) {

// The WP <-> YOURLS bridge function: get short URL of a WP post. Returns string(url)
function wp_ozh_yourls_get_new_short_url( $url, $post_id = 0 ) {
// Init plugin (redundant when in admin, needed when plugin called from public part, for instance triggered by a template tag)
global $wp_ozh_yourls;
if (!$wp_ozh_yourls)
wp_ozh_yourls_admin_init();

// Check plugin is configured
$service = wp_ozh_yourls_service();
Expand Down Expand Up @@ -233,7 +239,7 @@ function wp_ozh_yourls_maketweet( $url, $title ) {
}

// Init plugin options
function wp_ozh_yourls_admin_init(){
function wp_ozh_yourls_init(){
global $wp_ozh_yourls;
if (function_exists('register_setting')) // testing for the function existence in case we're initting out of of the admin scope
register_setting( 'wp_ozh_yourls_options', 'ozh_yourls', 'wp_ozh_yourls_sanitize' );
Expand Down
23 changes: 23 additions & 0 deletions inc/options.php
Expand Up @@ -223,6 +223,29 @@ function wp_ozh_yourls_do_page() {
</tr>

</table>

<h3>Short URL auto-discovery</h3>

<p>Add a <code>&lt;link></code> in the <code>&lt;head></code> (more info: <a href="http://microformats.org/wiki/rel-shortlink">microformats.org</a>, <a href="http://wiki.snaplog.com/short_url">short url discovery</a>)</p>

<table class="form-table">

<tr valign="top">
<th scope="row">On individual posts</th>
<td>
<input id="link_on_post" name="ozh_yourls[link_on_post]" type="checkbox" value="1" <?php checked( '1', $ozh_yourls['link_on_post'] ); ?> /><label for="link_on_post"> </label><br/>
</td>
</tr>

<tr valign="top">
<th scope="row">On individual pages</th>
<td>
<input id="link_on_page" name="ozh_yourls[link_on_page]" type="checkbox" value="1" <?php checked( '1', $ozh_yourls['link_on_page'] ); ?> /><label for="link_on_page"> </label><br/>
</td>
</tr>

</table>



<p class="submit">
Expand Down
11 changes: 9 additions & 2 deletions plugin.php
Expand Up @@ -5,7 +5,7 @@
Description: Create short URLs for posts with <a href="http://yourls.org/" title="Your Own URL Shortener">YOURLS</a> (or other services such as tr.im) and tweet them.
Author: Ozh
Author URI: http://planetozh.com/
Version: 1.3
Version: 1.3.1
*/

/* Release History :
Expand All @@ -21,6 +21,7 @@
* 1.2.1: Fixed: oops, forgot to remove a test hook
* 1.3: Fixed: Don't generate short URLs on preview pages
Fixed: Tweet when posting scheduled post or using the XMLRPC API
* 1.3.1: Added: option to add <link> in <real>
*/


Expand Down Expand Up @@ -73,14 +74,20 @@ function wp_ozh_yourls_geturl( $id ) {
require_once(dirname(__FILE__).'/inc/options.php');
// Add menu page, init options, add box on the Post/Edit interface
add_action('admin_menu', 'wp_ozh_yourls_add_page');
add_action('admin_init', 'wp_ozh_yourls_admin_init', 1 );
add_action('admin_init', 'wp_ozh_yourls_addbox', 10);
// Handle AJAX requests
add_action('wp_ajax_yourls-promote', 'wp_ozh_yourls_promote' );
add_action('wp_ajax_yourls-reset', 'wp_ozh_yourls_reset_url' );
// Custom icon & plugin action link
add_filter( 'plugin_action_links_'.plugin_basename(__FILE__), 'wp_ozh_yourls_plugin_actions', -10);
add_filter( 'ozh_adminmenu_icon_ozh_yourls', 'wp_ozh_yourls_customicon' );
// Init plugin
add_action('admin_init', 'wp_ozh_yourls_init', 1 );
} else {
// Add <link> in <head> if applicable
add_action('wp_head', 'wp_ozh_yourls_add_head_link');
// Init plugin
add_action('init', 'wp_ozh_yourls_init', 1 );
}

// Handle new stuff published
Expand Down

0 comments on commit 33fd9bd

Please sign in to comment.