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/wp-conte.../plugins/content-.../inc
File: class-ps-migrator.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace passster;
[2] Fix | Delete
[3] Fix | Delete
class PS_Migrator {
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Handle the migration from v3 to v4 in Passster.
[7] Fix | Delete
*
[8] Fix | Delete
* @return void
[9] Fix | Delete
*/
[10] Fix | Delete
public static function migrate() {
[11] Fix | Delete
// Reset new settings first.
[12] Fix | Delete
$options = array();
[13] Fix | Delete
[14] Fix | Delete
// Start migration.
[15] Fix | Delete
$options = self::migrate_customizer_settings( $options );
[16] Fix | Delete
$options = self::migrate_options( $options );
[17] Fix | Delete
[18] Fix | Delete
update_option( 'passster', $options );
[19] Fix | Delete
[20] Fix | Delete
// Now we can delete the old options.
[21] Fix | Delete
self::delete_options();
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Migrates customizer settings to option.
[26] Fix | Delete
*
[27] Fix | Delete
* @param $options
[28] Fix | Delete
*
[29] Fix | Delete
* @return mixed
[30] Fix | Delete
*/
[31] Fix | Delete
public static function migrate_customizer_settings( $options ) {
[32] Fix | Delete
$customizer_data = array(
[33] Fix | Delete
'headline' => get_theme_mod( 'passster_form_instructions_headline' ),
[34] Fix | Delete
'instruction' => get_theme_mod( 'passster_form_instructions_text' ),
[35] Fix | Delete
'placeholder' => get_theme_mod( 'passster_form_instructions_placeholder' ),
[36] Fix | Delete
'error' => get_theme_mod( 'passster_form_error_text' ),
[37] Fix | Delete
'button_label' => get_theme_mod( 'passster_form_button_label' ),
[38] Fix | Delete
'show_password' => get_theme_mod( 'passster_form_instructions_password_typing' ),
[39] Fix | Delete
'form_background_color' => get_theme_mod( 'passster_form_general_background_color' ),
[40] Fix | Delete
'headline_font_color' => get_theme_mod( 'passster_form_instructions_headline_color' ),
[41] Fix | Delete
'headline_font_size' => get_theme_mod( 'passster_form_instructions_headline_font_size' ),
[42] Fix | Delete
'headline_font_weight' => get_theme_mod( 'passster_form_instructions_headline_font_weight' ),
[43] Fix | Delete
'instruction_font_color' => get_theme_mod( 'passster_form_instructions_text_color' ),
[44] Fix | Delete
'instruction_font_size' => get_theme_mod( 'passster_form_instructions_text_font_size' ),
[45] Fix | Delete
'instruction_font_weight' => get_theme_mod( 'passster_form_instructions_text_font_weight' ),
[46] Fix | Delete
'button_background_color' => get_theme_mod( 'passster_form_button_background_color' ),
[47] Fix | Delete
'button_font_color' => get_theme_mod( 'passster_form_button_text_color' ),
[48] Fix | Delete
'button_background_color_hover' => get_theme_mod( 'passster_form_button_background_hover_color' ),
[49] Fix | Delete
'button_font_color_hover' => get_theme_mod( 'passster_form_button_text_hover_color' ),
[50] Fix | Delete
'form_max_width' => '700px',
[51] Fix | Delete
'form_border_radius' => 0,
[52] Fix | Delete
'form_padding' => array(
[53] Fix | Delete
'top' => '20px',
[54] Fix | Delete
'right' => '20px',
[55] Fix | Delete
'bottom' => '20px',
[56] Fix | Delete
'left' => '20px'
[57] Fix | Delete
),
[58] Fix | Delete
'form_margin' => array(
[59] Fix | Delete
'top' => '0px',
[60] Fix | Delete
'right' => '0px',
[61] Fix | Delete
'bottom' => '0px',
[62] Fix | Delete
'left' => '0px'
[63] Fix | Delete
),
[64] Fix | Delete
'button_padding' => array(
[65] Fix | Delete
'top' => '10px',
[66] Fix | Delete
'right' => '10px',
[67] Fix | Delete
'bottom' => '10px',
[68] Fix | Delete
'left' => '10px'
[69] Fix | Delete
),
[70] Fix | Delete
'button_margin' => array(
[71] Fix | Delete
'top' => '0px',
[72] Fix | Delete
'right' => '0px',
[73] Fix | Delete
'bottom' => '0px',
[74] Fix | Delete
'left' => '0px'
[75] Fix | Delete
),
[76] Fix | Delete
'button_border_radius' => 0,
[77] Fix | Delete
);
[78] Fix | Delete
[79] Fix | Delete
$default_data = array(
[80] Fix | Delete
'headline' => __( 'Protected Area', 'content-protector' ),
[81] Fix | Delete
'instruction' => __( 'This content is password-protected. Please verify with a password to unlock the content.', 'content-protector' ),
[82] Fix | Delete
'placeholder' => __( 'Enter your password..', 'content-protector' ),
[83] Fix | Delete
'error' => __( 'Sorry, there was an error.', 'content-protector' ),
[84] Fix | Delete
'button_label' => __( 'Unlock', 'content-protector' ),
[85] Fix | Delete
'show_password' => false,
[86] Fix | Delete
'form_background_color' => '#FAFAFA',
[87] Fix | Delete
'headline_font_color' => '#6804cc',
[88] Fix | Delete
'headline_font_size' => 24,
[89] Fix | Delete
'headline_font_weight' => 500,
[90] Fix | Delete
'instruction_font_color' => '#000',
[91] Fix | Delete
'instruction_font_size' => 16,
[92] Fix | Delete
'instruction_font_weight' => 300,
[93] Fix | Delete
'button_background_color' => '#6804cc',
[94] Fix | Delete
'button_font_color' => '#fff',
[95] Fix | Delete
'button_background_color_hover' => '#000',
[96] Fix | Delete
'button_font_color_hover' => '#fff',
[97] Fix | Delete
'form_border_radius' => 0,
[98] Fix | Delete
'button_border_radius' => 0,
[99] Fix | Delete
);
[100] Fix | Delete
[101] Fix | Delete
foreach ( $customizer_data as $option => $value ) {
[102] Fix | Delete
if ( ! empty( $value ) ) {
[103] Fix | Delete
$options[ $option ] = $value;
[104] Fix | Delete
} else {
[105] Fix | Delete
$options[ $option ] = $default_data[ $option ];
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
return $options;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
/**
[113] Fix | Delete
* Migrate old options to new option.
[114] Fix | Delete
*
[115] Fix | Delete
* @param $options
[116] Fix | Delete
*
[117] Fix | Delete
* @return mixed
[118] Fix | Delete
*/
[119] Fix | Delete
public static function migrate_options( $options ) {
[120] Fix | Delete
// Migrate general settings.
[121] Fix | Delete
$general_settings = get_option( 'passster_general_settings' );
[122] Fix | Delete
[123] Fix | Delete
if ( ! is_array( $general_settings ) ) {
[124] Fix | Delete
return $options;
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
if ( 'on' !== $general_settings['toggle_cookie'] ) {
[128] Fix | Delete
$options['disable_cookie'] = false;
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
if ( 'on' === $general_settings['toggle_ajax'] ) {
[132] Fix | Delete
$options['unlock_mode'] = true;
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
if ( 'on' === $general_settings['passster_activate_concurrent'] ) {
[136] Fix | Delete
$options['use_concurrent'] = true;
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
if ( 'on' === $general_settings['passster_activate_concurrent'] ) {
[140] Fix | Delete
$options['use_concurrent'] = true;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
if ( ! empty( $general_settings['passster_cookie_duration'] ) ) {
[144] Fix | Delete
$options['cookie_duration'] = $general_settings['passster_cookie_duration'];
[145] Fix | Delete
} else {
[146] Fix | Delete
$options['cookie_duration'] = "1";
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
$options['third_party_shortcodes'] = $general_settings['third_party_shortcodes'];
[150] Fix | Delete
$options['number_of_concurrents'] = $general_settings['passster_number_of_concurrent_logins'];
[151] Fix | Delete
[152] Fix | Delete
update_option( 'passster', $options );
[153] Fix | Delete
[154] Fix | Delete
// Migrate advanced settings.
[155] Fix | Delete
$advanced_settings = get_option( 'passster_advanced_settings' );
[156] Fix | Delete
[157] Fix | Delete
if ( ! is_array( $advanced_settings ) ) {
[158] Fix | Delete
return $options;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
$options['recaptcha_version'] = $advanced_settings['passster_recaptcha_type'];
[162] Fix | Delete
$options['recaptcha_site_key'] = $advanced_settings['passster_recaptcha_site_key'];
[163] Fix | Delete
$options['recaptcha_secret'] = $advanced_settings['passster_recaptcha_secret'];
[164] Fix | Delete
$options['recaptcha_language'] = $advanced_settings['passster_recaptcha_language'];
[165] Fix | Delete
$options['bitly_token'] = $advanced_settings['passster_bitly_access_key'];
[166] Fix | Delete
[167] Fix | Delete
// Migrate Global Protection settings.
[168] Fix | Delete
$options['global_protection_id'] = get_option( 'passster_global_id' );
[169] Fix | Delete
[170] Fix | Delete
// Also add new options to avoid missing keys on migration.
[171] Fix | Delete
$options['password_length'] = "6";
[172] Fix | Delete
$options['include_uppercase'] = false;
[173] Fix | Delete
$options['include_numbers'] = false;
[174] Fix | Delete
$options['cookie_duration_unit'] = 'days';
[175] Fix | Delete
[176] Fix | Delete
return $options;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* Delete old options.
[181] Fix | Delete
*
[182] Fix | Delete
* @return void
[183] Fix | Delete
*/
[184] Fix | Delete
public static function delete_options() {
[185] Fix | Delete
// Delete theme mods.
[186] Fix | Delete
remove_theme_mod( 'passster_form_instructions_headline' );
[187] Fix | Delete
remove_theme_mod( 'passster_form_instructions_text' );
[188] Fix | Delete
remove_theme_mod( 'passster_form_instructions_placeholder' );
[189] Fix | Delete
remove_theme_mod( 'passster_form_error_text' );
[190] Fix | Delete
remove_theme_mod( 'passster_form_button_label' );
[191] Fix | Delete
remove_theme_mod( 'passster_form_instructions_password_typing' );
[192] Fix | Delete
remove_theme_mod( 'passster_form_general_background_color' );
[193] Fix | Delete
remove_theme_mod( 'passster_form_instructions_headline_font_size' );
[194] Fix | Delete
remove_theme_mod( 'passster_form_instructions_headline_font_weight' );
[195] Fix | Delete
remove_theme_mod( 'passster_form_instructions_text_color' );
[196] Fix | Delete
remove_theme_mod( 'passster_form_instructions_text_font_size' );
[197] Fix | Delete
remove_theme_mod( 'passster_form_instructions_text_font_weight' );
[198] Fix | Delete
remove_theme_mod( 'passster_form_button_background_color' );
[199] Fix | Delete
remove_theme_mod( 'passster_form_button_text_color' );
[200] Fix | Delete
remove_theme_mod( 'passster_form_button_background_hover_color' );
[201] Fix | Delete
remove_theme_mod( 'passster_form_button_text_hover_color' );
[202] Fix | Delete
[203] Fix | Delete
// Delete old options.
[204] Fix | Delete
delete_option( 'passster_general_settings' );
[205] Fix | Delete
delete_option( 'passster_advanced_settings' );
[206] Fix | Delete
delete_option( 'passster_global_id' );
[207] Fix | Delete
}
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function