<?php
/*
Plugin Name: EzSticky
Plugin URI: http://maurizio.mavida.com/ezsticky
Description: Show post_excerpt of specified categoty, sticky is default. Usage: put the function ezsticky() anywhere in the template.
Version: 0.2
Author: maurizio
Author URI: http://maurizio.mavida.com
*/
/*
License: GPL
Installation:
Place the ezsticky.php file in your /wp-content/plugins/ directory
and activate through the administration panel.
*/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* Changelog
* 2006-11-21 - v0.2
- add sticky_cat param for change category filter selection
- add $wpdb before table name
- add some comments
* 2006-11-20 - v0.1
- Initial release
*/
function ezsticky ($sticky_cat = 'sticky', $before_title = '<h3>', $after_title = '</h3>', $before_post = '<div>', $after_post = '</div>' ) {
global $wpdb, $tableposts;
$sql = '';
$sql .= "SELECT ID, post_title, post_content, post_excerpt, category_id, cat_name ";
$sql .= "FROM $wpdb->posts ";
$sql .= "INNER JOIN $wpdb->post2cat ON $wpdb->posts.id = $wpdb->post2cat.post_id ";
$sql .= "INNER JOIN $wpdb->categories ON $wpdb->post2cat.category_id = $wpdb->categories.cat_id ";
$sql .= "WHERE post_status = 'publish' and cat_name = '$sticky_cat' ";
$sql .= "ORDER BY post_date ";
$posts = $wpdb->get_results($sql);
$output = '';
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$post_title = str_replace('"', '', $post_title);
//$post_title = substr($post_title, 0, 25);
$permalink = get_permalink($post->ID);
$post_content = strip_tags($post->post_content);
$post_content = stripslashes($post_content);
$post_excerpt = stripslashes($post->post_excerpt);
$output .= '<div class="ezsticky">';
$output .= $before_title;
$output .= '<a href="' . $permalink . '" rel="bookmark" title="' . $post_title . '">' . $post_title . '</a>';
$output .= $after_title;
$output .= $before_post;
$output .= $post_excerpt ;
$output .= ' ( <a href="' . $permalink . '" rel="bookmark" title="' . $post_title . '">Continua ...</a> )';
$output .= $after_post;
$output .= '</div>';
}
echo $output;
}
?>
$currentCat = $_REQUEST['cat'];
$categories = new articleHandler($CATEGORIES_PATH) ;
...
// getting the breadcrumds
if(is_string($currentCat)){
$bread = $categories->get_breadCrumbs($currentCat);
for($i = count($bread)-1; $i >= 0; $i--){
if($i==O){
//this is the location the user is @, so no link has to be set
$t->set_var("currentone" , $bread[$i][0]);
}else{
//parse the breadcrumbs
$t->set_var("loc", $bread[$i][1]);
$t->set_var("tekst", $bread[$i][0]);
$t->parse("crumbs" , "bread", true);
}
}
}
//get items in a categorie
//1 stands for the field number being used
$itemsInCat = $items->searchFor($currentCat, 1);
//get subcategories of an categorie
//5 stands for the field number being used
$subCats = $categories->searchFor($currentCat, 5);
//adding an article without a photo
$items->add_art($cat, $csv);
//adding a product with a photo
$items->add_art($cat, $csv,$_FILES["_pic"]["tmp_name"]);
//deleting an article
$items->del_art(...);
...
//The same goes with categories