Challenge 1 and 2 - Gabriel - #25
Open
gabrielgpacheco wants to merge 3 commits into
Open
Conversation
- Register 6 custom post types (attorney, practice_area, case_result, testimonial, office, faq) with proper hierarchical flags - Register 4 taxonomies (practice-area-group, case-type, region, attorney-position) attached to the relevant post types - Add native meta boxes using register_post_meta (single, typed) with editor UI for every field, all exposed in REST - Enrich REST API with related posts hydration and case_result.amount_formatted (cents to human-readable amount) - Create front-page.php schema overview listing CPTs and taxonomies with direct admin and REST links - Add recommended plugins notice (ACF Free, CF7, Yoast, Redirection, WP Super Cache, Wordfence, UpdraftPlus) with purpose descriptions - Include professional README.md with setup instructions and testing steps - Write all code comments in English; update style.css header for the Pug & Puggle theme
Author
Pull Request DescriptionOverview ✅ Challenge 1 – Airpug (Front‑End Theme)
✅ Challenge 2 – Law Firm Backend Schema (This PR)All code lives inside the theme (
🔬 How to Test (Challenge 2)
📝 Notes for Reviewers
Feedback welcome! 🐾 |
…tion vulnerabilities SUMMARY This commit addresses multiple critical security vulnerabilities across the theme, implementing WordPress security best practices for output escaping, input sanitization, CSRF protection, and safe file operations. CHANGES BY PHASE Phase 1: Cross-Site Scripting (XSS) Prevention (50+ fixes) - header.php: Escaped unescaped ACF field outputs (URLs and text) * Fixed contact_phone['url'] with esc_url() * Fixed contact_phone['title'] with esc_html() * Applied escaping to both desktop and mobile nav sections - inc/template_functions.php: Secured inf_acf_link() function * Added esc_url() for link URLs * Added esc_attr() for CSS classes * Added esc_html() for link text * Fixed missing quotes in href attribute - searchform.php: Fixed variable naming bug * Corrected $ps_unique_id to $inf_unique_id on label reference - templates/ppc-landing-page-matchup.php: Escaped 40+ field outputs * Applied esc_url() to all image src and href attributes * Applied esc_attr() to alt text and data attributes * Applied esc_html() to all text content * Applied wp_kses_post() to rich HTML content * Fixed inline style URL syntax with proper quote handling - inc/services/locations.php: Secured AJAX response output * Escaped link URLs with esc_url() * Escaped link titles with esc_html() Phase 2: Input Sanitization & CSRF Protection - inc/services/locations.php: Added nonce verification and input sanitization * Added wp_verify_nonce() check for AJAX requests * Sanitized $_POST['q'] and $_POST['post_type'] with sanitize_text_field() * Validated post_type against registered post types * Sanitized geopoint array values with floatval() * Added documentation note for frontend nonce requirement - functions.php: Added AJAX nonce to frontend * Added location_navigator_nonce to wp_localize_script() * Makes nonce available to JavaScript AJAX calls - inc/hooks.php: Secured review submission handler * Added input validation for required fields * Sanitized post_title with sanitize_text_field() * Sanitized post_content with wp_kses_post() * Validated rating as integer in range (0-5) * Added error checking with is_wp_error() * Sanitized reviewer_name before database update Phase 5: File Operations & Path Validation - functions.php: Implemented safe file version retrieval * Added inf_get_asset_version() helper function * Checks file existence before filemtime() call * Falls back to theme version if file missing * Suppresses warnings with error control operator * Updated all asset enqueueing to use helper function - functions.php: Added path traversal protection * Added regex validation in inf_load_blocks(): /^[a-z0-9\-]+$/ * Prevents arbitrary path access via block names * Skips invalid block names safely * Uses helper function for all block file version retrieval SECURITY IMPACT - Prevents XSS attacks via unescaped user-controllable data - Blocks CSRF attacks on AJAX endpoints - Validates and sanitizes all user input - Prevents path traversal vulnerabilities - Improves error handling and graceful degradation TESTING NOTES - All escaping functions follow WordPress standards - AJAX nonce must be included in frontend JavaScript calls - Requires update to frontend code to send 'nonce' parameter - File operations now fail gracefully with theme version fallback FILES MODIFIED - theme/header.php - theme/inc/template_functions.php - theme/searchform.php - theme/templates/ppc-landing-page-matchup.php - theme/inc/services/locations.php - theme/inc/hooks.php - theme/functions.php RELATED ISSUES Security audit identified 50+ vulnerabilities across XSS, CSRF, input sanitization, and file operation categories.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@steinbachr