define('DISALLOW_FILE_EDIT', true); WordPress – unFocus Projects – Kevin Newman and Ken Newman http://www.unfocus.com Home of Scripts 'n Styles for WordPress, Backstage2D and History Keeper! Thu, 03 May 2012 19:44:36 +0000 en-US hourly 1 https://wordpress.org/?v=6.2.5 Scripts n Styles Update 3.1 http://www.unfocus.com/2012/05/03/scripts-n-styles-update-3-1/ http://www.unfocus.com/2012/05/03/scripts-n-styles-update-3-1/#respond Thu, 03 May 2012 19:11:16 +0000 http://www.unfocus.com/?p=4191 Continue reading "Scripts n Styles Update 3.1"]]> Scripts n Styles received a major update today. The two big features added are LESS.js support and Dynamic Shortcodes! The “Global” Settings page now has a LESS editor with syntax highlighting (via CodeMirror) and on-the-fly compiling so you can see how it’ll be outputted on the theme-side. The per-page meta-box has gained a new tab in which you can create one-off shortcodes which can contain arbitrary HTML content.

Scripts n Styles is a free OpenSource GPL project that you can fork and contribute to on github! (You can also fork and contribute to CodeMirror and LESS.js)

As a Shortcode example: I placed the following html into the Shortcodes tab and gave it the name “tweet test”.

[code lang=”html”]
<a href="https://twitter.com/share" data-via="WraithKenny" data-size="large" data-related="unFocusProjects" data-hashtags="ScriptsnStyles">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
[/code]

I then use the shortcode [[sns_shortcode name=”tweet test”]] to display: [sns_shortcode name=”tweet test”]

]]>
http://www.unfocus.com/2012/05/03/scripts-n-styles-update-3-1/feed/ 0
Scripts n Styles update 2.0.1 http://www.unfocus.com/2011/06/24/scripts-n-styles-update-2-0-1/ http://www.unfocus.com/2011/06/24/scripts-n-styles-update-2-0-1/#respond Fri, 24 Jun 2011 20:24:37 +0000 http://www.unfocus.com/?p=634 Scripts n Styles is a tool to allow admins (and editors in single installs) to add scripts and styles without editing template files, or worrying about authors overwriting the code (code is stripped when an author updates since they don’t have permission to use unfiltered html).

Improvements in version 2.0.1:

The meta box has been improved to provide a tabbed interface for less clutter, and syntax highlight and formating is added using the open-source CodeMirror 2.1.

An option has been added to allow adding script to the head element in addition to the traditional bottom of the page spot.

An Options page (under Tools) has been added so you can add Script n Styles to the entire site, rather then just the individual posts and pages.

Some minor code improvements:

  • Better selection of post_types.
  • micro-optimization for storage of class names.
  • Defined a later priority for Scripts n Styles to print after other scripts and styles.
  • Better adherence to coding standards.
  • began contextual help (notes on capabilities).
]]>
http://www.unfocus.com/2011/06/24/scripts-n-styles-update-2-0-1/feed/ 0
WordPress Admin Bar Theme Support http://www.unfocus.com/2011/02/07/wordpress-admin-bar-theme-support/ http://www.unfocus.com/2011/02/07/wordpress-admin-bar-theme-support/#respond Tue, 08 Feb 2011 00:37:01 +0000 http://www.unfocus.com/?p=568 Continue reading "WordPress Admin Bar Theme Support"]]> Here’s a quickie for WordPress Theme designers:

If your theme is getting unwanted scroll-bars because of the new Admin Bar is WordPress 3.1, the core team included a way to handle it. Add Theme Support for it!

