0

St. Louis WordPress Users Group

Posted by Eric Juden on Jun 30, 2010

Lately I’ve been thinking it would be good to start a St. Louis WordPress users group. I’d love to attend some of these and meet some other WordPress people in the St. Louis area. The idea of having a St. Louis WordCamp is also appealing, but I think it would be beneficial to find out how many people are interested in WordPress before investing the time for a WordCamp.

So who out there has a place to host such an event and would want to put it on? I’d be happy to help, but I’m not sure I’d be able to make it to every meeting. I wouldn’t want to be the point person, I’m just trying to get the ball rolling.

EDIT: I did come across a group on Facebook, the St. Louis and St. Charles WordPress Users Group. I signed up, but it doesn’t seem very active.

EDIT x2: I just found a meetup group for STL WordPress: http://www.meetup.com/stlwordpress/

Bookmark and Share

0

WordPress 3.0 and Menu Dropdown Box

Posted by Eric Juden on May 25, 2010

I’ve started to play around with WordPress 3.0 Beta 2 and the new menu system it has. While playing around with it, I thought it might be nice to include a dropdown box of menu choices on a settings page for a theme. So I made a function similar to that of the dropdown box for categories (wp_dropdown_categories). I called this one wp_dropdown_nav_menus.

function wp_dropdown_nav_menus($args = ''){
	$defaults = array(
		'echo' => 1,
		'id' => '',
		'orderby' => 'name', 
		'order' => 'ASC',
		'hide_empty' => 1,
		'selected' => 0,
		'class' => 'postform',
		'tab_index' => 0,
		'show_option_all' => '', 
		'show_option_none' => '',
	);
 
	$r = wp_parse_args( $args, $defaults );
	extract( $r );
 
	$tab_index_attribute = '';
	if ( (int) $tab_index > 0 )
		$tab_index_attribute = " tabindex=\"$tab_index\"";
 
	$terms = get_terms( 'nav_menu', array( 'hide_empty' => $r['hide_if_empty'], 'orderby' => $r['orderby'], 'order' => $r['order'] ));
	
	if(! empty($terms)){
		$output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
 
		if($show_option_none){
			$selected = ( '-1' === strval($r['selected']) ) ? " selected='selected'" : '';
			$output .= "<option value='-1'$selected>$show_option_none</option>";
		}
 
		if ($show_option_all) {
			$selected = ( '0' === strval($r['selected']) ) ? " selected='selected'" : '';
			$output .= "\t<option value='0'$selected>$show_option_all</option>\n";
		}
 
		foreach($terms as $menu){
			$selected = ( $menu->term_id === strval($r['selected']) ) ? " selected='selected'" : '';
			$output .= "<option value='$menu->term_id'$selected>$menu->name</option>";
		}
		$output .= "</select>\n";
	}
 
	if ($echo){
		echo $output;
	}
 
	return $output;
}

If you want to use this in your code, please change the prefix of the function from wp_ to something more useful for your purpose. Just in case WordPress comes out with a function similar to this one.

Bookmark and Share

0

Piwik Analytics

Posted by Eric Juden on Oct 15, 2009

Has anyone messed with Piwik Analytics? I just got it setup on thejudens.com yesterday, and so far it seems pretty slick. The one thing I like most about it is that the data is mine! I don’t have to share it with google! Right now we have both google analytics and piwik running on the server. I’m going to let them run and see how they compare with each other. I’m just kind of curious how close the results will be with the other. I’ll report back later and let everyone know.

In the meantime, you better go check out Piwik. It runs on php/mysql and you can most likely install it on your hosting account.

Bookmark and Share

18

WordPress MU List Blogs

Posted by Eric Juden on Aug 31, 2009

I recently had to make a list of all the active blogs for the university’s blog site running WordPress MU. Here’s the code to do so:

<?php if(is_front_page()){?>
    <h1>Blog Directory</h1>
 
<?php
    global $wpdb;
    $query = "SELECT blog_id FROM " . $wpdb->base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' AND blog_id != '1' ORDER BY path";
    
    $blogs = $wpdb->get_results($query);
    
    echo '<ul>';
    foreach($blogs as $blog){
        $blog_details = get_blog_details($blog->blog_id);
        echo '<li><a href="'. $blog_details->siteurl .'">' . $blog_details->blogname .'</a></li>';
    }
    echo '</ul>';
}
?>

You’ll notice the query is set to filter out blogs that are marked as archived, spam, private. Also, it hides the main blog from the list.

Bookmark and Share

1

Newsletter Converter 1.0.6 Released

Posted by Eric Juden on Aug 10, 2009

Not sure if anyone has noticed, but the Newsletter Converter for WordPress has been updated to version 1.0.6. Hopefully this release fixes a lot of the timeout issues people were experiencing. You also have the ability to use cURL instead of php’s file_get_contents() function, which is apparently not enabled on a lot of web hosts…go figure.

If you are happy with it, feel free to buy me a beer (in the sidebar).

