BP_Group_Extension::parse_legacy_properties()
Parse legacy properties.
Description
The old standard for BP_Group_Extension was for plugins to register their settings as properties in their constructor. The new method is to pass a config array to the init() method. In order to support legacy plugins, we slurp up legacy properties, and later on we’ll parse them into the new init() array.
Source
File: bp-groups/classes/class-bp-group-extension.php
protected function parse_legacy_properties() {
// Only run this one time.
if ( ! empty( $this->legacy_properties_converted ) ) {
return;
}
$properties = $this->get_legacy_property_list();
// By-reference variable for convenience.
$lpc =& $this->legacy_properties_converted;
foreach ( $properties as $property ) {
// No legacy config exists for this key.
if ( ! isset( $this->{$property} ) ) {
continue;
}
// Grab the value and record it as appropriate.
$value = $this->{$property};
switch ( $property ) {
case 'enable_create_step' :
$lpc['screens']['create']['enabled'] = (bool) $value;
break;
case 'enable_edit_item' :
$lpc['screens']['edit']['enabled'] = (bool) $value;
break;
case 'enable_admin_item' :
$lpc['screens']['admin']['enabled'] = (bool) $value;
break;
case 'create_step_position' :
$lpc['screens']['create']['position'] = $value;
break;
// Note: 'admin' becomes 'edit' to distinguish from Dashboard 'admin'.
case 'admin_name' :
$lpc['screens']['edit']['name'] = $value;
break;
case 'admin_slug' :
$lpc['screens']['edit']['slug'] = $value;
break;
case 'create_name' :
$lpc['screens']['create']['name'] = $value;
break;
case 'create_slug' :
$lpc['screens']['create']['slug'] = $value;
break;
case 'admin_metabox_context' :
$lpc['screens']['admin']['metabox_context'] = $value;
break;
case 'admin_metabox_priority' :
$lpc['screens']['admin']['metabox_priority'] = $value;
break;
default :
$lpc[ $property ] = $value;
break;
}
}
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.8.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.