Posts Tagged ‘’

Wordpress: add_action

Friday, July 4th, 2008

Hooks a function on to a specific action. See Plugin API for a list of hooks for action.
Usage

Examples
To email some friends whenever an entry is posted on your blog:
function email_friends($post_ID) {
$friends = ‘bob@example.org, susie@example.org’;
mail($friends, “sally’s blog updated” , ‘I just put something on my blog: http://blog.example.com’);
return $post_ID;
}
add_action(’publish_post’, ‘email_friends’);

Parameters

$tag
(string) The name of the action you wish to hook onto.

$function_to_add
(callback) The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the ‘callback’ type are valid.

$priority
How important your function is. Alter this to make your function be called before or after other functions. The default is 10, so (for example) setting it to 5 would make it run earlier and setting it to 12 would make it run later.

$accepted_args
How many arguments your function takes. In WordPress 1.5.1+, hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. For example, the action comment_id_not_found will pass any functions that hook onto it the ID of the requested comment.

Easy WordPress and Google Calendar Integration

Tuesday, July 1st, 2008

http://www.googletutor.com/2008/02/19/easy-wordpress-and-google-calendar-integration/
http://code.google.com/p/wpng-calendar/

The Wordpress Google calendar plugin allows for the integration of a Google calendar into a Wordpress blog. This section describes how to install the plugin and get it working.
1. Request Google GDATA API key (see link below)
2. Upload the contents of the ZIP file to the /wp-content/plugins/ directory
3. Activate the plugin through the Plugins menu
4. Configure your GDATA API key in the plugin options panel
5. Configure a Google calendar in the plugin options panel
6. Configure the option to render the description field as Wiki markup
7. Create a page and add the ’show-wpng-calendar’ custom field with the number of weeks you want to be displayed
8. Add the widget to your sidebar and configure the title and number of events to display

wordpress relative url

Monday, June 30th, 2008

edit wp-includes/functions.php

--
function get_option( $setting ) {
	global $wpdb;

	if (in_array($setting, array('siteurl', 'home'))) {
		if (ereg('(wp-includes)', $_SERVER['PHP_SELF'], $r)) {
			return ('http://'.$_SERVER['SERVER_NAME'].(
				substr(
					$_SERVER['PHP_SELF'], 0,
					strpos($_SERVER['PHP_SELF'], $r[0])
				)
			));
		} else if (ereg('wp-admin', $_SERVER['PHP_SELF'])) {
			return 'http://'.$_SERVER['SERVER_NAME']
			. dirname(dirname($_SERVER['PHP_SELF']));
		} else {
			$_SERVER_PHP_SELF = $_SERVER['PHP_SELF'];
			$_SERVER_SCRIPT_FILENAME = $_SERVER['SCRIPT_FILENAME'];
			while ($_SERVER_SCRIPT_FILENAME = dirname($_SERVER_SCRIPT_FILENAME)) {
				$_SERVER_PHP_SELF = dirname($_SERVER_PHP_SELF);
				if (file_exists($_SERVER_SCRIPT_FILENAME.'/wp-content')) {
					break;
				}
				if ($_SERVER_SCRIPT_FILENAME == '.') break;
			}
			return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER_PHP_SELF;
		}
	}
--