Skip to content

stantchev/PressGrid-WordPress-Theme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PressGrid β€” WordPress Theme

A production-ready, security-hardened WordPress theme engineered for high-traffic news and magazine websites.

WordPress PHP License Lighthouse WP.org Compliant Version


✦ Overview

PressGrid is a fully open-source WordPress theme built for the demands of modern news operations. It ships with a visual Layout Builder, 6 advertisement zones, a secure font upload system, CSS variable theming, OpenWeatherMap weather integration, Frankfurter ECB forex ticker, and full WordPress.org Theme Review compliance β€” all with zero JavaScript dependencies beyond WordPress core.

πŸ“– Full Documentation β†’ πŸ”‘ API Setup Guide β†’


⚑ Key Features

Category Details
Performance Lighthouse 95+, deferred JS, lazy images, no_found_rows, Redis-compatible transient cache, preconnect hints
Security Nonces, capability checks, WOFF2 MIME validation, security headers, author enumeration block
Layout Builder 8 configurable homepage sections with enable/disable, layout type, category, and post count
Ad System 6 ad zones with mobile/desktop visibility, async load, and wp_kses() sanitization
Customizer CSS custom property theming with live postMessage preview β€” 6 color controls
Typography Secure .woff2 font upload (MIME-validated, 1MB cap, random rename, .htaccess protected)
Weather OpenWeatherMap widget β€” sidebar + top bar mini widget, 5-day forecast, geolocation, Bulgarian UI
Forex Ticker Frankfurter ECB rates β€” auto-activates when a Business/Finance section is present in Layout Builder
Reading UX Progress bar, estimated read time, native share buttons, related posts, back-to-top button
SEO NewsArticle schema, Open Graph, Twitter Cards, breadcrumbs, canonical tags
Accessibility WCAG 2.1 AA β€” skip links, ARIA labels, focus-visible, semantic HTML5
Compatibility WP Super Cache, W3TC, LiteSpeed, WP Rocket, Redis, Memcached
Standards GPL-2.0+, PHPCS WordPress Coding Standards, WP.org Theme Review compliant

πŸ“¦ GitHub Repository Info

Repo Name:

pressgrid

Repo Description:

Production-ready WordPress theme for high-traffic news & magazine websites. Layout Builder, 6 Ad Zones, OpenWeatherMap, Frankfurter forex ticker, CSS variable Customizer, security-hardened, Lighthouse 95+, vanilla JS, GPL licensed.

Topics / Tags:

wordpress wordpress-theme news-theme magazine-theme layout-builder
customizer advertisement-zones performance security-hardened
vanilla-js gpl lighthouse accessibility wcag schema-org
openweathermap frankfurter forex weather

πŸ—‚οΈ File Structure

pressgrid/
β”œβ”€β”€ style.css                   # Theme header + complete CSS (~22KB)
β”œβ”€β”€ functions.php               # Setup, enqueue, transients, SEO, schema, preconnect
β”œβ”€β”€ header.php                  # Sticky nav, breaking ticker / forex ticker, logo
β”œβ”€β”€ footer.php                  # Widgets, nav, developer credit
β”œβ”€β”€ index.php                   # Fallback archive template
β”œβ”€β”€ front-page.php              # Layout Builder homepage
β”œβ”€β”€ single.php                  # Single post β€” progress bar, share, related posts
β”œβ”€β”€ archive.php                 # Category / tag / author archives
β”œβ”€β”€ page.php                    # Static pages
β”œβ”€β”€ search.php                  # Search results
β”œβ”€β”€ comments.php                # Threaded comments + form
β”œβ”€β”€ sidebar.php                 # Sticky sidebar widget area
β”œβ”€β”€ 404.php                     # Custom 404
β”œβ”€β”€ API-GUIDE.md                # API setup guide (Google Fonts, OWM, Frankfurter)
β”‚
β”œβ”€β”€ inc/
β”‚   β”œβ”€β”€ security.php            # Headers, XMLRPC toggle, font upload security
β”‚   β”œβ”€β”€ customizer.php          # All Customizer controls + CSS variable output
β”‚   β”œβ”€β”€ typography.php          # Secure .woff2 upload admin page
β”‚   β”œβ”€β”€ ads.php                 # 6 ad zones, wp_kses sanitization, rendering
β”‚   β”œβ”€β”€ layout-builder.php      # Layout Builder + Security settings admin pages
β”‚   β”œβ”€β”€ weather.php             # OpenWeatherMap integration + Customizer settings
β”‚   └── forex.php               # Frankfurter ECB forex ticker + business section detection
β”‚
β”œβ”€β”€ template-parts/
β”‚   β”œβ”€β”€ content/
β”‚   β”‚   β”œβ”€β”€ post-card.php       # Reusable post card component (with hover animation)
β”‚   β”‚   └── none.php            # No results state
β”‚   └── layout/
β”‚       β”œβ”€β”€ hero.php            # Hero grid (1 large + sidebar cards)
β”‚       β”œβ”€β”€ latest-posts.php    # Latest posts β€” grid-2/3/4 or list
β”‚       β”œβ”€β”€ category-grid.php   # Category grid (transient cached)
β”‚       β”œβ”€β”€ trending.php        # Trending by comment count (cached)
β”‚       β”œβ”€β”€ editor-picks.php    # Editor picks random (cached 30min)
β”‚       └── newsletter.php      # Newsletter CTA section
β”‚
β”œβ”€β”€ assets/js/
β”‚   β”œβ”€β”€ main.js                 # Nav, lazy-load, progress bar, share, back-to-top (deferred)
β”‚   └── customizer-preview.js  # Live CSS variable Customizer preview
β”‚
β”œβ”€β”€ languages/
β”‚   β”œβ”€β”€ pressgrid.pot           # Translation template (182 strings)
β”‚   β”œβ”€β”€ pressgrid-bg_BG.po/mo  # Bulgarian translation
β”‚   └── pressgrid-en_GB.po/mo  # English (UK)
β”‚
β”œβ”€β”€ screenshot.png              # 880Γ—660 theme screenshot
└── readme.txt                  # WordPress.org compliant readme

