post->ID;
//$post_id=the_ID();
if(is_page()){
$post_id = $GLOBALS['post']->ID;}
$argschildren = array(
'post_type' => 'attachment',
'numberposts' => -1,
//'post_mime_type' => 'application/pdf',
'post_parent' => $post_id,
'orderby' => 'menu_order ID'
);
//echo 'variable post_id '.$post_id.'
';
//echo 'the ID ';
//the_ID();
$parent_permalink = get_permalink( $post_id);
$attachments = get_children($argschildren);
if ($attachments) {
// TEST Y a-t-il des attachments autres que des images?
$count=0;
foreach ($attachments as $attachment) {
if (substr($attachment->post_mime_type, 0, 5) != 'image'){$count++;}
}
if ($count){
echo $before_widget;
echo '
| post_title; ?> |
'._e('Title'); echo ''; echo '
'; echo ''._e('Title').' 2'; echo ''; echo '
'; echo ''; } // activate and deactivate plugin function attachement_activate() { // options, default values $options = array( 'widget' => array( 'title1' => 'Files attached', 'title2' => 'to this post' ) ); // register option add_option( 'attachement_widget', $options['widget'] ); // activated return; } function attachement_deactivate() { // unregister option delete_option('attachement_widget'); // deactivated return; } // initialization function attachement_init() { // register widget $class['classname'] = 'attachement_widget'; wp_register_sidebar_widget('attachement', __('Attachement'), 'attachement_widget', $class); wp_register_widget_control('attachement', __('Attachement'), 'attachement_widget_control', 'width=200&height=200'); // initialization done return; } // actions add_action( 'activate_'.plugin_basename(__FILE__), 'attachement_activate' ); add_action( 'deactivate_'.plugin_basename(__FILE__), 'attachement_deactivate' ); add_action( 'init', 'attachement_init'); ?>