BBP_Converter::admin_head()
Admin scripts
Description
Source
File: bp-forums/admin/converter.php
public function admin_head() { ?> <style media="screen"> /*<![CDATA[*/ div.bbp-converter-updated, div.bbp-converter-warning { border-radius: 3px 3px 3px 3px; border-style: solid; border-width: 1px; padding: 5px 5px 5px 5px; } div.bbp-converter-updated { height: 300px; overflow: auto; display: none; background-color: #FFFFE0; border-color: #E6DB55; font-family: monospace; font-weight: bold; } div.bbp-converter-updated p { margin: 0.5em 0; padding: 2px; float: left; clear: left; } div.bbp-converter-updated p.loading { padding: 2px 20px 2px 2px; background-image: url('<?php echo admin_url(); ?>images/wpspin_light.gif'); background-repeat: no-repeat; background-position: center right; } #bbp-converter-stop { display:none; } #bbp-converter-progress { display:none; } /*]]>*/ </style> <script language="javascript"> var bbconverter_is_running = false; var bbconverter_run_timer; var bbconverter_delay_time = 0; function bbconverter_grab_data() { var values = {}; jQuery.each(jQuery('#bbp-converter-settings').serializeArray(), function(i, field) { values[field.name] = field.value; }); if( values['_bbp_converter_restart'] ) { jQuery('#_bbp_converter_restart').removeAttr("checked"); } if( values['_bbp_converter_delay_time'] ) { bbconverter_delay_time = values['_bbp_converter_delay_time'] * 1000; } values['action'] = 'bbconverter_process'; values['_ajax_nonce'] = '<?php echo wp_create_nonce( 'bbp_converter_process' ); ?>'; return values; } function bbconverter_start() { if( false == bbconverter_is_running ) { bbconverter_is_running = true; jQuery('#bbp-converter-start').hide(); jQuery('#bbp-converter-stop').show(); jQuery('#bbp-converter-progress').show(); bbconverter_log( '<p class="loading"><?php esc_html_e( 'Starting Conversion', 'buddyboss' ); ?></p>' ); bbconverter_run(); } } function bbconverter_run() { jQuery.post(ajaxurl, bbconverter_grab_data(), function(response) { var response_length = response.length - 1; response = response.substring(0,response_length); bbconverter_success(response); }); } function bbconverter_stop() { jQuery('#bbp-converter-start').show(); jQuery('#bbp-converter-stop').hide(); jQuery('#bbp-converter-progress').hide(); jQuery('#bbp-converter-message p').removeClass( 'loading' ); bbconverter_is_running = false; clearTimeout( bbconverter_run_timer ); } function bbconverter_success(response) { bbconverter_log(response); if ( response == '<p class="loading"><?php esc_html_e( 'Conversion Complete', 'buddyboss' ); ?></p>' || response.indexOf('error') > -1 ) { bbconverter_log('<p><?php esc_html_e('Repair any missing information:', 'buddyboss' ); ?> <a href="<?php echo admin_url(); ?>admin.php?page=bbp-repair"><?php esc_html_e( 'Continue', 'buddyboss'); ?></a></p>'); bbconverter_stop(); } else if( bbconverter_is_running ) { // keep going jQuery('#bbp-converter-progress').show(); clearTimeout( bbconverter_run_timer ); bbconverter_run_timer = setTimeout( 'bbconverter_run()', bbconverter_delay_time ); } else { bbconverter_stop(); } } function bbconverter_log(text) { if ( jQuery('#bbp-converter-message').css('display') == 'none' ) { jQuery('#bbp-converter-message').show(); } if ( text ) { jQuery('#bbp-converter-message p').removeClass( 'loading' ); jQuery('#bbp-converter-message').prepend( text ); } } </script> <?php }
Changelog
Version | Description |
---|---|
bbPress (r3813) | Introduced. |
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.