_ck_
Forum Replies Created
-
Forum: Plugins
In reply to: better convert_smilies routine?Thanks for the suggestion, I didn’t even know they existed. But I absolutely detest mailing lists in this day and age. That’s what forums were invented for! Mailing lists are good for one-way announcements…
I will attempt to submit the suggestion to trac though.
I found a nice plugin that handles “code” and “pre” rather well and deactivates the smilies so it solves all “preserve code formatting”
http://www.coffee2code.com/archives/2005/03/29/plugin-preserve-code-formatting/Forum: Plugins
In reply to: better convert_smilies routine?No I wanted something more universal for the more smilies plugin etc. where the smilies templates can vary widely with whitespace.
Plus with stripped whitespace you have to be more careful about replaements so you don’t trash someones code or other weird comment.
I think I came up with something with only a slight performance hit. I’m an amatuer so I’ll need a php pro to tell me what they think.
add this before/changed to convert_smilies
function prepSmilies($string) {return "/(s|^)".quotemeta(trim($string))."(s|$)/";}
function convert_smilies($text) {
global $wp_smiliessearch, $wp_smiliesreplace;
$prep_search = array_map('prepSmilies', $wp_smiliessearch);
and then change the content replacement call to
$content = preg_replace($prep_search, $wp_smiliesreplace, $content);
seems to test really well for me. If a user manually types a smilie without whitespace before or after it at the start or end of a line, it still works. Otherwise the insert smilie clicks still insert the spaces before and after for best formatting.
I don’t see where the default routine skips formatting between “code” tags??? If that is missing it needs to be added!
Forum: Themes and Templates
In reply to: Previous posts required for author page link(thought I found the direct fix for 2.1a2 but I was wrong)
Forum: Fixing WordPress
In reply to: WP intercepting ALL 404 errors from main site?Okay figured out my own answer again sorry.
But this might help someone else in the future.When you run WP in a sub-directory, the special .htacesss goes into that sub-directory, not the webroot .htacess !
Didn’t realize that, though it seems obvious now.
Forum: Plugins
In reply to: New plugin – UserextraHere’s a bug fix for UserExtra 0.3 for WP 2
where you get line 662 errors
Basically this happens because the filter_posts function returns an empty array after it receives a null arrray (and should return a null arrary)1. open userextra.php
2. go to line 657 which is"function filter_posts($posts) {"
3. add this line right after (new line 663)
if(!is_array($posts)) {return;}then when there is a 404 ie. bad category, no search results, etc. it returns the null arrary right back to the loop
Forum: Alpha/Beta/RC
In reply to: RE: list of working plugins in WP2.1alpha2Can you identify in general what *might* cause a plugin to break under 2.1 vs 2.0.x ?
There aren’t any database layout changes in 2.1 correct, just additional options for some fields?
ie. “future” for the post status is new in 2.1 but the field data type is identical so it shouldn’t break anything unless it’s poor code that doesn’t know what to do with an unknown setting (or interprets it wrong)
Forum: Fixing WordPress
In reply to: how to revert a “post” back to a “page” (broke it with zempt)Aha!
I didn’t think this out enough.
I just created a fresh “page” to compare for myself in phpmyadmin and from what I can see, the difference between a “page” and a “post is that“post_status” is set to “static” for “page”
and it’s set to “published” for “posts”nice! now let me see if I can hack Zempt to support it…
(no luck on Zempt, it’s hardcoded, wrote the support people on that…)
Forum: Fixing WordPress
In reply to: how to revert a “post” back to a “page” (broke it with zempt)Definitely not blaming WordPress at all.
Just would like to know how to manually fix it.I am certain zempt changed it because it was designed pre-Wordpress and probably saved it with attributes of a post (unknowingly).
I could also post the fix to the zempt authors.
Perhaps there is even a work-around possible without a zempt update (which may be a long time coming) so it can actually save “pages” correctly.
Oh heck, I just discover this ticket which is slated for 2.1
http://trac.wordpress.org/ticket/1762
same thing I did with better code
Forum: Fixing WordPress
In reply to: Long URLS in comments break my design — any way to fix?Don’t plugins have a priority level?
Perhaps I can change the url shortening to a higher priority and the word wrap to a lower one so they get executed in the prefered order?Forum: Requests and Feedback
In reply to: Rewrite rules structuresee my hack here:
http://wordpress.org/support/topic/64959?replies=6#post-416809it’s worse than just the var edits but you can at least change it from the panel
TADA!
Once you upload and go to the permalinks section you will see you can change all the bases – tested working.You can use the “WordPress Internal Rewrite Viewer” to see the changes happen after you save.
http://www.dagondesign.com/articles/wordpress-internal-rewrite-viewer-plugin/There is only one bug right now that I can see.
Unlike the category field, if you clear out the others, they do not revert to their default.I think this has to do with the way wp_rewrite inits and has default settings, category_base is done differently and I am not sure how.
Unsetting the variables may fix it, I am too much a novice at PHP to figure it out right now, perhaps a greater mind can tell me easily how to fix that.
This is too late for 2.0.4 I guess but I’d like to see this fix permanently done for 2.1.0 – I have no idea how to use the bugtrack system so feel free to submit all this for me if you are a bugtrack pro.
Last step is a big addition of code, find this line near the top
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base'])
and all the way to
$category_base = get_settings('category_base');
replace it with this chunk:
if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) || isset($_POST['author_base']) || isset($_POST['feed_base']) || isset($_POST['search_base']) || isset($_POST['comments_base'])) {
check_admin_referer('update-permalink');if ( isset($_POST['permalink_structure']) ) {
$permalink_structure = $_POST['permalink_structure'];
if (! empty($permalink_structure) )
$permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
$wp_rewrite->set_permalink_structure($permalink_structure);
}if ( isset($_POST['category_base']) ) {
$category_base = $_POST['category_base'];
if (! empty($category_base) )
$category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']);
$wp_rewrite->set_category_base($category_base);
}if ( isset($_POST['author_base']) ) {
$author_base = $_POST['author_base'];
if (! empty($author_base) )
$author_base = preg_replace('#/+#', '/', '/' . $_POST['author_base']);
$wp_rewrite->set_author_base($author_base);
}if ( isset($_POST['feed_base']) ) {
$feed_base = $_POST['feed_base'];
if (! empty($feed_base) )
$feed_base = preg_replace('#/+#', '/', '/' . $_POST['feed_base']);
$wp_rewrite->set_feed_base($feed_base);
}if ( isset($_POST['search_base']) ) {
$search_base = $_POST['search_base'];
if (! empty($search_base) )
$search_base = preg_replace('#/+#', '/', '/' . $_POST['search_base']);
$wp_rewrite->set_search_base($search_base);
}if ( isset($_POST['comments_base']) ) {
$comments_base = $_POST['comments_base'];
if (! empty($comments_base) )
$comments_base = preg_replace('#/+#', '/', '/' . $_POST['comments_base']);
$wp_rewrite->set_comments_base($comments_base);
}}
$permalink_structure = get_settings('permalink_structure');
$category_base = get_settings('category_base');
$author_base = get_settings('author_base');
$feed_base = get_settings('feed_base');
$search_base = get_settings('search_base');
$comments_base = get_settings('comments_base');Okay after a bunch of poking around I got this working nicely from the permalinks option in the dashboard/control panel.
Unfortunately due to my limited knowledge of WordPress and if the init() function is replaceable by a plugin, I chose to do this directly as a hack for now. Those that know better can see what I did and perhaps make it a complete standalone plugin with no hacks needed?
Okay, start here:
wp-includes\classes.php
function init() at or around line 1425 in wp2.0.3
it’s missing all the options to set ANY base except for category – someone was either in a hurry or lazyadd below the $this->category_base…
$this->author_base = get_settings('author_base');
$this->feed_base = get_settings('feed_base');
$this->search_base = get_settings('search_base');
$this->comments_base = get_settings('comments_base');
that will allow WP to rebuild all the rules for those extra basesnow find this part of code in classes.php
function set_category_base($category_base) {
if ($category_base != $this->category_base) {
update_option('category_base', $category_base);
$this->init();
}
}and again mimic it for the other bases, adding
function set_author_base($author_base) {
if ($author_base != $this->author_base) {
update_option('author_base', $author_base);
$this->init();
}
}function set_feed_base($feed_base) {
if ($feed_base != $this->feed_base) {
update_option('feed_base', $feed_base);
$this->init();
}
}function set_search_base($search_base) {
if ($search_base != $this->search_base) {
update_option('search_base', $search_base);
$this->init();
}
}function set_comments_base($comments_base) {
if ($comments_base != $this->comments_base) {
update_option('comments_base', $comments_base);
$this->init();
}
}it’s a shame all this isn’t done in a nice “eval” loop with an array of all the bases but that’s too much work for me right now and I don’t want to break anything
now we need to move to
wp-admin/options-permalink.php
it’s going to need bunch of additions, all mimicking the functions for base_categoryfirst find
<?php _e('Category base'); ?>: <input name="category_base" type="text" class="code" value="<?php echo $category_base; ?>" size="30" />and again, add and mimic:
<?php _e('Author base'); ?>: <input name="author_base" type="text" class="code" value="<?php echo $author_base; ?>" size="30" /><?php _e('Feed base'); ?>: <input name="feed_base" type="text" class="code" value="<?php echo $feed_base; ?>" size="30" />
<?php _e('Search base'); ?>: <input name="search_base" type="text" class="code" value="<?php echo $search_base; ?>" size="30" />
<?php _e('Comments base'); ?>: <input name="comments_base" type="text" class="code" value="<?php echo $comments_base; ?>" size="30" />
(saving and coming back to edit)
I’ll add a “me too” request to this.
I’ve been studying other plugins to figure it out and I think the key is that $author_base is readable, not writeable.
For example if you look at the $category_base it’s for reading the property only and then there is set_category_base($category_base)
There is no set_author_base so we have to make one. If I can find the code for set_category_base we can hack it for that.
Here we go, it’s in wordpress/trunk/wp-includes/rewrite.php
function set_category_base($category_base) {
if ($category_base != $this->category_base) {
update_option('category_base', $category_base);
$this->init();
}
}
so just change the word “category” to “author” everywhere in the function and we are set.
Now I just need to learn how to make that function hook into the wp startup code. Seems like it would slow things down as it has to be called everytime. Would have been nice just to have it in wp-config.php or something similar.
Ah and here is a plugin that lets you modify ALL the rewrite rules, though I am not sure if WP will then know if things like $author_base have changed?
http://www.dynamiccorestudios.com/archive/wordpress-plugin-custom-rewrite-rules/