Changeset 3749

Show
Ignore:
Timestamp:
10/19/05 04:30:39 (3 years ago)
Author:
morganiq
Message:

Bug fixes: label id, pagination on Options page, filename issues, WHERE and JOIN collision fixes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mini-posts/trunk/mini-posts.php

    r439 r3749  
    44Plugin URI: http://doocy.net/mini-posts/ 
    55Description: An approach to "asides", or small posts. Allows you to mark entries as "mini" posts and handle them differently than normal posts. <strong>Requires WordPress 1.5.</strong> 
    6 Version: 0.5.1 
     6Version: 0.5.2 
    77Author: Morgan Doocy 
    88Author URI: http://doocy.net/ 
     
    4040        (WARNING: The argument sequence of get_mini_posts() has changed to accommodate this.) 
    41410.5.1  - Added 'save_post' hook 
     420.5.2  - Fixed label id for "This is a mini post" checkbox 
     43       - Added pagination on Options page 
     44       - Changed all references to the plugin's filename to basename(__FILE__), to avoid file naming issues 
     45       - Added aliases to JOIN and WHERE clauses to avoid collisions with other plugins 
     46        (thanks, Jerome and Mark!) 
    4247 
    4348*/ 
    4449 
    4550if (is_plugin_page()) { 
     51      include(ABSPATH.'wp-blog-header.php'); 
     52 
     53      $paged_val = get_query_var('paged'); 
     54      $paged_val = $paged_val ? "&paged=$paged_val" : ''; 
    4655       
    4756      if (isset($_POST["update_options"])) { 
     
    4958            update_option('suppress_autop_on_mini_posts', $_POST['suppress_autop_on_mini_posts'] == 1 ? 1 : 0); 
    5059            update_option('filter_mini_posts_from_feeds', $_POST['filter_mini_posts_from_feeds'] == 1 ? 1 : 0); 
    51             echo '<div class="updated"><p><strong>' . __('Options updated.', 'MiniPosts') . '</strong></p></div>'; 
     60            echo '<div class="updated"><p><strong>' . __('Options saved.', 'MiniPosts') . '</strong></p></div>'; 
    5261      } 
    5362      elseif (isset($_POST["update_miniposts"])) { 
    54             include(ABSPATH.'wp-blog-header.php'); 
    55              
    5663            $is_mini_post = $_POST["is_mini_post"]; 
    5764            foreach ($posts as $post) { 
     
    6067                  add_post_meta($post->ID, '_mini_post', $setting); 
    6168            } 
    62             header("Location: admin.php?page=mini-posts.php&updated=true"); 
     69            header("Location: options-general.php?page=" . basename(__FILE__) . "&miniposts_updated=true$paged_val"); 
    6370            exit(); 
    6471      } 
     
    7178      <div class="wrap"> 
    7279      <h2><?php _e('Mini Post Options', 'MiniPosts') ?></h2> 
    73       <form method="post"
     80      <form method="post" action="./options-general.php?page=<?php echo basename(__FILE__) . $paged_val; ?>"
    7481            <table width="100%" cellspacing="2" cellpadding="5" class="editform"> 
    7582                  <tr valign="top"> 
     
    9097      <?php 
    9198       
    92       if ($_GET["updated"] == "true")    { 
     99      if ($_GET["miniposts_updated"] == "true")      { 
    93100             
    94101      ?> 
     
    101108      <div class="wrap"> 
    102109      <h2><?php _e('Mini Post Manager', 'MiniPosts') ?></h2> 
    103       <form method="post"
     110      <form method="post" action="./options-general.php?page=<?php echo basename(__FILE__); ?>&noheader=true<?php echo $paged_val; ?>"
    104111      <table width="100%" cellpadding="3" cellspacing="3"> 
    105112            <thead> 
     
    117124            <tbody> 
    118125      <?php 
    119        
    120       include(ABSPATH.'wp-blog-header.php'); 
    121126       
    122127      foreach($posts as $post) 
     
    141146            </tbody> 
    142147      </table> 
     148      <div class="navigation"> 
     149            <?php 
     150                  // Remove 'miniposts_updated' value from query string, if present, so that 
     151                  // get_pagenum_link() doesn't perpetuate it. 
     152                  $_SERVER['REQUEST_URI'] = preg_replace('/&miniposts_updated=true/', '', $_SERVER['REQUEST_URI']); 
     153                  $_SERVER['REQUEST_URI'] = preg_replace('/\?miniposts_updated=true&/', '?', $_SERVER['REQUEST_URI']); 
     154                  $_SERVER['REQUEST_URI'] = preg_replace('/\?miniposts_updated=true/', '', $_SERVER['REQUEST_URI']); 
     155            ?> 
     156            <div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries')) ?></div> 
     157            <div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;')) ?></div> 
     158      </div> 
    143159      <div class="submit"><input type="submit" name="update_miniposts" value="<?php _e('Update Mini Posts', 'MiniPosts') ?> &raquo;" /></div> 
    144160      </form> 
     
    267283             
    268284            if (!is_plugin_page() && $pagenow != 'post.php' && $pagenow != 'edit.php' && get_settings('filter_mini_posts_from_loop') && !is_single() && !is_archive() && !is_page() && (is_feed() && get_settings('filter_mini_posts_from_feeds') || !is_feed()) && !stristr($text, "wp_postmeta")) { 
    269                   $text .= " LEFT JOIN $wpdb->postmeta ON ($wpdb->posts.ID = $wpdb->postmeta.post_id)"; 
     285                  $text .= " LEFT JOIN $wpdb->postmeta AS miniposts_meta ON ($wpdb->posts.ID = miniposts_meta.post_id)"; 
    270286            } 
    271287             
     
    277293             
    278294            if (!is_plugin_page() && $pagenow != 'post.php' && $pagenow != 'edit.php' && get_settings('filter_mini_posts_from_loop') && !is_single() && !is_archive() && !is_page() && (is_feed() && get_settings('filter_mini_posts_from_feeds') || !is_feed())) { 
    279                   $text .= " AND ($wpdb->postmeta.meta_key = '_mini_post' AND $wpdb->postmeta.meta_value = 0)"; 
     295                  $text .= " AND (miniposts_meta.meta_key = '_mini_post' AND miniposts_meta.meta_value = 0)"; 
    280296            } 
    281297             
     
    323339            $check = $is_mini ? 'checked="checked" ' : ''; 
    324340             
    325             echo '<fieldset><legend><a href="http://doocy.net/mini-posts/help/" title="Help with MiniPosts">' . __('Mini Post', 'MiniPosts') . '</a></legend>'; 
    326             echo '<label for="mini_post"><input type="checkbox" name="is_mini_post" id="is_mini_post" value="1" '. $check . '/> '. __('This is a mini post', 'MiniPosts') . '</label></fieldset>'; 
     341            echo '<fieldset><legend><a href="http://doocy.net/mini-posts/help/" title="Help with MiniPosts">' . __('MiniPosts', 'MiniPosts') . '</a></legend>'; 
     342            echo '<label for="is_mini_post"><input type="checkbox" name="is_mini_post" id="is_mini_post" value="1" '. $check . '/> '. __('This is a mini post', 'MiniPosts') . '</label></fieldset>'; 
    327343      } 
    328344       
     
    334350       
    335351      function mini_admin_menu() { 
    336             add_options_page(__('Mini Post Manager', 'MiniPosts'), __('MiniPosts', 'MiniPosts'), 5, 'mini-posts.php'); 
     352            add_options_page(__('Mini Post Manager', 'MiniPosts'), __('MiniPosts', 'MiniPosts'), 5, basename(__FILE__)); 
    337353      } 
    338354