Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/module/helpers
File: OptionTemplate.php
'remove_suffix_if_empty' => $placeholder_has_space_suffix ? true : false,
[500] Fix | Delete
) );
[501] Fix | Delete
[502] Fix | Delete
// Cache result
[503] Fix | Delete
$this->set_cache( $cache_name, $cache_key, $rebuilt_placeholder );
[504] Fix | Delete
[505] Fix | Delete
return $rebuilt_placeholder;
[506] Fix | Delete
}
[507] Fix | Delete
[508] Fix | Delete
// 2. Field attribute value's type is array (sequential)
[509] Fix | Delete
if ( is_array( $attr_value ) && isset( $attr_value[0] ) ) {
[510] Fix | Delete
$rebuild_attr_value = array();
[511] Fix | Delete
[512] Fix | Delete
foreach ( $attr_value as $array_value ) {
[513] Fix | Delete
// Array consists of string is most likely used for defining field relationship
[514] Fix | Delete
// such as `show_if` attribute; Replace prefix and suffix placeholder with
[515] Fix | Delete
// placeholder replacement also consider that text_shadow advanced field
[516] Fix | Delete
// automatically adds underscore after prefix so it needs to be adjusted as well
[517] Fix | Delete
if ( is_string( $array_value ) ) {
[518] Fix | Delete
$rebuild_attr_value[] = $this->rebuild_string_placeholder( $array_value, $template_data, array(
[519] Fix | Delete
'suffix' => '_',
[520] Fix | Delete
'remove_suffix_if_empty' => $auto_add_prefix_underscore,
[521] Fix | Delete
) );
[522] Fix | Delete
} elseif ( 'presets' === $attr_name ) {
[523] Fix | Delete
// Handle preset attribute specifically due to how it is structured
[524] Fix | Delete
$rebuild_attr_value[] = $this->rebuild_preset_placeholder( $array_value, $template_data, array(
[525] Fix | Delete
'suffix' => '_',
[526] Fix | Delete
'remove_suffix_if_empty' => $auto_add_prefix_underscore,
[527] Fix | Delete
) );
[528] Fix | Delete
} else {
[529] Fix | Delete
// Non string and `presets` attribute less likely contains placeholder
[530] Fix | Delete
$rebuild_attr_value[] = $array_value;
[531] Fix | Delete
}
[532] Fix | Delete
}
[533] Fix | Delete
[534] Fix | Delete
// Cache result
[535] Fix | Delete
$this->set_cache( $cache_name, $cache_key, $rebuild_attr_value );
[536] Fix | Delete
[537] Fix | Delete
return $rebuild_attr_value;
[538] Fix | Delete
}
[539] Fix | Delete
[540] Fix | Delete
// 3. Field attribute value's type is array (associative)
[541] Fix | Delete
if ( is_array( $attr_value ) && ! isset( $attr_value[0] ) ) {
[542] Fix | Delete
$attr_object = array();
[543] Fix | Delete
[544] Fix | Delete
// Loop existing attrValue and populate the rebuilt result on `attrObject`.
[545] Fix | Delete
foreach ( $attr_value as $item_key => $item_value ) {
[546] Fix | Delete
$attr_object_key = $this->rebuild_string_placeholder( $item_key, $template_data );
[547] Fix | Delete
[548] Fix | Delete
// Replaces placeholder with actual value on border's nested composite structure fields
[549] Fix | Delete
if ( 'composite_structure' === $attr_name ) {
[550] Fix | Delete
$item_value = $this->rebuild_composite_structure_placeholder( $template_type, $item_value, $template_data );
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
$attr_object[ $attr_object_key ] = $item_value;
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
// Cache result
[557] Fix | Delete
$this->set_cache( $cache_name, $cache_key, $attr_object );
[558] Fix | Delete
[559] Fix | Delete
return $attr_object;
[560] Fix | Delete
}
[561] Fix | Delete
[562] Fix | Delete
// Cache result
[563] Fix | Delete
$this->set_cache( $cache_name, $cache_key, $attr_value );
[564] Fix | Delete
[565] Fix | Delete
// 4. Unknown attribute value type; directly pass it
[566] Fix | Delete
return $attr_value;
[567] Fix | Delete
}
[568] Fix | Delete
[569] Fix | Delete
public function rebuild_field_template( $template_id, $parent_template_id = false ) {
[570] Fix | Delete
// Check for cached result first for faster performance
[571] Fix | Delete
$cache_name = 'field_template';
[572] Fix | Delete
$cache_key = $parent_template_id ? "{$template_id}-inherits-{$parent_template_id}" : $template_id;
[573] Fix | Delete
$cache = $this->get_cache( $cache_name, $cache_key );
[574] Fix | Delete
[575] Fix | Delete
if ( ! is_null( $cache ) ) {
[576] Fix | Delete
return $cache;
[577] Fix | Delete
}
[578] Fix | Delete
[579] Fix | Delete
$fields = array();
[580] Fix | Delete
$template_data = $this->get_data( $template_id );
[581] Fix | Delete
[582] Fix | Delete
// No fields will be found without template data. Return early;
[583] Fix | Delete
if ( empty( $template_data ) ) {
[584] Fix | Delete
return $fields;
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
$template_type = self::$_->array_get( $template_data, '0' );
[588] Fix | Delete
$template_settings = self::$_->array_get( $template_data, '1', array() );
[589] Fix | Delete
$prefix = self::$_->array_get( $template_settings, 'prefix', '' );
[590] Fix | Delete
[591] Fix | Delete
$parent_template_data = false;
[592] Fix | Delete
[593] Fix | Delete
// If rebuilt parent template is inside another templateId (ie. Text Shadow inside Font)
[594] Fix | Delete
// its placeholder is passed for data; The expected structure becomes
[595] Fix | Delete
// `[templateType, parentTemplateSettings]` instead of `[templateType, templateSettings]`;
[596] Fix | Delete
// Thus get parent template's settings and use it
[597] Fix | Delete
if ( $parent_template_id ) {
[598] Fix | Delete
$parent_template_data = $this->get_data( $parent_template_id );
[599] Fix | Delete
$parent_template_settings = self::$_->array_get( $parent_template_data, "1", true );
[600] Fix | Delete
[601] Fix | Delete
$template_settings_inherits_from_parant = array();
[602] Fix | Delete
[603] Fix | Delete
foreach ( $template_settings as $name => $value ) {
[604] Fix | Delete
$placeholder = $this->get_template_placeholder( $value );
[605] Fix | Delete
[606] Fix | Delete
if ( is_array( $placeholder ) && isset( $placeholder[0] ) ) {
[607] Fix | Delete
$template_settings_inherits_from_parant[ $name ] = self::$_->array_get(
[608] Fix | Delete
$parent_template_settings,
[609] Fix | Delete
$placeholder[0],
[610] Fix | Delete
$value
[611] Fix | Delete
);
[612] Fix | Delete
}
[613] Fix | Delete
}
[614] Fix | Delete
[615] Fix | Delete
$parent_template_data = array(
[616] Fix | Delete
$template_type,
[617] Fix | Delete
$template_settings_inherits_from_parant
[618] Fix | Delete
);
[619] Fix | Delete
}
[620] Fix | Delete
[621] Fix | Delete
// Get fields template for given template type
[622] Fix | Delete
$fields_template = $this->get_template( $template_type );
[623] Fix | Delete
[624] Fix | Delete
// Loop fields template and replace placeholder with actual value
[625] Fix | Delete
foreach ( $fields_template as $field_name_template => $field_template ) {
[626] Fix | Delete
// Certain advanced field (ie. Text Shadow) automatically adds underscore
[627] Fix | Delete
// Related template type needs to be adjusted
[628] Fix | Delete
$remove_suffix_if_empty = 'text_shadow' === $template_type && '' === $prefix;
[629] Fix | Delete
[630] Fix | Delete
// Replace field attribute name's placeholder
[631] Fix | Delete
$field_template_data = $parent_template_id ? $parent_template_data : $template_data;
[632] Fix | Delete
$field_name = $this->rebuild_string_placeholder(
[633] Fix | Delete
$field_name_template,
[634] Fix | Delete
$field_template_data,
[635] Fix | Delete
array(
[636] Fix | Delete
'remove_suffix_if_empty' => $remove_suffix_if_empty,
[637] Fix | Delete
// placeholder's suffix, not placeholder named %%suffix%%
[638] Fix | Delete
'suffix' => '_',
[639] Fix | Delete
)
[640] Fix | Delete
);
[641] Fix | Delete
[642] Fix | Delete
// Replace field attribute value's placeholder
[643] Fix | Delete
$field = array();
[644] Fix | Delete
if ( is_array( $field_template ) ) {
[645] Fix | Delete
foreach( $field_template as $attr_name => $attr_value ) {
[646] Fix | Delete
$rebuilt_attr_value = $this->rebuild_field_attr_value(
[647] Fix | Delete
$attr_name,
[648] Fix | Delete
$attr_value,
[649] Fix | Delete
$field_template_data
[650] Fix | Delete
);
[651] Fix | Delete
[652] Fix | Delete
// Omit attribute with empty value: existance of attribute even with empty
[653] Fix | Delete
// string value is handled differently in many field (ie, `show_if`)
[654] Fix | Delete
if ( '' === $rebuilt_attr_value ) {
[655] Fix | Delete
continue;
[656] Fix | Delete
}
[657] Fix | Delete
[658] Fix | Delete
$field[ $attr_name ] = $rebuilt_attr_value;
[659] Fix | Delete
}
[660] Fix | Delete
} else {
[661] Fix | Delete
$fields = array_merge(
[662] Fix | Delete
$fields,
[663] Fix | Delete
$this->rebuild_field_template( $field_name_template, $template_id )
[664] Fix | Delete
);
[665] Fix | Delete
}
[666] Fix | Delete
[667] Fix | Delete
// `name` attribute is dynamically added based on field's array key
[668] Fix | Delete
$field['name'] = $field_name;
[669] Fix | Delete
[670] Fix | Delete
// Populate rebuilt field
[671] Fix | Delete
$fields[ $field_name ] = $field;
[672] Fix | Delete
}
[673] Fix | Delete
[674] Fix | Delete
// Cache result
[675] Fix | Delete
$this->set_cache( $cache_name, $cache_key, $fields );
[676] Fix | Delete
[677] Fix | Delete
return $fields;
[678] Fix | Delete
}
[679] Fix | Delete
[680] Fix | Delete
public function rebuild_default_props( $template_id ) {
[681] Fix | Delete
// Check for cached result first for faster performance
[682] Fix | Delete
$cache_name = 'default_props';
[683] Fix | Delete
$cache_key = $template_id;
[684] Fix | Delete
$cache = $this->get_cache( $cache_name, $cache_key );
[685] Fix | Delete
[686] Fix | Delete
if ( ! is_null( $cache ) ) {
[687] Fix | Delete
return $cache;
[688] Fix | Delete
}
[689] Fix | Delete
[690] Fix | Delete
$default_props = array();
[691] Fix | Delete
$rebuilt_fields = $this->rebuild_field_template( $template_id );
[692] Fix | Delete
[693] Fix | Delete
foreach( $rebuilt_fields as $field_name => $field ) {
[694] Fix | Delete
$value = '';
[695] Fix | Delete
[696] Fix | Delete
if ( isset( $field['composite_type'], $field['composite_structure'] ) ) {
[697] Fix | Delete
require_once ET_BUILDER_DIR . 'module/field/attribute/composite/Parser.php';
[698] Fix | Delete
$composite_atts = ET_Builder_Module_Field_Attribute_Composite_Parser::parse( $field['composite_type'], $field['composite_structure'] );
[699] Fix | Delete
$default_props = array_merge( $default_props, $composite_atts );
[700] Fix | Delete
} else {
[701] Fix | Delete
if ( isset( $field['default_on_front'] ) ) {
[702] Fix | Delete
$value = $field['default_on_front'];
[703] Fix | Delete
} else if ( isset( $field['default'] ) ) {
[704] Fix | Delete
$value = $field['default'];
[705] Fix | Delete
}
[706] Fix | Delete
[707] Fix | Delete
$default_props[ $field_name ] = $value;
[708] Fix | Delete
}
[709] Fix | Delete
}
[710] Fix | Delete
[711] Fix | Delete
// Cache result
[712] Fix | Delete
$this->set_cache( $cache_name, $cache_key, $default_props );
[713] Fix | Delete
[714] Fix | Delete
return $default_props;
[715] Fix | Delete
}
[716] Fix | Delete
}
[717] Fix | Delete
[718] Fix | Delete
[719] Fix | Delete
[720] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function