πŸš€ Installation

Option 1 β€” WordPress Admin

  1. Go to Appearance β†’ Themes β†’ Add New β†’ Upload Theme
  2. Select pressgrid-v2.5.0.zip β†’ Install Now β†’ Activate
  3. Configure at Appearance β†’ Customize, Layout Builder, Theme Ads

Option 2 β€” WP-CLI

wp theme install pressgrid-v2.5.0.zip --activate

Option 3 β€” FTP / Manual

# Unzip and upload to your WordPress themes directory:
/wp-content/themes/pressgrid/

βš™οΈ Requirements

Requirement Minimum Recommended
WordPress 6.3 6.7+
PHP 8.0 8.2+
MySQL / MariaDB 5.7 / 10.3 8.0 / 10.6+
Browser ES2017+, CSS Grid β€”

🎨 Customizer

Navigate to Appearance β†’ Customize β†’ PressGrid: Colors to set your brand palette. All colors are output as CSS custom properties on :root with live postMessage preview.

Setting CSS Variable Default
Primary Color --pg-primary #1a73e8
Secondary Color --pg-secondary #0d47a1
Accent Color --pg-accent #e91e63
Background Color --pg-bg #ffffff
Text Color --pg-text #212121
Link Hover Color --pg-link-hover #0d47a1

πŸ—οΈ Layout Builder

Appearance β†’ Layout Builder β€” Configure 8 homepage sections:

Section Default Layout Description
hero hero-grid 1 large featured + sidebar cards
latest_posts grid-3 Most recent posts
category_grid grid-4 Posts from a category (cached)
trending list By comment count, last 7 days
editor_picks grid-4 Random featured posts (30-min cache)
newsletter newsletter Newsletter CTA section
custom_html custom_html Free-form HTML (wp_kses_post)
ad_block ad_block Renders between-posts ad zone

Tip: Assign a Business or Finance category to any section and the top bar Breaking News ticker will automatically switch to the Frankfurter forex ticker β€” no configuration needed.


πŸ“’ Advertisement System

Appearance β†’ Theme Ads β€” Manage 6 zones:

Zone Location Typical Size
header Below sticky navigation 728Γ—90
sidebar_top Top of sidebar 300Γ—250
sidebar_middle Middle of sidebar 300Γ—600
in_article Above article content Responsive
between_posts Homepage ad block Responsive
footer Above site footer 728Γ—90

Each zone: enable/disable toggle, HTML/JS ad code input (sanitized with wp_kses()), desktop/mobile visibility, async load option.


🌀️ Weather Widget

Powered by OpenWeatherMap (free API key required).

Appearance β†’ Customize β†’ PressGrid: Π’Ρ€Π΅ΠΌΠ΅Ρ‚ΠΎ

