/*
Plugin Name: Text Spinner
Plugin URI: http://wpgurus.net/
Description: Allows you to use spintax in your posts, pages and theme files.
Version: 0.1
Author: Hassan Akhtar
Author URI: http://wpgurus.net/
License: GPL2
*/
/**********************************************
*
* Spintax functions
*
***********************************************/
function wpts_spin($text)
{
return preg_replace_callback(
'/\{(((?>[^\{\}]+)|(?R))*)\}/x',
'wpts_replace',
$text
);
}
function wpts_replace($text)
{
$text = wpts_spin($text[1]);
$parts = explode('|', $text);
return $parts[array_rand($parts)];
}
/**********************************************
*
* Shorcode setup
*
***********************************************/
function wpts_render_shortcode( $atts, $content = null ) {
return wpts_spin($content);
}
add_shortcode( 'wpts_spin', 'wpts_render_shortcode' );
readme dosyasında da sunlar yazıyor
=== Text Spinner ===
Contributors: khaxan
Tags: text spinner, spinner, seo, wordpress seo, spintax, unique content, php spintax, shortcode
Donate link: http://wpgurus.net/
Requires at least: 2.5
Tested up to: 3.8
Stable tag: 0.1
License: License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Allows you to use spintax in your posts, pages and theme files
== Description ==
This tiny plugin allows you to use spintax like `{phrase 1|phrase 2|phrase 3}` in your posts, pages and theme files. Just enclose the content that you want to be processed in the shortcode [wpts_spin][/wpts_spin] and a unique copy will be generated on each page load. Alternatively, you can pass the spintax string to the function `wpts_spin()` and echo the returned value.
The plugin can help you avoid duplicate content penalties. For instance if you have a sizable block of text that needs to appear throughout the website then you can write spintax for it and use the above-mentioned shortcode or template tag to generate unique copies.
Nested spintax like `{phrase 1|phrase 2|{sub-phrase 1|sub-phrase 2|sub-phrase 3}}` is also supported by the plugin.
== Installation ==
1. Use WordPress' plugin installer to install the plugin.
2. Use the shortcode [wpts_spin] in posts or pages.
== Frequently Asked Questions ==
= How deep can the nesting be? =
It can be as deep as you like. However a nested string might take more time to be processed.
= The same content is appearing on every page load. What could be the problem? =
The plugin works only when the page is rendered dynamically. If the post or page is being loaded from a cache then the same content might keep appearing on every page load.
== Changelog ==
== Changelog ==
= 0.1 =
* Initial release