php - Fish Can't Whistle
26
Mar
2013
In development
General
php
WordPress
WordPress 3.0
WordPress Development
WordPress Multisite
WordPress Plugins
By Andy
An apology and an explanation
On 26, Mar 2013 | No Comments | In development, General, php, WordPress, WordPress 3.0, WordPress Development, WordPress Multisite, WordPress Plugins | By Andy
This post is aimed at the lovely people who are using one or more of our WordPress plugins.
16
Oct
2012
In development
mySQL
php
phpMyAdmin
WordPress
WordPress 3.0
WordPress Development
WordPress Multisite
By Andy
Undo Domain Mapping – WordPress Multisite
On 16, Oct 2012 | One Comment | In development, mySQL, php, phpMyAdmin, WordPress, WordPress 3.0, WordPress Development, WordPress Multisite | By Andy
I recently had a situation where a site within a WordPress multisite was domain mapped and the DNS at the registrar was changed away from the multisite without the multisite install being updated first. This meant that the WordPress site was not available and the client wanted certain information from the original WordPress dashboard.
How to fix the recent errors with TubePress and Vimeo
On 28, Feb 2012 | No Comments | In hack, php, WordPress, WordPress 3.0, WordPress Development | By Andy
I was informed last night that a previously working site using the TubePress WordPress plugin had suddenly started throwing a fatal error.
The error was this
Fatal error: Cannot use object of type stdClass as array in ***/wp-content/plugins/tubepress/sys/classes/org/tubepress/impl/factory/commands/VimeoFactoryCommand.class.php on line 164
After much digging around it turns out to be a problem with the Vimeo API rather than TubePress and a simple fix will sort you out.
25
Oct
2011
In getshopped
hack
php
WordPress
WordPress 3.0
WordPress Development
WordPress Plugins
wp e-commerce
By Andy
Getshopped – Add more details to sales CSV
On 25, Oct 2011 | 2 Comments | In getshopped, hack, php, WordPress, WordPress 3.0, WordPress Development, WordPress Plugins, wp e-commerce | By Andy
I have previously showed I added shipping columns to the sales logs page in a getshopped (Wp-Ecommerce) installation. This was fine but now we need that data to show up in the csv download.
Here’s how to do it-
06
Oct
2011
In getshopped
hack
php
WordPress
WordPress 3.0
WordPress Development
WordPress Plugins
wp e-commerce
By Andy
GetShopped – Add order without shipping column to sales view
On 06, Oct 2011 | One Comment | In getshopped, hack, php, WordPress, WordPress 3.0, WordPress Development, WordPress Plugins, wp e-commerce | By Andy
The sales view in the wp-ecommerce (GetShopped) is great but it will show you the total price of an order rather than the price without shipping, the shipping, and the total.
To introduce this functionality you do have to hack the plugin files, but there is not another way as I can not see any hooks I could make use of. If I have missed one, please do let me know!
WP E-commerce Category list order and more control…
On 05, Jun 2011 | 10 Comments | In getshopped, hack, php, WordPress Development, WordPress Plugins, wp e-commerce | By Andy
So ive been trying to use wpsc functions to control my widget of category listings… not fun. i have very little control over the listings without editing the core files which is something i would rather not do.
There are a number of supposed solutions out there but with the recent change to use wordpress tables rather than wpsc custom tables, at lot of those fixes no longer work.
So my solution has been to just use the already existing WordPress function “wp_list_categories”.
Like this
<?php
$args = array('taxonomy' => 'wpsc_product_category', 'orderby' => 'ID', 'order' => 'ASC', 'style' => 'none', 'child_of' => 15);
wp_list_categories( $args );
?>
Just put that in your sidebar or wherever else you want to display categories. Forget the widget for category listings, it doesnt allow you enough control. Using the above code will allow you to have control over the following (from http://codex.wordpress.org/Template_Tags/wp_list_categories)
<?php $args = array(
'show_option_all' => ,
'orderby' => 'name',
'order' => 'ASC',
'show_last_update' => 0,
'style' => 'list',
'show_count' => 0,
'hide_empty' => 1,
'use_desc_for_title' => 1,
'child_of' => 0,
'feed' => ,
'feed_type' => ,
'feed_image' => ,
'exclude' => ,
'exclude_tree' => ,
'include' => ,
'hierarchical' => true,
'title_li' => __( 'Categories' ),
'show_option_none' => __('No categories'),
'number' => NULL,
'echo' => 1,
'depth' => 0,
'current_category' => 0,
'pad_counts' => 0,
'taxonomy' => 'category',
'walker' => 'Walker_Category' ); ?>
I was using three category widgets but now am simply using this in my sidebar-
<h2>SHOP BY AGE</h2>
<?php
$args = array('taxonomy' => 'wpsc_product_category', 'orderby' => 'ID', 'order' => 'ASC', 'style' => 'none', 'child_of' => 15);
wp_list_categories( $args );
?>
<h2>SHOP BY ARTIST</h2>
<?php
$args = array('taxonomy' => 'wpsc_product_category', 'orderby' => 'ID', 'order' => 'ASC', 'style' => 'none', 'child_of' => 8);
wp_list_categories( $args );
?>
<h2>SHOP BY TYPE</h2>
<?php
$args = array('taxonomy' => 'wpsc_product_category', 'orderby' => 'ID', 'order' => 'ASC', 'style' => 'none', 'child_of' => 11);
wp_list_categories( $args );
?>
Much simpler and allows me absolute control over the order, appearance, depth and exclusions etc.
Its sad the this plugin doesnt have native support for this. maybe because its not needed when we can just use the WordPress functions?…
05
Jun
2011
In getshopped
hack
php
WordPress 3.0
WordPress Development
WordPress Plugins
wp e-commerce
By Andy
Add related products to wp e-commerce (getshopped) store
On 05, Jun 2011 | 25 Comments | In getshopped, hack, php, WordPress 3.0, WordPress Development, WordPress Plugins, wp e-commerce | By Andy
Here is a nice and simple way to enable related products on a single product page when using wp e-commerce. There’s only four steps!
Step one: Download the “Related Posts” plugin from http://www.microkid.net/wordpress/related-posts/ and install it.
Step two: Set up the plugin and familiarise yourself with the admin panel. Here is a great place to start.
Step three: Insert the following where you want your related products to display (for me this is in the imported wpsc-single_product.php file in my theme folder)-
MRP_show_related_posts()
Step four: Change line 450 in microkids-related-posts.php (now in your wp-content/plugins/microkids-related-posts folder)
FROM
$output .= "<li><a href="".get_permalink( $related_post->ID )."">".$related_post->post_title."</a></li>n";
TO
$output .= "<li><a href="".get_permalink( $related_post->ID ).""><img src="".wpsc_the_product_thumbnail(get_option('product_image_width'),get_option('product_image_height'),$related_post->ID,'single')."" ><br>".$related_post->post_title."</a></li>n";
And you’re done.
Custom WordPress search with pretty urls
On 06, Dec 2010 | No Comments | In php, WordPress 3.0, wordpress search | By Andy
A recent contact of mine recently posted the following question at wordpress.org -
Hi everyone,
i hope someone here has an idea how to solve this.
I am using a complex plugin combination related to the search engine in wordpress.
Basically, right now i have a URL like
http://www.test.com/search/key1&key2
Is there any way ( maybe a redirection plugin or htaccess rewrite rules ) that i can use the URL http://www.test.com/s/key1-key2
and show the content from http://www.test.com/search/key1&key2 ?
I dont want the URL to change, so the user should see the initial URL, but the plugins ( or WordPress in generall ) should of course use all informations for the search engine.
Looking forward for your ideas or help.
So I gave it some thought and figured it could be done using the 404.php template file.
For the inpatient among you, here is the code (it’s only the first 37 lines that are really of any relevance…) -
<?php
$url = $_SERVER['REQUEST_URI'];
if (substr($url,0, 3) == '/s/'){
$search=substr($url,3);
$searchitems = explode('-', $search);
echo "<title>Search results for ";
$i=0;
foreach ($searchitems as $value){
if($i>0){
$searchkeys .= " & ";
}
$searchkeys .= $value;
$i++;
}
echo $searchkeys;
echo "</title>";
get_header();
$search_query = new WP_query();
$search_query->query("s=$searchkeys"); ?>
<div id="container">
<div id="content" role="main">
<?php if ($search_query->have_posts()) : ?>
<h1><?php echo 'Search results for <span>' . $searchkeys . '</span>'; ?></h1>
<?php while ($search_query->have_posts()) : $search_query->the_post();?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div>
<?php the_excerpt(); ?>
</div>
<?php endwhile;
else : ?>
<h1>Sorry! No posts were found with the term<?php if($i>1){echo 's';} echo '<span> '.$searchkeys.'</span>'; ?></h1>
<?php endif;
wp_reset_query();?>
</div>
</div>
<?php }else{
/**
* The template for displaying 404 pages (Not Found).
*
* @package WordPress
* @subpackage Twenty_Ten
* @since Twenty Ten 1.0
*/
get_header(); ?>
<div id="container">
<div id="content" role="main">
<div id="post-0">
<h1><?php _e( 'Not Found', 'twentyten' ); ?></h1>
<div>
<p><?php _e( 'Apologies, but the page you requested could not be found. Perhaps searching will help.', 'twentyten' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</div><!-- #post-0 -->
</div><!-- #content -->
</div><!-- #container -->
<script type="text/javascript">
// focus on search field after it has loaded
document.getElementById('s') && document.getElementById('s').focus();
</script>
<?php }; ?>
<?php get_footer(); ?>
That is the entirety of the 404.php template file.
Lets look at the important bit -
$url = $_SERVER['REQUEST_URI'];
if (substr($url,0, 3) == '/s/'){
$search=substr($url,3);
$searchitems = explode('-', $search);
echo "<title>Search results for ";
$i=0;
foreach ($searchitems as $value){
if($i>0){
$searchkeys .= " & ";
}
$searchkeys .= $value;
$i++;
}
echo $searchkeys;
echo "</title>";
get_header();
$search_query = new WP_query();
$search_query->query("s=$searchkeys"); ?>
<div id="container">
<div id="content" role="main">
<?php if ($search_query->have_posts()) : ?>
<h1><?php echo 'Search results for <span>' . $searchkeys . '</span>'; ?></h1>
<?php while ($search_query->have_posts()) : $search_query->the_post();?>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div>
<?php the_excerpt(); ?>
</div>
<?php endwhile;
else : ?>
<h1>Sorry! No posts were found with the term<?php if($i>1){echo 's';} echo '<span> '.$searchkeys.'</span>'; ?></h1>
<?php endif;
wp_reset_query();?>
</div>
</div>
<?php }else{
Quite simply what that does is look to see if the string ‘/s/’ is in the url (as Hamed specified in his question), puts the various keys in to an array, loops the array building the correct argument for the custom query that we then implement using wp_query.
Of course how you get to the url to initialise this code isn’t in here. That will differ for each person depending on how they are using it. However a simple redirect upon submission of the search form adding the keys to the url would probably be what i would do…