Feature Details
Current conditions Temperature, feels like, hi/lo, humidity, wind, clouds
5-day forecast Daily icons + temps in a compact row
Top bar mini widget β˜€οΈ 7Β°C Β· Sofia β€” hidden on small screens
Geolocation βŠ• button β€” detects user location, no data stored
Cache 30 min (current) Β· 1 hour (forecast)
Language Bulgarian day names, translated UI

πŸ‘‰ How to get a free OpenWeatherMap API key β†’


πŸ’± Forex Ticker

Powered by Frankfurter β€” free, no API key, ECB data.

The forex ticker automatically replaces the Breaking News bar when the Layout Builder has an active section targeting a Business or Finance category. No configuration required.

Appearance β†’ Customize β†’ PressGrid: Π’Π°Π»ΡƒΡ‚ΠΈ (Forex)

Setting Default
Base currency EUR
Target currencies USD, GBP, BGN, CHF, JPY
Business category slug Auto-detected (business, biznes, бизнСс, finance, финанси…)
Force always on false
Feature Details
Data source European Central Bank via frankfurter.app
Update frequency Once daily (weekdays ~16:00 CET)
Cache 6 hours
API key required No

πŸ‘‰ Frankfurter API docs β†’


πŸ“– Single Post Features (v2.5)

Feature How it works
Reading progress bar Thin red line at top of viewport, JS-driven, single posts only
Estimated read time str_word_count / 200 β€” shown in post meta
Share buttons Web Share API (mobile) + copy-to-clipboard fallback + LinkedIn β€” zero external JS
Related posts 3 posts from same category, random order, no plugin
Back-to-top button Appears after 400px scroll, smooth scroll, pure CSS + ~8 lines JS

⚑ Performance Architecture

  • Transient caching β€” hero, trending, category grid, editor picks (5–30 min TTL, cleared on save_post)
  • no_found_rows: true on cached queries β€” skips SQL_CALC_FOUND_ROWS
  • Post ID caching β€” only IDs stored in transients; query reconstructed from cache
  • Preconnect hints β€” <link rel="preconnect"> for Google Fonts, OpenWeatherMap, Frankfurter (conditional)
  • Deferred JS β€” <script defer> strategy for all theme scripts
  • Native lazy loading β€” loading="lazy" + decoding="async" on all non-LCP images
  • LCP optimization β€” fetchpriority="high" on hero image
  • No render-blocking resources β€” all scripts in footer or deferred
  • No jQuery, no Bootstrap β€” 100% vanilla JavaScript
  • CSS Grid + Flexbox β€” no CSS framework overhead (~22KB unminified CSS)
  • Redis/Memcached compatible β€” set_transient() uses object cache backend when available

πŸ”’ Security Hardening

  • βœ… Every $_POST / $_GET β€” wp_verify_nonce() + current_user_can()
  • βœ… All output β€” esc_html(), esc_url(), esc_attr(), wp_kses_post()
  • βœ… Ad HTML β€” wp_kses() with strict allowed-tags whitelist
  • βœ… Font upload β€” WOFF2 magic-byte validation (0x774F4632), 1MB cap, random rename, .htaccess protected directory
  • βœ… Security headers via wp_headers filter β€” X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy
  • βœ… WordPress version removed from <head> and all feeds
  • βœ… Author enumeration blocked via /?author=N redirect
  • βœ… Login errors genericized β€” no username enumeration
  • βœ… No eval(), no direct DB queries, no obfuscated code
  • βœ… Direct file access blocked in every PHP file
  • βœ… Optional XML-RPC disable β€” Appearance β†’ Theme Security
  • βœ… All functions prefixed pressgrid_ β€” no global namespace pollution
  • βœ… All external API calls server-side only (wp_remote_get) β€” browser never contacts APIs directly

🌐 SEO & Schema

  • NewsArticle JSON-LD on all single posts (auto-generated)
  • Open Graph β€” og:title, og:description, og:image, og:type, og:site_name
  • Twitter Cards β€” summary_large_image with featured image auto-population
  • Canonical <link> on every page
  • Breadcrumb navigation β€” semantic, accessible
  • Semantic HTML5 β€” <header>, <main>, <article>, <nav>, <aside>, <footer>
  • Reading time estimation displayed in post meta
  • Pagination rel="prev" / rel="next" via WordPress core

🌍 Translation

Text domain: pressgrid β€” .pot file included in /languages/ (182 strings).

Bundled translations:

Locale File Status
bg_BG pressgrid-bg_BG.po/mo Complete
en_GB pressgrid-en_GB.po/mo Complete
# Generate POT file
wp i18n make-pot . languages/pressgrid.pot --domain=pressgrid

