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.../plugins/contact-.../includes
File: upgrade.php
<?php
[0] Fix | Delete
[1] Fix | Delete
add_action( 'wpcf7_upgrade', 'wpcf7_upgrade_58', 10, 2 );
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Runs functions necessary when upgrading from old plugin versions before 5.8.
[5] Fix | Delete
*
[6] Fix | Delete
* @since 5.8.0 New `_config_validation` post meta is introduced.
[7] Fix | Delete
*/
[8] Fix | Delete
function wpcf7_upgrade_58( $new_ver, $old_ver ) {
[9] Fix | Delete
if ( ! version_compare( $old_ver, '5.8-dev', '<' ) ) {
[10] Fix | Delete
return;
[11] Fix | Delete
}
[12] Fix | Delete
[13] Fix | Delete
$posts = WPCF7_ContactForm::find( array(
[14] Fix | Delete
'post_status' => 'any',
[15] Fix | Delete
'posts_per_page' => -1,
[16] Fix | Delete
) );
[17] Fix | Delete
[18] Fix | Delete
foreach ( $posts as $post ) {
[19] Fix | Delete
$post_id = $post->id();
[20] Fix | Delete
[21] Fix | Delete
// Delete the old post meta for config-validation results.
[22] Fix | Delete
delete_post_meta( $post_id, '_config_errors' );
[23] Fix | Delete
[24] Fix | Delete
// Add the contact form hash.
[25] Fix | Delete
add_post_meta( $post_id, '_hash',
[26] Fix | Delete
wpcf7_generate_contact_form_hash( $post_id ),
[27] Fix | Delete
true // Unique
[28] Fix | Delete
);
[29] Fix | Delete
}
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
[33] Fix | Delete
add_action( 'wpcf7_upgrade', 'wpcf7_convert_to_cpt', 10, 2 );
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Converts old data in the dedicated database table to custom posts.
[37] Fix | Delete
*
[38] Fix | Delete
* @since 3.0.0 `wpcf7_contact_form` CPT is introduced.
[39] Fix | Delete
*/
[40] Fix | Delete
function wpcf7_convert_to_cpt( $new_ver, $old_ver ) {
[41] Fix | Delete
global $wpdb;
[42] Fix | Delete
[43] Fix | Delete
if ( ! version_compare( $old_ver, '3.0-dev', '<' ) ) {
[44] Fix | Delete
return;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
$old_rows = array();
[48] Fix | Delete
[49] Fix | Delete
$table_name = $wpdb->prefix . "contact_form_7";
[50] Fix | Delete
[51] Fix | Delete
if ( $wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) ) {
[52] Fix | Delete
$old_rows = $wpdb->get_results( "SELECT * FROM $table_name" );
[53] Fix | Delete
} elseif ( $opt = get_option( 'wpcf7' )
[54] Fix | Delete
and ! empty( $opt['contact_forms'] ) ) {
[55] Fix | Delete
foreach ( (array) $opt['contact_forms'] as $key => $value ) {
[56] Fix | Delete
$old_rows[] = (object) array_merge(
[57] Fix | Delete
$value,
[58] Fix | Delete
array( 'cf7_unit_id' => $key )
[59] Fix | Delete
);
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
foreach ( (array) $old_rows as $row ) {
[64] Fix | Delete
$q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_old_cf7_unit_id'"
[65] Fix | Delete
. $wpdb->prepare( " AND meta_value = %d", $row->cf7_unit_id );
[66] Fix | Delete
[67] Fix | Delete
if ( $wpdb->get_var( $q ) ) {
[68] Fix | Delete
continue;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
$postarr = array(
[72] Fix | Delete
'post_type' => 'wpcf7_contact_form',
[73] Fix | Delete
'post_status' => 'publish',
[74] Fix | Delete
'post_title' => maybe_unserialize( $row->title ),
[75] Fix | Delete
);
[76] Fix | Delete
[77] Fix | Delete
$post_id = wp_insert_post( $postarr );
[78] Fix | Delete
[79] Fix | Delete
if ( $post_id ) {
[80] Fix | Delete
update_post_meta( $post_id, '_old_cf7_unit_id', $row->cf7_unit_id );
[81] Fix | Delete
[82] Fix | Delete
$metas = array(
[83] Fix | Delete
'form',
[84] Fix | Delete
'mail',
[85] Fix | Delete
'mail_2',
[86] Fix | Delete
'messages',
[87] Fix | Delete
'additional_settings',
[88] Fix | Delete
);
[89] Fix | Delete
[90] Fix | Delete
foreach ( $metas as $meta ) {
[91] Fix | Delete
update_post_meta( $post_id, '_' . $meta,
[92] Fix | Delete
wpcf7_normalize_newline_deep( maybe_unserialize( $row->{$meta} ) )
[93] Fix | Delete
);
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
[100] Fix | Delete
add_action( 'wpcf7_upgrade', 'wpcf7_prepend_underscore', 10, 2 );
[101] Fix | Delete
[102] Fix | Delete
/**
[103] Fix | Delete
* Prepends an underscore to post meta keys.
[104] Fix | Delete
*/
[105] Fix | Delete
function wpcf7_prepend_underscore( $new_ver, $old_ver ) {
[106] Fix | Delete
if ( version_compare( $old_ver, '3.0-dev', '<' ) ) {
[107] Fix | Delete
return;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
if ( ! version_compare( $old_ver, '3.3-dev', '<' ) ) {
[111] Fix | Delete
return;
[112] Fix | Delete
}
[113] Fix | Delete
[114] Fix | Delete
$posts = WPCF7_ContactForm::find( array(
[115] Fix | Delete
'post_status' => 'any',
[116] Fix | Delete
'posts_per_page' => -1,
[117] Fix | Delete
) );
[118] Fix | Delete
[119] Fix | Delete
foreach ( $posts as $post ) {
[120] Fix | Delete
$props = $post->get_properties();
[121] Fix | Delete
[122] Fix | Delete
foreach ( $props as $prop => $value ) {
[123] Fix | Delete
if ( metadata_exists( 'post', $post->id(), '_' . $prop ) ) {
[124] Fix | Delete
continue;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
update_post_meta( $post->id(), '_' . $prop, $value );
[128] Fix | Delete
delete_post_meta( $post->id(), $prop );
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function