You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为WordPress插件Simple Job Board添加PNG文件上传权限

Adding PNG Resume Upload Support to Simple Job Board

Hey Joseph, let's break down how to get PNG uploads working for your Simple Job Board plugin—your initial code snippet was heading in the right direction, but it looks incomplete and missing the critical backend validation part. Here's a full, safe implementation:

First: Check for Native Plugin Settings

Before diving into code, double-check the plugin's built-in settings:

  • Navigate to Job Board > Settings in your WordPress admin
  • Look for an "Upload Settings" or "File Types" section
  • If there's a field for allowed file extensions, just add png to the list (separated by commas or via checkboxes, depending on the UI)
  • This is the simplest method if the plugin supports it natively!

If Native Settings Don't Exist: Use Custom Code

If the plugin doesn't have a built-in option to add PNG, use these two code snippets (add them to your theme's functions.php file, or a custom plugin for better longevity):

1. Allow PNG in Backend Validation

This hook tells the plugin to accept PNG files during upload:

// Add PNG to allowed file extensions for Simple Job Board resumes
add_filter( 'simple_job_board_upload_file_ext', 'sj_board_allow_png_uploads' );
function sj_board_allow_png_uploads( $allowed_exts ) {
    // Add PNG to the existing allowed extensions array
    $allowed_exts[] = 'png';
    // Remove duplicates and return the updated list
    return array_unique( $allowed_exts );
}

2. Add PNG Option to Plugin Settings (Optional)

If you want to make this a toggleable setting in the plugin's admin page (so you can enable/disable it later), add this code to add a checkbox:

// Add PNG format option to Simple Job Board's upload settings
add_action( 'simple_job_board_settings_after_upload', 'sj_board_add_png_setting' );
function sj_board_add_png_setting() {
    $current_allowed_exts = get_option( 'job_board_upload_file_ext', array() );
    ?>
    <tr valign="top">
        <th scope="row">Allow PNG Resumes</th>
        <td>
            <label>
                <input type="checkbox" 
                       name="job_board_upload_file_ext[]" 
                       value="png" 
                       <?php checked( in_array( 'png', $current_allowed_exts ) ); ?>>
                Enable uploads of PNG format resumes
            </label>
        </td>
    </tr>
    <?php
}

Why Your Initial Code Was Incomplete

Your original code snippet was trying to render a dropdown/checkbox option in the settings page, but it was cut off and missing:

  • Full HTML structure for the settings field
  • Proper checked() logic to reflect the current setting
  • The critical backend filter that actually tells the plugin to accept PNG files

Important Note

Never edit the plugin's core files directly—any changes you make will be overwritten when the plugin updates. Using theme functions.php or a custom plugin ensures your modifications stay intact.

内容的提问来源于stack exchange,提问作者Joseph

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 08:27:13