This tweak will change the “All Posts” page in the administration section of a WordPress site.
It adds the ability to filter the post list based on a custom field that has been used in any of the posts at any time. Continue reading
This tweak will change the “All Posts” page in the administration section of a WordPress site.
It adds the ability to filter the post list based on a custom field that has been used in any of the posts at any time. Continue reading
Content in the visual post editor (TinyMCE) in WordPress doesn’t look that much like the finished article by default. Thankfully WordPress includes a style sheet that we can use to make things better.
The editor style sheet is called “editor-styles.css” and can be found in the root folder of the active theme along side the main style sheet “styles.css”.
There is a really simple way to make the editor content look more like the live and to include all of the styles from the main style sheet. Simply include the main style sheet at the top of the editor style sheet:
/* Start with the the theme styles */
@import url("style.css");
Then add an override for the content width to match your theme and force the background to be white (or to match your theme):
html .mceContentBody {
max-width: 640px;
background-color: white;
}
And there you have it. You might note that the editor style sheet for the twentyeleven theme is vastly more complex than this but I suspect that nearly all of the settings are already in the main style sheet and so are no longer required. You may of course find that you need to add a few more tweaks to cater for “edge cases”.
You might also note a number of articles on the web that suggest that you need to do this by an addition to your functions.php file like this:
// @since 1.2.0 IT, add theme styles to TinyMCE visual editor
add_action(‘after_theme_setup’,‘jk_theme_setup’);
function jk_theme_setup(){
add_editor_style('style.css');
}
But in fact, this isn’t required if we simply change the editor style sheet as suggested which I think is much easier to manage and maintain.
Most web designers are well aware of the need to design with accessibility in mind and that this is a legal requirement in many countries.
Not so many IT architects and designers who deal with internal, enterprise systems are aware, though, that these laws and requirements also apply to internal systems.
Recently I’ve yet again seen a number of dreadfully designed user interfaces (UI) for enterprise systems that most certainly don’t meet usability standards let alone accessibility standards! Continue reading
“Jash is a DHTML-based window that gives you command-line JavaScript access to the current browser window. With this console you can quickly debug scripts, manipulate the DOM, view the current page’s objects, functions, and variables, execute arbitrary Javascript, enter new CSS (in IE, Firefox, Opera, and Safari), and much more.” – A useful tool to execute JavaScript, make live (temporary) CSS changes to a page, discover the page structure, etc. for developers. Written totally in JavaScript so can be used on any platform with any browser. Include in your own pages for debugging or load via a bookmarklet to run on any page.
Well this one threw me!
I was trying out the new custom post types in WordPress 3.0 RC1 and could not work out why mine wasn’t working even when I copied an example from the web and only changed a few things.
It turns out that there is a limitation in the naming of post types – they cannot have a name longer than 20 characters!
If you use more than 20 characters, the “Publish” button becomes “Submit for Review” and if you submit, you get the dreaded:
Are you sure you want to do this?
Please try again.
error.
I need to find a load of addresses by proximity to a postcode. I have the addresses in a Microsoft Access database.
Well, I couldn’t be bothered to fight with Access so I exported the key tables and used Excel instead!
The principals are the same. Load the tables as tabs, load the Postcode data as a tab. Create a front sheet containing the reference Postcode (Create a Named Cell for this “STARTREGION”). Translate the reference Postcode to Latitude and Longitude by doing a VLOOKUP to the Postcode table, e.g.:
=VLOOKUP(TRIM(LEFT(RC2,SEARCH(" ",RC2 & " "))),UK_PostCodes!C1:C4,3,FALSE)
Where RC2 contains the reference Postcode and “UK_PostCodes!C1:C4″ is the postcodes table (column 3 contains the Latitude and 4 the Longitude). Note that I’ve used R1C1 reference style as it is easier to mix fixed and relative references.
Now use the same formula in the main data tables so that you have Lat. and Long. columns added based on the Postcode on each line.
Finally add a “Distance” column to each data table with the following formula:
=ROUND(DEGREES(ACOS(SIN(RADIANS(STARTLAT))*SIN(RADIANS(RC28))+COS(RADIANS(STARTLAT))*COS(RADIANS(RC28))*COS(RADIANS(STARTLON-RC29))))*60*1.1515,0)
In this case, we’ve used the STARTREGION named cell and the Lat./Long. data is in columns 28 & 29 respectively.
The calculation and Postcode reference data came from HM2K’s website: How to search by nearest uk postcode in php.
One handy function I’ve added to .bashrc (so it is always available) under Cygwin (the LINUX command environment for Windows) works out the current working version of a document. It assumes that you keep copies that have a version number or date in the file name that will sort correctly.
# Opens the latest version of a file using the Windows default application
# Assumes that you have a range of files that can be identified using some for of prefix
# and that the last part of the file contains a version number or date that sorts in the correct order
# e.g. myfile-lots-of-rubbish-20090720-01.doc & myfile-lots-of-rubbish-20090723.01.doc
# Two arguments are required. The first is the PATH to search in. The 2nd is the shared file prefix (e.g. 'myfile-lots-of-rubbish-')
# Put single quotes around the arguments to prevent them from being GLOBed by the shell.
# Only searches in the GIVEN path, not subfolders.
# Use with an ALIAS to have an easy way of opening a specific file from the shell
function cyOpenLatest {
# We have to use find rather than ls because of shell expansion issues in the arguments (and problems with spaces in file/folder names)
res=`find "$1" -iname "${2}*" -type f -prune -printf '%f\n' | sort -r | head -1`
# Work out the file type from the .ext
ext=`echo $res | sed "s/.*\.//"`
# Add whatever you want to this list above the *)
case $ext in
doc*) TYPE="in Word" ;;
xls*) TYPE="in Excel" ;;
ppt*) TYPE="in PowerPoint" ;;
vsd*) TYPE="in Visio" ;;
*) TYPE="with Windows default application"
esac
if [ "$res" != "" ]; then
echo "Opening [$res] $TYPE"
cygstart "$res"
fi
}
You can use it with an alias like this:
alias gic="cyOpenLatest '$HOME/Documents/Here is a folder with a space or two/' 'a-document-'"
If you name your documents sensibly such as “a-document-2009-07-20.doc” or “a-document-v01.01.doc”, then the latest version of the file will be opened in the default application
The open source version of Komodo’s code editor and development environment Komodo Edit is a great tool for development. I use it for PHP, HTML, JavaScript and more.
However, I haven’t done any serious coding for a while so I haven’t needed to run it under Windows 7 even though I had it installed. When I did, I was disapointed to find it behaving very poorly. It wouldn’t resize properly without messing up the screen. I tried with some of the compatibility settings that Windows 7 gives you but that made no difference. I also tried an upgrade to the latest version.
A quick search didn’t reveal anything about Windows 7 specifically but I did spot a discussion about problems under Vista that were related to file permissions. Sure enough, making Komodo Edit run as Administrator fixed the issues.
I’ve had a few file permission issues under Windows 7, I’m fairly sure it is down to me messing around. However, it is clear that Windows Vista and Windows 7 are both rather sensitive to permissions issues which is worth bearing in mind.
Looking at %USERPROFILE%\AppData\Roaming\ActiveState\KomodoEdit, I could see that SYSTEM, my user and Administrators all had full access but that Administrator was the owner of some of the files. I can only summise that this is the issue.
As this needs rebuilding with Windows 7 RC, I haven’t the time to test further but certainly running as Administrator does the trick.
By the way, Komodo Edit is available for Mac and Linux as well as Windows. It has a big brother “Komodo IDE” with additional features if you need them. Both are highly configurable, support many languages and are based on the Mozilla code (like Firefox and Thunderbird) & can easily be extended with JavaScript.
After yesterdays OneNote tool, I thought I’d do another while I think about it.
Another annoyance of OneNote is it’s lack of control over pasting information from the clipboard. I’ve raised a suggestion with MS to improve this; you can see my comment in the newsgroup.
To ease things a little if you need to copy and paste lots of stuff to OneNote, here is an AutoHotKey script to help. You need to assign this to a hot-key and have OneNote open in the background. Select something and press the hot-key and it will be pasted (using the current default paste option as this cannot be controlled) into the current note in OneNote.
; AutoHotKey Script to copy pre-selected stuff from the currently active window
; to the currently open note in OneNote
;
; Usage: #include in your main AutoHotKey.ahk assigned to a hot key
; Limitations:
; 1) OneNote must be open - maybe change this in the future so that content goes to a new unfiled note
; 2) Doesn't swap back to original application
;
; Author: Julian Knight, http://www.knightnet.org.uk/contact.htm
; Version: 2009-04-01 v1.0
; We need a partial title match but we will also reset to previous setting
oldTitleMatchMode := A_TitleMatchMode
SetTitleMatchMode, 2
; Settings
winTitlePart := " - Microsoft Office OneNote" ; Partial title of ON windows
; Copy currently selected stuff
SendPlay, ^c ; Use sendplay to avoid unexpected interactions with Win key
; If OneNote is not started, give up
IfWinExist, %winTitlePart%
{
; Save the currently active window title
WinGetTitle, actWin, A
; If OneNote is not active, activate it now
IfWinNotActive, %winTitlePart%
WinActivate, %winTitlePart%
; Check again, if ON active then paste else error
IfWinActive, %winTitlePart%
{
; Paste to ON & Add some blank lines
SendPlay, ^v`r ; Use sendplay to avoid unexpected interactions with Win key
; Switch window back to previously active
WinActivate, %actWin%
}
else
MsgBox, Could not activate OneNote window.
} else
MsgBox, Can't find ON [%winTitlePart%]
SetTitleMatchMode, %oldTitleMatchMode%
return
Although I like Microsoft OneNote and use it continuously, it does have a few failings. One of these is the inability to set the default styles and layout for text.
In particular, when you create a new paragraph or list entry in OneNote, the default – non-changeable – setting is to have no white space between the paragraphs.
This is very poor design and makes more than a small amount of text quite unreadable. I’ve raised this with Microsoft but who knows if or when it might be sorted.
In the mean time, I need a far quicker way of changing this. Currently, I’ve had to:
Not nice!
Having determined that there is nothing clever that can be done in OneNote, I decided that the old standy “AutoHotKey” would be useful. So I’ve created a script for AutoHotKey that will change the inter-list gap for the currently selected container.
; [win]-z Set OneNote list to 6pt separation
#z::
; We need a partial title match but we will also reset to previous setting
oldTitleMatchMode := A_TitleMatchMode
SetTitleMatchMode, 2
debug := 1 ; Set to 1 to output debug messages, or 0
winTitlePart := " - Microsoft Office OneNote" ; Partial title of ON windows
winText := "List" ; Text to identify List Task Pane - Visible Window Text: MsoDockRight, Task Pane, List
listDefault := "0.00 pt" ; The default setting for list separation between items
listNew := "6.00 pt" ; My desired spacing between list items
; Only do something if ON is the active window
IfWinActive, %winTitlePart%
{
; We need the List Task Pane to be visible
IfWinNotExist, %winTitlePart%, %winText%
{
;IfEqual, debug, 1, MsgBox List not active
; Send chars to activate menu, can't use WinMenuSelectItem with Office apps
; SendPlay is used to prevent the Windows key locking the PC (Win+L)
SendPlay, !oL
}
; List Task Pane should now be visible, save the existing setting
ControlGetText, Var1 , RichEdit20W2, %winTitlePart%, %winText%
; If the current setting is the default setting then make the change
if Var1 = %listDefault%
{
; Focus on the input box & set the text
ControlFocus, RichEdit20W2, %winTitlePart%, %winText%
ControlSetText, RichEdit20W2, %listNew%, %winTitlePart%, %winText%
; This is optional to check if we were successful
ControlGetText, Var2 , RichEdit20W2, %winTitlePart%, %winText%
if ErrorLevel ; i.e. it's not blank or zero then error
MsgBox, %Var1% - %Var2% - Problem - %ErrorLevel%.
else
IfEqual, debug, 1, MsgBox, OK - %Var1% - %Var2%.
}
; Close the List Task Pane (actually it closes the Task Pane, period, sorry)
SendPlay, ^{F1}
}
else ; ON not active so do nothing
IfEqual, debug, 1, MsgBox, OneNote not active
SetTitleMatchMode, %oldTitleMatchMode%
return
OK, so it’s a bit rough-and-ready but it does save a whole lot of time. I’ve got this in my default AHK script so it is loaded whenever I log in and is activated with [win]z.