File: /www/wwwroot/gxdaosen.net/wp-content/themes/simplepark/widget.php
<?php
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Sidebar Widgets',
'id' => 'sidebar-widgets',
'description' => '页面挂件区域(关于我们等)',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
));
}
function unregister_default_wp_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Search');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_Recent_Posts');
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_RSS');
unregister_widget('WP_Widget_Tag_Cloud');
}
include_once("widget/nav.php");
include_once("widget/cat_posts-news1.php");
include_once("widget/cat_posts-news2.php");
include_once("widget/cat_posts-news3.php");
include_once("widget/cat_posts-news_smoll.php");
add_action('widgets_init', 'unregister_default_wp_widgets', 1);
function catch_that_image() {
global $post, $posts;
$src= wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), "full" , false, '' ); ;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = $src[0];
}
return $first_img;
}
?>