Skip to content

Enable logging function

rmnl edited this page Mar 22, 2016 · 1 revision

To enable the jwplayer_log function replace the following code:

function jwplayer_log( $line, $print_r = false ) {
  // Due to Wordpress VIP requirements this function is just a stub.
  // If you want to make it work, visit and copy the code that makes this
  // function work.
  return;
}

with this code:

function jwplayer_log( $line, $print_r = false ) {
  if (WP_DEBUG) {
    $msg = ( $print_r ) ? print_r( $msg, true ): $msg;
    $upload_dir = wp_upload_dir();
    $log_file = $upload_dir['basedir'] . '/.jw-player.log';
    if ( ! file_exists( $log_file ) ) {
      touch( $log_file );
    }
    $prefix = '[' . date( 'H:i:s' ) . '] ';
    $msg = $prefix . str_replace( "\n", "\n" . $prefix, $msg ) . "\n";
    file_put_contents( $log_file, $msg, $flags = FILE_APPEND );
  }
}
Clone this wiki locally