WP Super Edit 2.4.7

This is the “Things might be a mess around here, but I’m still working release” for WP Super Edit 2.4.7. There are no new features or major changes for this release. This update should fix a couple of issues.

  1. Migrate from depreciated WordPress functions.
  2. Update included TinyMCE plugins to TInyMCE 3.5.8

You are welcome to contact me about current issues, or leave a comment here. I am incredibly busy, but I hope to try to keep up with issues as much as I can.

BP Registration Options 3.0.3 with Fixes for BuddyPress 1.3 – Trunk

Just posting some modifications made to get the BP Registration Options 3.0.3 plugin working with WordPress 3.2-trunk and BuddyPress 1.3-trunk that I needed for a current project. This was only tested on a WordPress multi-site network with BuddyPress and using sub-domain mapping, so my modifications may not fix everything for you. I also did not build in any backwards compatibility or test with BuddyPress 1.2.8. Here are my notes.

  1. I got the menus added to the WordPress multi-site “Network” menu.
  2. Removed the global $iprefix and went with $wpdb->base_prefix to set the database prefixes instead. Not really necessary, but cleaner and possibly more appropriate.
  3. Created the pbrwg_get_loaded_components() function to replace $bp->root_components since I think it’s depreciated. The pbrwg_get_loaded_components() uses the $bp->pages objects to build an array with the component name as the key and the slug as the value. This should replace some URL parsing since $bp->current_component can be used instead of trying to figure out the URL to component relationship.
  4. Changed the ‘bp_core_activate_account’ action for ‘bp_members_activated_user’ and passed through the user-ID.
  5. Changed a few values from string to INT where possibly appropriate.

Stopped myself, but probably could have done some isset() and empty() in a few places. I didn’t want to rewrite the whole plugin because I’m expecting this will improve as BuddyPress gets updated, and I don’t want to merge a massive change back into the current project using this plugin. BP Registration Options has a nice simple premise, but just needs a little code simplification love (not that my_overly_verbose_ass can do any better).

All the changes are in this package: BP Registration Options 3.0.3 with Fixes for BuddyPress 1.3 (zip)

My Ugly WordPress, HyperDB, & BuddyPress Deployment Shell Script

This is the source of some of the website deployment scripts I have. This is one is fairly complex and it is my pocket tool of choice for development of big nasty WordPress sites. Probably only interesting to folks who deal with unix shells and do mildly heavy WordPress work.

It’s designed to update from SVN trunk for WordPress, HyperDB, & BuddyPress. My favorite is quick rsync for folders and subfolders so you can upload theme changes quickly because the web is my sketchpad.

Common List of Commands:

# Get the configured site 
./wp-work.sh get
# Put the configured site 
./wp-work.sh put
# Upgrade the configured site to latest WordPress, HyperDB, & BuddyPress
./wp-work.sh upgrade
# Put specific folders in the sites root
./wp-work.sh work put the-site-folder
# get specific folders in the sites root
./wp-work.sh work get the-site-folder

The Big Ugly Script:

You will really want to customize the top values for sure.

#!/bin/sh

# Batch Update jess
#
# Uses flat array list of site locations, updates using latest source from SVN and performs all update steps.
#

# Website Name
WEB_ROOT_NAME="example.com"

# Web Direcory locations Using $HOME is good.
WEB_ROOT_LOCAL="${HOME}/luser/${WEB_ROOT_NAME}/"
WEB_ROOT_REMOTE="/home/luser/${WEB_ROOT_NAME}/"

# Archive -a mode is -rlptgoD -pgo is permission, user, group and be an issue had to add -vz
RSYNC_SWITCH='-vzrltD'
# SSH command because you might need: 'ssh -i /shh/secret-key/master-magic-key -p 56232'
RSYNC_SSH='ssh'
# Remember the ssh account is where your files land.
RSYNC_SSH_ACCOUNT='me@example.com'

# Tools location for exclude files ans stuff. Using $HOME is good.
TOOLS_ROOT_LOCAL="${HOME}/luser/stuff/"
TOOLS_ROOT_EXCLUDES="${HOME}/luser/stuff/"

# Temp files
TEMP_ROOT_LOCAL="${HOME}/luser/tmp/"

# Putting the path into a variable gets tricky
WORKING_TEMP_LOCATION=$( readlink -nf ${TEMP_ROOT_LOCAL} )

# Move to tools directory so we can find things easier.
cd ${TOOLS_ROOT_LOCAL}

# Print good ole help if no command
if [ $# == 0 ]; then
	echo  "${WEB_ROOT_NAME} Commands: get, put, upgrade, work [put or get] [directory]"
	exit	
fi

# Get all remote
if [ $1 == "get" ]; then
  echo '----- Start Site Download -----'
  echo  "Get all stuff with a few exceptions."
  rsync ${RSYNC_SWITCH} --delete -e "${RSYNC_SSH}" ${RSYNC_SSH_ACCOUNT}:${WEB_ROOT_REMOTE} ${WEB_ROOT_LOCAL}
  exit
fi

# Put all with some exceptions
if [ $1 == "put" ]; then
  echo '----- Start Site Upload -----'
  echo  "Put all stuff with a few exceptions."
  rsync ${RSYNC_SWITCH} --delete --exclude-from=${TOOLS_ROOT_EXCLUDES}wordpress-exclude.txt -e "${RSYNC_SSH}" ${WEB_ROOT_LOCAL} ${RSYNC_SSH_ACCOUNT}:${WEB_ROOT_REMOTE}
  exit
fi

# Upgrade with merge from several sources
if [ $1 == "upgrade" ]; then

	echo  "Don't have this for work.funroe.net"

	exit
	
	mkdir ${WORKING_TEMP_LOCATION}
	mkdir ${WORKING_TEMP_LOCATION}/wordpress
	mkdir ${WORKING_TEMP_LOCATION}/buddypress
	mkdir ${WORKING_TEMP_LOCATION}/hyperdb
	
	svn co http://svn.automattic.com/wordpress/trunk/ ${WORKING_TEMP_LOCATION}/wordpress/
	svn co http://svn.buddypress.org/trunk/ ${WORKING_TEMP_LOCATION}/buddypress/
	svn co http://svn.wp-plugins.org/hyperdb/trunk/ ${WORKING_TEMP_LOCATION}/hyperdb/
	 
	mv -f ${WORKING_TEMP_LOCATION}/buddypress ${WORKING_TEMP_LOCATION}/wordpress/wp-content/plugins/buddypress
	mv -f ${WORKING_TEMP_LOCATION}/hyperdb/db.php ${WORKING_TEMP_LOCATION}/wordpress/wp-content/db.php
	
	echo '----- Update local site -----'
	rsync ${RSYNC_SWITCH} --delete --exclude-from=${TOOLS_ROOT_EXCLUDES}wpmu-bbpres-bp-exclude.txt  ${WORKING_TEMP_LOCATION}/wordpress/ ${WEB_ROOT_LOCAL}
	
	echo  "----- Remove temp working directory! -----"
	rm -Rf ${WORKING_TEMP_LOCATION}
	
	echo  "----- Update remote site! -----"	
	rsync ${RSYNC_SWITCH} --delete --exclude-from=${TOOLS_ROOT_EXCLUDES}wordpress-exclude.txt -e "${RSYNC_SSH}" ${WEB_ROOT_LOCAL} ${RSYNC_SSH_ACCOUNT}:${WEB_ROOT_REMOTE}
	echo '----- DONE! -----'
	
	exit
fi

# Work allows get and put of specific directories starting at web root ie. this.command work put wp-content/themes
if [ $1 == "work" ]; then

 	# Putting the path into a variable gets tricky
 	WORKING_LOCAL_LOCATION=$( readlink -nf ${WEB_ROOT_LOCAL}${3} )
	
	if [ ! -d "${WORKING_LOCAL_LOCATION}" ]; then
		if [ ! -f "${WORKING_LOCAL_LOCATION}" ]; then
			 echo "Not a valid work site! Please try again."
			 exit
		fi
	fi
	
	# Set remote location
	WORKING_REMOTE_LOCATION=${WEB_ROOT_REMOTE}${3}
			
	# Add slashes to end if they were omitted
	if [ `echo "$WORKING_LOCAL_LOCATION" | grep "[^/]$"` ]; then 
		WORKING_LOCAL_LOCATION="${WORKING_LOCAL_LOCATION}/"; 
		WORKING_REMOTE_LOCATION="${WORKING_REMOTE_LOCATION}/"; 
	fi
	
	# Remove double slashes
	WORKING_LOCAL_LOCATION=${WORKING_REMOTE_LOCATION//////}	
	WORKING_REMOTE_LOCATION=${WORKING_REMOTE_LOCATION//////}

	echo "rsync ${RSYNC_SWITCH} --delete --exclude-from=${TOOLS_ROOT_EXCLUDES}wordpress-exclude.txt -e "${RSYNC_SSH}" ${WORKING_LOCAL_LOCATION}  ${RSYNC_SSH_ACCOUNT}:${WORKING_REMOTE_LOCATION}"

	if [ $2 == "get" ]; then
	  echo "----- Get All ${WEB_ROOT_NAME} -----"
	  echo  "Downloading all work.funroe.net/$work_site files..."
	  rsync ${RSYNC_SWITCH} --delete -e "${RSYNC_SSH}" ${RSYNC_SSH_ACCOUNT}:${WORKING_REMOTE_LOCATION} ${WORKING_LOCAL_LOCATION}
	  exit
	fi
	
	if [ $2 == "put" ]; then
	  echo "----- Put ${WEB_ROOT_NAME} -----"
	  echo  "Uploading selected work.funroe.net/$work_site files..."
      rsync ${RSYNC_SWITCH} --delete --exclude-from=${TOOLS_ROOT_EXCLUDES}wordpress-exclude.txt -e "${RSYNC_SSH}" ${WORKING_LOCAL_LOCATION}  ${RSYNC_SSH_ACCOUNT}:${WORKING_REMOTE_LOCATION}
	  exit
	fi	

fi

Exclude file: wordpress-exclude.txt needs to be in that TOOLS_ROOT_EXCLUDES directory. I use it skip stuff that I don’t want to be synced on upload because the remote file changes are most important.

.htaccess
wp-config.php
bb-config.php
cache/
blogs.dir
uploads
wp-content/advanced-cache.php
wp-cache-config.php
sitemap.xml.gz
robots.txt
sitemap.xml
googlee-thingyfile.html

Exclude file: wpmu-bbpress-bp.txt needs to be in that TOOLS_ROOT_EXCLUDES directory. This is to keep files from being overwritten when a package is created from the SVN repositories and moved to the local site staging area. This really may need customized to protect your personal themes, plugins, and files.

# WP Core excludes
<ul>
<li>.htaccess</li>
<li>wp-config.php</li>
<li>bb-config.php</li>
<li>/cgi-bin</li>
<li>/cache</li>
<li>blogs.dir</li>
<li>uploads</li>
</ul>
# Themes
+ themes/index.php
+ themes/classic
+ themes/default
+ themes/twentyten
- themes/*

# Plugins
+ plugins/readme.txt
+ plugins/index.php
+ plugins/buddypress
- plugins/*

# MU Plugins
+ mu-plugins/readme.txt
+ mu-plugins/index.php
- mu-plugins/*

# Hyper DB
- db-settings.php

WordPress 3.0 Ajax Notes

Collecting up some WordPress 3.0 and Ajax notes.

Nice round look at current state of Ajax and WordPress:
http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/

Here’s the WordPress Trac discussion for implementation in WordPress 3.0:
http://core.trac.wordpress.org/ticket/12400

WP Super Edit & Some WordPress TinyMCE Notes

Discussion on wp-hackers centering around a simpler api for creating simple buttons.

Otto:

There’s an example to add a quick button to TinyMCE at:
http://tinymce.moxiecode.com/examples/example_20.php

To do this in a WP plugin, you’d hook to mce_buttons_2 (or 3, or 4) to add your button to the list. Then you’d hook up a filter on tiny_mce_before_init to add your javascript code to the $initArray[‘setup’]. That should be pretty much that, really.

Someone suggested to combine that a simple button api with the shortcode api to create a simple visual editor button api. Probably way to many use cases to cover, but it is an interesting concept. Some groundwork exists in the Super Emoticons code for WP Super Edit.

Fixing The WordPress.com Custom CSS Plugin

That plugin is custom to WordPress.com, so it’s not really for wide usage yet. But I did find these notes for WPMU usage:

I needed to do two things to make it work:

On line 131 change is_int() to is_numeric():

if ( is_numeric( $blog_id ) ) {
switch_to_blog( $blog_id );
$current_plugins = apply_filters( ‘active_plugins’, get_option( ‘active_plugins’ ) );
}

Then in my .htaccess add the following:

RewriteRule ^custom-css.php /index.php [L,QSA]

Now works a treat.