Categories
Mobile Ringtones

Salim Ringtone

Espero que hayáis visto ya Slumdog Millionarie (y si no, corred a los cines, malditos!), posiblemente una de las mejores películas de este año (y eso que estamos en febrero…) y que tiene una OST magnifica.

Como me paso con Crank, el sonidito del móvil de Salim me gustó, así que…

Salim Ringtone
[audio:http://rick.jinlabs.com/stuff/ringtones/SalimRingtone.mp3]
http://rick.jinlabs.com;/stuff/ringtones/SalimRingtone.mp3;Salim Ringtone;
http://rick.jinlabs.com;/stuff/ringtones/SalimRingtone.m4r;Salim Ringtone (iPhone);

Salim Ringtone (Long)
[audio:http://rick.jinlabs.com/stuff/ringtones/SalimRingtone(Long).mp3]
http://rick.jinlabs.com;/stuff/ringtones/SalimRingtone(Long).mp3;Salim Ringtone (Long);

Categories
Asides

El Secreto de la Felicidad

Esperar lo mejor y estar preparado para lo peor…

Lo jodido es conseguirlo…

Categories
Asides

Cita: ¿Estás herido?

– ¿Estás herido?
– La palabra es dañado

Six a Baltar. Battlestar Galactica

Categories
General

Converse

Converse en flickr

Converse en flickr

Categories
Photo

Barca

Barca en flickr

Que gran quedada la de ayer!

Barca en flickr

Categories
Photo

Rio

Rio en flickr

Una de las pocas fotos decentes que saque en la quedada de este sábado 🙂

Aunque la verdad es que eso es lo de menos: me lo pase genial todo el día, aprendí un montón de fotografía de gente que controlaba mucho y, lo más importante, conocí a gente majísima que también tiene uno de mis múltiples (pero sanos) vicios 🙂

Rio en flickr

Categories
English Wordpress

How add options to your WordPress 2.7 dashboard widgets

Well, in this article, I assume you have read the WP Engineer’s excellent post Add WordPress Dashboard Widgets, because his code will be our start point.

So, we have this code:


// Load up the localization file if we're using WordPress in a different language
// Place it in this plugin's folder and name it "MainFunction-[value in wp-config].mo"
load_plugin_textdomain( 'MainFunction', '/wp-content/plugins/MainFunction' );

/**
 * Content of Dashboard-Widget
 */
function MainFunction() {
	echo 'Test Add Dashboard-Widget';
}
 
/**
 * add Dashboard Widget via function wp_add_dashboard_widget()
 */
function MainFunction_Init() {
	wp_add_dashboard_widget( 'MainFunction', __( 'MainFunction Widget Title' ), 'MainFunction' );
}
 
/**
 * use hook, to integrate new widget
 */
add_action('wp_dashboard_setup', 'MainFunction_Init');

OK, now, remenber the wp_add_dashboard_widget function?

function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null )

The $control_callback parameter (obviously optional) is our main target. It gives the ‘Configure’ option to our spiffy widget.
So, we need to add a 4th parameter to wp_add_dashboard_widget:

wp_add_dashboard_widget( 'MainFunction', __( 'MainFunction Widget Title' ), 'MainFunction', 'MainFunction_Setup');

The MainFunction_Setup function handles two things: the options (set the default options, recolect new values, etc) and the option’s presentation (i.e. the HTML part)

So, here goes the code:


function MainFunction_Options() {
	$defaults = array( 'items' => 5, 'boolean' => 1);
	if ( ( !$options = get_option( 'MainFunction' ) ) || !is_array($options) )
		$options = array();
	return array_merge( $defaults, $options );
}

function MainFunction_Setup() {

	$options = MainFunction_Options();


	if ( 'post' == strtolower($_SERVER['REQUEST_METHOD']) && isset( $_POST['widget_id'] ) && 'MainFunction' == $_POST['widget_id'] ) {
		foreach ( array( 'items', 'boolean' ) as $key )
				$options[$key] = $_POST[$key];
		update_option( 'MainFunction', $options );
	}
		
?>
	

As you can see, MainFunction_Options puts the default values (if necessary, of course) and MainFunction_Setup show the current values and let change them. You can merge this two, of course...

Now, we have to get the options and use them in our MainFunction function. Change MainFunction like that:

/**
 * Content of Dashboard-Widget
 */
function MainFunction() {

        $widget_options = MainFunction_Options();

	echo 'Test Add Dashboard-Widget
'; echo "You have selected $widget_options['items'] items
"; echo "boolean is $widget_options['boolean']
"; }

The complete code here:

';
	echo "You have selected $widget_options['items'] items
"; echo "boolean is $widget_options['boolean']
"; } /** * add Dashboard Widget via function wp_add_dashboard_widget() */ function MainFunction_Init() { wp_add_dashboard_widget( 'MainFunction', __( 'MainFunction Widget Title' ), 'MainFunction' , 'MainFunction_Setup' ); } function MainFunction_Options() { $defaults = array( 'items' => 5, 'boolean' => 1); if ( ( !$options = get_option( 'MainFunction' ) ) || !is_array($options) ) $options = array(); return array_merge( $defaults, $options ); } function MainFunction_Setup() { $options = MainFunction_Options(); if ( 'post' == strtolower($_SERVER['REQUEST_METHOD']) && isset( $_POST['widget_id'] ) && 'MainFunction' == $_POST['widget_id'] ) { foreach ( array( 'items', 'boolean' ) as $key ) $options[$key] = $_POST[$key]; update_option( 'MainFunction', $options ); } ?>

You can view a PHPS version (without PHP crippled tags) here.