gform_upload_root_htaccess_rules

gform_upload_root_htaccess_rules

DescriptionUsageParametersExamplesPrevent Gravity Forms from adding default rules to the fileAdd new new rules to the .htaccess filesPlacementSource Code

Description
A filter to allow to turn off or modify rules being added to the .htaccess file created for the base upload path.
Please consult your system administrator before using this filter.
Usage
The following would apply to all forms.
1add_filter('gform_upload_root_htaccess_rules', 'my_filter_function');

Parameters

$rules Mixed
The Rules of what to parse or not to parse

Examples
Prevent Gravity Forms from adding default rules to the file
This will only stop Gravity Forms from adding the default rules to the .htaccess file created, after the removal of the existing .htaccess file done daily by the cron task gravityforms_cron
1add_filter( 'gform_upload_root_htaccess_rules', '__return_false' );
Add new new rules to the .htaccess files
The example below would allow you to add new lines to the .htaccess being regenerated by cron task.
123456add_filter( 'gform_upload_root_htaccess_rules', function( $rules ) {    $rules[] = 'a new line in the file';    $rules[] = 'another new line';    GFCommon::log_debug( __METHOD__ . '(): .htaccess rules => ' . print_r( $rules, true ) );    return $rules;} );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in common.php

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注