Zadejte hledaný výraz...

Ako editovať advanced random post plugin

Valerian
verified
rating uzivatele
(10 hodnocení)
6. 10. 2010 16:45:39
Ahoj,
potreboval by som editovať vzhľad, ako sa zobrazujú príspevky, lebo v s účasnosti je to nevyhovujúce, škaredo to vyzerá. Netuším však, ako na to, plugin neobsahuje žiaden CSS súbor.
Mohol by mi niekto poradiť, kde a ako to meniť v PHP časti ? Ak by to niekomu pomohlo, prikladám celý súbor...
/*
Plugin Name: Advanced Random Posts
Plugin URI: http://www.yakupgovler.com/?p=416
Description: Display random posts from selected categories or current category or all posts with thumbnail images (optional).
Version: 2.3
Author: Yakup GÖVLER
Author URI: http://www.yakupgovler.com
*/
class yg_adv_random_posts extends WP_Widget {
function yg_adv_random_posts() {
//Load Language
load_plugin_textdomain( 'adv-rnd-posts', false, dirname(plugin_basename(__FILE__)) . '/lang' );
$widget_ops = array('description' => __('Shows Random Posts. You can customize it easily.', 'adv-rnd-posts') );
//Create widget
$this->WP_Widget('advancedrandomposts', __('Advanced Random Posts', 'adv-rnd-posts'), $widget_ops);
}
function widget($args, $instance) {
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance) ? __('Random Posts', 'adv-rnd-posts') : apply_filters('widget_title', $instance);
$parameters = array(
'title' => $title,
'limit' => (int) $instance,
'excerpt' => (int) $instance,
'actcat' => (bool) $instance,
'cats' => esc_attr($instance),
'cusfield' => esc_attr($instance),
'w' => (int) $instance,
'h' => (int) $instance,
'firstimage' => (bool) $instance,
'atimage' =>(bool) $instance,
'defimage' => esc_url($instance)
);
if ( !empty( $title ) ) {
echo $before_title . $title . $after_title;
};
//print random posts
yg_randomposts($parameters);
echo $after_widget;
} //end of widget
//Update widget options
function update($new_instance, $old_instance) {
$instance = $old_instance;
//get old variables
$instance = esc_attr($new_instance);
$instance = (int) abs($new_instance);
if ($instance > 20) $instance = 20;
$instance = (int) abs($new_instance);
$instance = esc_attr($new_instance);
$instance = $new_instance ? 1 : 0;
$instance = esc_attr($new_instance);
$instance = esc_attr($new_instance);
$instance = esc_attr($new_instance);
$instance = $new_instance ? 1 : 0;
$instance = $new_instance ? 1 : 0;
$instance = esc_url($new_instance);
return $instance;
} //end of update
//Widget options form
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => __('Advanced Random Posts','adv-rnd-posts'), 'show-num' => 10, 'excerpt-length' => 0, 'actcat' => 0, 'cats' => '', 'cus-field' => '', 'width' => '', 'height' => '', 'firstimage' => 0, 'atimage' => 0,'defimage'=>'' ) );
$title = esc_attr($instance);
$show_num = (int) $instance;
$excerpt_length = (int) $instance;
$cats = esc_attr($instance);
$actcat = (bool) $instance;
$cus_field = esc_attr($instance);
$width = esc_attr($instance);
$height = esc_attr($instance);
$firstimage = (bool) $instance;
$atimage = (bool) $instance;
$defimage = esc_url($instance);
?>


px
px

/>

/>

