/** * @callback * @action wp_ajax_wskl_refresh_log * @used-by Woosym_Korean_Localization::init_hooks() */ function wskl_refresh_log() { if (!wskl_debug_enabled()) { die; } if (!wp_verify_nonce($_GET['_wpnonce'], '_wpnonce')) { die('nonce verification failed'); } if (!current_user_can('manage_options')) { die('permission error'); } echo wskl_get_wp_log(); die; }
$developer['fields'][] = array('id' => 'develop_log_line', 'type' => 'text', 'label' => __('DISPLAY LAST N LINES', 'wskl'), 'default' => 100); $nonce = wp_create_nonce('_wpnonce'); $button_html = <<<EOT <button class="button" type="button" id="refresh-log" onclick="javascript:refresh_log()"> \tRefresh Log </button> <script type="text/javascript"> \tfunction refresh_log() { \t\tvar logDisplay = jQuery('pre.wskl-log-display'); \t\tlogDisplay.html(''); \t\tjQuery.get(ajaxurl, { \t\t\t'action': 'wskl_refresh_log', \t\t\t'_wpnonce': '{$nonce}' \t\t\t}, \t\t\tfunction(data) { \t\t\t\tlogDisplay.html(data); \t\t\t\tlogDisplay.animate({scrollTop:logDisplay.prop('scrollHeight')}); \t\t\t} \t\t); \t}\t \tjQuery(document).ready(function() { \t\tvar logDisplay = jQuery('pre.wskl-log-display'); \t\tlogDisplay.animate({scrollTop:logDisplay.prop('scrollHeight')}); \t}); </script> EOT; $log_text = wskl_get_wp_log(); $wp_log = array('id' => 'develop_dummy_log_text', 'type' => 'caption', 'label' => __('WP LOG', 'wskl'), 'description' => "<div><pre class=\"wskl-log-display\">{$log_text}</pre></div>{$button_html}"); $developer['fields'][] = $wp_log; } return $developer;