The class-attribute.php is located in wp-contents/plugins/hivepress/includes/components
All I want to do is to dynamically change this:
<?php
*
* Attribute component.
*
* @package HivePress\Components
*/
namespace HivePress\Components;
use HivePress\Helpers as hp;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Handles model attributes.
*/
final class Attribute extends Component {
/**
* Model parameters.
*
* @var array
*/
protected $models = [];
/**
* Model attributes.
*
* @var array
*/
protected $attributes = [];
/**
* Class constructor.
*
* @param array $args Component arguments.
*/
public function __construct( $args = [] ) {
$args = hp\merge_arrays(
[
'models' => [
'listing' => [],
'vendor' => [],
'user' => [],
],
],
$args
);
parent::__construct( $args );
}
TO THIS:
<?php
/**
* Attribute component.
*
* @package HivePress\Components
*/
namespace HivePress\Components;
use HivePress\Helpers as hp;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/*
* Handles model attributes.
*/
final class Attribute extends Component {
/**
* Model parameters.
*
* @var array
*/
protected $models = [];
/**
* Model attributes.
*
* @var array
*/
protected $attributes = [];
/**
* Class constructor.
*
* @param array $args Component arguments.
*/
public function __construct( $args = [] ) {
$args = hp\merge_arrays(
[
'models' => [
'listing' => [],
'vendor' => [],
'user' => [],
'escort' => [],
],
],
$args
);
parent::__construct( $args );
}
USING a filter but, those listed at Source: components/class-attribute.php | HivePress Hook Reference doesn’t seem to work.
Here’s my code (trial A):
<?php
/**
* Attribute component.
*
* @package HivePress\Components
*/
namespace HivePress\Components;
use HivePress\Helpers as hp;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Handles model attributes.
*/
add_filter(
'hivepress/v1/components/attribute/models',
function( $models ) {
// Add 'escort' post type to the attribute-enabled models.
$models[] = 'escort';
return $models;
}
);
TRIAL B:
<?php
/**
* Attribute component.
*
* @package HivePress\Components
*/
namespace HivePress\Components;
use HivePress\Helpers as hp;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
/**
* Handles model attributes.
*/
class Attribute extends Component {
/**
* Class constructor.
*
* @param array $args Component arguments.
*/
public function __construct( $args = [] ) {
parent::__construct( $args );
add_filter(
'hivepress/v1/components/attribute/models',
[ $this, 'add_escort_model' ]
);
}
/**
* Adds the 'escort' post type to the attribute-enabled models.
*
* @param array $models Model names.
* @return array
*/
public function add_escort_model( $models ) {
// Add 'escort' post type to the attribute-enabled models.
$models[] = 'escort';
return $models;
}
}
ALL I WANT IS TO INTEGRATE MY CUSTOM POST TYPE ESCORT WITH THE EXISTING HIVEPRESS ATTRIBUTES
Pls help!