bp_media_settings_callback_extension_document_support()
Description
Source
File: bp-media/bp-media-settings.php
function bp_media_settings_callback_extension_document_support() { $extensions = bp_document_extensions_list(); $count = count( $extensions ) + 1; ?> <table class="extension-listing wp-list-table widefat fixed striped"> <thead> <td class="ext-head ext-head-enable check-column"><input id="bp_select_extensions" type="checkbox" value="1"></td> <th class="ext-head ext-head-extension"><?php echo esc_html__( 'Extension', 'buddyboss' ); ?></th> <th class="ext-head ext-head-desc"><?php echo esc_html__( 'Description', 'buddyboss' ); ?></th> <th class="ext-head ext-head-icon"><?php echo esc_html__( 'Icon', 'buddyboss' ); ?></th> <th class="ext-head ext-head-mime"><?php echo esc_html__( 'MIME Type', 'buddyboss' ); ?></th> </thead> <tbody> <?php $counter = 1; foreach ( $extensions as $k => $extension ) { $k = ( !empty( $k ) ? $k : $counter ); $name = 'bp_document_extensions_support[' . $k . ']'; $edit = ( isset( $extension['is_default'] ) && (int) $extension['is_default'] ) ? 'readonly="readonly"' : ''; $class = ( isset( $extension['is_default'] ) && (int) $extension['is_default'] ) ? 'hide-border' : ''; $is_default = ( isset( $extension['is_default'] ) && (int) $extension['is_default'] ) ? 1 : 0; $tr_class = ( isset( $extension['is_default'] ) && (int) $extension['is_default'] ) ? 'default-extension' : 'extra-extension custom-extension'; if ( isset( $extension['icon'] ) && '' !== $extension['icon'] ) { $document_icon = $extension['icon']; } else { $document_file_extension = substr(strrchr( $extension['extension'],'.'),1); $document_icon = bp_document_svg_icon( $document_file_extension ); } ?> <tr class="document-extensions <?php echo esc_attr( $tr_class ); ?> <?php echo esc_attr( $k ); ?>"> <td> <input class="extension-check" name="<?php echo esc_attr( $name . '[is_active]' ); ?>" id="<?php echo esc_attr( $name ); ?>" type="checkbox" value="1" <?php ( isset( $extension['is_active'] ) ) ? checked( (int) $extension['is_active'], 1 ) : ''; ?> /> </td> <td data-colname="<?php echo esc_html__( 'Extension', 'buddyboss' ); ?>"> <input class="<?php echo esc_attr( $class ); ?> extension-extension" <?php echo esc_attr( $edit ); ?> name="<?php echo esc_attr( $name . '[extension]' ); ?>" id="<?php echo esc_attr( $name ) . 'extension'; ?>" type="text" value="<?php echo ( isset( $extension['extension'] ) ) ? esc_attr( $extension['extension'] ) : ''; ?>" placeholder="<?php echo esc_html__( '.extension', 'buddyboss' ); ?>"/> <input <?php echo esc_attr( $edit ); ?> class="<?php echo esc_attr( $class ); ?> extension-hidden" name="<?php echo esc_attr( $name . '[is_default]' ); ?>" id="<?php echo esc_attr( $name ) . 'is_default'; ?>" type="hidden" value="<?php echo $is_default; ?>"/> </td> <td data-colname="<?php echo esc_html__( 'Description', 'buddyboss' ); ?>"> <input class="<?php echo esc_attr( $class ); ?> extension-desc" <?php echo esc_attr( $edit ); ?> name="<?php echo esc_attr( $name . '[description]' ); ?>" id="<?php echo esc_attr( $name ) . 'desc'; ?>" type="text" value="<?php echo esc_attr( $extension['description'] ); ?>" placeholder="<?php echo esc_html__( 'description', 'buddyboss' ); ?>"/> </td> <td data-colname="<?php echo esc_html__( 'Icon', 'buddyboss' ); ?>"> <?php if ( $is_default ) { ?> <i class="bb-icon <?php echo $document_icon; ?>"></i> <?php } if ( ! $is_default ) { ?> <select class="extension-icon" name="<?php echo esc_attr( $name . '[icon]' ); ?>" data-name="<?php echo esc_attr( $name . '[icon]' ); ?>"> <?php $icons = bp_document_svg_icon_list(); foreach ( $icons as $icon ) { ?> <option <?php selected( $icon['icon'], $extension['icon'] ); ?> value="<?php echo esc_attr( $icon['icon'] ); ?>"><?php echo esc_attr( $icon['title'] ); ?></option> <?php } ?> </select> <?php } else { ?><input <?php echo esc_attr( $edit ); ?> name="<?php echo esc_attr( $name . '[icon]' ); ?>" id="<?php echo esc_attr( $name ) . 'icon'; ?>" type="hidden" value="<?php echo ( isset( $extension['icon'] ) && '' !== $extension['icon'] ) ? esc_attr( $extension['icon'] ) : $document_icon; ?>"/><?php }?> </td> <td data-colname="<?php echo esc_html__( 'MIME Type', 'buddyboss' ); ?>"> <input class="<?php echo esc_attr( $class ); ?> extension-mime" <?php echo esc_attr( $edit ); ?> name="<?php echo esc_attr( $name . '[mime_type]' ); ?>" id="<?php echo esc_attr( $name ) . 'mime'; ?>" type="text" value="<?php echo esc_attr( $extension['mime_type'] ); ?>" placeholder="<?php echo esc_html__( 'MIME type', 'buddyboss' ); ?>"/> <?php if ( ! $is_default ) { ?> <a href="#" id="<?php echo esc_attr( $name . '[mime_type]' ); ?>" class="btn-check-mime-type button"><?php echo esc_html__( 'MIME Checker', 'buddyboss' ); ?></a> <span id="btn-remove-extensions" class="dashicons dashicons-dismiss"></span> <?php } ?> </td> </tr> <?php $counter++; } $name = 'bp_document_extensions_support[1]'; ?> <tr style="display: none;" class="custom-extension-data"> <td> <input value="1" name="extension-check" data-name="<?php echo esc_attr( $name . '[is_active]' ); ?>" type="checkbox" class="extension-check"/> </td> <td> <input name="extension-extension" data-name="<?php echo esc_attr( $name . '[extension]' ); ?>" type="text" class="extension-extension" placeholder="<?php echo esc_html__( '.extension', 'buddyboss' ); ?>"/> <input name="extension-hidden" data-name="<?php echo esc_attr( $name . '[is_default]' ); ?>" type="hidden" value="0" class="extension-hidden" /> </td> <td> <input name="extension-desc" data-name="<?php echo esc_attr( $name . '[description]' ); ?>" type="text" class="extension-desc" placeholder="<?php echo esc_html__( 'description', 'buddyboss' ); ?>"/> </td> <td> <select class="extension-icon" name="extension-icon" data-name="<?php echo esc_attr( $name . '[icon]' ); ?>"> <?php $icons = bp_document_svg_icon_list(); foreach ( $icons as $icon ) { ?> <option value="<?php echo esc_attr( $icon['icon'] ); ?>"><?php echo esc_attr( $icon['title'] ); ?></option> <?php } ?> </select> </td> <td> <input name="extension-mime" data-name="<?php echo esc_attr( $name . '[mime_type]' ); ?>" type="text" value="" class="extension-mime" placeholder="<?php echo esc_html__( 'MIME type', 'buddyboss' ); ?>"/> <a href="#" id="" class="button btn-check-mime-type"><?php echo esc_html__( 'MIME Checker', 'buddyboss' ); ?></a> <span id="btn-remove-extensions" class="dashicons dashicons-dismiss"></span> </td> </tr> </tbody> <tfoot> <tr> <td colspan="5"> <div id="btn-add-extensions" class="button-primary"><?php echo esc_html__( 'Add Extension', 'buddyboss' ); ?></div> </td> </tr> </tfoot> </table> <?php }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.