From 8889dfadfc50e4dd379063131a89df234988c91d Mon Sep 17 00:00:00 2001 From: Sjur Hernes Date: Sun, 3 Jul 2011 11:45:50 +0200 Subject: [PATCH] widgets for artister og program, custom post for artist --- .gitignore | 2 + .gitmodules | 3 + wp-config.php | 6 +- .../plugins/neuf-artist/neuf-artist.php | 170 ++++++++++++++++++ wp-content/themes/studio11/functions.php | 48 +++++ wp-content/themes/studio11/sidebar.php | 4 +- wp-content/themes/twentyten/functions.php | 1 + 7 files changed, 229 insertions(+), 5 deletions(-) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 wp-content/plugins/neuf-artist/neuf-artist.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..81f878f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +wp-config.php +*~ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..371e2fb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "wp-content/plugins/neuf-events"] + path = wp-content/plugins/neuf-events + url = git@github.com:neuf/neuf-events.git \ No newline at end of file diff --git a/wp-config.php b/wp-config.php index 11c42d8..ed43d37 100755 --- a/wp-config.php +++ b/wp-config.php @@ -16,13 +16,13 @@ // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ -define('DB_NAME', 'oyvinbak'); +define('DB_NAME', 'studio11'); /** MySQL database username */ -define('DB_USER', 'oyv_wordpress'); +define('DB_USER', 'studio11'); /** MySQL database password */ -define('DB_PASSWORD', 'LGwW35HRPcjXNcmd'); +define('DB_PASSWORD', 'studio11'); /** MySQL hostname */ define('DB_HOST', 'localhost'); diff --git a/wp-content/plugins/neuf-artist/neuf-artist.php b/wp-content/plugins/neuf-artist/neuf-artist.php new file mode 100644 index 0000000..7583803 --- /dev/null +++ b/wp-content/plugins/neuf-artist/neuf-artist.php @@ -0,0 +1,170 @@ + + + array( + 'name' => __( 'Artister' ), + 'singular_name' => __( 'Artist' ), + 'add_new' => __( 'Legg til ny artist' ), + 'add_new_item' => __( 'Legg til ny artist' ), + 'edit_item' => __( 'Rediger artist' ), + 'new_item' => __( 'Legg til ny artist' ), + 'view_item' => __( 'Vis artist' ), + 'search_items' => __( 'Søk etter artist' ), + 'not_found' => __( 'ingen artister funnet' ), + 'not_found_in_trash' => __( 'ingen artister funnet i søppel' ) + ), + 'public' => true, + 'publicly_queryable' => true, + 'query_var' => 'artist', + 'capability_type' => 'post', + + 'supports' => array( + 'title', + 'editor', + 'thumbnail', + ), + 'register_meta_box_cb' => 'add_studart_metaboxes', + ) + ); + } + + + /******************************************************************************* + ******************************************************************************** + ** Add meta-boxes *********************************************************** + ******************************************************************************** + *******************************************************************************/ + + function add_studart_metaboxes() { + + add_meta_box( + 'studio_artist_pop', + __('Artiststørrelse'), + 'studio_artist_custom_box', + 'artist', + 'side', + 'high' + ); + } + + /******************************************************************************* + ******************************************************************************** + ** Eventtype metabox ******************************************************** + ******************************************************************************** + *******************************************************************************/ + + function studio_artist_custom_box(){ + + global $post; + + $artist_pop = get_post_meta($post->ID, 'studio_artist_pop' , true); + $artist_link = get_post_meta($post->ID, 'studio_artist_link', true); + + echo "Størrelse:"; + echo ''; + + echo '
Artisturl:
'; + + + } + + /** + * When the post is saved, saves our custom data + */ + + + function studio_artist_save_info( $post_id ) { + + if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; + + if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; + + // Get posted data + $studart['studio_artist_pop'] = $_POST['studio_artist_pop' ]; + $studart['studio_artist_link'] = $_POST['studio_artist_link']; + + foreach($studart as $key=>$value) + if ( !update_post_meta($post_id, $key, $value)) + add_post_meta($post_id, $key, $value, true); + return $post_id; + } + + /** View of the custom page */ + + function studio_artist_list() { + global $post, $wp_locale; + + $artister = new WP_Query( array('post_type' => 'artist','posts_per_page' => -1,'order' => 'ASC' ) ); + $html = ''; + + if ( $artister->have_posts() ) { + + $html .= ''; + } + + return $html; + + } + } + } +} + +if (class_exists("StudioArtist")) { + $studio_artist_object = new StudioArtist(); +} + +if ( isset($studio_artist_object)){ + add_action( 'init', 'studio_artist_post_type', 0); + add_action( 'save_post', 'studio_artist_save_info'); + add_shortcode( 'studio-artist-list', 'studio_artist_list' ); +} + +?> diff --git a/wp-content/themes/studio11/functions.php b/wp-content/themes/studio11/functions.php index 161a700..c43319a 100644 --- a/wp-content/themes/studio11/functions.php +++ b/wp-content/themes/studio11/functions.php @@ -15,3 +15,51 @@ function studio11_widgets_init() { } /** Register sidebars by running twentyten_widgets_init() on the widgets_init hook. */ add_action( 'widgets_init', 'studio11_widgets_init' ); + + + +class Program_Widget extends WP_Widget { + + function Program_Widget() { parent::WP_Widget(false, 'Program'); } + function form($instance) {} + function update($new_instance, $old_instance) { return $new_instance; } + + function widget($args, $instance) { + global $post, $wp_locale; + $args['title'] = 'Program'; + $events = new WP_Query( array('post_type' => 'event','posts_per_page' => -1,'meta_key' => 'neuf_events_starttime','orderby' => 'meta_value','order' => 'ASC') ); + echo $args['before_widget'] . $args['before_title'] . $args['title'] . $args['after_title']; + if ( $events->have_posts() ) { + echo ''; + wp_reset_query(); + } echo $args['after_widget']; + } +} + +class Artist_Widget extends WP_Widget { + function Artist_Widget() { parent::WP_Widget(false, 'Artister'); } + function form($instance) {} + function update($new_instance, $old_instance) { return $new_instance; } + + function widget($args, $instance) { + global $post, $wp_locale; + $args['title'] = 'Artister'; + $studart = new WP_Query( array('post_type' => 'artist', 'posts_per_page' => -1,'meta_key' => 'studio_artist_pop','orderby' => 'meta_value', 'order' => 'ASC')); + echo $args['before_widget'] . $args['before_title'] . $args['title'] . $args['after_title']; + if ( $studart->have_posts() ) { + while ( $studart->have_posts() ) { + $studart->the_post(); + echo get_post_meta($post->ID, 'studio_artist_pop', true); + $link = get_post_meta($post->ID, 'studio_artist_link', true) ? get_post_meta($post->ID, 'studio_artist_link', true) : get_permalink(); + echo '

' . get_the_title() . '

'; + } + } echo $args['after_widget']; + } +} + +register_widget('Program_Widget'); +register_widget('Artist_Widget'); \ No newline at end of file diff --git a/wp-content/themes/studio11/sidebar.php b/wp-content/themes/studio11/sidebar.php index 3684ace..e668739 100644 --- a/wp-content/themes/studio11/sidebar.php +++ b/wp-content/themes/studio11/sidebar.php @@ -21,8 +21,8 @@ */ if ( ! dynamic_sidebar( 'left-primary-widget-area' ) ) : ?> - - + + diff --git a/wp-content/themes/twentyten/functions.php b/wp-content/themes/twentyten/functions.php index 36f5506..70b9742 100644 --- a/wp-content/themes/twentyten/functions.php +++ b/wp-content/themes/twentyten/functions.php @@ -506,3 +506,4 @@ function twentyten_posted_in() { ); } endif; +