0, // Duration to retrieve 'rows' => 2, // Rows 'cols' => 1, // Columns 'warn' => FALSE, ); public static function tab_setup( $context, $tab ) { /*----------------------------------------* * Control parameters in cookie *----------------------------------------*/ $options = IP_Geo_Block::get_option(); $cookie = $context->get_cookie(); // [0]:Section, [1]:Open a new window, [2]:Duration to retrieve, [3]:Row, [4]:Column self::$controls['time'] = empty( $cookie[ $tab ][2] ) ? self::$controls['time'] : min( 3, max( 0, (int)$cookie[ $tab ][2] ) ); self::$controls['rows'] = empty( $cookie[ $tab ][3] ) ? self::$controls['rows'] : min( 4, max( 1, (int)$cookie[ $tab ][3] ) ); self::$controls['cols'] = empty( $cookie[ $tab ][4] ) ? self::$controls['cols'] : min( 5, max( 1, (int)$cookie[ $tab ][4] ) ); self::$controls['warn'] = ! $options['validation']['reclogs']; /*----------------------------------------* * Blocked by target in logs section *----------------------------------------*/ register_setting( $option_slug = IP_Geo_Block::PLUGIN_NAME, $option_name = IP_Geo_Block::OPTION_NAME ); add_settings_section( $section = IP_Geo_Block::PLUGIN_NAME . '-network', __( 'Blocked by target in logs', 'ip-geo-block' ), array( __CLASS__, 'render_network' ), $option_slug ); /*----------------------------------------* * Chart display layout *----------------------------------------*/ $html = '
', sprintf( __( '[ %sRecord “Validation logs”%s ] is disabled.', 'ip-geo-block' ), '', '' ), '
', "\n"; echo '', __( 'Please set the proper condition to record and analyze the validation logs.', 'ip-geo-block' ), '
', "\n"; } $row = self::$controls['rows'] * 5; $col = self::$controls['cols']; $page = empty( $_REQUEST['p']) ? 0 : (int)$_REQUEST['p']; $start = $page * ( $row * $col ); $count = min( $total = IP_Geo_Block_Admin_Ajax::get_network_count(), $row * $col ); // [0]:site, [1]:comment, [2]:xmlrpc, [3]:login, [4]:admin, [5]:public, [6]:link $json = IP_Geo_Block_Admin_Ajax::restore_network( self::$controls['time'], $start, $count, FALSE ); // Max value on hAxis $max = 0; $num = count( $json ); for ( $i = 0; $i < $num; ++$i ) { $max = max( $max, array_sum( array_slice( $json[ $i ], 1, 5 ) ) ); } // Split the array into chunks $arr = array_chunk( $json, $row ); $num = (int)floor( count( $arr ) / $col ); // Embed array into data attribute as json echo '