Uplink_Controller::register_license_fields( array $fields_array )
Register the license fields.
Contents
Parameters
- $fields_array
-
(array) (Required) The array of fields.
Return
(array)
Source
File: src/Common/Libraries/Uplink_Controller.php
public function register_license_fields( $fields_array ) {
$plugins = get_plugins();
$fields_to_inject = [];
foreach ( $plugins as $plugin ) {
$legacy_slug = str_replace( '-', '_', $plugin->get_slug() );
$field = get_field( $plugin->get_slug() );
$field->set_field_name( 'pue_install_key_' . $legacy_slug )->show_label( false );
$prefix = tribe( Libraries_Provider::class )->get_hook_prefix();
// If there is a license registered prior Uplink but not with Uplink. Return license registered prior Uplink.
add_filter(
'stellarwp/uplink/' . $prefix . '/' . $plugin->get_slug() . '/license_get_key',
function ( $license, Resource $plugin ) {
if ( $license ) {
return $license;
}
return get_option( 'pue_install_key_' . str_replace( '-', '_', $plugin->get_slug() ), '' );
},
10,
2
);
$field_html = $field->get_render_html();
// Remove duplicate entries of plugins migrated to uplink.
if ( isset( $fields_array[ 'pue_install_key_' . $legacy_slug . '-heading' ] ) ) {
unset( $fields_array[ 'pue_install_key_' . $legacy_slug . '-heading' ] );
}
// Remove duplicate entries of plugins migrated to uplink.
if ( isset( $fields_array[ 'pue_install_key_' . $legacy_slug ] ) ) {
unset( $fields_array[ 'pue_install_key_' . $legacy_slug ] );
}
$fields_to_inject[ 'stellarwp-uplink_' . $plugin->get_slug() . '-heading' ] = [
'type' => 'heading',
'label' => $plugin->get_name(),
];
$fields_to_inject[ 'stellarwp-uplink_' . $plugin->get_slug() ] = [
'type' => 'html',
'label' => '',
'html' => $field_html,
];
}
$fields_array = Arr::insert_after_key( 'tribe-form-content-start', $fields_array, $fields_to_inject );
return $fields_array;
}
Changelog
| Version | Description |
|---|---|
| 6.3.0 | Introduced. |