Title: cmarshall's Replies | WordPress.org

---

# cmarshall

  [  ](https://wordpress.org/support/users/cmarshall/)

 *   [Profile](https://wordpress.org/support/users/cmarshall/)
 *   [Topics Started](https://wordpress.org/support/users/cmarshall/topics/)
 *   [Replies Created](https://wordpress.org/support/users/cmarshall/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/cmarshall/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/cmarshall/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/cmarshall/engagements/)
 *   [Favorites](https://wordpress.org/support/users/cmarshall/favorites/)

 Search replies:

## Forum Replies Created

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/users/cmarshall/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/cmarshall/replies/page/2/?output_format=md)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to List Private Posts as Well as Published Ones](https://wordpress.org/support/topic/how-to-list-private-posts-as-well-as-published-ones/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/how-to-list-private-posts-as-well-as-published-ones/#post-606502)
 * Just FYI. I just fixed an error:
 *     ```
       else
       						{
       						$mypost = next ( $posts );
       						}
       					echo '</div>';
       					}
       /* THIS IS THE FIX */		echo '</div> <!-- listposts_new_posts -->';
       			$display = ob_get_contents();
       ```
   
 * You can delete the calendar stuff. I added a filter to remove eventcalendar3 
   entries.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to List Private Posts as Well as Published Ones](https://wordpress.org/support/topic/how-to-list-private-posts-as-well-as-published-ones/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/how-to-list-private-posts-as-well-as-published-ones/#post-606456)
 * Here’s the whole kit n’ kaboodle. Open wide…
 *     ```
       <?php
       /*
       Plugin Name: ListPosts
       Version: 1.0
       Plugin URI: http://www.example.com
       Description: Lists new posts like the front page.. Add <!- - LIST_POSTS - -> to a page or a post to generate the form.
       Author: Example
       Author URI: http://www.exa,ple.com
       */
       function lp_get_the_password_form($id) {
       	$id = "password_$id";
       	$output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post">
       	<p>' . __("This post is password protected. To view it please enter your password below:") . '</p>
       	<p><label for="'.__($id).'">' . __("Password:") . '</label> <input name="post_password" id="'.__($id).'" type="password" size="20" /> <input type="submit" name="Submit" value="' . __("Submit") . '" /></p>
       	</form>
       	';
       	return $output;
       }
       function lp_get_posts()
       {
       	global $wpdb;
       	$today = current_time('mysql', 1);
   
       	return $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5");
       }
   
       function listposts ( $in_content )
       {
       	if ( preg_match ( "/<!-- LIST_POSTS -->/", $in_content ) )
       		{
       		$posts = lp_get_posts();
       		ob_start();
       			?><div class="listposts_new_posts">
       			<div class="listposts_header">Latest Information</div><?php
       				ec3_filter_the_posts ( $posts );
       				$mypost = current ( $posts );
       				while ( $mypost )
       					{
       					if ( !$mypost->ec3_schedule )
       						{
       						$url = get_permalink( $mypost->ID );
       						$title = htmlspecialchars( $mypost->post_title );
       						$meta = '';
       						$cats = wp_get_post_categories ( $mypost->ID );
       						foreach ( $cats as $cat )
       							{
       							if ( $meta )
       								{
       								$meta .= ", ";
       								}
       							$meta .= '<a href="' . get_category_link($cat) . '" title="' . sprintf(__("View all posts in %s"), get_the_category_by_ID($cat)) . '">'.get_the_category_by_ID($cat).'</a>';
       							}
       						ec3_filter_the_content ( $mypost->post_content );
       						$content = $mypost->post_content;
       						if ( !empty($mypost->post_password) )
       							{ // if there's a password
       							if ( stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $mypost->post_password )
       								{	// and it doesn't match the cookie
       								$content = lp_get_the_password_form($mypost->ID);
       								}
       							}
       						$content = apply_filters ( 'the_content', $content );
       						$content = str_replace(']]>', ']]>', $content);
       						$content = get_extended ( $content );
       						echo '<div class="listposts_post">';
       							echo '<div class="listposts_post_title"><a href="'.$url.'">';
       							echo $title;
       							echo '</a></div>';
       							if ( $meta )
       								{
       								echo '<div class="listposts_category_meta">Posted in '.$meta.'</div>';
       								}
       							echo '<div class="listposts_post_teaser">'.$content['main'];
       							if ( $content['extended'] )
       								{
       								echo '<div class="listposts_post_more"><a href="'.$url.'">Read More...</a></div>';
       								}
   
       							$mypost = next ( $posts );
   
       							if ( $mypost )
       								{
       								echo '<div class="post_separator"></div>';
       								}
       							echo '</div>';
       						}
       					else
       						{
       						$mypost = next ( $posts );
       						}
       					echo '</div>';
       					}
       			$display = ob_get_contents();
       		ob_end_clean();
       		$in_content = preg_replace ( "/(<p[^>]*>)*?<!-- LIST_POSTS -->(<\/p[^>]*>)/", $display, $in_content );
       		}
   
       	return $in_content;
       }
       add_filter ( 'the_content', 'listposts' );
       ?>
       ```
   
 *   Forum: [Installing WordPress](https://wordpress.org/support/forum/installation/)
   
   In reply to: [Make Sure You Let People Know [Plugin: enhanced-links]](https://wordpress.org/support/topic/make-sure-you-let-people-know/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/make-sure-you-let-people-know/#post-607731)
 * I meant on the [WP page](http://wordpress.org/extend/plugins/enhanced-links/).
 * Don’t forget that the WP page contains a [direct download link](http://downloads.wordpress.org/plugin/enhanced-links.2.0.3.zip),
   so people often don’t go to the plugin home page.
 * It’s a nice plugin, and scriptalicious isn’t a bad system to have, so I won’t
   lose much sleep over it, but it did mean I spent a few extra minutes figuring
   out why it didn’t work right off the bat.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to List Private Posts as Well as Published Ones](https://wordpress.org/support/topic/how-to-list-private-posts-as-well-as-published-ones/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/how-to-list-private-posts-as-well-as-published-ones/#post-606388)
 * Well, I solved it, but it would have been nice to do it in a less “hacky” fashion:
 *     ```
       function lp_get_posts()
       {
       	global $wpdb;
       	$today = current_time('mysql', 1);
   
       	return $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5");
       }
   
       function listposts ( $in_content )
       {
       	if ( preg_match ( "/<!-- LIST_POSTS -->/", $in_content ) )
       		{
       		$posts = lp_get_posts();
       ```
   
 *   Forum: [Requests and Feedback](https://wordpress.org/support/forum/requests-and-feedback/)
   
   In reply to: [Login Cookies TOO Secure](https://wordpress.org/support/topic/login-cookies-too-secure/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/login-cookies-too-secure/#post-604306)
 * er, that’s “COOKIEHASH”.
 * The file in question is wp-settings.php.
 * The offending section is this one:
 *     ```
       if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) {
           // Used to guarantee unique hash cookies
           $cookiehash = md5(get_option('siteurl'));
       	define('COOKIEHASH', $cookiehash);
       }
   
       if ( !defined('USER_COOKIE') )
       	define('USER_COOKIE', 'wordpressuser_'. COOKIEHASH);
       if ( !defined('PASS_COOKIE') )
       	define('PASS_COOKIE', 'wordpresspass_'. COOKIEHASH);
       if ( !defined('COOKIEPATH') )
       	define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
       if ( !defined('SITECOOKIEPATH') )
       	define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
       if ( !defined('COOKIE_DOMAIN') )
       	define('COOKIE_DOMAIN', false);
       ```
   
 * This calls `get_option('siteurl') and get_option('home')`. However, the plugins
   have not yet been scanned for their add_filter() calls, so the intercepted calls
   are not made.
 * It may be as simple as moving the above section to below this section:
 *     ```
       if ( get_option('active_plugins') ) {
       	$current_plugins = get_option('active_plugins');
       	if ( is_array($current_plugins) ) {
       		foreach ($current_plugins as $plugin) {
       			if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/' . $plugin))
       				include_once(ABSPATH . PLUGINDIR . '/' . $plugin);
       		}
       	}
       }
       ```
   
 * But I’m not so sure about that. Some of the plugins may need the constants above
   defined.
 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [How to only show the latest post on custom index.php?](https://wordpress.org/support/topic/how-to-only-show-the-latest-post-on-custom-indexphp/)
 *  [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/how-to-only-show-the-latest-post-on-custom-indexphp/#post-603167)
 * If anyone is interested, I wrote a plugin that does something similar. Check 
   out the main page in my profile link. At the moment, there is only one post there,
   but it will list the latest five non-event posts.
 *   Forum: [Your WordPress](https://wordpress.org/support/forum/your-wordpress/)
   
   In reply to: [Attacked for using WordPress](https://wordpress.org/support/topic/attacked-for-using-wordpress/)
 *  [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/attacked-for-using-wordpress/#post-604246)
 * Don’t worry about. Doesn’t sound like a forum that I’d find very useful.
 * I like to play in [Webmaster World](http://webmasterworld.com). They’re grown-
   ups there (mostly -I think I shorted the curve a bit).
 *   Forum: [Your WordPress](https://wordpress.org/support/forum/your-wordpress/)
   
   In reply to: [Heavy-Duty Google Maps Implementation](https://wordpress.org/support/topic/heavy-duty-google-maps-implementation/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/heavy-duty-google-maps-implementation/#post-603684)
 * Hmpf. Nothing, huh? No big deal.
 * However, it looks like the problem is really a usability one. I’m used to including
   links very subtly inline, and the WP theme for these forums makes links darn 
   near invisible.
 * In any case, here’s a bigger link:
 * **[BIGGER LINK](http://littlegreenviper.com/main/?page_id=4&results_sel=1&long=-73.96820068359375&lat=40.62854560636584&radius=5&zoom=12&weekday=0&sasna_boundary_checkbox=false)**
 * This is done with a plugin and a theme. They work together.
 *   Forum: [Your WordPress](https://wordpress.org/support/forum/your-wordpress/)
   
   In reply to: [MY VERSION OF WORDPRESS IS ALL MESSED UP!](https://wordpress.org/support/topic/my-version-of-wordpress-is-all-messed-up/)
 *  [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/my-version-of-wordpress-is-all-messed-up/#post-603676)
 * First of all, you can get older versions [here](http://wordpress.org/download/release-archive/).
 * Second, there are a number of reasons that the upgrade may have broken. I suspect
   that you may not have confined your mods to the wp-content directory, or that
   you are relying on a plugin that can’t handle the upgrade. I had to delete all
   my admin theme plugins because they broke when used with other plugins. I stick
   with the vanilla admin theme.
 * I do constant backups of the DB and source. If there is a problem, I can always
   revert. I recommend that you follow a similar best practice.
 * If you do an upgrade, logging into the admin should invoke a DB upgrade. In many
   cases, this is simply a version change, but it could be more comprehensive.
 * Again, I cannot say this strongly enough: **USE THE wp-content DIRECTORY FOR 
   ALL YOUR MODS!** It’s quite possible to do [radical changes to the appearance and operation of the site without hacking the core](http://littlegreenviper.com/main/?page_id=4&results_sel=1&long=-73.96820068359375&lat=40.62854560636584&radius=5&zoom=12&weekday=0&sasna_boundary_checkbox=false).
   Also, even if you do stick with the wp-content directory, you could rely on internal
   calls that may not survive upgrades.
 * Also, be conservative with which plugins you use. Plugins may not survive upgrades
   very gracefully, especially big upgrades. A good example is what happened to 
   the Role Manager plugin. It broke in 2.2. Luckily, [a German guy took it over and applied a fix](http://www.im-web-gefunden.de/wordpress-plugins/role-manager/).
   Plugins can also step on each other. I had to remove the wp-sticky plugin because
   it stepped on the event calendar 3 plugin, and I decided that I needed events
   more than sticky posts.
 * Good luck.
 *   Forum: [Your WordPress](https://wordpress.org/support/forum/your-wordpress/)
   
   In reply to: [Looking for feedback on my theme](https://wordpress.org/support/topic/looking-for-feedback-on-my-theme/)
 *  [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/looking-for-feedback-on-my-theme/#post-602583)
 * I like it. You do have to be a green lover to get into it, but I like green.
 * I like the fact that the two backgrounds sync up so well.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Accessing Page Content in wp_head()](https://wordpress.org/support/topic/accessing-page-content-in-wp_head/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/accessing-page-content-in-wp_head/#post-593245)
 * Just an update. I was able to hack this without TOO much nose-holding, thusly:
 * In my wp_head handler:
 *     ```
       if ( $_GET['page_id'] )
       		{
       		$page = get_page ( $_GET['page_id'] );
       		}
       	elseif ( $_GET['p'] )
       		{
       		$page = get_post ( $_GET['p'] );
       		}
   
       	if ( $page )
       		{
       		$page = $page->post_content;
       		}
   
       	if ( preg_match ( "/<!-- MY_TRIGGER_COMMENT -->/", $page ) )
       		{
       		echo '<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key='.$gkey.'" type="text/javascript"></script>'."\n";
       		}
       ```
   
 * That does it for now. I still have a lot of testing to go, so we’ll see how it
   holds up (I need to test the plugin as a post, as opposed to a page. It may need
   work).
 * I have to take some issue with the philosophy that **_any_** aspect of a project
   is “not debatable.” In my world, the User Experience is always king, and we should
   be doing everything we can to always optimize the UE.
 * The “that’s just the way it works” outlook is one that is very attractive to (
   and typical of) engineers and “purists.” We become enamored with the beauty of
   the design or philosophy, and blind to the UE.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Accessing Page Content in wp_head()](https://wordpress.org/support/topic/accessing-page-content-in-wp_head/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/accessing-page-content-in-wp_head/#post-593227)
 * That’s pretty much what I thought.
 * Here’s why I ask (Actually, this is very much a debatable issue, and should be
   debated):
 * I have a mondo heavy-duty plugin that displays some real bitchin’ [Google Maps](http://www.google.com/apis/maps/documentation/)
   stuff.
 * Kewl, Knarly, etc. <wave hang-ten fingers/>
 * The problem is that the GM API is REAL BIG, and introduces SERIOUS lag time to
   the page. I just found out that the GM API sticks <style> tags in their include,
   so I can’t reference it from the content.
 * This means that EVERYONE, whether or not they will ever use the GM stuff, has
   to pay for it.
    — UPDATE: I’ll probably write some real, bloody, dripping, machete-
   style hack that will look for a “page_id” or a “p” in the argument list, and 
   will read the content from the DB (bad thing to do, as it bypasses all kinds 
   of nice stuff). I’ll peek in the content to see if my trigger comments are there.
   If so, I’ll include the files. If not, I’ll just skip them.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Intercepting the New “home” and “siteurl” bloginfo](https://wordpress.org/support/topic/intercepting-the-new-home-and-siteurl-bloginfo/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/intercepting-the-new-home-and-siteurl-bloginfo/#post-592524)
 * [Resolved Here](http://wordpress.org/support/topic/125613?replies=3#post-587796).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Sorry-WP Went Whacky. I Need Examples of Using the “option_xxx” Filter.](https://wordpress.org/support/topic/sorry-wp-went-whacky-i-need-examples-of-using-the-option_xxx-filter/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sorry-wp-went-whacky-i-need-examples-of-using-the-option_xxx-filter/#post-592894)
 * **REALLY ANNOYING FOLLOW-UP:**
    This won’t work for admin. Admin re-loads straight
   from the DB, so it can’t be patched. Probably more secure, but it means that 
   you need to hack the core to use admin on local machines without going in and
   changing the database.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [Sorry-WP Went Whacky. I Need Examples of Using the “option_xxx” Filter.](https://wordpress.org/support/topic/sorry-wp-went-whacky-i-need-examples-of-using-the-option_xxx-filter/)
 *  Thread Starter [cmarshall](https://wordpress.org/support/users/cmarshall/)
 * (@cmarshall)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/sorry-wp-went-whacky-i-need-examples-of-using-the-option_xxx-filter/#post-592889)
 * Okay, I got it working.
 * I remember someone once saying that filter/hook function names should always 
   be lowercase, so that’s what I did, and now it works just ducky.
 * This could be a useful function for people who like to have test laptops with
   all kinds of virtual systems (like I do), so I’ll share my very simple patcher.
   You will need to add your own local URIs:
 *     ```
       <?php
       /*
       Plugin Name: localhosts
       Plugin URI: http://...
       Description: Makes things local, for testing.
       Version: 1.0
       */
       function get_uri( $ret )
           {
           if ( preg_match ( '|10\.211\.55\.2|', $_SERVER['SERVER_ADDR'] ) )
               {
               $ret = "http://10.211.55.2/.../public_html/main";
               }
           elseif ( preg_match ( '|127\.0\.0\.1|', $_SERVER['SERVER_ADDR'] ) || preg_match ( '|localhost|', $_SERVER['REQUEST_URI'] ) )
               {
               $ret = "http://localhost/.../public_html/main";
               }
           return $ret;
           }
   
       add_filter ( 'option_home', 'get_uri', 10, 1 );
       add_filter ( 'option_siteurl', 'get_uri', 10, 1 );
       ?>
       ```
   

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/users/cmarshall/replies/page/2/?output_format=md)
[→](https://wordpress.org/support/users/cmarshall/replies/page/2/?output_format=md)