WP plugin - omkodning
HejJeg har fundet et Random quote plugin til wordpress, som er godt, men gerne skulle ændres lidt.
Jeg vil nemlig gerne vise 5 quotes på 1 gang - derudover skal de adskilles med et linjeskift.
Jeg har fundet ud af, at jeg kan ændre:
$sorgu = "SELECT * FROM $wpdb->ysoz ORDER BY RAND() limit 0,1 ";
til
$sorgu = "SELECT * FROM $wpdb->ysoz ORDER BY RAND() limit 0,5 ";
- nu kommer der 5 quotes, men de hænger alle sammen i et langt link?!
Nogle der kan hjælpe?
Koden er herunder:
<?php
/*
Plugin Name: Yakuter Random Quotes Plugin
Plugin URI: http://www.yakuter.com/yakuter-random-quotes-plugin
Description: It helps you to show random quotes at your blog. Author
Version: 2.0
Author: yakuter
Author URI: http://www.yakuter.com
*/
//Yeni Mesaj-New Quote
function soz_ekle ()
{ global $wpdb ;
$yenisoz= "INSERT INTO ".$wpdb->ysoz." VALUES ('','".$_POST['metin']."')";
$wpdb->query($yenisoz); ?>
<div id="message" class="updated fade"><p>New quote added! </p></div>
<?php }
//Sil-Delete
function soz_sil ()
{ global $wpdb ;
$silinecek="DELETE FROM ".$wpdb->ysoz." WHERE id='".$_GET['silno']."'";
$wpdb->query($silinecek);?>
<div id="message" class="updated fade"><p><strong>Quote deleted!</strong></p></div>
<?php
}
function soz_duzenle ()
{ global $wpdb ;
$sqlduzenle="update ".$wpdb->ysoz." set metin='".$_POST['metin']."' where id='".$_POST['id']."' ";
$wpdb->query($sqlduzenle);?>
<div id="message" class="updated fade"><p><strong>Quote updated!</strong></p></div>
<?php
}
//Temel Fonksiyon - Main Function
function ysoz( )
{
global $wpdb;
$sorgu = "SELECT * FROM $wpdb->ysoz ORDER BY RAND() limit 0,1 ";
$sonuclar = $wpdb->get_results($sorgu);
if ($sonuclar) {
foreach ($sonuclar as $sonuc) { echo $sonuc->metin; } }
}
//Y?netim Paneli- Admin Panel
add_action('admin_menu', 'yonetime_ekle');
function yonetime_ekle() {
add_submenu_page('options-general.php', 'Random Quotes', 'Random Quotes', 10, __FILE__, 'ysoz_menu');
}
function ysoz_menu() {
global $wpdb,$wpcf_strings;
echo '<div class="wrap">';
if ($_POST['islem']== 'ekle') { soz_ekle (); }
if ($_GET['islem']== 'sil') { soz_sil (); }
if ($_POST['islem']== 'duzenle') { soz_duzenle (); }
$sorgu = "SELECT * FROM $wpdb->ysoz order by id desc";
$sonuclar = $wpdb->get_results($sorgu);
if ($sonuclar) {
echo "<ol>";
foreach ($sonuclar as $sonuc) {
echo "<li>".$sonuc->metin;
echo "-[<a href='".$_SERVER['PHP_SELF']
."?page=ysoz.php&islem=sil&silno=".$sonuc->id."'>Delete</a>]";
echo "-[<a href='".$_SERVER['PHP_SELF']
."?page=ysoz.php°istir=".$sonuc->id."'>Edit</a>]</li>";
}
echo "</ol>";
} else { echo "There is no quote yet!"; }
if (!isset($_GET['degistir'])) {
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>?page=ysoz.php" method="post" >
<fieldset>
<table width="400">
<tr><td width="400"><b>New Quote</b></td></tr>
<tr><td><textarea name="metin" id="metin" cols="45" rows="6" tabindex="4"></textarea></td></tr>
<tr><td><input type="submit" name="submit" value="Add Quote" class="button" tabindex="5" /></td></tr>
</table>
<INPUT TYPE="hidden" name="islem" value="ekle"></p>
</fieldset>
</form>
<?php
}
else
{
$sorgutekipucu = "SELECT * FROM $wpdb->ysoz where id=".$_GET['degistir'];
$sonuclartekipucu = $wpdb->get_results($sorgutekipucu);
if ($sonuclartekipucu) {
foreach ($sonuclartekipucu as $sonuctekipucu) {
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>?page=ysoz.php" method="post" >
<fieldset>
<table width="400">
<tr><td width="400"><b>Edit Quote</b></td></tr>
<tr><td><textarea name="metin" id="metin" cols="45" rows="6" tabindex="4"><?php echo $sonuctekipucu->metin; ?></textarea></td></tr>
<tr><td><input type="submit" name="submit" value="Edit Quote" class="button" tabindex="5" /></td></tr>
</table>
<INPUT TYPE="hidden" name="islem" value="duzenle">
<INPUT TYPE="hidden" name="id" value="<?php echo $sonuctekipucu->id; ?>">
</fieldset>
</form>
<?php
} } }
echo "</div>";
}
/* Veritabani y?kleme - DB Install */
$wpdb->ysoz = $wpdb->prefix . 'ysoz';
function ysoz_install() {
global $wpdb;
$db_sql="CREATE TABLE IF NOT EXISTS `$wpdb->ysoz` (
`id` bigint(20) NOT NULL auto_increment,
`metin` text NOT NULL ,
PRIMARY KEY (`id`)
)";
$wpdb->query($db_sql);
}
if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
add_action('init', 'ysoz_install'); }
?>
I frontend filen er følgende indsat:
<?php ysoz(); ?>