With a full height layout, you’ll want to avoid adding a margin or padding to a height that is already at 100% because you’ll get useless scrollbars, and no one wants that. Instead, find the first non-full height element (usually #header or some-such), and apply the margin there (either the 28px for the height of the admin bar, or add 28 to the existing margin if the element already has one). In the code snippet below I assumed you’d create an element or assign the class ‘admin-bar-fix’ to an existing element.

In your theme’s function file, add the following and modify as you see fit: (best to leave out the closing php tag though)
[cc lang=”php”]
< ?php add_action( 'after_setup_theme', 'custom_theme_setup' ); function custom_theme_setup() { add_theme_support( 'admin-bar', array( 'callback' => ‘admin_bar_bump_callback’) );
}
function admin_bar_bump_callback() { ?>

< ?php } ?>
[/cc]

This snippet is derived from the TwentyTen Theme’s function file. The callback’s original code can be found in the source. Original snippet also found commented in the source (props ocean90).

Basically, by declaring support for the new (as of 3.1) “Admin Bar,” you declare that you can handle how your theme’s content gets “bumped” (by default, it gets pushed down by 28px via a margin on the html.) Most of the time the default behavior is fine… but it’s not fine on theme’s that have a height declaration of 100% (even min-height) or that have external scripts that declare 100% height on the html/body (like Google Translate does).

WordPress’s admin needed a similar treatment but that got patched. The 28px margin is just a default to handle most normal cases. Your theme is your responsibility 🙂

Cheers! Hope this saves some time for someone!

Update: Admin Bar Shim!

If you don’t have a 100% height type of layout but are annoyed by improperly scrolling anchored links try the following.

If you add a >div id=”admin-bar-shim”> (for lack of a better name) in your theme surrounding everything inside the body except the wp_footer call (where the admin-bar gets echoed), you can add
[cc lang=”css”]
.admin-bar #admin-bar-shim {
position: fixed;
bottom: 0pt;
left: 0pt;
right: 0pt;
overflow: auto;
top: 28px;
}
[/cc]
to your style sheet, or use the method above adding the callback. This new method allows anchor links to scroll properly.

]]>
http://www.unfocus.com/2011/02/07/wordpress-admin-bar-theme-support/feed/ 0
Update Theme http://www.unfocus.com/2010/03/11/update-theme/ http://www.unfocus.com/2010/03/11/update-theme/#comments Thu, 11 Mar 2010 21:35:09 +0000 http://www.unfocus.com/?p=405 Just a quick note. The old theme (iNove) was creating extra history entries for some reason when you came to unfocus.com. I have no idea why, but that theme is now history. This new theme (iCandy 1.4 by Nischal Maniar) fixes the problem and looks nicer anyway. 🙂

]]>
http://www.unfocus.com/2010/03/11/update-theme/feed/ 1
Testing the WordPress iPhone app http://www.unfocus.com/2009/07/27/testing-the-wordpress-iphone-app/ http://www.unfocus.com/2009/07/27/testing-the-wordpress-iphone-app/#comments Mon, 27 Jul 2009 05:50:06 +0000 http://www.unfocus.com/?p=254 Continue reading "Testing the WordPress iPhone app"]]> Just testing the iPhone app. Seems pretty spiffy. Can’t manage plugins and whatnot but that’s ok. This is pretty good for posting on the go. It supports landscape typing too. 🙂

For fun (and for testing I attached some pics of some cool clouds that rolled right accross the road on the way into work one day). It was fun watching that.

No rich text editor. That’s a significant shortcoming.

]]>
http://www.unfocus.com/2009/07/27/testing-the-wordpress-iphone-app/feed/ 2
Share This sans-prototype.js http://www.unfocus.com/2007/09/08/share-this-sans-prototypejs/ http://www.unfocus.com/2007/09/08/share-this-sans-prototypejs/#respond Sat, 08 Sep 2007 07:05:49 +0000 http://www.unfocus.com/projects/2007/09/08/share-this-sans-prototypejs/ Continue reading "Share This sans-prototype.js"]]> I had a planed to replace the use of Prototype.js in the Share This WordPress plugin, since that was the only plugin using it. Prototype is quite large, and my server isn’t currently set up to gzip javascript files. I started to replace it with jQuery, and add an option to switch between the two. I figured it’d be a good way to help make the blog load more quickly if I make sure all the plugins were using the same (smaller) JavaScript framework.

I found along the way that Share This doesn’t actually use very much of Prototype.js at all. It does a few id based element queries, and uses Prototype’s Position.cumulativeOffset once. So I just converted the dollar sign based id query with DOM standard getElementById, and replaced the cumulativeOffset method call. Then removed the bits that output a prototype.js header link.

That’s it. No more bulky prototype.js dependency!

You can grab the patch from the WP Plugins trac.

While I was at it, I also added gzip support for the js, css and static share-this page, along with a new flag to turn gzip on and off.

Here’s the gzip support patch.

If you’d rather skip all the patching, here is a prepatched share-this.php archive. To use it, download the Share This plugin, and overwrite share-this.php with the new one (patched against the latest from SVN as of this post date).

]]>
http://www.unfocus.com/2007/09/08/share-this-sans-prototypejs/feed/ 0
Case Insensitive Permalinks Plugin for WordPress http://www.unfocus.com/2007/08/31/case-insensitive-permalinks-plugin-for-wordpress/ http://www.unfocus.com/2007/08/31/case-insensitive-permalinks-plugin-for-wordpress/#comments Fri, 31 Aug 2007 06:39:04 +0000 http://www.unfocus.com/projects/2007/08/31/case-insensitive-permalinks-plugin-for-wordpress/ Continue reading "Case Insensitive Permalinks Plugin for WordPress"]]> For a while I have been creating and sending links to History Keeper to http://www.unfocus.com/projects/HistoryKeeper/. When I moved that page into WordPress the URL became lower case, and case sensitive. This can be a problem for those used to Windows and IIS non-case sensitive URLs. To get around the problem, I added a hack to my 404.php error handler (more on that later) that would detect capitals in the permalink URL, convert it to lowercase, and then forward the user to the new page with a php Location header (http redirect). That seemed like a clunky solution, so I made a WordPress plugin that does pretty much the exact same thing, only it’s in a plugin! So that makes it less clunky. Well whatever.

