query(" UPDATE $wpdb->postmeta SET meta_key = '".AKA_META_KEY."' WHERE ( meta_key = 'article' AND meta_value = '1' ) "); header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page='.basename(__FILE__).'&updated=true'); die(); } function aka_plugin_action_links($links, $file) { $plugin_file = basename(__FILE__); if (basename($file) == $plugin_file) { $settings_link = ''.__('Settings', '').''; array_unshift($links, $settings_link); } return $links; } add_filter('plugin_action_links', 'aka_plugin_action_links', 10, 2); function aka_request_handler() { if (isset($_POST['ak_action'])) { switch ($_POST['ak_action']) { case 'aka_update_settings': aka_update_settings(); break; case 'aka_upgrade_1_3': aka_upgrade_1_3(); 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 (!current_user_can('manage_options')) { wp_die('Permission denied.'); } $settings = array('aka_columns', 'aka_token'); foreach ($settings as $setting) { if (isset($_POST[$setting])) { if (get_option($setting)) { update_option($setting, intval($_POST[$setting])); } else { add_option($setting, intval($_POST[$setting])); } } } header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page='.basename(__FILE__).'&updated=true'); die(); } function aka_get_articles() { global $wpdb, $post; $original_post = $post; if (!($columns = get_option('aka_columns'))) { $columns = 1; } $query = new WP_Query('meta_key='.AKA_META_KEY.'&meta_value=1&posts_per_page=99999999'); if (!count($query->posts)) { return ''; } $posts = array(); $post_ids = array(); foreach ($query->posts 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 LEFT JOIN $wpdb->term_taxonomy ON $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id LEFT JOIN $wpdb->terms ON $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id WHERE $wpdb->term_relationships.object_id IN (".implode(',', $post_ids).") AND $wpdb->term_taxonomy.taxonomy = 'category' 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 .= '
'.__('Mark as an Article?', 'articles').' '; $article = get_post_meta($post->ID, AKA_META_KEY, true); if ($article == '') { $article = '0'; } echo ' '; echo '
'.__('To add post to your Articles list, simply select the Yes option for the Article setting on a post-by-post basis.', 'articles').'
'.__('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.', 'articles').'
'.__('You can always add a template tag to your theme (in a page template perhaps) to show your articles list.', 'articles').'
<php aka_show_articles(); ?>