_x( 'Articalise', 'taxonomy general name' ), 'singular_name' => _x( 'Articalise', 'taxonomy singular name' ), 'search_items' => __( 'Search Articalise' ), 'popular_items' => __( 'Popular Articalise' ), 'all_items' => __( 'All Articalise' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit Articalise' ), 'update_item' => __( 'Update Articalise' ), 'add_new_item' => __( 'Add New Articalise' ), 'new_item_name' => __( 'New Articalise Name' ), 'separate_items_with_commas' => __( 'Separate articalise with commas' ), 'add_or_remove_items' => __( 'Add or remove articalise' ), 'choose_from_most_used' => __( 'Choose from the most used articalise' ) ); register_taxonomy( 'articalise', array('post','page'), array( 'hierarchical' => true, 'labels' => $tax_labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'articalise' ), )); } add_filter( 'the_title', 'prefix_articalisation_to_title'); function prefix_articalisation_to_title($title, $id=null){ global $post; $opts = get_option('articalise'); // Only dissplay term (articalise group name) if we're in the loop. // This should avoid menu's e.t.c. if( in_the_loop() && $opts['title'] ){ $post_terms = wp_get_object_terms($post->ID, 'articalise'); if( is_single() && count($post_terms) > 0 ){ $term_name = $post_terms[0]->name; $title = $term_name.': '.$title; } } return $title; } add_filter( 'the_content', 'add_articalisation_to_posts' ); function add_articalisation_to_posts($content){ if( is_home() || is_singular() ){ $menu = get_articalise_menu(); $opts = get_option('articalise'); if( $opts['pre'] ) $content = $menu . $content; if( $opts['post']) $content = $content . $menu; } return $content; } function get_articalise_menu(){ global $post; $wp_cache_key = 'articalise_menu_'.$post->ID; $extra = wp_cache_get($wp_cache_key, 'articalise'); if( empty($extra) ){ $opts = get_option('articalise'); $post_terms = wp_get_object_terms($post->ID, 'articalise'); if( count($post_terms) > 0 ){ $term_id = $post_terms[0]->term_id; // Assume only ever one of these $term_name = empty($opts['alt']) ? $post_terms[0]->name : $opts['alt']; $term_slug = $post_terms[0]->slug; $sibling_objects = get_objects_in_term($term_id, 'articalise'); $article_pages = get_posts( array('include'=>$sibling_objects,'order'=>'ASC') ); if( count($article_pages) > 0 ){ $extra = ''; } $adjust = empty($opts['adjust']) ? '' : 'articalise-'.$opts['adjust']; $extra = '
'.$extra.'

'; } wp_cache_set('articalise_menu', $extra, 'articalise'); } return $extra; } add_action('wp_print_styles', 'add_articalise_style'); function add_articalise_style(){ global $post; $post_terms = wp_get_object_terms($post->ID, 'articalise'); if( count($post_terms) > 0 ){ wp_register_style('articalise', ARTICALISEPLUGINURL.'/articalise.css'); wp_enqueue_style('articalise'); } } add_action('admin_menu', 'add_articalise_options_page'); function add_articalise_options_page(){ add_options_page( 'Articalise','Articalise', 'edit_published_posts', 'articalise-options', 'articalise_options_menu' ); } function articalise_options_menu(){ if( !current_user_can('edit_published_posts') ) wp_die( __('You do not have sufficient permissions to access this page.') ); $saved = ''; $opts = get_option('articalise'); if( 'articalise_save' == $_POST['action'] ){ $opts['pre'] = isset($_POST['articalise_pre']) ? $_POST['articalise_pre'] : ''; $opts['post'] = isset($_POST['articalise_post']) ? $_POST['articalise_post'] : ''; $opts['adjust'] = isset($_POST['articalise_adjust']) ? $_POST['articalise_adjust'] : ''; $opts['title'] = isset($_POST['articalise_title']) ? $_POST['articalise_title'] : ''; $opts['alt'] = isset($_POST['articalise_alt']) ? $_POST['articalise_alt'] : ''; $opts['link'] = isset($_POST['articalise_link']) ? $_POST['articalise_link'] : ''; update_option('articalise', $opts); $saved = '
Articalise settings updated.
'; } $pre = $opts['pre']; $post = $opts['post']; $adjust = $opts['adjust']; $title = $opts['title']; $alt = $opts['alt']; $link = $opts['link']; echo '
'; echo '

'; echo '

Articalise Settings

'; echo $saved; ?>

Post Options

Menu options

Adjust text:

'; }