Categories
Wordpress

How to use media library / uploader in code

How to use WordPress 3.5 Media Uploader in Theme Options

Categories
Tech

Chicken of VNC full screen mode “bug”

put it into full screen mode and keyboard stopped working.

Turns out that the keyboard command control-option-command-` puts the keyboard into a  control-lock situation.

hold the shift and click on the mouse fixes this problem

http://sourceforge.net/tracker/?func=detail&aid=1709492&group_id=64347&atid=507159

Categories
Wordpress

WordPress settings for custom plugin

Ottopress has a pretty good tutorial for writing a wordpress plugin settings page but its a little confusing if you dont see the software flow

Here is my interpretation

 

 

 

/**
*
* Created by Urbanpixels.com
* Author: Chuck
* Copyright: 8/12]0/12 All Rights Reserved
*
*/
add_action('admin_menu', 'kpi_forum_admin_add_page');
$settings_slug = 'kpi-forum-settings'; // array catcher
$plugin_slug = 'kpi-forum';
$section_slug = 'kpi-forum-section';
add_action('admin_init', 'kpi_forum_admin_init');
function kpi_forum_admin_init(){
global $plugin_slug,$settings_slug,$section_slug;
register_setting( $settings_slug, $settings_slug, 'kpi_forum_validate' );
add_settings_section($section_slug, 'KPI Forum Settings', 'kpi_forum_section_description', $plugin_slug);
add_settings_field('kpi-forum-test-field', 'Test', 'kpi_forum_test_field', $plugin_slug, $section_slug);
add_settings_field('kpi-forum-foo-field', 'Foo', 'kpi_forum_foo_field', $plugin_slug, $section_slug);

}
function kpi_forum_admin_add_page() {
global $plugin_slug;
add_options_page('Custom Plugin Page', 'KPI Forum', 'manage_options', $plugin_slug, 'kpi_forum_form');
}
function kpi_forum_form() {
global $plugin_slug,$settings_slug;
?>
<div>
<h2>KPI Forum Settings</h2>
<form method="post" action="options.php">
<?php
settings_fields( $settings_slug );
do_settings_sections( $plugin_slug );
submit_button();
?>

</form>
</div>
<?php
}

function kpi_forum_section_description() {
?>
Some text describe section one
<?php
}

function kpi_forum_test_field() {
global $settings_slug;
$options = get_option($settings_slug);
?>
<input type="text" name="kpi-forum-settings[test]" value="<?php echo $options['test'];?>"/>
<?php
}
function kpi_forum_foo_field() {
global $settings_slug;
$options = get_option($settings_slug);
?>
<input type="text" name="kpi-forum-settings[foo]" value="<?php echo $options['foo'];?>"/>
<?php
}
function kpi_forum_validate($options) {
return $options;
}

Categories
Wordpress

Custom URL structure in wordpress

http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/

Read the comments about rewrite. I would put definitely use admin-init and put it inside of the settings page to flush.

Categories
Wordpress

mysql date to php

$date = strtotime( '2009-12-02');
$php_date = date( 'Y-m-d H:i:s', $date );
Categories
Development Firefox/XUL

Firefox plugins and XUL

Writing XUL is a giant pain in the ass and the documentation is lacking any examples.
Here is a good resource

https://forums.mozilla.org/addons/viewtopic.php?f=7&t=384

Excerpt from that page

There is a list of some resources here
https://addons.mozilla.org/en-US/develo … ng-started

This tutorial is quite a helpful introduction
https://developer.mozilla.org/En/Firefo … Extensions

I generally just use MDC (Mozilla Developer Center) for reference (just keep an eye on what version of Firefox/Gecko the documentation applies to)
https://developer.mozilla.org/En

The XUL periodic table is a helpful resource for basic XUL element layout
http://www.hevanet.com/acorbin/xul/top.xul

W3Schools is a useful basic reference for DOM and Javascript
http://www.w3schools.com/jsref/default.asp

There is a list of the Mozilla interfaces here
http://www.oxymoronical.com/experiments/apidocs/

The DOM inspector is a “must have”
https://addons.mozilla.org/en-US/firefox/addon/6622

Anyway that’s just a few that you might find useful

HTH