Articles Options here. Questions on configuration, etc.? Make sure to read the README. Version: 1.2 Author: Alex King Author URI: http://alexking.org */ load_plugin_textdomain('alexking.org'); function aka_install() { add_option('aka_columns', '1'); add_option('aka_token', '1'); } if (isset($_GET['activate']) && $_GET['activate'] == 'true') { if (get_option('aka_columns') == '') { aka_install(); } } function aka_request_handler() { if (isset($_POST['ak_action'])) { switch ($_POST['ak_action']) { case 'aka_update_settings': aka_update_settings(); break; } } } add_action('init', 'aka_request_handler'); function aka_head() { if (get_option('aka_columns') == 2) { print(' '); } } add_action('wp_head', 'aka_head'); function aka_update_settings() { if (isset($_POST['aka_columns'])) { update_option('aka_columns', intval($_POST['aka_columns'])); } if (isset($_POST['aka_token'])) { update_option('aka_token', intval($_POST['aka_token'])); } header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=articles.php&updated=true'); die(); } function aka_get_articles() { global $wpdb, $post; $original_post = $post; $columns = get_option('aka_columns'); $now = gmdate("Y-m-d H:i:s",time()); $posts_data = $wpdb->get_results(" SELECT $wpdb->posts.* FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->posts.ID = $wpdb->postmeta.post_id WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_date_gmt < '$now' AND $wpdb->postmeta.meta_key = 'article' AND $wpdb->postmeta.meta_value = '1' GROUP BY $wpdb->posts.ID ORDER BY $wpdb->posts.post_date_gmt DESC "); if (!$posts_data || count($posts_data) == 0) { return ''; } $posts = array(); $post_ids = array(); foreach ($posts_data as $post) { $posts['post_'.$post->ID] = $post; $post_ids[] = $post->ID; } $cats = $wpdb->get_results(" SELECT $wpdb->term_relationships.object_id, $wpdb->terms.term_id, $wpdb->terms.name, $wpdb->terms.slug FROM $wpdb->term_relationships, $wpdb->term_taxonomy, $wpdb->terms WHERE $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_relationships.object_id IN (".implode(',', $post_ids).") ORDER BY $wpdb->terms.slug, $wpdb->term_relationships.object_id DESC "); $output = ''; $current = ''; $open = false; $i = 0; if ($columns == '2') { $half = 0; $next = false; $output .= '
'; } foreach ($cats as $cat) { $slug = $cat->slug; if ($current != $slug) { if ($next) { $output .= '
'; $half++; $open = false; $next = false; } if ($i > 0 && $open) { $output .= ' '; } $output .= '

'.$cat->name.'

'; } if ($columns == '2') { $output .= '
'; } $post = $original_post; return $output; } function aka_show_articles() { print(aka_get_articles()); } function aka_the_content($content) { if (strstr($content, '###articles###')) { $content = str_replace('###articles###', aka_get_articles(), $content); } return $content; } if (get_option('aka_token') == '1') { add_action('the_content', 'aka_the_content'); } function aka_the_excerpt($content) { return str_replace('###articles###', '', $content);; } if (get_option('aka_token') == '1') { add_action('the_excerpt', 'aka_the_excerpt'); } function aka_options_form() { if (get_option('aka_columns') == '2') { $column_options = ''; } else { $column_options = ''; } if (get_option('aka_token') == '0') { $token_options = ''; } else { $token_options = ''; } print('

'.__('Articles Options', 'alexking.org').'

'.__('Adding Articles to Your List', 'alexking.org').'

'.__('To add post to your Articles list, simply add a custom field to the post:', 'alexking.org').'

'.__('Showing the Articles List', 'alexking.org').'

'.__('Token Method', 'alexking.org').'

'.__('If you have enabled the token method above, you can simply add ###articles### to any post or page and your articles list will be inserted at that place in the post/page.', 'alexking.org').'

'.__('Template Tag Method', 'alexking.org').'

'.__('You can always add a template tag to your theme (in a page template perhaps) to show your articles list.', 'alexking.org').'

<php aka_show_articles(); ?>

'); } function aka_options() { if (function_exists('add_options_page')) { add_options_page( __('Articles Options', 'alexking.org') , __('Articles', 'alexking.org') , 10 , basename(__FILE__) , 'aka_options_form' ); } } add_action('admin_menu', 'aka_options'); ?>