Search Results for 'code'
-
Search Results
-
Topic: problem with some queries
Hi, I’ve written a custom plugin to convert my old bbcode syntax myurl to myurl>.
It worked for a large amount of posts but I still get a lot (also) of errors.
Here’s a query error :
UPDATE bb_posts SET post_text ='Bon c'est sur que si on compare :rolleyes:nn
nn
' WHERE post_id = 114958As you see, the url tags have not been updated neither.
My function :
function replace_bbcode_urls() {
global $bbdb;
$regex=”#[url ?
[^[]*) ?] ?([^]]*) ?[/url]#”; $sql = “SELECT post_id, post_text FROM bb_posts WHERE post_text LIKE ‘%[url=%'”;
$results = $bbdb->get_results($sql);
foreach($results as $row){
$new_monchamp = preg_replace($regex, “\2“, $row->post_text);
$sql2 = sprintf(“UPDATE bb_posts SET post_text =’%s’ WHERE post_id = “.$row->post_id, mysql_real_escape_string($new_monchamp));
if ($bbdb->query( $bbdb->prepare($sql2) )) {
//echo $row->post_id.”
“;}else {
//echo “error processing post “.$row->post_id.”
“;echo $sql2.”
“;exit;
}
}
}
Help would be appreciated.
Thanks !
I just realized today if you are using a bunch of plugins that have their options stored in the bbpress meta, your query count has jumped on every page in bbPress 1.0.x
Apparently 1.0 now has a reserved list of option names that are pre-loaded, instead of *all* of them like 0.9 could. Plugins have to add their desired names to the pre-caching option, which of course 100% of all pre-exisiting plugings are not aware of, so they all cause an extra query in 1.0
This isn’t a magic bullet by any means but you can at least fix this behavior. There isn’t any flag you can turn on to cache all (that would be far too easy) but you can fool the routine by loading all the options before it gets around to it.
Simply make the below into a mini-plugin, or right click here
and save as
_load-options.phpin yourmy-plugins/directoryI strongly suggest you save it with a leading underscore so it auto-loads.
<?php
/*
Plugin Name: Load Options
*/
global $bbdb;
$results = $bbdb->get_results( "SELECT meta_key, meta_value FROM $bbdb->meta WHERE object_type = 'bb_option' ");
foreach ( $results as $options ) {
wp_cache_delete( $options->meta_key, 'bb_option_not_set' );
wp_cache_set( $options->meta_key, maybe_unserialize( $options->meta_value ), 'bb_option' );
}
?>Topic: date and time
Hi, I want to change the time and date format to Dutch. I saw this code for it
‘<?php topic_time(); ?>`
in post.php:
` <?php printf(__(‘Posted %s ago’,’rag’), bb_get_post_time()); ?> <a href=”<?php post_anchor_link(); ‘
Login on WPMU, you’re in on bbPress, and vice versa.
)