Skip to content

Commit

Permalink
License field refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
davegreenwp committed Nov 29, 2023
1 parent 3ff9973 commit faac71f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Uplink/Admin/License_Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,14 @@ public function get_field_html( Plugin $plugin ) : string {
* @inheritDoc
*/
public function render( bool $show_title = true, bool $show_button = true ) {
$plugin = $this->get_plugin();

if ( ! $plugin ) {
return;
}

echo $this->get_content( [
'plugin' => $this->get_plugin(),
'plugin' => $plugin,
'show_title' => $show_title,
'show_button' => $show_button,
] );
Expand All @@ -91,8 +97,14 @@ public function render( bool $show_title = true, bool $show_button = true ) {
* @return void
*/
public function enqueue_assets() {
$plugin = $this->get_plugin();

if ( ! $plugin ) {
return;
}

$handle = sprintf( 'stellarwp-uplink-license-admin-%s', Config::get_hook_prefix() );
$path = preg_replace( '/.*\/vendor/', plugin_dir_url( $this->get_plugin()->get_path() ) . 'vendor', dirname( __DIR__, 2 ) );
$path = preg_replace( '/.*\/vendor/', plugin_dir_url( $plugin->get_path() ) . 'vendor', dirname( __DIR__, 2 ) );
$js_src = apply_filters( 'stellarwp/uplink/' . Config::get_hook_prefix() . '/admin_js_source', $path . '/assets/js/key-admin.js' );
wp_register_script( $handle, $js_src, [ 'jquery' ], '1.0.0', true );
wp_enqueue_script( $handle );
Expand Down

0 comments on commit faac71f

Please sign in to comment.