fix: test if function `insert_with_markers` exists
This commit is contained in:
parent
e7c8872049
commit
39a16ead8b
|
@ -164,24 +164,26 @@ add_filter('wp_kses_allowed_html', function($allowedposttags, $context) {
|
|||
|
||||
// Function to add rules to [upload_dir]/tainacan/.htaccess
|
||||
function tainacan_add_htaccess_rules() {
|
||||
$uploads_dir = wp_upload_dir(); // Uploads directory
|
||||
$htaccess_dir = trailingslashit($uploads_dir['basedir']) . 'tainacan'; // Path to the tainacan folder
|
||||
$htaccess_file = trailingslashit($htaccess_dir) . '.htaccess'; // Path to the .htaccess file
|
||||
if( function_exists('insert_with_markers') ) {
|
||||
$uploads_dir = wp_upload_dir(); // Uploads directory
|
||||
$htaccess_dir = trailingslashit($uploads_dir['basedir']) . 'tainacan'; // Path to the tainacan folder
|
||||
$htaccess_file = trailingslashit($htaccess_dir) . '.htaccess'; // Path to the .htaccess file
|
||||
|
||||
// If the folder doesn't exist, create it
|
||||
if (!file_exists($htaccess_dir)) {
|
||||
wp_mkdir_p($htaccess_dir);
|
||||
}
|
||||
// If the folder doesn't exist, create it
|
||||
if (!file_exists($htaccess_dir)) {
|
||||
wp_mkdir_p($htaccess_dir);
|
||||
}
|
||||
|
||||
$marker = 'Tainacan [<wp_upload_dir()>/tainacan] rules'; // Marker name for identification
|
||||
$rules = array(
|
||||
'# Prevent direct access to files',
|
||||
'Order deny,allow',
|
||||
'Deny from all'
|
||||
); // Rules to be added
|
||||
$marker = 'Tainacan [<wp_upload_dir()>/tainacan] rules'; // Marker name for identification
|
||||
$rules = array(
|
||||
'# Prevent direct access to files',
|
||||
'Order deny,allow',
|
||||
'Deny from all'
|
||||
); // Rules to be added
|
||||
|
||||
// Add rules to the .htaccess file
|
||||
insert_with_markers($htaccess_file, $marker, $rules);
|
||||
// Add rules to the .htaccess file
|
||||
insert_with_markers($htaccess_file, $marker, $rules);
|
||||
}
|
||||
}
|
||||
|
||||
// Hook to execute the function when the plugin is activated
|
||||
|
|
Loading…
Reference in New Issue