Files
roi-theme/wp-content/plugins/thrive-ab-page-testing/includes/class-thrive-ab-post.php
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

77 lines
1.3 KiB
PHP
Executable File

<?php
/**
* Thrive Themes - https://thrivethemes.com
*
* @package thrive-ab-page-testing
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Silence is golden
}
class Thrive_AB_Post {
/**
* @var WP_Post
*/
protected $_post;
/**
* @var Thrive_AB_Meta
*/
private $_meta;
/**
* Thrive_AB_Post constructor.
*
* @param $post WP_Post|int
*
* @throws Exception
*/
public function __construct( $post ) {
$post = is_int( $post ) ? get_post( $post ) : $post;
if ( ! ( $post instanceof WP_Post ) ) {
throw new Exception( __( 'Post not found', 'thrive-ab-page-testing' ) );
}
$this->_post = $post;
}
public function get_meta() {
if ( empty( $this->_meta ) ) {
$this->_meta = new Thrive_AB_Meta( $this->_post->ID );
}
return $this->_meta;
}
/**
* @param $meta Thrive_AB_Meta
*/
public function set_meta( $meta ) {
$this->_meta = $meta;
}
public function __get( $key ) {
$value = null;
if ( method_exists( $this, $key ) ) {
$value = call_user_func( array( $this, $key ) );
} elseif ( isset( $this->_post->$key ) ) {
$value = $this->_post->$key;
} elseif ( ( $meta = $this->get_meta()->get( $key ) ) !== null ) {
$value = $meta;
}
return $value;
}
public function get_post() {
return $this->_post;
}
}