Archived
Adds image display in admin interface
This commit is contained in:
1 parent
7c8e2f7163
commit
e56098c416
3 files changed
+18
-10
No files matched your search
@@ -0,0 +1 @@
|
||||
*.swp
|
||||
@@ -3,15 +3,14 @@
|
||||
function neuf_societies_change_columns( $cols ) {
|
||||
$custom_cols = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Forening', 'trans' ),
|
||||
'image' => __( 'Bilde', 'trans' ),
|
||||
'homepage' => __( 'Hjemmeside', 'trans' ),
|
||||
/*'author' => __( 'Forfatter', 'trans' ),
|
||||
'date' => __( 'Publiseringsdato', 'trans' ),
|
||||
'type' => __( 'Type', 'trans' ),
|
||||
'starttime' => __( 'Dato og klokkeslett', 'trans' ),
|
||||
'endtime' => __( 'Sluttdato og -klokkeslett', 'trans' ),
|
||||
'venue' => __( 'Sted', 'trans' )*/
|
||||
'type' => __( 'Type', 'trans' ),*/
|
||||
);
|
||||
return array_merge($cols, $custom_cols);
|
||||
return $custom_cols;
|
||||
}
|
||||
add_filter( "manage_society_posts_columns", "neuf_societies_change_columns" );
|
||||
|
||||
@@ -19,7 +18,15 @@ add_filter( "manage_society_posts_columns", "neuf_societies_change_columns" );
|
||||
function neuf_societies_custom_columns( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case "homepage":
|
||||
echo get_post_meta( $post_id, '_neuf_societies_homepage', true);
|
||||
$homepage = get_post_meta( $post_id, '_neuf_societies_homepage', true );
|
||||
// default to permalink if not set
|
||||
$homepage = $homepage ? $homepage : get_permalink( $post_id );
|
||||
echo '<a href="'.$homepage.'" alt="'.$homepage.'" target="_blank">'.$homepage.'</a>';
|
||||
break;
|
||||
case "image":
|
||||
$thumb = get_the_post_thumbnail( $post_id, array(100, 50) );
|
||||
$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'large' );
|
||||
echo '<a href="'.$large_image_url[0].'" alt="'.$large_image_url[0].'">'.$thumb.'</a>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +63,14 @@ function neuf_societies_save_postdata( $post_id ) {
|
||||
if ( !current_user_can( 'edit_post', $post_id ) )
|
||||
return;
|
||||
}
|
||||
// OK, we're authenticated.
|
||||
|
||||
// OK, we're authenticated: we need to find and save the data
|
||||
|
||||
$mydata = $_POST['_neuf_societies_homepage'];
|
||||
// prefix with protocol if not present
|
||||
$mydata = esc_url( $_POST['_neuf_societies_homepage'] );
|
||||
|
||||
// Do something with $mydata
|
||||
// probably using add_post_meta(), update_post_meta(), or
|
||||
// a custom table (see Further Reading section below)
|
||||
add_post_meta($post_id, '_neuf_societies_homepage', $mydata, true);
|
||||
update_post_meta($post_id, '_neuf_societies_homepage', $mydata);
|
||||
}
|
||||
?>
|
||||
Reference in new issue
Block a user