$val ) $new_fields[ $key ] = $val; return $new_fields; } // Test updating themes //set_site_transient( 'update_themes', null ); add_filter( 'themes_api', 'autoprice24_theme_native_api', 10, 3 ); add_filter('pre_set_site_transient_update_themes', 'autoprice24_update_theme_native'); function autoprice24_theme_native_api( $false, $action, $args ) { // Check if this themes API is about this theme if( $args->slug != AUTOPRICE24_AUTO_PARTS_SHOP_SLUG) return $false; // POST data to send to your API $args = array( 'action' => 'get-theme-information' ); // Send request for detailed information $response = autoprice24_api_theme_native_request( $args ); return $response; } function autoprice24_update_theme_native( $transient ) { // The transient contains the 'checked' information // Now append to it information form your own API $theme_path = get_template(); // Check if the transient contains the 'checked' information // If no, just return its value without hacking it if ( empty( $transient->checked ) ){ $currentVersion = AUTOPRICE24_AUTO_PARTS_SHOP_VERSION; } else { $currentVersion = $transient->checked[$theme_path]; } // POST data to send to your API $args = array( 'action' => 'check-latest-version' ); // Send request checking for an update $response = autoprice24_api_theme_native_request( $args ); // If there is a new version, modify the transient if( version_compare( $response['new_version'], $currentVersion, '>' ) ){ $transient->response[$theme_path] = $response; } else if (version_compare( $response['new_version'], $currentVersion, '=' )){ if (isset($transient->response[$theme_path])){ unset($transient->response[$theme_path]); } } return $transient; } function autoprice24_api_theme_native_request( $args ) { // Send request $request = wp_remote_post( 'http://update.demoshop24.ru/'.AUTOPRICE24_AUTO_PARTS_SHOP_SLUG.'/', array( 'body' => $args ) ); if ( is_wp_error( $request ) || 200 != wp_remote_retrieve_response_code( $request ) ) return false; return unserialize($request['body']); }