Bookmark and Share

33

jQuery Image Resize

Posted by Eric Juden on Jul 08, 2009

Let me start off by saying, I LOVE jQuery! It’s the greatest thing since sliced bread! Now that I have that out of the way, I’ve been working on developing some WordPress themes for work. We are going to be launching a blogs site (using WordPress MU) fairly soon for faculty, staff, and eventually students. So, in the process we are building a blog that will be used as an online newsletter. On the blog page, they want the top story to take precedence, and for the image to be larger. So to accomplish this, I wanted to scale down the other images and keep the aspect ratio. Enter jQuery…

I was looking out there at some of the solutions already completed. I didn’t see anything that quite did what I was looking for. So I made my own function:

$(document).ready(function() {
    $('.story-small img').each(function() {
        var maxWidth = 100; // Max width for the image
        var maxHeight = 100;    // Max height for the image
        var ratio = 0;  // Used for aspect ratio
        var width = $(this).width();    // Current image width
        var height = $(this).height();  // Current image height
 
        // Check if the current width is larger than the max
        if(width > maxWidth){
            ratio = maxWidth / width;   // get ratio for scaling image
            $(this).css("width", maxWidth); // Set new width
            $(this).css("height", height * ratio);  // Scale height based on ratio
            height = height * ratio;    // Reset height to match scaled image
            width = width * ratio;    // Reset width to match scaled image
        }
 
        // Check if current height is larger than max
        if(height > maxHeight){
            ratio = maxHeight / height; // get ratio for scaling image
            $(this).css("height", maxHeight);   // Set new height
            $(this).css("width", width * ratio);    // Scale width based on ratio
            width = width * ratio;    // Reset width to match scaled image
        }
    });
});

The 2nd line of code says to grab every image with a class of ‘story-small’. The block for the height is just a safety net. I have it there in case the height is still larger than the max. There are a hundred ways to skin a cat, so I’m sure there are plenty of other ways to do this.

Bookmark and Share

0

HttpWebRequest and Multiple Files

Posted by Eric Juden on Jun 24, 2009

I’m working on a project at work right now to pull inventory data from the bookstore’s point-of-sale system into the e-commerce site I’m setting up for them. One of the parts in the process is to check the web server for any new/updated images for the items on the website. I am doing a web request for each image on the server to see if I really does exist. After doing so many, I noticed that all of the files kept coming back saying they weren’t there, when I know darn well they are! So after a little research online, I noticed that you need to close your Response object when you are finished with it.

Here’s my code:

private static bool _FileExists(string filename) {
    try {
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(filename);
        req.Timeout = 5000;
        req.Method = "HEAD";
        HttpWebResponse response = (HttpWebResponse)req.GetResponse();
 
        if (response.StatusCode == HttpStatusCode.OK) {
            response.Close();    // IMPORTANT
            return true;
        } else {
            response.Close();    // IMPORTANT
            return false;
        }
    } catch(Exception ex) {
        return false;
    }
}

The big thing to note here is when I’m calling response.Close(), as that closes out the connection. So if you are experiencing issues where you keep getting time out errors, give this a try. Here’s the original article that helped me.

Bookmark and Share

0

FLV 404 Error on Windows Server 2003

Posted by Eric Juden on Sep 11, 2008

Wow! That was a wierd problem. I haven’t done much with embedding videos online before, so I’m learning a lot about the nuances. I was getting a 404 error from a .flv file that I was using with a flash .swf file. Luckily, there’s been other people with the same problem (I love google).

  1. On the Windows 2003 server, open the Internet Information Services Manager.
  2. Expand the Local Computer Server.
  3. Right-click the local computer server and select Properties.
  4. Select the MIME Types tab.
  5. Click New and enter the following information:
    • Associated Extension box: .FLV
    • MIME Type box:flv-application/octet-stream
  6. Click OK.
  7. Restart the World Wide Web Publishing service.

The original article I found is here

Bookmark and Share

0

Windows Mobile Event Viewer – First Release

Posted by Eric Juden on Apr 10, 2008

Alright troops…who’s gonna be first to test out the latest and greatest Event Viewer for Windows Mobile?

I’m not going to say its perfect, because the only person to test it has been me! If you don’t like it, then just don’t tell your friends about it. If you do like it, by all means get your developer friends to use it in their Windows Mobile applications.

You can download the files here.

Bookmark and Share

0

Windows Mobile Event Viewer

Posted by Eric Juden on Feb 06, 2008

Well, I started in on a new project last night. This project will essentially be an event viewer for windows mobile devices. One of my concerns is that it won’t log events from the device…I’m not exactly sure how to hook in to device events yet. I can’t guarantee that this application will be running all the time to record device events, so I am thinking mainly of using it for application developers that want to use it to record events from their programs. They will be able to call a
method and pass all the information to create a new event in the event log.

I’ll post something worthwhile when it gets a little farther.

Bookmark and Share