feat: initial ACRIB WordPress deployment
- WordPress 6.9.4 (es_ES) with Kadence theme - Homepage: Hero, La Asociación, Pilares, Beneficios, Eventos, Miembros, Hazte Miembro, Contacto - Brand identity: #13294b navy, #a12932 burgundy, #c69c48 gold - Fonts: Raleway (headings) + Source Sans 3 (body) + Lato (UI) - Plugins: Kadence Blocks, Polylang, Contact Form 7 - Custom CSS with full brand styling and responsive layout - HTTPS enforced via wp-config.php proxy detection
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
<?php declare( strict_types=1 );
|
||||
|
||||
namespace KadenceWP\KadenceBlocks\Optimizer\Path;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* The Path Data Transfer Object.
|
||||
*
|
||||
* Represents a URL path and optionally its associated post ID.
|
||||
* The post_id is optional but recommended for reliable status synchronization.
|
||||
*
|
||||
* @see Path_Factory
|
||||
*/
|
||||
final class Path {
|
||||
|
||||
/**
|
||||
* The path from $wp->request.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private string $path;
|
||||
|
||||
/**
|
||||
* Optional post ID associated with this path.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
private ?int $post_id;
|
||||
|
||||
/**
|
||||
* @param string $path The path from $wp->request.
|
||||
* @param int|null $post_id Optional post ID for status synchronization.
|
||||
*
|
||||
* @throws InvalidArgumentException If the path is empty.
|
||||
*/
|
||||
public function __construct( string $path, ?int $post_id = null ) {
|
||||
if ( ! $path ) {
|
||||
throw new InvalidArgumentException( 'Cannot hash an empty path. Verify you are using this after the wp hook fired.' );
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
$this->post_id = $post_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function path(): string {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a sha256 hash for the path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function hash(): string {
|
||||
return hash( 'sha256', $this->path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated post ID if available.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function post_id(): ?int {
|
||||
return $this->post_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Path with post ID attached (immutable).
|
||||
*
|
||||
* Useful for adding post context to an existing Path object.
|
||||
*
|
||||
* @param int $post_id The post ID.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function with_post_id( int $post_id ): self {
|
||||
return new self( $this->path, $post_id );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php declare( strict_types=1 );
|
||||
|
||||
namespace KadenceWP\KadenceBlocks\Optimizer\Path;
|
||||
|
||||
use KadenceWP\KadenceBlocks\StellarWP\SuperGlobals\SuperGlobals as SG;
|
||||
use WP_Post;
|
||||
|
||||
/**
|
||||
* A path object to generate a unique key for each URL on a site.
|
||||
*/
|
||||
final class Path_Factory {
|
||||
|
||||
/**
|
||||
* Create a path object based on the current relative path and $post global.
|
||||
*
|
||||
* @throws \InvalidArgumentException If the path is empty.
|
||||
*
|
||||
* @return Path
|
||||
*/
|
||||
public function make(): Path {
|
||||
$uri = SG::get_server_var( 'REQUEST_URI', '' );
|
||||
|
||||
// Normalize leading slashes BEFORE wp_parse_url to prevent // being treated as protocol-relative URL.
|
||||
$uri = preg_replace( '#^/+#', '/', $uri );
|
||||
|
||||
if ( $uri === null ) {
|
||||
return new Path( '' );
|
||||
}
|
||||
|
||||
$path = wp_parse_url( $uri, PHP_URL_PATH ) ?: '';
|
||||
|
||||
// Normalize multiple slashes within the path.
|
||||
$normalized = preg_replace( '#/{2,}#', '/', $path );
|
||||
|
||||
if ( $normalized === null || $normalized === '' ) {
|
||||
return new Path( '' );
|
||||
}
|
||||
|
||||
// Ensure the path starts with a slash.
|
||||
if ( ! str_starts_with( $normalized, '/' ) ) {
|
||||
$normalized = '/' . $normalized;
|
||||
}
|
||||
|
||||
// This will get the proper front/posts page ID.
|
||||
$current_post = get_queried_object();
|
||||
|
||||
if ( ! $current_post instanceof WP_Post ) {
|
||||
return new Path( $normalized, null );
|
||||
}
|
||||
|
||||
return new Path( $normalized, $current_post->ID );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user