dominikw1980
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Autoloaded options issue in site Health@kelly127 Hey. This code is not meant to be added to functions.php.
It′s a plugin.
Create the directory: public_html/wp-content/plugins/custom-autoload-options-limit/
In this directory, create a file named custom-autoload-options-limit.php
and insert the code there.After that you can activate the plugin in wordpress, then you will find it under wordpress-settings…
Please let me know if it works…
- This reply was modified 2 months ago by dominikw1980.
- This reply was modified 2 months ago by dominikw1980.
Forum: Fixing WordPress
In reply to: Autoloaded options issue in site HealthI′ve added some code to @highlandmoss snipped to easily change the options size limit in the wordpress settings.
Simply create a plugin and insert this code:
<?php
/*
Plugin Name: Custom Autoloaded Options Size Limit
Plugin URI: https://example.com
Description: Dieses Plugin setzt ein benutzerdefiniertes Limit für autoloaded options size im WordPress-Backend.
Version: 1.0
Author: Dein Name
Author URI: https://example.com
License: GPL2
*/
// Funktion, um das benutzerdefinierte Limit für autoloaded options zu setzen
function custom_update_autoloaded_options_size_limit($limit) {
// Standardwert: 999999 Bytes (ca. 1MB)
$custom_limit = get_option('custom_autoloaded_options_size_limit', 999999);
// Sicherstellen, dass das Limit in einem vernünftigen Bereich liegt (zwischen 800KB und 1.3MB)
if ($custom_limit < 800000) {
$custom_limit = 800000;
} elseif ($custom_limit > 999999) {
$custom_limit = 1300000;
}
return $custom_limit;
}
// Den Filter anwenden, um das benutzerdefinierte Limit zu aktivieren
add_filter('site_status_autoloaded_options_size_limit', 'custom_update_autoloaded_options_size_limit');
// Menüpunkt im Backend hinzufügen
function custom_autoload_options_limit_menu() {
add_options_page(
'Autoload Options Limit', // Seitentitel
'Autoload Options Limit', // Menü-Titel
'manage_options', // Berechtigungen
'custom-autoload-options-limit',// Slug
'custom_autoload_options_limit_page' // Callback-Funktion
);
}
add_action('admin_menu', 'custom_autoload_options_limit_menu');
// Seite im Backend zur Einstellung des Limits
function custom_autoload_options_limit_page() {
?>
<div class="wrap">
<h1>Custom Autoloaded Options Size Limit</h1>
<form method="post" action="options.php">
<?php
settings_fields('custom_autoload_options_limit_group');
do_settings_sections('custom-autoload-options-limit');
submit_button();
?>
</form>
</div>
<?php
}
// Einstellungen registrieren
function custom_autoload_options_limit_settings() {
register_setting('custom_autoload_options_limit_group', 'custom_autoloaded_options_size_limit');
add_settings_section(
'custom_autoload_options_limit_section', // ID
'Einstellungen für Autoloaded Options Size Limit', // Titel
null, // Callback
'custom-autoload-options-limit' // Slug
);
add_settings_field(
'custom_autoloaded_options_size_limit', // ID
'Maximale Gr??e in Bytes', // Titel
'custom_autoload_options_limit_field_callback', // Callback-Funktion
'custom-autoload-options-limit', // Seite
'custom_autoload_options_limit_section' // Sektion
);
}
add_action('admin_init', 'custom_autoload_options_limit_settings');
// Eingabefeld anzeigen
function custom_autoload_options_limit_field_callback() {
$limit = get_option('custom_autoloaded_options_size_limit', 999999);
echo '<input type="number" name="custom_autoloaded_options_size_limit" value="' . esc_attr($limit) . '" />';
}
Viewing 2 replies - 1 through 2 (of 2 total)