Tribe__PUE__Plugin_Info::to_wp_format()
Transform plugin info into the format used by the native WordPress.org API
Return
(object)
Source
File: src/Tribe/PUE/Plugin_Info.php
public function to_wp_format() {
$info = new StdClass;
// The custom update API is built so that many fields have the same name and format
// as those returned by the native WordPress.org API. These can be assigned directly.
$sameFormat = array(
'name',
'slug',
'version',
'requires',
'tested',
'rating',
'upgrade_notice',
'num_ratings',
'downloaded',
'homepage',
'last_updated',
'api_expired',
'api_upgrade',
'api_invalid',
);
foreach ( $sameFormat as $field ) {
if ( isset( $this->$field ) ) {
$info->$field = $this->$field;
} else {
$info->$field = null;
}
}
//Other fields need to be renamed and/or transformed.
$info->download_link = $this->download_url;
if ( ! empty( $this->author_homepage ) ) {
$info->author = sprintf( '<a href="%s">%s</a>', esc_url( $this->author_homepage ), $this->author );
} else {
$info->author = $this->author;
}
if ( is_object( $this->sections ) ) {
$info->sections = get_object_vars( $this->sections );
} elseif ( is_array( $this->sections ) ) {
$info->sections = $this->sections;
} else {
$info->sections = array( 'description' => '' );
}
return $info;
}