theme_version = WOODMART_VERSION; } /** * Get count patches map. * * @return string */ public function get_count_patches_map() { global $pagenow; $patches_maps = get_transient( $this->transient_name ); if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && ( 'xts_dashboard' === $_GET['page'] || 'xts_theme_settings' === $_GET['page'] ) ) { //phpcs:ignore $patches_maps = $this->get_patches_maps(); } if ( ! $patches_maps || ! is_array( $patches_maps ) ) { return ''; } $patches_installed = get_option( 'xts_successfully_installed_patches', array() ); if ( isset( $patches_installed[ $this->theme_version ] ) ) { $patches_maps = array_diff_key( $patches_maps, $patches_installed[ $this->theme_version ] ); } $count = count( $patches_maps ); if ( 0 === $count ) { return ''; } ob_start(); ?> get_patches_maps_from_server(); $patch_installed = get_option( 'xts_successfully_installed_patches' ); ?>

print_notices(); // Must be in one line. ?>
$patcher ) : ?> theme_version ][ $patch_id ] ) ? ' xts-applied' : ''; ?>
check_filesystem_api() ) : ?> ' data-id="">
banner

check_filesystem_api() ) { $this->notices['warning'] = esc_html__( 'Direct access to theme file is not allowed on your server. You need to download and replace the files manually.', 'woodmart' ); } if ( ! $this->notices ) { return; } foreach ( $this->notices as $type => $notice ) { $this->print_notice( $notice, $type ); } } /** * Print notice. * * @param string $message Message. * @param string $type Type. */ private function print_notice( $message, $type = 'warning' ) { ?>
transient_name ); if ( ! $patches_maps ) { $patches_maps = $this->get_patches_maps_from_server(); } if ( ! is_array( $patches_maps ) ) { return array(); } return $patches_maps; } /** * Queries the patches server for a list of patches. * * @return array */ public function get_patches_maps_from_server() { $url = add_query_arg( array( 'theme_slug' => WOODMART_SLUG, 'version' => $this->theme_version, ), $this->remote_patches_uri ); $response = wp_remote_get( $url ); if ( is_wp_error( $response ) ) { $this->notices['error'] = $response->get_error_message(); $this->update_set_transient( 'error' ); return array(); } if ( ! isset( $response['body'] ) ) { $this->notices['error'] = $response['response']['code'] . ': ' . $response['response']['message']; $this->update_set_transient( 'error' ); return array(); } $response_body = json_decode( $response['body'], true ); if ( isset( $response_body['code'] ) && isset( $response_body['message'] ) ) { $this->notices['error'] = $response_body['message']; $this->update_set_transient( 'error' ); return array(); } if ( isset( $response_body['type'] ) && isset( $response_body['message'] ) ) { $this->notices[ $response_body['type'] ] = $response_body['message']; $this->update_set_transient( $response_body['type'] ); return array(); } if ( ! $response_body ) { $this->update_set_transient( 'actual' ); return array(); } $this->update_set_transient( $response_body ); return $response_body; } /** * Sets/updates the value of a transient. * * @param string|array $data Value. * * @return void */ public function update_set_transient( $data ) { set_transient( $this->transient_name, $data, DAY_IN_SECONDS ); } /** * Check filesystem API. * * @return bool */ public function check_filesystem_api() { global $wp_filesystem; if ( function_exists( 'WP_Filesystem' ) ) { WP_Filesystem(); } return 'direct' === $wp_filesystem->method; } }