'DESC', "only_title" => 1, "list" => 0, "limit" => 0, "order_by" => 'post_date' ), $atts)); //Et a partir d'ici, on évite de toucher pour ne pas tout casser ;) global $wpdb, $post; if($order_by == 'rand') { $order_by = 'rand()'; }else{ $order_by = 'wposts.'.$order_by.' '.$order.''; } if ( !empty($content) ) { $content = stripslashes($content); if ($sentence) { $search_terms = array($content); } else { preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $content, $matches); $search_terms = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); } $n = ($exact) ? '' : '%'; $searchand = ''; foreach((array)$search_terms as $term) { $term = addslashes_gpc($term); $search .= "{$searchand}((wposts.post_title LIKE '{$n}{$term}{$n}')"; if(!$only_title) $search .= " OR (wposts.post_content LIKE '{$n}{$term}{$n}')"; $search .= ")"; $searchand = ' AND '; } $term = $wpdb->escape($content); if (!$sentence && count($search_terms) > 1 && $search_terms[0] != $content ) $search .= " OR (wposts.post_title LIKE '{$n}{$term}{$n}')"; if(!$only_title) $search .= " OR (wposts.post_content LIKE '{$n}{$term}{$n}')"; if ( !empty($search) ) $search = " AND ({$search}) "; } $mylimit = 'LIMIT 1'; if($list){ if($limit){ $mylimit = 'LIMIT '.$limit; }else{ $mylimit = ''; } } $request = " SELECT wposts.* FROM $wpdb->posts wposts WHERE wposts.post_status = 'publish' AND wposts.post_type = 'post' And wposts.ID != $post->ID $search ORDER BY $order_by $mylimit"; $mybucle = $wpdb->get_results($request, OBJECT); //Debugage if($list){ $tempsstock = ''; } if($mybucle){ if($list){ return $tempsstock; }else{ return ''.$content.''; } }else{ return $content; } } add_shortcode("shal", "sc_shal"); # Fin de la prise en charge du Shortcode [shal] ######################################################## # Ajout du bouton du Shortcode [shal] ######################################################## function sc_inject_shal() { $stock='"; echo $stock; } add_action("admin_head", "sc_inject_shal"); # Fin d'ajout du bouton du Shortcode [shal] ?>