Mark Jaquith
Forum Replies Created
-
Forum: Plugins
In reply to: display only some words from category descriptionYou’d have to run it through a filter. The hook is
category_descriptionExample:
<?php
/*
Plugin Name: 15 Word Category Description
Version: 0.1
Plugin URI: http://txfx.net/code/wordpress/
Description: Limits the category description to 15 words
Author: Mark Jaquith
Author URI: http://txfx.net/
*/function txfx_limit_cat_description($text) {
$excerpt_length = 15; // number of words
$text = strip_tags($text); // otherwise we could cut off in the middle of a tag
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) { // only filter if we need to
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
return $text;
}add_filter('category_description', 'txfx_limit_cat_description');
?>
Forum: Fixing WordPress
In reply to: View Page SQL Queries?Alternative… and safer:
<?php
if ( SAVEQUERIES && current_user_can('manage_options') && $_GET['showqueries'] ) {
echo "<!--n";
print_r($wpdb->queries);
echo "n-->n";
}
?>
Then just access http://example.com/?showqueries=1 while logged in as an Administrator level account.
Forum: Installing WordPress
In reply to: Error establishing a database connectionYou should open a support ticket with your host… tell them you need a MySQL database with user/pass/db/host info.
Forum: Fixing WordPress
In reply to: WP 2.0.4 – running terribly slowly!To anyone experiencing problems: be sure to turn off all your plugins and switch to the default theme, just to be sure it isn’t something there. Beyond that, dumps of your queries and a description of your hosting environment (OS, server, PHP version, mod_php/cgi/fastcgi etc) might help. It’s not a universal problem, so we have to figure out what it is about your specific setup that’s doing it.
Forum: Installing WordPress
In reply to: Updated from 2.02 to 2.03 – now wont let me delete postsTry Owen Winkler’s Role Manager plugin [1] and give your role the missing capabilities.
Forum: Fixing WordPress
In reply to: XML Parsing Error! Why?The plugin doesn’t touch feeds, so it was likely a copy/paste error. Try downloading the plugin instead of copy/pasting the source code.
Forum: Fixing WordPress
In reply to: If In SubcategoryLatest version here:
http://comox.textdrive.com/pipermail/wp-hackers/2006-June/006693.htmlForum: Fixing WordPress
In reply to: Huge WordPress problems, againI’d get a new host. They don’t sound like the most capable folks around.
Personally, I love A Small Orange‘s shared hosting plans. They’ve bent over backwards for me in the past fixing problems that weren’t their fault (i.e. they were my fault). And they know how to compile PHP so it won’t segfault. 🙂
Forum: Fixing WordPress
In reply to: Problem post 2.03 upgradeIf you are getting a message telling you that you don’t have permission to do something, then it’s a permissions issue. WordPress has soles (administrator, editor, author, etc) and those roles have capabilities (
edit_posts,edit_links, etc). If it says you can’t do something than your user must belong to a role that lacks the capability.You can try the Role Manager plugin to add the necessary capabilities to your user… assuming that your user can
edit_usersSome people have found that the force upgrade script I wrote fixes some permissions issues.
Forum: Fixing WordPress
In reply to: foreach() errors on subpages onlyYou’re calling
list_catson a category that has no children.Foreach errors are best fixed by casting to array the supposed array:
foreach ( $foo as $bar ) {Becomes:
foreach ( (array) $foo as $bar ) {Forum: Plugins
In reply to: update_optionsGPC is automatically slashed by WP. Use
stripslashes()before updating the option, becauseupdate_option()will try to add slashes again.Forum: Fixing WordPress
In reply to: Restrict page edit to page authorYes. By default, people with the role of “Author” can only edit their own posts. “Editors” or “Administrators” can edit anyone’s posts.
Check out this handy table:
http://codex.wordpress.org/Roles_and_Capabilities#Capability_vs._Role_Table
Forum: Fixing WordPress
In reply to: If In SubcategoryPut this in a hacks or plugin file. Then just do
<?php if (in_category_recursive_up(24)) {It works by first checking the categories that they post has for a match. It then takes each category and “digs up” (basically asking each one, “who’s your daddy?”) until it either runs out of categories (false) or finds a match (true). I haven’t tested it too much, but initial tests indicate that it works.
function in_category_recursive_up($cat_id=0) {
if ( !is_single() )
return false;
$cats = get_the_category();
if ( !count($cats) ) // error: no cats defined!
return false;
foreach ( (array) $cats as $cat ) {
if ( $cat->cat_ID == $cat_id ) { // match!
return true;
}if ( in_category_dig_parents($cat->category_parent, $cat_id) )
return true;
}
return false;
}function in_category_dig_parents($cat_id, $look_for) {
if ( !$cat_id )
return false;
if ( $cat_id == $look_for )
return true;
$cat = get_category($cat_id);
return in_category_dig_parents($cat->category_parent, $look_for);
}Forum: Fixing WordPress
In reply to: Page Error Unsolved(1) Does your host support
mod_rewrite?
(2) Was WordPress able to write its rewrite rules to.htaccess?
(3) What do you see when you go toOptions > Permalinks?Forum: Plugins
In reply to: modify recommend pluginRight after the first
wp_mail()call, put this:
wp_mail(get_option('admin_email'), $subject, $defaultmessage, $headers);