/>

} //end of form
}
add_action( 'widgets_init', create_function('', 'return register_widget("yg_adv_random_posts");') );
//Register Widget
// Show random posts function
function yg_randomposts($args = '') {
global $wpdb;
$defaults = array('limit' => 10, 'excerpt' => 0, 'actcat' => 0, 'cats'=>'', 'cusfield' =>'', 'w' => 48, 'h' => 48, 'firstimage' => 0, 'atimage' => 0, 'defimage' => '');
$args = wp_parse_args( $args, $defaults );
extract($args);
$limit = (int) abs($limit);
$firstimage = (bool) $firstimage;
$atimage = (bool) $atimage;
$defimage = esc_url($defimage);
$w = (int) $w;
$h = (int) $h;
$excerptlength = (int) abs($excerpt);
$excerpt = '';
$cats = str_replace(" ", "", esc_attr($cats));
if (($limit < 1 ) || ($limit > 20)) $limit = 10;
if (($actcat) && (is_category())) {
$cats = get_query_var('cat');
}
if (($actcat) && (is_single())) {
$cats = '';
foreach (get_the_category() as $catt) {
$cats .= $catt->cat_ID.' ';
}
$cats = str_replace(" ", ",", trim($cats));
}
if (!intval($cats)) $cats='';
$query = "cat=$cats&showposts=$limit&orderby=rand";
$rnd_posts = get_posts($query); //get posts by random
$postlist = '';
$height = $h ? ' height = "' . $h .'"' : '';
$width = $w ? ' width = "' . $w . '"' : '';
foreach ($rnd_posts as $post) {
$post_title = htmlspecialchars(stripslashes($post->post_title));
if ($excerptlength) {
$excerpt = $post->post_excerpt;
if ( '' == $excerpt ) {
$text = $post->post_content;
$text = strip_shortcodes( $text );
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 100;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
$text = implode(' ', $words);
}
$excerpt = $text;
}
if(strlen($excerpt) > $excerptlength) {
$excerpt = mb_substr($excerpt, 0, $excerptlength) . '...';
}
$excerpt = ': ' . $excerpt;
}
$image = '';
$img = '';
if ($cusfield) {
$cusfield = esc_attr($cusfield);
$img = get_post_meta($post->ID, $cusfield, true);
}
if (!$img && $firstimage) {
$match_count = preg_match_all("//", $post->post_content, $match_array, PREG_PATTERN_ORDER);
$img = $match_array;
}
if (!$img && $atimage) {
$p = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => 1,
'order' => 'ASC',
'orderby' => 'menu_order ID',
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($p);
if ($attachments) {
$imgsrc = wp_get_attachment_image_src($attachments->ID, 'thumbnail');
$img = $imgsrc;
}
}
if (!$img && $defimage)
$img = $defimage;
if ($img)
$image = '';
$postlist .= "
  • ID) . "" title="". $post_title ."" >$image" . $post_title ."$excerpt
  • n";
    }
    echo '
      '; echo $postlist; echo '
    ';
    }
    ?>
    6. 10. 2010 16:45:39
    https://webtrh.cz/diskuse/ako-editovat-advanced-random-post-plugin#reply569593
    Valerian
    verified
    rating uzivatele
    (10 hodnocení)
    8. 10. 2010 23:19:33
    Nikto nevie ani za iTrader ???
    8. 10. 2010 23:19:33
    https://webtrh.cz/diskuse/ako-editovat-advanced-random-post-plugin#reply569592
    Otakar Pěnkava
    verified
    rating uzivatele
    (25 hodnocení)
    10. 10. 2010 20:39:00
    Napsal Valerian;582230
    Nikto nevie ani za iTrader ???
    Itrader je utilitka k obchodování, to za pomoc se nedává. Se tolik neptej a zkoušej sám, tady co 2 téma to otázka od tebe...
    10. 10. 2010 20:39:00
    https://webtrh.cz/diskuse/ako-editovat-advanced-random-post-plugin#reply569591
    Valerian
    verified
    rating uzivatele
    (10 hodnocení)
    10. 10. 2010 21:02:27
    No vďaka ľuďom ako ja žije toto fórum...pýtam sa vtedy, keď na žiadnom obdobnom fóre/v Googli nenájdem relevantnú odpoveď, takže takto môže webtrh vyplniť medzeru na trhu...a mimochodom hľadám samozrejme aj cez anglické výrazy...
    10. 10. 2010 21:02:27
    https://webtrh.cz/diskuse/ako-editovat-advanced-random-post-plugin#reply569590
    Pro odpověď se přihlašte.
    Přihlásit