Limit Content on Index page…

I am trying to make the "Limit Posts" Plugin WordPress MU Friendly. The original plugin makes you add a template tag to your code that limits posts on your index page to "X" ammount of characters, with a link to the full post.

To add the tag you replace "the_conten"t with "the_content_limit(1000, "more":wink:"

Anyways, What I am trying to do is add a admin page for this plugin that the users can enter a custom # and then that number is placed into the template tag.

Would this be easy to do? I have little experience coding. I can cut and paste code and switch things out fairly well. But I am not sure how to code this. Can anyone help?

The source code for the work i’ve done already can be found here

I would really appreciate any help on this. Or if there is a plugin that does this already please let me know.

Plugin Code :

Plugin URI: http://labitacora.net/comunBlog/limit-post.phps

Description: Limits the displayed text length on the index page entries and generates a link to a page to read the full content if its bigger than the selected maximum length.

Usage: the_content_limit($max_charaters, $more_link)

Version: 1.1

Author: Alfonso Sánchez-Paus Díaz y Julián Simón de Castro

Author URI: http://labitacora.net/

License: GPL

Download URL: http://labitacora.net/comunBlog/limit-post.phps

Make:

In file index.php

replace the_content()

with the_content_limit(1000, "more":wink:

*/

$sumcon_options = get_option(‘sumcon’:wink:;

add_action(‘admin_head’, ‘sumcon_admin_head’:wink:;

function sumcon_admin_head()

{

add_options_page(‘Limit Posts’, ‘Limit Posts Options’, ‘manage_options’, ‘limit-posts/options.php’:wink:;

}

function the_content_limit($max_char, $more_link_text = ‘(Continue Reading…:wink:’, $stripteaser = 0, $more_file = ”:wink: {

$content = get_the_content($more_link_text, $stripteaser, $more_file);

$content = apply_filters(‘the_content’, $content);

$content = str_replace(‘]]>’, ‘]]>’, $content);

$content = strip_tags($content);

$max_char = $sumcon ;

if (strlen($_GET) > 0) {

echo "<p>";

echo $content;

echo " <a href=’";

the_permalink();

echo "’>"."Continue Reading →";

echo "</p>";

}

else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {

$content = substr($content, 0, $espacio);

$content = $content;

echo "<p>";

echo $content;

echo "…";

echo " <a href=’";

the_permalink();

echo "’>".$more_link_text."";

echo "</p>";

}

else {

echo "<p>";

echo $content;

echo " <a href=’";

the_permalink();

echo "’>"."Continue Reading →";

echo "</p>";

}

}

?>

Admin Page:

<?php

if (function_exists(‘load_plugin_textdomain’:wink:) {

load_plugin_textdomain(‘header-footer’, ‘wp-content/plugins/limit-posts’:wink:;

}

function sumcon_request($name, $default=null)

{

if (!isset($_REQUEST[$name])) return $default;

if (get_magic_quotes_gpc()) return sumcon_stripslashes($_REQUEST[$name]);

else return $_REQUEST[$name];

}

function sumcon_stripslashes($value)

{

$value = is_array($value) ? array_map(‘sumcon_stripslashes’, $value) : stripslashes($value);

return $value;

}

function sumcon_field_checkbox($name, $label=”, $tips=”, $attrs=”:wink:

{

global $options;

echo ‘<th scope="row">’;

echo ‘<label for="options">’ . $label . ‘</label></th>’;

echo ‘<td><input type="checkbox" ‘ . $attrs . ‘ name="options" value="1" ‘ .

($options[$name]!= null?’checked’:”:wink: . ‘/>’;

echo ‘ ‘ . $tips;

echo ‘</td>’;

}

function sumcon_field_textarea($name, $label=”, $tips=”, $attrs=”:wink:

{

global $options;

if (strpos($attrs, ‘cols’:wink: === false) $attrs .= ‘cols="3"’;

if (strpos($attrs, ‘rows’:wink: === false) $attrs .= ‘rows="1"’;

echo ‘<th scope="row">’;

echo ‘<label for="options">’ . $label . ‘</label></th>’;

echo ‘<td><textarea wrap="off" ‘ . $attrs . ‘ name="options">’ .

htmlspecialchars($options[$name]) . ‘</textarea>’;

echo ‘ ‘ . $tips;

echo ‘</td>’;

}

if (isset($_POST))

{

$options = sumcon_request(‘options’:wink:;

update_option(‘sumcon’, $options);

}

else

{

$options = get_option(‘sumcon’:wink:;

}

?>

<div class="wrap">

<form method="post">

<h2> Enter Content Limit</h2>

Please enter a number between 0 and 1000.

<p<example: 150 (Entering 150 means that posts on your index page will be cut to 150 characters.)</p>

<input name="" type="text" maxlength="1000" />

<p class="submit"><input type="submit" name="save" value="<?php _e(‘save’, ‘header-footer’:wink:; ?>"></p>

</form>

</div>