Adding a little style

Last night I decided to clean up the home page a little bit. The plugins I am working on are being used on the home page and they don’t have any styling to them. It was just basic output of the RSS feed. It looked pretty ugly. So, after getting back from watching 300, I decided that I should do a little clean-up.

I used the same basic css style sheet being used in the WP People plugin for the popup window. I just changed the colors and the border lines a little bit for now. Just a quick fix to make things look a little better. I am hoping that I can add the same quick fix to the phpBB Latest Posts and the 4images Latest Images plugins. At least that way, event without the correct feed working, it will still look better than raw data being displayed.

I also added the RSVP stats image to the home page. Meetup provides a graph that shows the number of people who have RSVP’d for each month. It only shows 6 months at a time and only the Organizer can see this graph. I have been taking the graph and putting it together with previous images to create an almost full year graph. I think I will probably get around to creating a little database table to store the monthly totals in and providing a dynamic graph.

So much to do.

WP People – style sheet done, style sheet problems.

Well, I went to Big Bear’s site and went through the float tutorial/example to get some ideas for the popup window. Obviously, I took a lot of the ideas from it. i will probably go back and touch it up a little more, to make it more mine. However, after I did get the basics working so that it looks great in FireFox, I checked out what it looked like in IE. Well, the styles weren’t showing up in IE!!! At first I thought it was a problem with the style tags, but when I looked at the example popup outside of WP People, the styles look fine in IE. So, it is something to do with the iBox. It seems that none of the style properties are being passed, so my guess it is something about including the style sheet. I tried both a header link

and a include
nclude($_SERVER['DOCUMENT_ROOT'] . $GLOBALS['blogRoot'] . '/wp-content/plugins/wp-people/wp-people-css.css');
But, neither seems to work. So, for now, I am just going to leave it like it is, no styles for IE.

I also had to use the WordPress Force Word Wrapping Plugin to keep the text from exanding past the popup window. I think there is some code I have to add to the header of the plugin to let people know that they need the other plugin. Obviously it will be part of the install description.

I am glad I am getting closer to finishing the plugin upgrade.

WP People, making it clean

Well, I was looking through the coding standards on Word Press. There was something in there about usingwpdb for database calls. I figured; okay, this shouldn’t be too hard, just switch over the query calls to wpdb->query and everything will be fine. Whoa nelly!! Man, that wasn’t as simple as I thought. I had to take out all of my error handling. I guess that the wpdb class has enough error handling. But, methods I were using to determine if the values were empty and such just didn’t work. It took me a lot longer than I expected to get the database calls working again. Hopefully this is the hardest change to cleaning up my code.

One of the issue about the coding standards is using the braces {} in an if statement. The funny thing is, the standards tell you to read the Hackers mailing list to get information. When I went to the link, it was bascially and argument about whether or not to use the braces. Well, I will still use the braces, I think it makes it easier to read the code. I will clean it up so that the format is similar to Word Press style.
if ( (condition1) || (condition2) ) {
action1;
} elseif ( (condition3) && (condition4) ) {
action2;
} else {
defaultaction;
} // end blah

This will probably take me another couple of days to get around to. Then it will all about working on the style sheets. I think I am going to have a style sheet just for the WP People Popup. Trying to use the sytle provided through a theme is not going to work. However, since it will use a style sheet, the user can easily adjust that css file.

The last thing I am going to do is go through and globalize/internationalize/localize the plugin. I’ve never done that before, so this will be new territory. I don’t have a lot of places to fix, so once I figure out how it works, then it shouldn’t take long at all.

Custom menu update

Well, d’uh!!!

My basic problem was that an Author is at Level 2. For some reason I thought it was higher.
So, when I added the menu, I had to have the minimum level at 2. There is also the option to allow someone to have access based on their capability. Since I wanted this available for someone who can create post, I changed the level 2 to publish_posts.

// mt_add_pages() is the sink function for the 'admin_menu' hook
function mt_add_pages()
{
add_management_page('WP People', 'WP People', 'publish_posts', 'wp-people','wp_people_admin');
}
// Insert the mt_add_pages() sink into the plugin hook list for 'admin_menu'
add_action('admin_menu', 'mt_add_pages');

Now my WP People menu item now shows up in the Manage area. All I have to do now is fix the css styling on the popup window and do some code clean up and WP People version 2.0 will be done. Yeah!!

WP People version 2.0 getting closer

I am getting closer to finishing the WP People version 2.0.
I have the administration page work. I have the install and upgrade buttons working. I also have the post replacement part working. All that is left is putting the link on a different menu so that Authors can update their WP People. Also, I need to format the css for the popup display.

So, after getting the install/update feature working, I figured out that only the Admin could see the WP People link on the User page. I figured this wasn’t good, because I setup WP People so that different users could have different WP People lists. So, the menu link needed to go somewhere else, because the User menu is not available to Authors. I tried to find a way to put it on the Profile menu, but couldn’t. Then I read about adding menus in the codex, but that didn’t seem to help me, because it talked about adding the menus in the Admin menu. So, it would still get back to only people with access to the Admin menu could see the new menu item.

However, I did decide that it would be better to add the WP People link to the Manage menu. It makes sense to manage the list there, since the links end up in the posts.

I think I might have to find some sort of plug-in to do this. Maybe like this one.

We’ll see how it goes.

WP People the next generation

Well, I’ve been working on updating the WP People hack to a WP 2.0 plugin.
Last night I was trying to get the links working. The biggest issue I had was pointing to the correct directory for the JavaScript and php files that creates the popup layer. Since not everyone has their blog on the root directory or as in my case, one level down, I can’t just go to the root and go from there. Also, not everyone named their blog directory “blog” or “wordpress”.

So, in the plugin part was easy, sort of

get_option('siteurl')

That got me the root and then I just went up from there, since everyone who uses 2.0 has to use the correct file structure. The next problem after that was putting it into the header. After searching through the codex stuff, I finally figure out how to do that.


function ibox_wp_head($unused)
{
$blogSiteURL = get_option('siteurl');
echo "<script type=\"text/javascript\" src=\"" . $blogSiteURL . "/wp-content/plugins/wp-people/ibox.js\"></script>";
echo "<link rel=\"stylesheet\" href=\"" . $blogSiteURL . "/wp-content/plugins/wp-people/ibox.css\" type=\"text/css\" media=\"screen\" />";
}
add_action('wp_head', 'ibox_wp_head');

By creating a function to insert the JavaScript and Style sheet links and then adding that function to the “wp_head” hook, I can place my code in the header area without breaking the site.

In the popup file, I had to be a little more creative. Since the popup file isn’t part of the blog structure, I can’t use the function to determine where the site root was.
$uriPieces = explode("/",$_SERVER['PHP_SELF']);
$key = array_search('wp-content', $uriPieces);
$blogRoot = "/wp-blog-header.php";
if($key > 0)
{
$blogRoot = "/" . $uriPieces[$key - 1] . $blogRoot;
}
require($_SERVER['DOCUMENT_ROOT'] . $blogRoot);

So, I found the current location of the page, split it up into an array, and then checked to see where the “wp-content” file was. From there, I just went down one level to get the blog root.

In the JavaScript I had to determine where the root image directory was.
var thisDomain = document.domain;
This gives me the document domain and from there I get the image directory.