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
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/module/settings/migratio...
File: DiscontinueHtmlEncoding.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Migration for the Code Module and Signup Module that had values html encoded.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 3.15.1
[4] Fix | Delete
*/
[5] Fix | Delete
class ET_Builder_Module_Settings_Migration_DiscontinueHtmlEncoding extends ET_Builder_Module_Settings_Migration {
[6] Fix | Delete
public function get_modules( $group = '' ) {
[7] Fix | Delete
$modules = array();
[8] Fix | Delete
[9] Fix | Delete
if ( in_array( $group, array( '', 'signup' ) ) ) {
[10] Fix | Delete
$modules[] = 'et_pb_signup';
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
if ( in_array( $group, array( '', 'code' ) ) ) {
[14] Fix | Delete
$modules[] = 'et_pb_code';
[15] Fix | Delete
$modules[] = 'et_pb_fullwidth_code';
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
return $modules;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function get_fields() {
[22] Fix | Delete
return array(
[23] Fix | Delete
'raw_content' => array(
[24] Fix | Delete
'affected_fields' => array(
[25] Fix | Delete
'raw_content' => $this->get_modules( 'code' ),
[26] Fix | Delete
),
[27] Fix | Delete
),
[28] Fix | Delete
'description' => array(
[29] Fix | Delete
'affected_fields' => array(
[30] Fix | Delete
'description' => $this->get_modules( 'signup' ),
[31] Fix | Delete
),
[32] Fix | Delete
),
[33] Fix | Delete
'footer_content' => array(
[34] Fix | Delete
'affected_fields' => array(
[35] Fix | Delete
'footer_content' => $this->get_modules( 'signup' ),
[36] Fix | Delete
),
[37] Fix | Delete
),
[38] Fix | Delete
);
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
private function decode_code_module_raw_content( $content ) {
[42] Fix | Delete
// convert previously escaped/encoded content back to normal
[43] Fix | Delete
$content = et_builder_replace_code_content_entities( $content );
[44] Fix | Delete
$content = ET_Builder_Element::convert_smart_quotes_and_amp( $content );
[45] Fix | Delete
[46] Fix | Delete
// TODO, not sure about this, but single quotes were encoded so this seemed to be needed
[47] Fix | Delete
$content = str_replace( "&#39;", "'", $content );
[48] Fix | Delete
[49] Fix | Delete
$author_id = get_post_field( 'post_author', get_the_ID() ) || get_current_user_id();
[50] Fix | Delete
[51] Fix | Delete
if ( ! user_can( $author_id, 'unfiltered_html' ) ) {
[52] Fix | Delete
$content = $this->_post_content_capability_check( $content );
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
$content = html_entity_decode( $content, ENT_QUOTES );
[56] Fix | Delete
[57] Fix | Delete
// Only apply this aspect of the migration on FE, its not needed to run in VB or BB,
[58] Fix | Delete
// thats the purpose ! is_admin() check is serving in this case.
[59] Fix | Delete
if ( ! is_admin() ) {
[60] Fix | Delete
// convert <br /> tags into placeholder so wpautop will leave them alone.
[61] Fix | Delete
$content = preg_replace( '|<br[\s]?[\/]?>|', '<!–- [et_pb_br_holder] -–>', $content );
[62] Fix | Delete
[63] Fix | Delete
// convert <p> tag to <pee> tag, so wpautop will leave them alone,
[64] Fix | Delete
// *and* so that we can clearly spot the <p> tags that wpautop adds
[65] Fix | Delete
// so we can quickly remove them.
[66] Fix | Delete
$content = preg_replace( '|<p |', '<pee ', $content );
[67] Fix | Delete
$content = preg_replace( '|<p>|', '<pee>', $content );
[68] Fix | Delete
$content = preg_replace( '|<\/p>|', '</pee>', $content );
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
return $content;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
public function migrate( $field_name, $current_value, $module_slug, $saved_value, $saved_field_name, $attrs, $content, $module_address ) {
[75] Fix | Delete
[76] Fix | Delete
// code module migration for BB
[77] Fix | Delete
if ( in_array( $module_slug, $this->get_modules( 'code' ) ) && 'raw_content' === $saved_field_name ) {
[78] Fix | Delete
return $this->decode_code_module_raw_content( $content );
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
$signup_fields = array( 'description', 'footer_content' );
[82] Fix | Delete
[83] Fix | Delete
if ( in_array( $module_slug, $this->get_modules( 'signup' ) ) && in_array( $saved_field_name, $signup_fields ) ) {
[84] Fix | Delete
return html_entity_decode( $saved_value, ENT_COMPAT, 'UTF-8' );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
return $saved_value;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
public function get_content_migration_modules( $group = '' ) {
[91] Fix | Delete
$modules = array();
[92] Fix | Delete
[93] Fix | Delete
if ( in_array( $group, array( '', 'code' ) ) ) {
[94] Fix | Delete
$modules[] = 'et_pb_code';
[95] Fix | Delete
$modules[] = 'et_pb_fullwidth_code';
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
return $modules;
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
public function migrate_content( $module_slug, $attrs, $content ) {
[102] Fix | Delete
if ( in_array( $module_slug, $this->get_content_migration_modules( 'code' ) ) ) {
[103] Fix | Delete
return $this->decode_code_module_raw_content( $content );
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
return $content;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
private function _post_content_capability_check( $content ) {
[110] Fix | Delete
$content = preg_replace_callback('/\[et_pb_code.*?\](.*)\[\/et_pb_code\]/mis', array( $this, '_sanitize_code_module_content_regex' ), $content );
[111] Fix | Delete
$content = preg_replace_callback('/\[et_pb_fullwidth_code.*?\](.*)\[\/et_pb_fullwidth_code\]/mis', array( $this, '_sanitize_code_module_content_regex' ), $content );
[112] Fix | Delete
[113] Fix | Delete
return $content;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
private function _sanitize_code_module_content_regex( $matches ) {
[117] Fix | Delete
$sanitized_content = wp_kses_post( $matches[1] );
[118] Fix | Delete
$sanitized_shortcode = str_replace( $matches[1], $sanitized_content, $matches[0] );
[119] Fix | Delete
[120] Fix | Delete
return $sanitized_shortcode;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
return new ET_Builder_Module_Settings_Migration_DiscontinueHtmlEncoding();
[126] Fix | Delete
[127] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function