' . sprintf( /* translators: %s: link to the data source */ esc_html__( 'Agent counts from %s', 'agenttally-state-agent-statistics' ), 'Base 7 Studio' ) . '
'; } function usrs_render_single( $code ) { $s = usrs_state( $code ); if ( ! $s ) { return '' . esc_html__( 'No data for that state.', 'agenttally-state-agent-statistics' ) . '
'; } $as_of = usrs_as_of(); return sprintf( '%1$s %2$s%3$s', esc_html( number_format_i18n( $s['agents'] ) ), esc_html( sprintf( /* translators: %s: state name */ __( 'real estate agents in %s', 'agenttally-state-agent-statistics' ), $s['name'] ) ), $as_of ? ' ' . esc_html( sprintf( /* translators: %s: month and year the data was compiled, e.g. August 2026 */ __( '(as of %s)', 'agenttally-state-agent-statistics' ), $as_of ) ) . '' : '' ); } function usrs_render_table( $a ) { $data = usrs_data(); $states = $data['states']; if ( ! $states ) { return '' . esc_html__( 'Statistics are unavailable.', 'agenttally-state-agent-statistics' ) . '
'; } $sort = in_array( $a['sort'], array( 'agents', 'name', 'phone', 'award' ), true ) ? $a['sort'] : 'agents'; usort( $states, function ( $x, $y ) use ( $sort ) { if ( 'name' === $sort ) { return strcmp( $x['name'], $y['name'] ); } $k = 'phone' === $sort ? 'phone_pct' : ( 'award' === $sort ? 'award_pct' : 'agents' ); return $y[ $k ] <=> $x[ $k ]; } ); $limit = absint( $a['limit'] ); if ( $limit > 0 ) { $states = array_slice( $states, 0, $limit ); } $cols = array_map( 'trim', explode( ',', $a['columns'] ) ); $out = '| ' . esc_html__( 'State', 'agenttally-state-agent-statistics' ) . ' | '; if ( in_array( 'agents', $cols, true ) ) { $out .= '' . esc_html__( 'Agents', 'agenttally-state-agent-statistics' ) . ' | '; } if ( in_array( 'phone', $cols, true ) ) { $out .= '' . esc_html__( 'With phone', 'agenttally-state-agent-statistics' ) . ' | '; } if ( in_array( 'award', $cols, true ) ) { $out .= '' . esc_html__( 'Award holders', 'agenttally-state-agent-statistics' ) . ' | '; } $out .= '
|---|---|---|---|
| ' . esc_html( $s['name'] ) . ' | '; if ( in_array( 'agents', $cols, true ) ) { $out .= '' . esc_html( number_format_i18n( $s['agents'] ) ) . ' | '; } if ( in_array( 'phone', $cols, true ) ) { $out .= '' . esc_html( $s['phone_pct'] ) . '% | '; } if ( in_array( 'award', $cols, true ) ) { $out .= '' . esc_html( $s['award_pct'] ) . '% | '; } $out .= '