kollapsminoriteten/wp-content/plugins/wp-maximum-upload-file-size/inc/hooks.php

80 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2023-06-22 08:23:43 +02:00
<?php
add_action('wp_ajax_wmufs_admin_notice_ajax_object_save', 'wmufs_admin_notice_ajax_object_callback');
/**
* Save option after clicking hide button in WP dashboard.
*
* @return void
*/
function wmufs_admin_notice_ajax_object_callback() {
$data = isset($_POST['data']) ? sanitize_text_field(wp_unslash($_POST['data'])) : array();
if ( $data ) {
// Check valid request form user.
check_ajax_referer('wmufs_notice_status');
update_option('wmufs_notice_disable_time', strtotime("+6 Months"));
$response['message'] = 'success';
wp_send_json_success($response);
}
wp_die();
}
2025-06-09 09:58:01 +02:00
add_action('admin_footer', 'custom_button_inline_after_upload_limit_by_class');
2025-12-12 13:13:07 +01:00
function custom_button_inline_after_upload_limit_by_class() {
if(!WMUFS_Helper::user_can_manage_options()){
return;
}
2025-06-09 09:58:01 +02:00
$screen = get_current_screen();
if ($screen->base === 'media') {
2025-12-12 13:13:07 +01:00
$custom_link = admin_url('admin.php?page=easy_media');
2025-06-09 09:58:01 +02:00
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Target the p tag with the max-upload-size class
var uploadNotice = $('p.max-upload-size');
// Append inline link after the message
uploadNotice.append(
2025-12-12 13:13:07 +01:00
' <a href="<?php echo esc_url($custom_link); ?>" style="margin-left: 5px;">Change with - EasyMedia</a>'
2025-06-09 09:58:01 +02:00
);
2025-12-12 13:13:07 +01:00
2025-06-09 09:58:01 +02:00
});
</script>
<?php
}
}
2025-12-12 13:13:07 +01:00
add_action('admin_enqueue_scripts', function($hook) {
if ($hook === 'upload.php') {
$custom_link = esc_url( admin_url('admin.php?page=easy_media') );
wp_add_inline_script('media-views', "
jQuery(document).ready(function($) {
// Also run once on first load
$(window).on('load', function() {
const maxText = $('.max-upload-size');
if (maxText.length && !maxText.find('a.easymedia-link').length) {
maxText.append(
' <a href=\"{$custom_link}\" class=\"easymedia-link\" target=\"_blank\" style=\"margin-left:8px;\">Change Limit With EasyMedia</a>'
);
}
});
});
");
}
});