My summer of code project is a plugin named codeWord, it implements CodePress into the WP theme code editor, but with a few additional features and fixes. 1. It now uses some simple jquery ajax code for saving, which avoids having to reload the whole page. 2. If you attempt to navigate away, but haven't saved your recent changes it shows a prompt. 3. It has an dropdown input that auto-completes WP functions. 4. Plus a few little fixes here and there, notably I fixed the tab key to insert a tab character.
I still have a fair bit of work left to do getting everything running smoothly, but I'd appreciate any feedback on my work so far.
In my remaining time I hope to develop the function lookup, adding in default parameters for each function and linking them through to the relevant page on the codex.
If you'd like to take a look round the plugin, then checkout my code from the WPSoC repository[1] and if you'd like to keep up to speed with my progress then grab a feed from my blog[2].
Gotta say that I'm not a fan of the way you're inserting the scripts...
Problem 1: A stylesheet link in the footer? Does not validate. Move it to the header section. Problem 2: Why are you not using wp_enqueue_script? Looks like you made an abortive attempt at that? Try this sort of thing:
function codeWord_scripts() { wp_enqueue_script('jquery-form'); // already defined by wordpress wp_enqueue_script('jquery-bgiframe', '/wp-content/plugins/codeword/autocomplete/jquery.bgiframe.min.js', array('jquery'), '2.1.1' ); wp_enqueue_script('jquery-autocomplete', '/wp-content/plugins/codeword/autocomplete/jquery.autocomplete.js', array('jquery'), '1.0.2' ); wp_enqueue_script('localdata', '/wp-content/plugins/codeword/autocomplete/localdata', array('jquery'), '1.0' ); wp_enqueue_styles('jquery-autocomplete', '/wp-content/plugins/codeword/autocomplete/jquery.autocomplete.css', array(), '1.0.2' );
}
add_action('admin_menu', 'codeWord_scripts');
That will work for both the styles and the scripts. Note that the enqueue style stuff is new to WordPress 2.6, I think. _______________________________________________ wp-hackers mailing list wp-hack...@lists.automattic.com http://lists.automattic.com/mailman/listinfo/wp-hackers
Additional: Just tried it, this code works with 2.6 beta 3:
function codeWord_footer() { global $codeWord_abs_dir; // the codeWord_url variable must be set incase WordPress is not installed in the base url. printf('<script type="text/javascript">var codeWord_url = \'%s\';</script>', get_bloginfo('wpurl')); // add main js file to determine the current filetype and browser and serve the according codePress engine. printf('<script type="text/javascript" src="%s/codeword.js"></script>', $codeWord_abs_dir);
// check the url to see if the current page is the theme editor, if so then chocks away.. if(strpos($_SERVER[ 'REQUEST_URI' ], 'theme-editor.php') !== false) { add_action('admin_footer', 'codeWord_footer'); add_action('admin_menu', 'codeWord_scripts');
}
It's very neat, actually. I like the syntax highlighting and the ability to use the Tab key correctly in the theme editor. _______________________________________________ wp-hackers mailing list wp-hack...@lists.automattic.com http://lists.automattic.com/mailman/listinfo/wp-hackers
That manual definition of the plugin directory/URL in codeword.php is not needed. There's a constant of WP_PLUGIN_URL that holds the URL to the plugins, so WP_PLUGIN_URL . 'codeword' would be good enough to give you the URL you need.
The function search box has a few issues. When I tried to type "the_", then it has trouble when I hit the shift key to type the underscore.
The Indent Guides button doesn't seem to do anything. Maybe I'm missing it?
Jason Webster wrote: > I'm assuming that this is only in trunk, am I correct? Not in 2.5.x as > far as I know, and a grep of the source seems to confirm that.
> Otto wrote: >> There's a constant of WP_PLUGIN_URL that holds the URL to >> the plugins...
> Jason Webster wrote: >> I'm assuming that this is only in trunk, am I correct? Not in 2.5.x >> as far as I know, and a grep of the source seems to confirm that.
>> Otto wrote: >>> There's a constant of WP_PLUGIN_URL that holds the URL to >>> the plugins...
> Gotta say that I'm not a fan of the way you're inserting the scripts...
You're right I really should have been using wp_enqueue_script for the other scripts that don't need to go in the document body and I'm not sure why the stylesheet ended up there too, I'll update my code.
> That manual definition of the plugin directory/URL in codeword.php is
not needed. There's a constant of WP_PLUGIN_URL ... I hadn't heard of the WP_PLUGIN_URL constant yet, so I'll use that too, thanks Gaarai for the link on backwards compatibility there.
> The function search box has a few issues. When I tried to type "the_",
then it has trouble when I hit the shift key to type the underscore. Yeah I just changed over the autocomplete script I was using, this one still needs some work integrating, but I've sorted out the shift key issue.
On Fri, Jul 11, 2008 at 11:41 AM, Otto <o...@ottodestruct.com> wrote: > Other minor nitpicks:
> That manual definition of the plugin directory/URL in codeword.php is > not needed. There's a constant of WP_PLUGIN_URL that holds the URL to > the plugins, so WP_PLUGIN_URL . 'codeword' would be good enough to > give you the URL you need.
Awesome, everyone can appreciate that advice. Thanks.