# Compile PO to MO
msgfmt languages/pressgrid-bg_BG.po -o languages/pressgrid-bg_BG.mo

Compatible with Loco Translate and WPML.


πŸ”‘ API Integrations

All external API calls are made server-side (PHP). The visitor's browser never contacts these services directly.

API Key required Cost Cache Used for
Google Fonts No Free Browser Playfair Display, Barlow fonts
OpenWeatherMap Yes (free tier) $0 30 min / 1 hr Weather widget
Frankfurter No Free 6 hours Forex ticker (ECB data)

πŸ‘‰ Full API setup guide with step-by-step instructions β†’


πŸ”§ Public Functions (Developer Reference)

// Output breadcrumbs
pressgrid_breadcrumbs();

// Output post meta (author, date, reading time)
pressgrid_post_meta( $post_id );

// Render an ad zone
pressgrid_render_ad( 'sidebar_top' );

// Get first category label HTML
pressgrid_get_category_label( $post_id );

// Get cached hero WP_Query
$query = pressgrid_get_hero_posts( 3 );

// Get cached trending WP_Query
$query = pressgrid_get_trending_posts( 6 );

// Get cached category WP_Query
$query = pressgrid_get_category_posts( $cat_id, 4 );

// Check if a Business/Finance section is active (for forex ticker logic)
$show_forex = pressgrid_has_business_section();

// Get exchange rates from Frankfurter ECB API
$rates = pressgrid_get_forex_rates(); // ['base' => 'EUR', 'rates' => [...], 'date' => '...']

// Get weather data from OpenWeatherMap
$weather  = pressgrid_get_weather();   // current conditions array
$forecast = pressgrid_get_forecast();  // 5-day forecast array

// Get estimated reading time in minutes
$mins = pressgrid_reading_time( $post_id );

β™Ώ Accessibility

  • Skip-to-content link (.skip-link)
  • All navigation has aria-label
  • Mobile toggle with aria-expanded state management
  • Keyboard-accessible dropdown menus with aria-haspopup
  • focus-visible outline styles for keyboard users
  • Sufficient color contrast ratios (WCAG AA)
  • Semantic heading hierarchy on all templates
  • Images require alt text β€” enforced via template functions
  • Progress bar marked aria-hidden="true" (decorative)
  • Share buttons with descriptive aria-label attributes

πŸ“‹ WordPress.org Compliance

  • βœ… GPL-2.0-or-later license
  • βœ… Proper theme header in style.css
  • βœ… Text domain: pressgrid
  • βœ… All strings translatable
  • βœ… No upsells, no tracking, no affiliate links
  • βœ… No obfuscated code
  • βœ… No required plugins
  • βœ… No admin nags
  • βœ… No hidden backlinks
  • βœ… Developer credit is removable
  • βœ… readme.txt included
  • βœ… screenshot.png included (880Γ—660)

πŸ“‹ Changelog

v2.5.0

  • New: Frankfurter ECB forex ticker β€” auto-activates when Layout Builder has a Business/Finance section
  • New: OpenWeatherMap weather widget (sidebar + top bar mini widget, 5-day forecast, geolocation)
  • New: Reading progress bar on single posts
  • New: Estimated read time in post meta
  • New: Native share buttons (Web Share API + copy-to-clipboard + LinkedIn, zero external JS)
  • New: Related posts section after article content (same category, no plugin)
  • New: Back-to-top button (appears at 400px scroll)
  • New: Sticky sidebar
  • New: Card hover animations (translateY + shadow)
  • New: Open Graph + Twitter Card meta tags
  • New: NewsArticle JSON-LD schema
  • New: Breadcrumb navigation
  • New: preconnect hints for Google Fonts, OpenWeatherMap, Frankfurter
  • New: API-GUIDE.md β€” step-by-step API setup documentation
  • New: bg_BG and en_GB translations (182 strings)
  • Improved: Hero grid layout rewrite (flex, 3-item limit, category labels, thumb hover)
  • Improved: pressgrid_post_meta() now includes read time and modified date

v1.0.0

  • Initial release

πŸ“„ License

PressGrid WordPress Theme
Copyright (C) 2024 Milen Stanchev

Released under the GNU General Public License v2 or later.


πŸ‘€ Author

Milen Stanchev
🌐 https://stanchev.bg/
πŸ™ github.com/stantchev


PressGrid is an independent open-source project. No affiliation with WordPress.org or Automattic.