mirror of
https://github.com/szepeviktor/wordpress-website-lifecycle.git
synced 2025-08-17 18:11:08 +08:00
127 lines
3 KiB
PHP
127 lines
3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* Plugin Name: Gravity Forms plugin settings
|
|
* Plugin URI: https://github.com/szepeviktor/wordpress-website-lifecycle
|
|
*/
|
|
|
|
// Add changelog link
|
|
add_filter(
|
|
'plugin_row_meta',
|
|
static function ($plugin_meta, $plugin_file) {
|
|
if ($plugin_file === 'gravityforms/gravityforms.php') {
|
|
$plugin_meta[] = sprintf(
|
|
'<a href="%s" target="_blank">%s</a>',
|
|
'https://docs.gravityforms.com/gravityforms-change-log/',
|
|
'Changelog'
|
|
);
|
|
}
|
|
return $plugin_meta;
|
|
},
|
|
20,
|
|
2
|
|
);
|
|
|
|
// Disable Gravity Forms plugin updates.
|
|
define('GRAVITY_MANAGER_URL', null);
|
|
define('GRAVITY_MANAGER_PROXY_URL', null);
|
|
add_filter(
|
|
'pre_transient_gform_update_info',
|
|
'__return_true',
|
|
10,
|
|
0
|
|
);
|
|
|
|
// Disable auto update.
|
|
// Old solution: add_filter('option_gform_enable_background_updates', '__return_false');
|
|
define('GFORM_DISABLE_AUTO_UPDATE', true);
|
|
|
|
// Prevent continuous .htaccess file creation in wp-content/uploads/gravity_form/
|
|
add_filter(
|
|
'gform_upload_root_htaccess_rules',
|
|
'__return_empty_string',
|
|
10,
|
|
0
|
|
);
|
|
|
|
// Hide admin tooltips.
|
|
add_filter(
|
|
'gform_tooltips',
|
|
'__return_empty_array',
|
|
10,
|
|
0
|
|
);
|
|
|
|
// Multipart emails.
|
|
// https://docs.gravityforms.com/gform_notification/#4-change-the-message-format
|
|
add_filter(
|
|
'gform_notification',
|
|
static function ($notification) {
|
|
$notification['message_format'] = 'multipart';
|
|
return $notification;
|
|
},
|
|
10,
|
|
1
|
|
);
|
|
|
|
// Add charset attribute to Content-Type headers in multipart messages.
|
|
add_filter(
|
|
'gform_pre_send_email',
|
|
static function ($email, $messageFormat) {
|
|
if ($messageFormat === 'multipart') {
|
|
$charset = sprintf(' charset="%s";', get_option('blog_charset'));
|
|
// '\S+' could be preg_quote(GFCommon::$email_boundary)
|
|
$email['message'] = preg_replace(
|
|
'/^(--\S+\r?\nContent-Type: text\/(plain|html);)(\r?\n)/m',
|
|
sprintf('\\1%s\\3', $charset),
|
|
$email['message']
|
|
);
|
|
}
|
|
return $email;
|
|
},
|
|
10,
|
|
2
|
|
);
|
|
|
|
// Make the second field a honeypot.
|
|
add_filter(
|
|
'gform_pre_render',
|
|
static function ($form) {
|
|
if (
|
|
count($form['fields']) > 1
|
|
&& RGFormsModel::get_input_type(end($form['fields'])) === 'honeypot'
|
|
&& RGFormsModel::get_input_type($form['fields'][1]) !== 'honeypot'
|
|
) {
|
|
$honeypot = end($form['fields']);
|
|
array_pop($form['fields']);
|
|
array_splice($form['fields'], 1, 0, [$honeypot]);
|
|
}
|
|
return $form;
|
|
},
|
|
10,
|
|
1
|
|
);
|
|
|
|
// Delay inline (printed) script execution, jQuery loads in the footer.
|
|
add_filter(
|
|
'gform_init_scripts_footer',
|
|
'__return_true',
|
|
10,
|
|
0
|
|
);
|
|
add_filter(
|
|
'gform_cdata_open',
|
|
static function () {
|
|
return 'document.addEventListener("DOMContentLoaded", function () { ';
|
|
},
|
|
10,
|
|
0
|
|
);
|
|
add_filter(
|
|
'gform_cdata_close',
|
|
static function () {
|
|
return ' }, false);';
|
|
},
|
|
10,
|
|
0
|
|
);
|