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/wp-admin/includes
File: upgrade.php
preg_match(
[3000] Fix | Delete
'/
[3001] Fix | Delete
`? # Name can be escaped with a backtick.
[3002] Fix | Delete
(?P<column_name> # 1) Name of the column.
[3003] Fix | Delete
(?:[0-9a-zA-Z$_-]|[\xC2-\xDF][\x80-\xBF])+
[3004] Fix | Delete
)
[3005] Fix | Delete
`? # Name can be escaped with a backtick.
[3006] Fix | Delete
(?: # Optional sub part.
[3007] Fix | Delete
\s* # Optional white space character between name and opening bracket.
[3008] Fix | Delete
\( # Opening bracket for the sub part.
[3009] Fix | Delete
\s* # Optional white space character after opening bracket.
[3010] Fix | Delete
(?P<sub_part>
[3011] Fix | Delete
\d+ # 2) Number of indexed characters.
[3012] Fix | Delete
)
[3013] Fix | Delete
\s* # Optional white space character before closing bracket.
[3014] Fix | Delete
\) # Closing bracket for the sub part.
[3015] Fix | Delete
)?
[3016] Fix | Delete
/x',
[3017] Fix | Delete
$index_column,
[3018] Fix | Delete
$index_column_matches
[3019] Fix | Delete
);
[3020] Fix | Delete
[3021] Fix | Delete
// Escape the column name with backticks.
[3022] Fix | Delete
$index_column = '`' . $index_column_matches['column_name'] . '`';
[3023] Fix | Delete
[3024] Fix | Delete
// We don't need to add the subpart to $index_columns_without_subparts
[3025] Fix | Delete
$index_columns_without_subparts[ $id ] = $index_column;
[3026] Fix | Delete
[3027] Fix | Delete
// Append the optional sup part with the number of indexed characters.
[3028] Fix | Delete
if ( isset( $index_column_matches['sub_part'] ) ) {
[3029] Fix | Delete
$index_column .= '(' . $index_column_matches['sub_part'] . ')';
[3030] Fix | Delete
}
[3031] Fix | Delete
}
[3032] Fix | Delete
[3033] Fix | Delete
// Build the normalized index definition and add it to the list of indices.
[3034] Fix | Delete
$indices[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns ) . ')';
[3035] Fix | Delete
$indices_without_subparts[] = "{$index_type} {$index_name} (" . implode( ',', $index_columns_without_subparts ) . ')';
[3036] Fix | Delete
[3037] Fix | Delete
// Destroy no longer needed variables.
[3038] Fix | Delete
unset( $index_column, $index_column_matches, $index_matches, $index_type, $index_name, $index_columns, $index_columns_without_subparts );
[3039] Fix | Delete
[3040] Fix | Delete
break;
[3041] Fix | Delete
}
[3042] Fix | Delete
[3043] Fix | Delete
// If it's a valid field, add it to the field array.
[3044] Fix | Delete
if ( $validfield ) {
[3045] Fix | Delete
$cfields[ $fieldname_lowercased ] = $fld;
[3046] Fix | Delete
}
[3047] Fix | Delete
}
[3048] Fix | Delete
[3049] Fix | Delete
// For every field in the table.
[3050] Fix | Delete
foreach ( $tablefields as $tablefield ) {
[3051] Fix | Delete
$tablefield_field_lowercased = strtolower( $tablefield->Field );
[3052] Fix | Delete
$tablefield_type_lowercased = strtolower( $tablefield->Type );
[3053] Fix | Delete
[3054] Fix | Delete
$tablefield_type_without_parentheses = preg_replace(
[3055] Fix | Delete
'/'
[3056] Fix | Delete
. '(.+)' // Field type, e.g. `int`.
[3057] Fix | Delete
. '\(\d*\)' // Display width.
[3058] Fix | Delete
. '(.*)' // Optional attributes, e.g. `unsigned`.
[3059] Fix | Delete
. '/',
[3060] Fix | Delete
'$1$2',
[3061] Fix | Delete
$tablefield_type_lowercased
[3062] Fix | Delete
);
[3063] Fix | Delete
[3064] Fix | Delete
// Get the type without attributes, e.g. `int`.
[3065] Fix | Delete
$tablefield_type_base = strtok( $tablefield_type_without_parentheses, ' ' );
[3066] Fix | Delete
[3067] Fix | Delete
// If the table field exists in the field array...
[3068] Fix | Delete
if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) {
[3069] Fix | Delete
[3070] Fix | Delete
// Get the field type from the query.
[3071] Fix | Delete
preg_match( '|`?' . $tablefield->Field . '`? ([^ ]*( unsigned)?)|i', $cfields[ $tablefield_field_lowercased ], $matches );
[3072] Fix | Delete
$fieldtype = $matches[1];
[3073] Fix | Delete
$fieldtype_lowercased = strtolower( $fieldtype );
[3074] Fix | Delete
[3075] Fix | Delete
$fieldtype_without_parentheses = preg_replace(
[3076] Fix | Delete
'/'
[3077] Fix | Delete
. '(.+)' // Field type, e.g. `int`.
[3078] Fix | Delete
. '\(\d*\)' // Display width.
[3079] Fix | Delete
. '(.*)' // Optional attributes, e.g. `unsigned`.
[3080] Fix | Delete
. '/',
[3081] Fix | Delete
'$1$2',
[3082] Fix | Delete
$fieldtype_lowercased
[3083] Fix | Delete
);
[3084] Fix | Delete
[3085] Fix | Delete
// Get the type without attributes, e.g. `int`.
[3086] Fix | Delete
$fieldtype_base = strtok( $fieldtype_without_parentheses, ' ' );
[3087] Fix | Delete
[3088] Fix | Delete
// Is actual field type different from the field type in query?
[3089] Fix | Delete
if ( $tablefield->Type != $fieldtype ) {
[3090] Fix | Delete
$do_change = true;
[3091] Fix | Delete
if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) {
[3092] Fix | Delete
if ( array_search( $fieldtype_lowercased, $text_fields, true ) < array_search( $tablefield_type_lowercased, $text_fields, true ) ) {
[3093] Fix | Delete
$do_change = false;
[3094] Fix | Delete
}
[3095] Fix | Delete
}
[3096] Fix | Delete
[3097] Fix | Delete
if ( in_array( $fieldtype_lowercased, $blob_fields, true ) && in_array( $tablefield_type_lowercased, $blob_fields, true ) ) {
[3098] Fix | Delete
if ( array_search( $fieldtype_lowercased, $blob_fields, true ) < array_search( $tablefield_type_lowercased, $blob_fields, true ) ) {
[3099] Fix | Delete
$do_change = false;
[3100] Fix | Delete
}
[3101] Fix | Delete
}
[3102] Fix | Delete
[3103] Fix | Delete
if ( in_array( $fieldtype_base, $int_fields, true ) && in_array( $tablefield_type_base, $int_fields, true )
[3104] Fix | Delete
&& $fieldtype_without_parentheses === $tablefield_type_without_parentheses
[3105] Fix | Delete
) {
[3106] Fix | Delete
/*
[3107] Fix | Delete
* MySQL 8.0.17 or later does not support display width for integer data types,
[3108] Fix | Delete
* so if display width is the only difference, it can be safely ignored.
[3109] Fix | Delete
* Note: This is specific to MySQL and does not affect MariaDB.
[3110] Fix | Delete
*/
[3111] Fix | Delete
if ( version_compare( $db_version, '8.0.17', '>=' )
[3112] Fix | Delete
&& ! str_contains( $db_server_info, 'MariaDB' )
[3113] Fix | Delete
) {
[3114] Fix | Delete
$do_change = false;
[3115] Fix | Delete
}
[3116] Fix | Delete
}
[3117] Fix | Delete
[3118] Fix | Delete
if ( $do_change ) {
[3119] Fix | Delete
// Add a query to change the column type.
[3120] Fix | Delete
$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ];
[3121] Fix | Delete
[3122] Fix | Delete
$for_update[ $table . '.' . $tablefield->Field ] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
[3123] Fix | Delete
}
[3124] Fix | Delete
}
[3125] Fix | Delete
[3126] Fix | Delete
// Get the default value from the array.
[3127] Fix | Delete
if ( preg_match( "| DEFAULT '(.*?)'|i", $cfields[ $tablefield_field_lowercased ], $matches ) ) {
[3128] Fix | Delete
$default_value = $matches[1];
[3129] Fix | Delete
if ( $tablefield->Default != $default_value ) {
[3130] Fix | Delete
// Add a query to change the column's default value
[3131] Fix | Delete
$cqueries[] = "ALTER TABLE {$table} ALTER COLUMN `{$tablefield->Field}` SET DEFAULT '{$default_value}'";
[3132] Fix | Delete
[3133] Fix | Delete
$for_update[ $table . '.' . $tablefield->Field ] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
[3134] Fix | Delete
}
[3135] Fix | Delete
}
[3136] Fix | Delete
[3137] Fix | Delete
// Remove the field from the array (so it's not added).
[3138] Fix | Delete
unset( $cfields[ $tablefield_field_lowercased ] );
[3139] Fix | Delete
} else {
[3140] Fix | Delete
// This field exists in the table, but not in the creation queries?
[3141] Fix | Delete
}
[3142] Fix | Delete
}
[3143] Fix | Delete
[3144] Fix | Delete
// For every remaining field specified for the table.
[3145] Fix | Delete
foreach ( $cfields as $fieldname => $fielddef ) {
[3146] Fix | Delete
// Push a query line into $cqueries that adds the field to that table.
[3147] Fix | Delete
$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
[3148] Fix | Delete
[3149] Fix | Delete
$for_update[ $table . '.' . $fieldname ] = 'Added column ' . $table . '.' . $fieldname;
[3150] Fix | Delete
}
[3151] Fix | Delete
[3152] Fix | Delete
// Index stuff goes here. Fetch the table index structure from the database.
[3153] Fix | Delete
$tableindices = $wpdb->get_results( "SHOW INDEX FROM {$table};" );
[3154] Fix | Delete
[3155] Fix | Delete
if ( $tableindices ) {
[3156] Fix | Delete
// Clear the index array.
[3157] Fix | Delete
$index_ary = array();
[3158] Fix | Delete
[3159] Fix | Delete
// For every index in the table.
[3160] Fix | Delete
foreach ( $tableindices as $tableindex ) {
[3161] Fix | Delete
$keyname = strtolower( $tableindex->Key_name );
[3162] Fix | Delete
[3163] Fix | Delete
// Add the index to the index data array.
[3164] Fix | Delete
$index_ary[ $keyname ]['columns'][] = array(
[3165] Fix | Delete
'fieldname' => $tableindex->Column_name,
[3166] Fix | Delete
'subpart' => $tableindex->Sub_part,
[3167] Fix | Delete
);
[3168] Fix | Delete
$index_ary[ $keyname ]['unique'] = ( 0 == $tableindex->Non_unique ) ? true : false;
[3169] Fix | Delete
$index_ary[ $keyname ]['index_type'] = $tableindex->Index_type;
[3170] Fix | Delete
}
[3171] Fix | Delete
[3172] Fix | Delete
// For each actual index in the index array.
[3173] Fix | Delete
foreach ( $index_ary as $index_name => $index_data ) {
[3174] Fix | Delete
[3175] Fix | Delete
// Build a create string to compare to the query.
[3176] Fix | Delete
$index_string = '';
[3177] Fix | Delete
if ( 'primary' === $index_name ) {
[3178] Fix | Delete
$index_string .= 'PRIMARY ';
[3179] Fix | Delete
} elseif ( $index_data['unique'] ) {
[3180] Fix | Delete
$index_string .= 'UNIQUE ';
[3181] Fix | Delete
}
[3182] Fix | Delete
[3183] Fix | Delete
if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
[3184] Fix | Delete
$index_string .= 'FULLTEXT ';
[3185] Fix | Delete
}
[3186] Fix | Delete
[3187] Fix | Delete
if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) {
[3188] Fix | Delete
$index_string .= 'SPATIAL ';
[3189] Fix | Delete
}
[3190] Fix | Delete
[3191] Fix | Delete
$index_string .= 'KEY ';
[3192] Fix | Delete
if ( 'primary' !== $index_name ) {
[3193] Fix | Delete
$index_string .= '`' . $index_name . '`';
[3194] Fix | Delete
}
[3195] Fix | Delete
[3196] Fix | Delete
$index_columns = '';
[3197] Fix | Delete
[3198] Fix | Delete
// For each column in the index.
[3199] Fix | Delete
foreach ( $index_data['columns'] as $column_data ) {
[3200] Fix | Delete
if ( '' !== $index_columns ) {
[3201] Fix | Delete
$index_columns .= ',';
[3202] Fix | Delete
}
[3203] Fix | Delete
[3204] Fix | Delete
// Add the field to the column list string.
[3205] Fix | Delete
$index_columns .= '`' . $column_data['fieldname'] . '`';
[3206] Fix | Delete
}
[3207] Fix | Delete
[3208] Fix | Delete
// Add the column list to the index create string.
[3209] Fix | Delete
$index_string .= " ($index_columns)";
[3210] Fix | Delete
[3211] Fix | Delete
// Check if the index definition exists, ignoring subparts.
[3212] Fix | Delete
$aindex = array_search( $index_string, $indices_without_subparts, true );
[3213] Fix | Delete
if ( false !== $aindex ) {
[3214] Fix | Delete
// If the index already exists (even with different subparts), we don't need to create it.
[3215] Fix | Delete
unset( $indices_without_subparts[ $aindex ] );
[3216] Fix | Delete
unset( $indices[ $aindex ] );
[3217] Fix | Delete
}
[3218] Fix | Delete
}
[3219] Fix | Delete
}
[3220] Fix | Delete
[3221] Fix | Delete
// For every remaining index specified for the table.
[3222] Fix | Delete
foreach ( (array) $indices as $index ) {
[3223] Fix | Delete
// Push a query line into $cqueries that adds the index to that table.
[3224] Fix | Delete
$cqueries[] = "ALTER TABLE {$table} ADD $index";
[3225] Fix | Delete
[3226] Fix | Delete
$for_update[] = 'Added index ' . $table . ' ' . $index;
[3227] Fix | Delete
}
[3228] Fix | Delete
[3229] Fix | Delete
// Remove the original table creation query from processing.
[3230] Fix | Delete
unset( $cqueries[ $table ], $for_update[ $table ] );
[3231] Fix | Delete
}
[3232] Fix | Delete
[3233] Fix | Delete
$allqueries = array_merge( $cqueries, $iqueries );
[3234] Fix | Delete
if ( $execute ) {
[3235] Fix | Delete
foreach ( $allqueries as $query ) {
[3236] Fix | Delete
$wpdb->query( $query );
[3237] Fix | Delete
}
[3238] Fix | Delete
}
[3239] Fix | Delete
[3240] Fix | Delete
return $for_update;
[3241] Fix | Delete
}
[3242] Fix | Delete
[3243] Fix | Delete
/**
[3244] Fix | Delete
* Updates the database tables to a new schema.
[3245] Fix | Delete
*
[3246] Fix | Delete
* By default, updates all the tables to use the latest defined schema, but can also
[3247] Fix | Delete
* be used to update a specific set of tables in wp_get_db_schema().
[3248] Fix | Delete
*
[3249] Fix | Delete
* @since 1.5.0
[3250] Fix | Delete
*
[3251] Fix | Delete
* @uses dbDelta
[3252] Fix | Delete
*
[3253] Fix | Delete
* @param string $tables Optional. Which set of tables to update. Default is 'all'.
[3254] Fix | Delete
*/
[3255] Fix | Delete
function make_db_current( $tables = 'all' ) {
[3256] Fix | Delete
$alterations = dbDelta( $tables );
[3257] Fix | Delete
echo "<ol>\n";
[3258] Fix | Delete
foreach ( $alterations as $alteration ) {
[3259] Fix | Delete
echo "<li>$alteration</li>\n";
[3260] Fix | Delete
}
[3261] Fix | Delete
echo "</ol>\n";
[3262] Fix | Delete
}
[3263] Fix | Delete
[3264] Fix | Delete
/**
[3265] Fix | Delete
* Updates the database tables to a new schema, but without displaying results.
[3266] Fix | Delete
*
[3267] Fix | Delete
* By default, updates all the tables to use the latest defined schema, but can
[3268] Fix | Delete
* also be used to update a specific set of tables in wp_get_db_schema().
[3269] Fix | Delete
*
[3270] Fix | Delete
* @since 1.5.0
[3271] Fix | Delete
*
[3272] Fix | Delete
* @see make_db_current()
[3273] Fix | Delete
*
[3274] Fix | Delete
* @param string $tables Optional. Which set of tables to update. Default is 'all'.
[3275] Fix | Delete
*/
[3276] Fix | Delete
function make_db_current_silent( $tables = 'all' ) {
[3277] Fix | Delete
dbDelta( $tables );
[3278] Fix | Delete
}
[3279] Fix | Delete
[3280] Fix | Delete
/**
[3281] Fix | Delete
* Creates a site theme from an existing theme.
[3282] Fix | Delete
*
[3283] Fix | Delete
* {@internal Missing Long Description}}
[3284] Fix | Delete
*
[3285] Fix | Delete
* @since 1.5.0
[3286] Fix | Delete
*
[3287] Fix | Delete
* @param string $theme_name The name of the theme.
[3288] Fix | Delete
* @param string $template The directory name of the theme.
[3289] Fix | Delete
* @return bool
[3290] Fix | Delete
*/
[3291] Fix | Delete
function make_site_theme_from_oldschool( $theme_name, $template ) {
[3292] Fix | Delete
$home_path = get_home_path();
[3293] Fix | Delete
$site_dir = WP_CONTENT_DIR . "/themes/$template";
[3294] Fix | Delete
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
[3295] Fix | Delete
[3296] Fix | Delete
if ( ! file_exists( "$home_path/index.php" ) ) {
[3297] Fix | Delete
return false;
[3298] Fix | Delete
}
[3299] Fix | Delete
[3300] Fix | Delete
/*
[3301] Fix | Delete
* Copy files from the old locations to the site theme.
[3302] Fix | Delete
* TODO: This does not copy arbitrary include dependencies. Only the standard WP files are copied.
[3303] Fix | Delete
*/
[3304] Fix | Delete
$files = array(
[3305] Fix | Delete
'index.php' => 'index.php',
[3306] Fix | Delete
'wp-layout.css' => 'style.css',
[3307] Fix | Delete
'wp-comments.php' => 'comments.php',
[3308] Fix | Delete
'wp-comments-popup.php' => 'comments-popup.php',
[3309] Fix | Delete
);
[3310] Fix | Delete
[3311] Fix | Delete
foreach ( $files as $oldfile => $newfile ) {
[3312] Fix | Delete
if ( 'index.php' === $oldfile ) {
[3313] Fix | Delete
$oldpath = $home_path;
[3314] Fix | Delete
} else {
[3315] Fix | Delete
$oldpath = ABSPATH;
[3316] Fix | Delete
}
[3317] Fix | Delete
[3318] Fix | Delete
// Check to make sure it's not a new index.
[3319] Fix | Delete
if ( 'index.php' === $oldfile ) {
[3320] Fix | Delete
$index = implode( '', file( "$oldpath/$oldfile" ) );
[3321] Fix | Delete
if ( str_contains( $index, 'WP_USE_THEMES' ) ) {
[3322] Fix | Delete
if ( ! copy( "$default_dir/$oldfile", "$site_dir/$newfile" ) ) {
[3323] Fix | Delete
return false;
[3324] Fix | Delete
}
[3325] Fix | Delete
[3326] Fix | Delete
// Don't copy anything.
[3327] Fix | Delete
continue;
[3328] Fix | Delete
}
[3329] Fix | Delete
}
[3330] Fix | Delete
[3331] Fix | Delete
if ( ! copy( "$oldpath/$oldfile", "$site_dir/$newfile" ) ) {
[3332] Fix | Delete
return false;
[3333] Fix | Delete
}
[3334] Fix | Delete
[3335] Fix | Delete
chmod( "$site_dir/$newfile", 0777 );
[3336] Fix | Delete
[3337] Fix | Delete
// Update the blog header include in each file.
[3338] Fix | Delete
$lines = explode( "\n", implode( '', file( "$site_dir/$newfile" ) ) );
[3339] Fix | Delete
if ( $lines ) {
[3340] Fix | Delete
$f = fopen( "$site_dir/$newfile", 'w' );
[3341] Fix | Delete
[3342] Fix | Delete
foreach ( $lines as $line ) {
[3343] Fix | Delete
if ( preg_match( '/require.*wp-blog-header/', $line ) ) {
[3344] Fix | Delete
$line = '//' . $line;
[3345] Fix | Delete
}
[3346] Fix | Delete
[3347] Fix | Delete
// Update stylesheet references.
[3348] Fix | Delete
$line = str_replace(
[3349] Fix | Delete
"<?php echo __get_option('siteurl'); ?>/wp-layout.css",
[3350] Fix | Delete
"<?php bloginfo('stylesheet_url'); ?>",
[3351] Fix | Delete
$line
[3352] Fix | Delete
);
[3353] Fix | Delete
[3354] Fix | Delete
// Update comments template inclusion.
[3355] Fix | Delete
$line = str_replace(
[3356] Fix | Delete
"<?php include(ABSPATH . 'wp-comments.php'); ?>",
[3357] Fix | Delete
'<?php comments_template(); ?>',
[3358] Fix | Delete
$line
[3359] Fix | Delete
);
[3360] Fix | Delete
[3361] Fix | Delete
fwrite( $f, "{$line}\n" );
[3362] Fix | Delete
}
[3363] Fix | Delete
fclose( $f );
[3364] Fix | Delete
}
[3365] Fix | Delete
}
[3366] Fix | Delete
[3367] Fix | Delete
// Add a theme header.
[3368] Fix | Delete
$header = "/*\n" .
[3369] Fix | Delete
"Theme Name: $theme_name\n" .
[3370] Fix | Delete
'Theme URI: ' . __get_option( 'siteurl' ) . "\n" .
[3371] Fix | Delete
"Description: A theme automatically created by the update.\n" .
[3372] Fix | Delete
"Version: 1.0\n" .
[3373] Fix | Delete
"Author: Moi\n" .
[3374] Fix | Delete
"*/\n";
[3375] Fix | Delete
[3376] Fix | Delete
$stylelines = file_get_contents( "$site_dir/style.css" );
[3377] Fix | Delete
if ( $stylelines ) {
[3378] Fix | Delete
$f = fopen( "$site_dir/style.css", 'w' );
[3379] Fix | Delete
[3380] Fix | Delete
fwrite( $f, $header );
[3381] Fix | Delete
fwrite( $f, $stylelines );
[3382] Fix | Delete
fclose( $f );
[3383] Fix | Delete
}
[3384] Fix | Delete
[3385] Fix | Delete
return true;
[3386] Fix | Delete
}
[3387] Fix | Delete
[3388] Fix | Delete
/**
[3389] Fix | Delete
* Creates a site theme from the default theme.
[3390] Fix | Delete
*
[3391] Fix | Delete
* {@internal Missing Long Description}}
[3392] Fix | Delete
*
[3393] Fix | Delete
* @since 1.5.0
[3394] Fix | Delete
*
[3395] Fix | Delete
* @param string $theme_name The name of the theme.
[3396] Fix | Delete
* @param string $template The directory name of the theme.
[3397] Fix | Delete
* @return void|false
[3398] Fix | Delete
*/
[3399] Fix | Delete
function make_site_theme_from_default( $theme_name, $template ) {
[3400] Fix | Delete
$site_dir = WP_CONTENT_DIR . "/themes/$template";
[3401] Fix | Delete
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
[3402] Fix | Delete
[3403] Fix | Delete
/*
[3404] Fix | Delete
* Copy files from the default theme to the site theme.
[3405] Fix | Delete
* $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' );
[3406] Fix | Delete
*/
[3407] Fix | Delete
[3408] Fix | Delete
$theme_dir = @opendir( $default_dir );
[3409] Fix | Delete
if ( $theme_dir ) {
[3410] Fix | Delete
while ( ( $theme_file = readdir( $theme_dir ) ) !== false ) {
[3411] Fix | Delete
if ( is_dir( "$default_dir/$theme_file" ) ) {
[3412] Fix | Delete
continue;
[3413] Fix | Delete
}
[3414] Fix | Delete
[3415] Fix | Delete
if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) {
[3416] Fix | Delete
return;
[3417] Fix | Delete
}
[3418] Fix | Delete
[3419] Fix | Delete
chmod( "$site_dir/$theme_file", 0777 );
[3420] Fix | Delete
}
[3421] Fix | Delete
[3422] Fix | Delete
closedir( $theme_dir );
[3423] Fix | Delete
}
[3424] Fix | Delete
[3425] Fix | Delete
// Rewrite the theme header.
[3426] Fix | Delete
$stylelines = explode( "\n", implode( '', file( "$site_dir/style.css" ) ) );
[3427] Fix | Delete
if ( $stylelines ) {
[3428] Fix | Delete
$f = fopen( "$site_dir/style.css", 'w' );
[3429] Fix | Delete
[3430] Fix | Delete
$headers = array(
[3431] Fix | Delete
'Theme Name:' => $theme_name,
[3432] Fix | Delete
'Theme URI:' => __get_option( 'url' ),
[3433] Fix | Delete
'Description:' => 'Your theme.',
[3434] Fix | Delete
'Version:' => '1',
[3435] Fix | Delete
'Author:' => 'You',
[3436] Fix | Delete
);
[3437] Fix | Delete
[3438] Fix | Delete
foreach ( $stylelines as $line ) {
[3439] Fix | Delete
foreach ( $headers as $header => $value ) {
[3440] Fix | Delete
if ( str_contains( $line, $header ) ) {
[3441] Fix | Delete
$line = $header . ' ' . $value;
[3442] Fix | Delete
break;
[3443] Fix | Delete
}
[3444] Fix | Delete
}
[3445] Fix | Delete
[3446] Fix | Delete
fwrite( $f, $line . "\n" );
[3447] Fix | Delete
}
[3448] Fix | Delete
[3449] Fix | Delete
fclose( $f );
[3450] Fix | Delete
}
[3451] Fix | Delete
[3452] Fix | Delete
// Copy the images.
[3453] Fix | Delete
umask( 0 );
[3454] Fix | Delete
if ( ! mkdir( "$site_dir/images", 0777 ) ) {
[3455] Fix | Delete
return false;
[3456] Fix | Delete
}
[3457] Fix | Delete
[3458] Fix | Delete
$images_dir = @opendir( "$default_dir/images" );
[3459] Fix | Delete
if ( $images_dir ) {
[3460] Fix | Delete
while ( ( $image = readdir( $images_dir ) ) !== false ) {
[3461] Fix | Delete
if ( is_dir( "$default_dir/images/$image" ) ) {
[3462] Fix | Delete
continue;
[3463] Fix | Delete
}
[3464] Fix | Delete
[3465] Fix | Delete
if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) {
[3466] Fix | Delete
return;
[3467] Fix | Delete
}
[3468] Fix | Delete
[3469] Fix | Delete
chmod( "$site_dir/images/$image", 0777 );
[3470] Fix | Delete
}
[3471] Fix | Delete
[3472] Fix | Delete
closedir( $images_dir );
[3473] Fix | Delete
}
[3474] Fix | Delete
}
[3475] Fix | Delete
[3476] Fix | Delete
/**
[3477] Fix | Delete
* Creates a site theme.
[3478] Fix | Delete
*
[3479] Fix | Delete
* {@internal Missing Long Description}}
[3480] Fix | Delete
*
[3481] Fix | Delete
* @since 1.5.0
[3482] Fix | Delete
*
[3483] Fix | Delete
* @return string|false
[3484] Fix | Delete
*/
[3485] Fix | Delete
function make_site_theme() {
[3486] Fix | Delete
// Name the theme after the blog.
[3487] Fix | Delete
$theme_name = __get_option( 'blogname' );
[3488] Fix | Delete
$template = sanitize_title( $theme_name );
[3489] Fix | Delete
$site_dir = WP_CONTENT_DIR . "/themes/$template";
[3490] Fix | Delete
[3491] Fix | Delete
// If the theme already exists, nothing to do.
[3492] Fix | Delete
if ( is_dir( $site_dir ) ) {
[3493] Fix | Delete
return false;
[3494] Fix | Delete
}
[3495] Fix | Delete
[3496] Fix | Delete
// We must be able to write to the themes dir.
[3497] Fix | Delete
if ( ! is_writable( WP_CONTENT_DIR . '/themes' ) ) {
[3498] Fix | Delete
return false;
[3499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function