Internet Explorer 6 is not supported.
Upgrade to view this site.

Blog Archive

Results for the blog category PHP.

Current URL in WordPress

This seems like it should be a given, but it seems that WordPress has no easy function to get the current URL. I didn’t want to use $_SERVER variables to get the URL, but after finding no good WordPress solution, I decided to bite the bullet and just make up a $_SERVER solution for the time being.

Some time passed, I forgot about it and found some other headaches to occupy my time. Then I found this post with a solution that was to my liking. The only thing that I didn’t like about it was that it always appended the original query string, whether you were using permalinks or not. I added a little conditional to it and now I have a current_url function that I wouldn’t kick out of bed.

		function current_url($trailingslash = false)
			global $wp;
			$current_url = isset($wp->request) ? home_url($wp->request) : add_query_arg($wp->query_string, '', home_url());
			return $trailingslash ? trailingslashit($current_url) : $current_url;

Abramski Site Launched

As I write this post, I am uploading a mess of files that I’ve been working on for the past month or two that make up the first real Abramski site. I use the word real, because I don’t believe downloading a theme you like and calling it your own flies if you are any type of developer or designer. For years now, I’ve had a theme or two up here masquerading as my site while I wrote some blog posts and I’m somewhat embarrassed about it. I had no portfolio to speak of because I had no work that felt like my own that I really wanted to showcase. This site was always meant to be a priority but like many other designers and developers, I put off getting this site together for years. Read more …

PyroCMS Fonts Module

I just released an addon module for PyroCMS. For those of you that may not know, PyroCMS is a content management system built on Codeigniter. For those of you that may not know Codeigniter, Google that shit. I can’t explain everything.

The Fonts module manages, protects and obfuscates webfonts. Your webfonts are protected by checking HTTP_REFERER to make sure that only requests from your website will be allowed to download the fonts. Direct directory download of the fonts is denied with an .htaccess rule in the fonts directory. The physical location of your fonts is hidden with programatic access through an encoded link. Read more …

Looping with Nested Views in CodeIgniter

I have been using CodeIgniter on my most current project and I am really happy with the way it works. If you know anything about MVC and OOP, there is very little learning curve to get moving with this framework.

CodeIgniter allows you to create views to display information passed in from the controller and the models of the application. Usually if you are sending arrays of information to display you will have to loop over the array. I like to write as little markup as possible so I nest views of markup that are reusable. I came across a problem where I wanted to load a view in the middle of a loop and have that nested view be aware of where it is in the loop. I needed the information from that position in the loop. The nested views have access to the variables sent by the controller, but doesn’t keep track of foreach iteration variables.

Here is the solution that I cooked up to get that information over to the nested view. Instead of using a foreach loop I use just a for loop and pass the iterator over in the view’s data parameter. Below is pseudocode of how this might look.

<?php for($i = 0; $i < count($items); $i++): ?>
<h1><?php echo $items[$i]['title']; ?></h1>
<?php $this->load->view('nestedview', array('i' => $i)); ?>
<?php endfor; ?>

Uploader WordPress Plugin

I’ve written my first WordPress plugin and added it to WordPress’ plugin repository. It is available for download here. It’s a pretty simple plugin that I hope to add into a larger plugin that I am planning to put together for the rollout of my personal site, which has been a long time coming. Now that I don’t have a job, maybe I can complete some of these projects I have building up over the years. Below is the description of the plugin.

Uploader creates an Uploader role (a Subscriber role with an extra uploader_upload capability) for blind file uploading within wp-admin after credentials have been input in wp-login.php. This plugin is based on the Uploadify project.