| Current Path : /home/x/b/o/xbodynamge/namtation/wp-content/ |
| Current File : /home/x/b/o/xbodynamge/namtation/wp-content/BbPress.tar |
Component.php 0000666 00000005100 15114460770 0007224 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Standalone\BbPress;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* bbPress Component class.
*
* @since 4.8.1
*/
class Component {
/**
* The current component template type.
*
* @since 4.8.1
*
* @var string|null
*/
public $templateType = null;
/**
* The topic single page data.
*
* @since 4.8.1
*
* @var array
*/
public $topic = [];
/**
* Class constructor.
*
* @since 4.8.1
*/
public function __construct() {
if ( is_admin() ) {
return;
}
$this->setTemplateType();
$this->setTopic();
}
/**
* Sets the template type.
*
* @since 4.8.1
*
* @return void
*/
private function setTemplateType() {
if ( function_exists( 'bbp_is_single_topic' ) && bbp_is_single_topic() ) {
$this->templateType = 'bbp-topic_single';
}
}
/**
* Sets the topic data.
*
* @since 4.8.1
*
* @return void
*/
private function setTopic() {
if ( 'bbp-topic_single' !== $this->templateType ) {
return;
}
if (
! function_exists( 'bbpress' ) ||
! function_exists( 'bbp_has_replies' ) ||
! bbp_has_replies()
) {
return;
}
$replyQuery = bbpress()->reply_query ?? null;
$replies = $replyQuery->posts ?? [];
$mainTopic = is_array( $replies ) && ! empty( $replies ) ? array_shift( $replies ) : null;
if ( $mainTopic instanceof \WP_Post ) {
$this->topic = [
'title' => $mainTopic->post_title,
'content' => $mainTopic->post_content,
'date' => $mainTopic->post_date,
'author' => get_the_author_meta( 'display_name', $mainTopic->post_author ),
];
$comments = [];
if ( ! empty( $replies ) ) {
foreach ( $replies as $reply ) {
if ( ! $reply instanceof \WP_Post ) {
continue;
}
$comments[ $reply->ID ] = [
'content' => $reply->post_content,
'date_recorded' => $reply->post_date,
'user_fullname' => get_the_author_meta( 'display_name', $reply->post_author ),
];
if ( ! empty( $reply->reply_to ) ) {
$comments[ $reply->reply_to ]['children'][] = $comments[ $reply->ID ];
unset( $comments[ $reply->ID ] );
}
}
$this->topic['comment'] = array_values( $comments );
}
return;
}
$this->resetComponent();
}
/**
* Resets some of the component properties.
*
* @since 4.8.1
*
* @return void
*/
private function resetComponent() {
$this->templateType = null;
}
/**
* Determines the schema type for the current component.
*
* @since 4.8.1
*
* @return void
*/
public function determineSchemaGraphsAndContext() {
}
} BbPress.php 0000666 00000002273 15114460770 0006632 0 ustar 00 <?php
namespace AIOSEO\Plugin\Common\Standalone\BbPress;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Handles the bbPress integration with AIOSEO.
*
* @since 4.8.1
*/
class BbPress {
/**
* Instance of the Component class.
*
* @since 4.8.1
*
* @var Component
*/
public $component;
/**
* Class constructor.
*
* @since 4.8.1
*/
public function __construct() {
if (
aioseo()->helpers->isAjaxCronRestRequest() ||
! aioseo()->helpers->isPluginActive( 'bbpress' )
) {
return;
}
// Hook into `plugins_loaded` to ensure bbPress has loaded some necessary functions.
add_action( 'plugins_loaded', [ $this, 'maybeLoad' ], 20 );
}
/**
* Hooked into `plugins_loaded` action hook.
*
* @since 4.8.1
*
* @return void
*/
public function maybeLoad() {
// If the bbPress version is below 2 we bail.
if ( ! function_exists( 'bbp_get_version' ) || version_compare( bbp_get_version(), '2', '<' ) ) {
return;
}
add_action( 'wp', [ $this, 'setComponent' ] );
}
/**
* Hooked into `wp` action hook.
*
* @since 4.8.1
*
* @return void
*/
public function setComponent() {
$this->component = new Component();
}
}