Here’s the code:
[cc lang=’php’ ]
< ?php /* Plugin Name: unFocus.Insensitivity Plugin URI: http://www.unfocus.com/projects/ Description: A plugin to make permalinks case insensitive. Version: 1.0a Author: Kevin Newman Author URI: http://www.unfocus.com/projects/ */ function unFocus_insensitivity() { if (preg_match('/[A-Z]/', $_SERVER['REQUEST_URI'])) { $_SERVER['REQUEST_URI'] = strtolower($_SERVER['REQUEST_URI']); $_SERVER['PATH_INFO'] = strtolower($_SERVER['PATH_INFO']); } } add_action('init', 'unFocus_insensitivity'); ?>
[/cc]
Pretty simple really. Honestly, it doesn’t really even need to use a WordPress hook, just the two lines that convert the $_SERVER variables would do it (assuming those aren’t locked down in the php.ini). But I wanted to learn the plugin API anyway. There is an archive download at the end of this post, just unzip the enclosed file, and put it in your plugin directory, upload it and turn it on. No other configuration necessary.

If there is any interest, I was thinking about adding a config option that would allow you to either forward to the all lowercase URL, or to do what it does now, which is to behave pretty much the way IIS does for any other static files it hosts.

Also, if there’s interest, I may try to figure a way to work this WordPress IIS Permalink 404 handler into the plugin, if it’s possible (IIS users would set their custom 404 handler redirect URLs to redirect to /wordpresslocation/index.php instead of /wordpresslocation/404.php, which is how you do it now):
[cc lang=’php’ ]
< ?php $_SERVER['REQUEST_URI'] = substr( $_SERVER['QUERY_STRING'], strpos( $_SERVER['QUERY_STRING'], ':80' ) +3 ); $_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI']; include('index.php'); ?>
[/cc]
The archive – unFocus.Insensitivity

Update: Fixed the download link.

]]>
http://www.unfocus.com/2007/08/31/case-insensitive-permalinks-plugin-for-wordpress/feed/ 25
Ajax Calendar – Widgetized http://www.unfocus.com/2007/08/31/ajax-calendar-widgetized/ http://www.unfocus.com/2007/08/31/ajax-calendar-widgetized/#comments Fri, 31 Aug 2007 06:00:07 +0000 http://www.unfocus.com/projects/2007/08/31/ajax-calendar-widgetized/ Continue reading "Ajax Calendar – Widgetized"]]> Update: This information applies to Giraffe AJAX Calendar 2.3.1. AJAX Calendar 2.4 was released on September 3, 2007. This information is incompatible with that new version.

Update 2: It seems that this new version is supposed to simply replace the functionality of the old Calendar, without requiring any extra work (so you’d just use the old Calendar Widget, and get the new functionality after the plugin is enabled). So far, I haven’t been able to get the Ajaxy stuff to work, although I can tell that it’s installed, because the calendar is wider in this theme with the new Calendar plugin.

While surfing the web aimlessly, I came across the Urban Giraffe Ajax Calendar plugin for WordPress. It’s not set up to take advantage of WordPress’s built-in Widget support, so I thought I’d add the necessary bits to make it work. Here’s how to do it.

Download the plugin, and add the following code to the bottom of ajax-calendar.php:
[cc lang=’php’ ]
function giraffe_ajax_register_widget() {

if ( !function_exists(‘register_sidebar_widget’) || !function_exists(‘register_widget_control’) )
return; register_sidebar_widget(‘Ajax Calendar’, ‘ajax_calendar’);

}add_action(‘plugins_loaded’, ‘giraffe_ajax_register_widget’);
[/cc]
Additionally, you can avoid a duplicate prototype.js header link, by replacing these lines:
[cc lang=’php’ ]
if ($giraffe_ajax_prototype)
add_action (‘wp_head’, ‘giraffe_ajax_head’);
[/cc]
with these:
[cc lang=’php’ ]
if (function_exists(‘wp_enqueue_script’))
wp_enqueue_script(‘prototype’);
else if ($giraffe_ajax_prototype)
add_action (‘wp_head’, ‘giraffe_ajax_head’);
[/cc]
You can see it working in my sidebar. And I didn’t even have to modify this theme. 🙂

]]>
http://www.unfocus.com/2007/08/31/ajax-calendar-widgetized/feed/ 3