this is a simple spintax plugin i like how ever its stopping my wordpress shortcodes working when i disable it , it then works can anybody examin my code and help me resolve this problem as i am not sure were the problem is thanks.
spinner.php
<?php
/*
Plugin Name: Spinnner
Plugin URI: http://justtheweb.com/
Version: 1.0
Author: Just the Web & <a href="http://ift.tt/1kMsT1R" target="_blank">RackTheme</a>
Author URI: http://ift.tt/1MZnXwj
Description: Spinner is a SEO plugin for Wordpress that assists authors in “spinning” their content to make it more SEO friendly.
*/
/*
* Defines a security variable to check for in included files.
*/
define('in_jtwSpinner', true);
/*
* Set the plugin folder path
*/
$jtwSpinner_pluginPath = WP_PLUGIN_DIR .'/'. str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
$jtwSpinner_pluginURL = WP_PLUGIN_URL .'/'. str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) .'/';
require( $jtwSpinner_pluginPath . 'jtwCore.php' );
add_filter('the_title','exec_spin_title');
add_filter('the_content','exec_spin');
add_option('jtwspin_dividechar', ",");
add_option('jtwspin_startchar', "[");
add_option('jtwspin_endchar', "]");
add_action( 'widgets_init', 'jtwspinner_load_widgets' );
function exec_spin_title($post_title) {
global $startChar, $endChar, $divideChar;
$startChar = get_option('jtwspin_startchar');
$endChar = get_option('jtwspin_endchar');
$divideChar = get_option('jtwspin_dividechar');
$post_title = str_replace('[wpts_spin]', '', $post_title);
$post_title = str_replace('[/wpts_spin]', '', $post_title);
return spinParse(-1, $post_title);
}
add_filter( "wpseo_title", 'tag2lowercase_title' );
add_filter( "wpseo_metadesc", 'tag2lowercase' );
function tag2lowercase($post_title) {
global $startChar, $endChar, $divideChar;
$startChar = get_option('jtwspin_startchar');
$endChar = get_option('jtwspin_endchar');
$divideChar = get_option('jtwspin_dividechar');
$post_title = str_replace('[wpts_spin]', '', $post_title);
$post_title = str_replace('[/wpts_spin]', '', $post_title);
return spinParse(-1, $post_title);
/*foreach( (array) $c as $k => $v ){
$a[] = strtolower( $v );
}
return $a;*/
}
function tag2lowercase_title($post_title) {
global $startChar, $endChar, $divideChar;
$startChar = get_option('jtwspin_startchar');
$endChar = get_option('jtwspin_endchar');
$divideChar = get_option('jtwspin_dividechar');
$post_title = str_replace('[wpts_spin]', '', $post_title);
$post_title = str_replace('[/wpts_spin]', '', $post_title);
return spinParse(-1, $post_title);
/*foreach( (array) $c as $k => $v ){
$a[] = strtolower( $v );
}
return $a;*/
}
add_filter( 'wp_title', 'filter_function_name', 100);
function filter_function_name($c) {
global $startChar, $endChar, $divideChar;
$startChar = get_option('jtwspin_startchar');
$endChar = get_option('jtwspin_endchar');
$divideChar = get_option('jtwspin_dividechar');
$ddd = spinParse(-1, $c);
return $ddd;
}
/* Register Widget */
function jtwspinner_load_widgets() {
register_widget('WordSpinnerWidget');
}
add_action('admin_menu', 'jtwspin_add_pages');
function jtwspin_add_pages() {
}
function jtwspin_admin() {
$disallowed = array('|','||','+');
// variables for the field and option names
$fieldFirst = 'jtwspin_divide';
$fieldSecond = 'jtwspin_start';
$fieldThird = 'jtwspin_end';
$hidden_field_name = 'jtwspin_hidden';
if( $_POST[ $hidden_field_name ] == 'Y' ) {
if ((in_array($_POST[$fieldFirst],$disallowed)) || (in_array($_POST[$fieldSecond],$disallowed)) || (in_array($_POST[$fieldThird],$disallowed))) {
echo ('<div class="updated"><p><strong>OPTIONS WERE NOT UPDATED!</strong></p>
<p>Part of that combination has been found to produce unexpected results. Please dont use any of the following:<br /><br />');
foreach ($disallowed as $value) {
echo $value." ";
}
echo ('</p></div>');
} else {
update_option( 'jtwspin_dividechar', $_POST[ $fieldFirst ] );
update_option( 'jtwspin_startchar', $_POST[ $fieldSecond ] );
update_option( 'jtwspin_endchar', $_POST[ $fieldThird ] );
echo ('<div class="updated"><p><strong>Options Saved</strong></p></div>');
}
}
echo '<div class="wrap">';
echo "<h2>Spinnner Settings</h2>";
?>
<p>Use these settings to define your start, end and dividing character for spinning text within your content. <br /><em>Example usage</em>: The [quick,brown,dirty,clean] fox [jumped,leaped,ran] across the bridge.</p>
<form name="form1" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
<table class="widefat" cellspacing="0" id="jtw-spinnner">
<thead>
<tr>
<th scope="col" class="manage-column">Split Character</th>
<th scope="col" class="manage-column">Begin Character</th>
<th scope="col" class="manage-column">End Character</th>
</tr>
</thead>
<tr>
<td><input type="text" name="<?php echo $fieldFirst; ?>" value="<?php echo get_option('jtwspin_dividechar'); ?>" size="2" maxlength="1" /></td>
<td><input type="text" name="<?php echo $fieldSecond; ?>" value="<?php echo get_option('jtwspin_startchar'); ?>" size="2" maxlength="2" /></td>
<td><input type="text" name="<?php echo $fieldThird; ?>" value="<?php echo get_option('jtwspin_endchar'); ?>" size="2" maxlength="2" /></td>
</tr>
</table>
<p class="submit"><input type="submit" name="Submit" value="Save" /></p>
</form>
</div>
<?php
}
$startChar = get_option('jtwspin_startchar');
$endChar = get_option('jtwspin_endchar');
$divideChar = get_option('jtwspin_dividechar');
function spinParse($pos, &$data) {
$startPos = $pos;
global $startChar, $endChar, $divideChar;
//print "Start Position: $startPos | Length: ".strlen($data)."<br>";
while ($pos++ < strlen($data)) {
//print "Current Position: $pos | Character: ".substr($data, $pos, 1)."<br>";
if (substr($data, $pos, strlen($startChar)) == $startChar) {
spinParse($pos, $data);
} elseif (substr($data, $pos, strlen($endChar)) == $endChar) {
$entirespinner = substr($data, $startPos+strlen($startChar), ($pos - $startPos)-strlen($endChar));
$data = str_replace($startChar.$entirespinner.$endChar,spinProcess($entirespinner),$data);
$pos = -1;
}
//echo ($data."<br />");
}
return $data;
}
function spinProcess($input) {
global $divideChar;
//echo ("Process Request: '$input'");
$txt = split($divideChar,$input);
$selection = $txt[mt_rand(0,count($txt)-1)];
//echo (" | Result: '$selection'<br />");
return $selection;
}
function exec_spin($text) {
global $startChar, $endChar, $divideChar;
$startChar = get_option('jtwspin_startchar');
$endChar = get_option('jtwspin_endchar');
$divideChar = get_option('jtwspin_dividechar');
return spinParse(-1, $text);
}
class WordSpinnerWidget extends WP_Widget {
function WordSpinnerWidget() {
$widget_ops = array('classname' => 'widget_text_spinner', 'description' => __('Spinnable text(s), with opening and closing chars'));
$control_ops = array('width' => 400, 'height' => 350);
$this->WP_Widget('spinningwords', __('Spin it!'), $widget_ops, $control_ops);
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
$text = apply_filters( 'widget_text', exec_spin($instance['text']) );
echo $before_widget;
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } ?>
<div class="textwidget"><?php echo $instance['filter'] ? wpautop($text) : $text; ?></div>
<?php
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
if ( current_user_can('unfiltered_html') )
$instance['text'] = $new_instance['text'];
else
$instance['text'] = wp_filter_post_kses( $new_instance['text'] );
$instance['filter'] = isset($new_instance['filter']);
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) );
$title = strip_tags($instance['title']);
$text = format_to_edit($instance['text']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id('text'); ?>" name="<?php echo $this->get_field_name('text'); ?>"><?php echo $text; ?></textarea>
<p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox" <?php checked($instance['filter']); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs.'); ?></label></p>
<?php
}
}
?>
jtwCore.php
<?php
/*
* jtwCore.php
* Defines functions which involve shared/re-usable JTW classes and frameworks.
*/
if (!defined('in_jtwSpinner')) die('This file cannot be accessed directly.');
/*
* jtwSpinner_menu()
* Checks if global JTW menu exists, and if not, registers it.
* Adds relevant menu items to JTW menu.
*/
if (!function_exists('jtwSpinner_menu')) {
function jtwSpinner_menu() {
global $jtwSpinner_pluginURL;
if (!defined('jtw_menu_setup')) {
// Create the menu
$icon = $jtwSpinner_pluginURL . 'images/icon.ico';
if (function_exists('add_object_page')) {
add_object_page( 'Just The Web Plugins', 'Just The Web', 'manage_options', 'jtw', 'jtwCore_menu', $icon);
} else {
add_menu_page( 'Just The Web Plugins', 'Just The Web', 'manage_options', 'jtw', 'jtwCore_menu', $icon);
}
define('jtw_menu_setup', true);
}
// Add the subpages we need
add_submenu_page('jtw', 'Spinner - Settings', 'Spinner', 'manage_options', 'jtw-extended-options', 'jtwspin_admin');
}
add_action('admin_menu', 'jtwSpinner_menu');
}
/*
* jtwCore_menu()
* A standard menu to give support and contact information for plugins.
*/
if (!function_exists('jtwCore_menu')) {
function jtwCore_menu() {
?>
<div class="wrap">
<div id="icon-options-general" class="icon32">
<br />
</div>
<h2>Just The Web Plugins</h2>
<p>Here we can publish information about our plugins, etc.</p>
</div>
<?php
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire