ProjectManager 2.1 with Bridge support
The new version of ProjectManager has only a small change, but with great effect. The formfield types make use of the wordpress filter system, which enables other plugins to add special fields. This makes it possible to enable LeagueManager to hook into the plugin and more datafields, e.g. goal statistics. The formfields are added with the following code:
add_filter( ‘projectmanager_formfields’, ‘filter_formfields’);
‘filter_formfields’ is just an example function adds another field, such as:
function filter_formfields( $formfields ) {
$formfields['goals'] = array( ‘name’ => __(‘Goals’, ‘leaguemanager’), ‘callback’ => array($this, ‘getNumGoals’), ‘args’ => array() );
return $formfields;
}
This is the example I used to add a special field type in LeagueManager which automatically calculates shot goals of a player. The ‘name’ is simply the label of the field, ‘callback’ is a function that retrieves and returns the data, while ‘args’ are additional arguments that are passed to the function. ProjectManager automatically passes as first argument the dataset name and id as associative array. The function in the used example looks like this.
function getNumGoals( $player ) {
$player_name = $player['name'];
$player_id = $player['id'];
// get number of goals for this player
}
I hope I could describe a little bit how the bridging between the plugins functions. As far as I can tell now ProjectManager won’t need any further changes since most of the bridging is done from LeagueManager. Anybody can use the above filter to add formfields with special data. Up to now the new LeagueManager version is still in development and the next release will have the field for goal statistics.



