-
-
Save imath/df65b7c856fbd02024a84c7ecc016090 to your computer and use it in GitHub Desktop.
Extract of the upgrade function used by the "Types de membre" plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function unique_prefix_upgrade_plugin() { | |
// Old way of storing Member type props. | |
$member_type_props = get_option( | |
'_unique_prefix_option_name' | |
array( | |
// Term ID => Member Type plural name. | |
170 => 'Company service A', | |
177 => 'Company service B', | |
) | |
); | |
// BuddyPress required file. | |
$bp_file = trailingslashit( buddypress()->plugin_dir ) . 'bp-core/admin/bp-core-admin-types.php'; | |
if ( $member_types_props && file_exists( $bp_file ) ) { | |
require_once $bp_file; | |
$member_types = bp_get_terms( | |
array( | |
'taxonomy' => bp_get_member_type_tax_name(), | |
'include' => array_keys( $member_type_props ), | |
'fields' => 'id=>slug', | |
) | |
); | |
foreach ( $member_types as $term_id => $slug ) { | |
if ( ! isset( $member_type_props[ $term_id ] ) ) { | |
continue; | |
} | |
bp_core_admin_update_type( | |
array( | |
'taxonomy' => bp_get_member_type_tax_name(), | |
'type_term_id' => $term_id, | |
'bp_type_name' => $member_type_props[ $term_id ], // Plural name. | |
'bp_type_singular_name' => $member_type_props[ $term_id ], // Singular name. | |
'bp_type_has_directory' => true, // True to allow the Members directory to be filtered by this type. | |
'bp_type_directory_slug' => $slug, | |
'bp_type_show_in_list' => true, // True to allow the type to be listed into the Member page's header. | |
) | |
); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment