Edit File by line
/home/barbar84/www/wp-conte.../themes/Divi/core/componen.../post
File: Object.php
<?php
[0] Fix | Delete
[1] Fix | Delete
[2] Fix | Delete
abstract class ET_Core_Post_Object {
[3] Fix | Delete
[4] Fix | Delete
/**
[5] Fix | Delete
* @var ET_Core_Data_Utils
[6] Fix | Delete
*/
[7] Fix | Delete
protected static $_;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Current instances of this class organized by type.
[11] Fix | Delete
*
[12] Fix | Delete
* @since 3.0.99
[13] Fix | Delete
* @var array[] {
[14] Fix | Delete
*
[15] Fix | Delete
* @type ET_Core_Post_Object[] $type {
[16] Fix | Delete
*
[17] Fix | Delete
* @type ET_Core_Post_Object $name Instance.
[18] Fix | Delete
* ...
[19] Fix | Delete
* }
[20] Fix | Delete
* ...
[21] Fix | Delete
* }
[22] Fix | Delete
*/
[23] Fix | Delete
private static $_instances = array();
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The `$args` array used when registering this post object.
[27] Fix | Delete
*
[28] Fix | Delete
* @since 3.0.99
[29] Fix | Delete
* @var array
[30] Fix | Delete
*/
[31] Fix | Delete
protected $_args;
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* The owner of this instance. Default 'core'. Accepts 'divi', 'builder', 'epanel', 'bloom', 'monarch'.
[35] Fix | Delete
*
[36] Fix | Delete
* @since 3.0.99
[37] Fix | Delete
* @var string
[38] Fix | Delete
*/
[39] Fix | Delete
protected $_owner = 'core';
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Whether or not the object has been registered.
[43] Fix | Delete
*
[44] Fix | Delete
* @since 3.0.99
[45] Fix | Delete
* @var bool
[46] Fix | Delete
*/
[47] Fix | Delete
protected $_registered = false;
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* The WP object for this instance.
[51] Fix | Delete
*
[52] Fix | Delete
* @since 3.0.99
[53] Fix | Delete
* @var WP_Post_Type|WP_Taxonomy
[54] Fix | Delete
*/
[55] Fix | Delete
protected $_wp_object;
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Post object key.
[59] Fix | Delete
*
[60] Fix | Delete
* @since 3.0.99
[61] Fix | Delete
* @var string
[62] Fix | Delete
*/
[63] Fix | Delete
public $name;
[64] Fix | Delete
[65] Fix | Delete
/**
[66] Fix | Delete
* Post object type. Accepts 'cpt', 'taxonomy'.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 3.0.99
[69] Fix | Delete
* @var string
[70] Fix | Delete
*/
[71] Fix | Delete
public $wp_type;
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* ET_Core_Post_Base constructor.
[75] Fix | Delete
*/
[76] Fix | Delete
public function __construct() {
[77] Fix | Delete
$this->_args = $this->_get_args();
[78] Fix | Delete
$this->_args['labels'] = $this->_get_labels();
[79] Fix | Delete
[80] Fix | Delete
$this->_apply_filters();
[81] Fix | Delete
$this->_sanity_check();
[82] Fix | Delete
[83] Fix | Delete
if ( empty( self::$_instances ) ) {
[84] Fix | Delete
self::$_instances['cpt'] = array();
[85] Fix | Delete
self::$_instances['taxonomy'] = array();
[86] Fix | Delete
[87] Fix | Delete
add_action( 'init', 'ET_Core_Post_Object::register_all' );
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
self::$_instances[ $this->wp_type ][ $this->name ] = $this;
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Applies filters to the instance's filterable properties.
[95] Fix | Delete
*/
[96] Fix | Delete
protected function _apply_filters() {
[97] Fix | Delete
$name = $this->name;
[98] Fix | Delete
[99] Fix | Delete
if ( 'cpt' === $this->wp_type ) {
[100] Fix | Delete
/**
[101] Fix | Delete
* Filters the `$args` for a custom post type. The dynamic portion of the
[102] Fix | Delete
* filter, `$name`, refers to the name/key of the post type being registered.
[103] Fix | Delete
*
[104] Fix | Delete
* @since 3.0.99
[105] Fix | Delete
*
[106] Fix | Delete
* @param array $args {@see register_post_type()}
[107] Fix | Delete
*/
[108] Fix | Delete
$this->_args = apply_filters( "et_core_cpt_{$name}_args", $this->_args );
[109] Fix | Delete
[110] Fix | Delete
} else if ( 'taxonomy' === $this->wp_type ) {
[111] Fix | Delete
/**
[112] Fix | Delete
* Filters the `$args` for a custom post taxonomy. The dynamic portion of the
[113] Fix | Delete
* filter, `$name`, refers to the name/key of the taxonomy being registered.
[114] Fix | Delete
*
[115] Fix | Delete
* @since 3.0.99
[116] Fix | Delete
*
[117] Fix | Delete
* @param array $args {@see register_taxonomy()}
[118] Fix | Delete
*/
[119] Fix | Delete
$this->_args = apply_filters( "et_core_taxonomy_{$name}_args", $this->_args );
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* This method is called right before registering the object. It is intended to be
[125] Fix | Delete
* overridden by child classes as needed.
[126] Fix | Delete
*/
[127] Fix | Delete
protected function _before_register() {}
[128] Fix | Delete
[129] Fix | Delete
/**
[130] Fix | Delete
* Returns the args for the instance.
[131] Fix | Delete
* See {@see register_post_type()} or {@see register_taxonomy()}.
[132] Fix | Delete
*
[133] Fix | Delete
* @return array $args
[134] Fix | Delete
*/
[135] Fix | Delete
abstract protected function _get_args();
[136] Fix | Delete
[137] Fix | Delete
/**
[138] Fix | Delete
* Returns labels for the instance.
[139] Fix | Delete
* See {@see register_post_type()} or {@see register_taxonomy()}.
[140] Fix | Delete
*
[141] Fix | Delete
* @return array $labels
[142] Fix | Delete
*/
[143] Fix | Delete
abstract protected function _get_labels();
[144] Fix | Delete
[145] Fix | Delete
/**
[146] Fix | Delete
* Checks for required properties and existing instances.
[147] Fix | Delete
*/
[148] Fix | Delete
protected function _sanity_check() {
[149] Fix | Delete
if ( ! $this->_args || ! $this->name || ! $this->wp_type ) {
[150] Fix | Delete
et_error( 'Missing required properties!' );
[151] Fix | Delete
wp_die();
[152] Fix | Delete
} else if ( isset( self::$_instances[ $this->wp_type ][ $this->name ] ) ) {
[153] Fix | Delete
et_error( 'Multiple instances are not allowed!' );
[154] Fix | Delete
wp_die();
[155] Fix | Delete
}
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
/**
[159] Fix | Delete
* Get a derived class instance.
[160] Fix | Delete
*
[161] Fix | Delete
* @since 3.0.99
[162] Fix | Delete
*
[163] Fix | Delete
* @param string $type See {@see self::$wp_type} for accepted values. Default is 'cpt'.
[164] Fix | Delete
* @param string $name The name/slug of the derived object. Default is an empty string.
[165] Fix | Delete
*
[166] Fix | Delete
* @return self|null
[167] Fix | Delete
*/
[168] Fix | Delete
public static function instance( $type = 'cpt', $name = '' ) {
[169] Fix | Delete
if ( ! self::$_ ) {
[170] Fix | Delete
self::$_ = ET_Core_Data_Utils::instance();
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
return self::$_->array_get( self::$_instances, "{$type}.{$name}", null );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
/**
[177] Fix | Delete
* Calls either {@see register_post_type} or {@see register_taxonomy} for each instance.
[178] Fix | Delete
*
[179] Fix | Delete
* @since 3.0.99
[180] Fix | Delete
*
[181] Fix | Delete
* @param string $owner Optional. Only register objects owned by a part of the codebase.
[182] Fix | Delete
* See {@see self::_owner} for accepted values.
[183] Fix | Delete
*/
[184] Fix | Delete
public static function register_all( $owner = null ) {
[185] Fix | Delete
if ( empty( self::$_instances ) ) {
[186] Fix | Delete
return;
[187] Fix | Delete
}
[188] Fix | Delete
[189] Fix | Delete
global $wp_taxonomies;
[190] Fix | Delete
[191] Fix | Delete
foreach ( self::$_instances['taxonomy'] as $name => $instance ) {
[192] Fix | Delete
$can_register = is_null( $owner ) || $owner === $instance->_owner;
[193] Fix | Delete
[194] Fix | Delete
if ( $instance->_registered || ! $can_register ) {
[195] Fix | Delete
continue;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
$instance->_before_register();
[199] Fix | Delete
[200] Fix | Delete
register_taxonomy( $name, $instance->post_types, $instance->_args );
[201] Fix | Delete
[202] Fix | Delete
$instance->_wp_object = $wp_taxonomies[ $name ];
[203] Fix | Delete
$instance->_registered = true;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
foreach ( self::$_instances['cpt'] as $name => $instance ) {
[207] Fix | Delete
$can_register = is_null( $owner ) || $owner === $instance->_owner;
[208] Fix | Delete
[209] Fix | Delete
if ( $instance->_registered || ! $can_register ) {
[210] Fix | Delete
continue;
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
$instance->_before_register();
[214] Fix | Delete
[215] Fix | Delete
$instance->_wp_object = register_post_type( $name, $instance->_args );
[216] Fix | Delete
$instance->_registered = true;
[217] Fix | Delete
}
[218] Fix | Delete
}
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function