Inventory_Presser_Addon_Updater::show_missing_license_notice( object $value, mixed $transient )
Changes “Automatic update is unavailable for this plugin.” to “License key is missing at Vehicles → Options” if the problem is a missing license key for one of our add-ons.
On This Page
Description Description
Does nothing for the WordPress Updates page. The message this method helps change appears only on the Plugins page.
Parameters Parameters
- $value
-
(object) (Required)
- $transient
-
(mixed) (Required)
Return Return
(object)
Source Source
File: includes/addon/class-addon-updater.php
public function show_missing_license_notice( $value, $transient ) {
// Store a list of strings to avoid outputting JavaScript for the same plugin more than once.
static $handled_plugin_slugs = array();
if ( empty( $value->response ) ) {
return $value;
}
// Is there a response from inventorypresser.com in this transient?
foreach ( $value->response as $plugin_path => $update_response ) {
if ( ! is_object( $update_response ) || empty( $update_response->slug ) ) {
continue;
}
if ( strlen( $update_response->url ) < strlen( Inventory_Presser_Addon_License::STORE_URL )
|| Inventory_Presser_Addon_License::STORE_URL != substr( $update_response->url, 0, strlen( Inventory_Presser_Addon_License::STORE_URL ) )
) {
continue;
}
// This is a plugin from inventorypresser.com.
// Is the problem a missing license key?
if ( ! empty( $update_response->msg )
&& 'No license key has been provided.' === $update_response->msg
&& ! in_array( $update_response->slug, $handled_plugin_slugs, true )
&& ( ! is_multisite() || is_blog_admin() )
) {
/**
* Yes, output JavaScript that will change
* "Automatic update is unavailable for this plugin." to
* "License key is missing at Vehicles → Options"
*/
add_action(
'admin_print_footer_scripts',
function () use ( $update_response ) {
?><script type="text/javascript"><!--
jQuery(document).ready(function(){
jQuery('#<?php echo esc_js( $update_response->slug ); ?>-update .update-message p em').html( 'License key is missing at Vehicles → Options');
});
--></script>
<?php
}
);
$handled_plugin_slugs[] = $update_response->slug;
}
}
return $value;
}
Expand full source codeCollapse full source codeView on Github