This commit is contained in:
hanyixuanten
2026-08-10 19:03:44 +08:00
parent c0f4a3ad3c
commit b718294d3c
15 changed files with 82 additions and 94 deletions
+3 -3
View File
@@ -17,7 +17,7 @@ final class OICS_Contest_Client {
apply_filters( 'oics_contest_data_url', self::DATA_URL ),
array(
'timeout' => 10,
'user-agent' => 'OI Contest Schedule/' . OICS_VERSION . '; ' . home_url( '/' ),
'user-agent' => 'vblg OI Contest Schedule/' . OICS_VERSION . '; ' . home_url( '/' ),
)
);
@@ -26,12 +26,12 @@ final class OICS_Contest_Client {
}
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
return new WP_Error( 'oics_http_error', __( 'The contest data source returned an unexpected response.', 'oi-contest-schedule' ) );
return new WP_Error( 'oics_http_error', __( 'The contest data source returned an unexpected response.', 'vblg-oi-contest-schedule' ) );
}
$payload = json_decode( wp_remote_retrieve_body( $response ), true );
if ( ! $this->is_valid_payload( $payload ) ) {
return new WP_Error( 'oics_invalid_payload', __( 'The contest data source returned invalid data.', 'oi-contest-schedule' ) );
return new WP_Error( 'oics_invalid_payload', __( 'The contest data source returned invalid data.', 'vblg-oi-contest-schedule' ) );
}
$normalized = array(
+12 -12
View File
@@ -37,11 +37,11 @@ final class OICS_Plugin {
'oics-schedule-editor',
'oicsScheduleEditorL10n',
array(
'title' => __( 'OI Contest Schedule', 'oi-contest-schedule' ),
'description' => __( 'Display upcoming OI contests with local times and live countdowns.', 'oi-contest-schedule' ),
'settings' => __( 'Schedule settings', 'oi-contest-schedule' ),
'limit' => __( 'Number of contests', 'oi-contest-schedule' ),
'compact' => __( 'Compact layout', 'oi-contest-schedule' ),
'title' => __( 'vblg OI Contest Schedule', 'vblg-oi-contest-schedule' ),
'description' => __( 'Display upcoming OI contests with local times and live countdowns.', 'vblg-oi-contest-schedule' ),
'settings' => __( 'Schedule settings', 'vblg-oi-contest-schedule' ),
'limit' => __( 'Number of contests', 'vblg-oi-contest-schedule' ),
'compact' => __( 'Compact layout', 'vblg-oi-contest-schedule' ),
)
);
@@ -77,12 +77,12 @@ final class OICS_Plugin {
'oics-schedule',
'oicsScheduleL10n',
array(
'running' => __( 'Running', 'oi-contest-schedule' ),
'ended' => __( 'Ended', 'oi-contest-schedule' ),
'day' => __( 'd', 'oi-contest-schedule' ),
'hour' => __( 'h', 'oi-contest-schedule' ),
'minute' => __( 'm', 'oi-contest-schedule' ),
'second' => __( 's', 'oi-contest-schedule' ),
'running' => __( 'Running', 'vblg-oi-contest-schedule' ),
'ended' => __( 'Ended', 'vblg-oi-contest-schedule' ),
'day' => __( 'd', 'vblg-oi-contest-schedule' ),
'hour' => __( 'h', 'vblg-oi-contest-schedule' ),
'minute' => __( 'm', 'vblg-oi-contest-schedule' ),
'second' => __( 's', 'vblg-oi-contest-schedule' ),
)
);
}
@@ -113,7 +113,7 @@ final class OICS_Plugin {
public function register_dashboard_widget() {
wp_add_dashboard_widget(
'oics_contest_schedule',
esc_html__( 'Upcoming OI Contests', 'oi-contest-schedule' ),
esc_html__( 'Upcoming OI Contests', 'vblg-oi-contest-schedule' ),
array( $this, 'render_dashboard_widget' )
);
}
+7 -7
View File
@@ -12,12 +12,12 @@ final class OICS_Schedule_Renderer {
public function render( $limit = 10, $compact = false ) {
$payload = $this->client->get_payload();
if ( is_wp_error( $payload ) ) {
return $this->render_notice( __( 'Contest data is temporarily unavailable. Please try again later.', 'oi-contest-schedule' ), 'error' );
return $this->render_notice( __( 'Contest data is temporarily unavailable. Please try again later.', 'vblg-oi-contest-schedule' ), 'error' );
}
$contests = array_slice( $payload['contests'], 0, $limit );
if ( empty( $contests ) ) {
return $this->render_notice( __( 'No upcoming contests.', 'oi-contest-schedule' ), 'empty' );
return $this->render_notice( __( 'No upcoming contests.', 'vblg-oi-contest-schedule' ), 'empty' );
}
$classes = 'oics-schedule';
@@ -30,13 +30,13 @@ final class OICS_Schedule_Renderer {
<div class="<?php echo esc_attr( $classes ); ?>" data-oics-schedule>
<div class="oics-schedule__header">
<div>
<h2 class="oics-schedule__heading"><?php esc_html_e( 'Upcoming OI Contests', 'oi-contest-schedule' ); ?></h2>
<h2 class="oics-schedule__heading"><?php esc_html_e( 'Upcoming OI Contests', 'vblg-oi-contest-schedule' ); ?></h2>
<p class="oics-schedule__meta">
<?php esc_html_e( 'Device time zone', 'oi-contest-schedule' ); ?>:
<?php esc_html_e( 'Device time zone', 'vblg-oi-contest-schedule' ); ?>:
<span data-oics-time-zone>UTC</span>
</p>
</div>
<span class="oics-schedule__count"><?php echo esc_html( sprintf( _n( '%d contest', '%d contests', count( $contests ), 'oi-contest-schedule' ), count( $contests ) ) ); ?></span>
<span class="oics-schedule__count"><?php echo esc_html( sprintf( _n( '%d contest', '%d contests', count( $contests ), 'vblg-oi-contest-schedule' ), count( $contests ) ) ); ?></span>
</div>
<div class="oics-schedule__list">
<?php foreach ( $contests as $contest ) : ?>
@@ -45,7 +45,7 @@ final class OICS_Schedule_Renderer {
</div>
<?php if ( ! empty( $payload['generated_at'] ) ) : ?>
<p class="oics-schedule__updated">
<?php esc_html_e( 'Data updated', 'oi-contest-schedule' ); ?>:
<?php esc_html_e( 'Data updated', 'vblg-oi-contest-schedule' ); ?>:
<time data-oics-time="<?php echo esc_attr( $payload['generated_at'] ); ?>" data-oics-seconds></time>
</p>
<?php endif; ?>
@@ -69,7 +69,7 @@ final class OICS_Schedule_Renderer {
</span>
</span>
<span class="oics-contest__countdown" data-oics-start="<?php echo esc_attr( $contest['start_time'] ); ?>" data-oics-end="<?php echo esc_attr( $contest['end_time'] ); ?>">
<?php echo 'running' === $contest['status'] ? esc_html__( 'Running', 'oi-contest-schedule' ) : esc_html__( 'Upcoming', 'oi-contest-schedule' ); ?>
<?php echo 'running' === $contest['status'] ? esc_html__( 'Running', 'vblg-oi-contest-schedule' ) : esc_html__( 'Upcoming', 'vblg-oi-contest-schedule' ); ?>
</span>
</a>
<?php