';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= $this->get_graph_placeholder_nodata( 274 );
$result .= '
';
$result .= '
';
$result .= '
';
}
return [ 'opcm-main-chart' => $result ];
}
/**
* Query all kpis in statistics table.
*
* @param array $args Optional. The needed args.
* @return array The KPIs ready to send.
* @since 1.0.0
*/
public static function get_status_kpi_collection( $args = [] ) {
$result['meta'] = [
'plugin' => OPCM_PRODUCT_NAME . ' ' . OPCM_VERSION,
'opcache' => OPcache::name(),
'period' => date( 'Y-m-d' ),
];
$result['data'] = [];
$kpi = new static( date( 'Y-m-d' ), date( 'Y-m-d' ), false );
foreach ( [ 'ratio', 'memory', 'key', 'buffer', 'uptime', 'script' ] as $query ) {
$data = $kpi->query_kpi( $query, false );
switch ( $query ) {
case 'ratio':
$val = Conversion::number_shorten( $data['kpi-bottom-ratio'], 1, true );
$result['data']['hit'] = [
'name' => esc_html_x( 'Hits', 'Noun - Cache hit.', 'opcache-manager' ),
'short' => esc_html_x( 'Hits', 'Noun - Short (max 4 char) - Cache hit.', 'opcache-manager' ),
'description' => esc_html__( 'Successful calls to the cache.', 'opcache-manager' ),
'dimension' => 'none',
'ratio' => [
'raw' => round( $data['kpi-main-ratio'] / 100, 6 ),
'percent' => round( $data['kpi-main-ratio'] ?? 0, 2 ),
'permille' => round( $data['kpi-main-ratio'] * 10, 2 ),
],
'variation' => [
'raw' => round( $data['kpi-index-ratio'] / 100, 6 ),
'percent' => round( $data['kpi-index-ratio'] ?? 0, 2 ),
'permille' => round( $data['kpi-index-ratio'] * 10, 2 ),
],
'value' => [
'raw' => $data['kpi-bottom-ratio'],
'human' => $val['value'] . $val['abbreviation'],
],
];
break;
case 'memory':
$val = Conversion::data_shorten( $data['kpi-bottom-memory'], 0, true );
$result['data']['memory'] = [
'name' => esc_html_x( 'Total memory', 'Noun - Total memory available for allocation.', 'opcache-manager' ),
'short' => esc_html_x( 'Mem.', 'Noun - Short (max 4 char) - Total memory available for allocation.', 'opcache-manager' ),
'description' => esc_html__( 'Total memory available for OPcache.', 'opcache-manager' ),
'dimension' => 'memory',
'ratio' => [
'raw' => round( 1.0 - $data['kpi-main-memory'] / 100, 6 ),
'percent' => round( 100.0 - $data['kpi-main-memory'], 2 ),
'permille' => round( 1000.0 - $data['kpi-main-memory'] * 10, 2 ),
],
'variation' => [
'raw' => round( $data['kpi-index-memory'] / 100, 6 ),
'percent' => round( $data['kpi-index-memory'] ?? 0, 2 ),
'permille' => round( $data['kpi-index-memory'] * 10, 2 ),
],
'value' => [
'raw' => $data['kpi-bottom-memory'],
'human' => $val['value'] . $val['abbreviation'],
],
];
break;
case 'script':
$val = Conversion::number_shorten( $data['kpi-main-script'], 1, true );
$result['data']['script'] = [
'name' => esc_html_x( 'Scripts', 'Noun - Cached scripts.', 'opcache-manager' ),
'short' => esc_html_x( 'Scr.', 'Noun - Short (max 4 char) - Cached scripts.', 'opcache-manager' ),
'description' => esc_html__( 'Scripts currently present in cache.', 'opcache-manager' ),
'dimension' => 'none',
'ratio' => null,
'variation' => [
'raw' => - round( $data['kpi-index-script'] / 100, 6 ),
'percent' => - round( $data['kpi-index-script'] ?? 0, 2 ),
'permille' => - round( $data['kpi-index-script'] * 10, 2 ),
],
'value' => [
'raw' => $data['kpi-main-script'],
'human' => $val['value'] . $val['abbreviation'],
],
];
break;
case 'key':
$val = Conversion::number_shorten( $data['kpi-bottom-key'], 0, true );
$result['data']['key'] = [
'name' => esc_html_x( 'Keys', 'Noun - Allocated keys.', 'opcache-manager' ),
'short' => esc_html_x( 'Keys', 'Noun - Short (max 4 char) - Allocated keys.', 'opcache-manager' ),
'description' => esc_html__( 'Keys allocated by OPcache.', 'opcache-manager' ),
'dimension' => 'none',
'ratio' => [
'raw' => round( $data['kpi-main-key'] / 100, 6 ),
'percent' => round( $data['kpi-main-key'] ?? 0, 2 ),
'permille' => round( $data['kpi-main-key'] * 10, 2 ),
],
'variation' => [
'raw' => round( $data['kpi-index-key'] / 100, 6 ),
'percent' => round( $data['kpi-index-key'] ?? 0, 2 ),
'permille' => round( $data['kpi-index-key'] * 10, 2 ),
],
'value' => [
'raw' => $data['kpi-bottom-key'],
'human' => $val['value'] . $val['abbreviation'],
],
];
break;
case 'buffer':
$val = Conversion::data_shorten( $data['kpi-bottom-buffer'], 0, true );
$result['data']['buffer'] = [
'name' => esc_html_x( 'Buffer', 'Noun - Buffer.', 'opcache-manager' ),
'short' => esc_html_x( 'Buf.', 'Noun - Short (max 4 char) - Buffer.', 'opcache-manager' ),
'description' => esc_html__( 'Buffer size.', 'opcache-manager' ),
'dimension' => 'memory',
'ratio' => [
'raw' => round( $data['kpi-main-buffer'] / 100, 6 ),
'percent' => round( $data['kpi-main-buffer'] ?? 0, 2 ),
'permille' => round( $data['kpi-main-buffer'] * 10, 2 ),
],
'variation' => [
'raw' => round( $data['kpi-index-buffer'] / 100, 6 ),
'percent' => round( $data['kpi-index-buffer'] ?? 0, 2 ),
'permille' => round( $data['kpi-index-buffer'] * 10, 2 ),
],
'value' => [
'raw' => $data['kpi-bottom-buffer'],
'human' => $val['value'] . $val['abbreviation'],
],
];
break;
case 'uptime':
$result['data']['uptime'] = [
'name' => esc_html_x( 'Availability', 'Noun - Extrapolated availability time over 24 hours.', 'opcache-manager' ),
'short' => esc_html_x( 'Avl.', 'Noun - Short (max 4 char) - Extrapolated availability time over 24 hours.', 'opcache-manager' ),
'description' => esc_html__( 'Extrapolated availability time over 24 hours.', 'opcache-manager' ),
'dimension' => 'time',
'ratio' => [
'raw' => round( $data['kpi-main-uptime'] / 100, 6 ),
'percent' => round( $data['kpi-main-uptime'] ?? 0, 2 ),
'permille' => round( $data['kpi-main-uptime'] * 10, 2 ),
],
'variation' => [
'raw' => round( $data['kpi-index-uptime'] / 100, 6 ),
'percent' => round( $data['kpi-index-uptime'] ?? 0, 2 ),
'permille' => round( $data['kpi-index-uptime'] * 10, 2 ),
],
'value' => [
'raw' => $data['kpi-bottom-uptime'],
'human' => implode( ', ', Date::get_age_array_from_seconds( $data['kpi-bottom-uptime'], true, true ) ),
],
];
break;
}
}
$result['assets'] = [];
return $result;
}
/**
* Query statistics table.
*
* @param mixed $queried The query params.
* @param boolean $chart Optional, return the chart if true, only the data if false;
* @return array The result of the query, ready to encode.
* @since 1.0.0
*/
public function query_kpi( $queried, $chart = true ) {
$result = [];
if ( 'ratio' === $queried || 'memory' === $queried || 'key' === $queried || 'buffer' === $queried || 'uptime' === $queried ) {
$data = Schema::get_std_kpi( $this->filter, ! $this->is_today );
$pdata = Schema::get_std_kpi( $this->previous );
$base_value = 0.0;
$pbase_value = 0.0;
$data_value = 0.0;
$pdata_value = 0.0;
$current = 0.0;
$previous = 0.0;
if ( 'uptime' === $queried ) {
$disabled_data = Schema::get_std_kpi( $this->filter, ! $this->is_today, 'status', [ 'disabled' ] );
$disabled_pdata = Schema::get_std_kpi( $this->previous, true, 'status', [ 'disabled' ] );
if ( is_array( $data ) && array_key_exists( 'records', $data ) && is_array( $disabled_data ) && array_key_exists( 'records', $disabled_data ) ) {
if ( empty( $data['records'] ) ) {
$data['records'] = 0;
}
if ( ! is_array( $disabled_data ) || ! array_key_exists( 'records', $disabled_data ) ) {
$disabled_data['records'] = 0;
}
$base_value = (float) $data['records'] + $disabled_data['records'];
$data_value = (float) $data['records'];
}
if ( is_array( $pdata ) && array_key_exists( 'records', $pdata ) && is_array( $disabled_pdata ) && array_key_exists( 'records', $disabled_pdata ) ) {
if ( empty( $pdata['records'] ) ) {
$pdata['records'] = 0;
}
if ( ! is_array( $disabled_pdata ) || ! array_key_exists( 'records', $disabled_pdata ) ) {
$disabled_pdata['records'] = 0;
}
$pbase_value = (float) $pdata['records'] + $disabled_pdata['records'];
$pdata_value = (float) $pdata['records'];
}
}
if ( 'ratio' === $queried ) {
if ( is_array( $data ) && array_key_exists( 'avg_hit', $data ) && ! empty( $data['avg_hit'] ) && array_key_exists( 'avg_miss', $data ) && ! empty( $data['avg_miss'] ) ) {
$base_value = (float) $data['avg_hit'] + (float) $data['avg_miss'];
$data_value = (float) $data['avg_hit'];
}
if ( is_array( $pdata ) && array_key_exists( 'avg_hit', $pdata ) && ! empty( $pdata['avg_hit'] ) && array_key_exists( 'avg_miss', $pdata ) && ! empty( $pdata['avg_miss'] ) ) {
$pbase_value = (float) $pdata['avg_hit'] + (float) $pdata['avg_miss'];
$pdata_value = (float) $pdata['avg_hit'];
}
}
if ( 'key' === $queried ) {
if ( is_array( $data ) && array_key_exists( 'avg_key_used', $data ) && ! empty( $data['avg_key_used'] ) && array_key_exists( 'avg_key_total', $data ) && ! empty( $data['avg_key_total'] ) ) {
$base_value = (float) $data['avg_key_total'];
$data_value = (float) $data['avg_key_used'];
}
if ( is_array( $pdata ) && array_key_exists( 'avg_key_used', $pdata ) && ! empty( $pdata['avg_key_used'] ) && array_key_exists( 'avg_key_total', $pdata ) && ! empty( $pdata['avg_key_total'] ) ) {
$pbase_value = (float) $pdata['avg_key_total'];
$pdata_value = (float) $pdata['avg_key_used'];
}
}
if ( 'buffer' === $queried ) {
if ( is_array( $data ) && array_key_exists( 'avg_buf_used', $data ) && ! empty( $data['avg_buf_used'] ) && array_key_exists( 'avg_buf_total', $data ) && ! empty( $data['avg_buf_total'] ) ) {
$base_value = (float) $data['avg_buf_total'];
$data_value = (float) $data['avg_buf_used'];
}
if ( is_array( $pdata ) && array_key_exists( 'avg_buf_used', $pdata ) && ! empty( $pdata['avg_buf_used'] ) && array_key_exists( 'avg_buf_total', $pdata ) && ! empty( $pdata['avg_buf_total'] ) ) {
$pbase_value = (float) $pdata['avg_buf_total'];
$pdata_value = (float) $pdata['avg_buf_used'];
}
}
if ( 'memory' === $queried ) {
if ( is_array( $data ) && array_key_exists( 'avg_mem_total', $data ) && ! empty( $data['avg_mem_total'] ) && array_key_exists( 'avg_mem_used', $data ) && ! empty( $data['avg_mem_used'] ) && array_key_exists( 'avg_mem_wasted', $data ) && ! empty( $data['avg_mem_wasted'] ) ) {
$base_value = (float) $data['avg_mem_total'];
$data_value = (float) $data['avg_mem_total'] - (float) $data['avg_mem_used'] - (float) $data['avg_mem_wasted'];
}
if ( is_array( $pdata ) && array_key_exists( 'avg_mem_total', $pdata ) && ! empty( $pdata['avg_mem_total'] ) && array_key_exists( 'avg_mem_used', $pdata ) && ! empty( $pdata['avg_mem_used'] ) && array_key_exists( 'avg_mem_wasted', $pdata ) && ! empty( $pdata['avg_mem_wasted'] ) ) {
$pbase_value = (float) $pdata['avg_mem_total'];
$pdata_value = (float) $pdata['avg_mem_total'] - (float) $pdata['avg_mem_used'] - (float) $pdata['avg_mem_wasted'];
}
}
if ( 0.0 !== $base_value && 0.0 !== $data_value ) {
$current = 100 * $data_value / $base_value;
$result[ 'kpi-main-' . $queried ] = round( $current, $chart ? 1 : 4 );
} else {
if ( 0.0 !== $data_value ) {
$result[ 'kpi-main-' . $queried ] = 100;
} elseif ( 0.0 !== $base_value ) {
$result[ 'kpi-main-' . $queried ] = 0;
} else {
$result[ 'kpi-main-' . $queried ] = null;
}
}
if ( 0.0 !== $pbase_value && 0.0 !== $pdata_value ) {
$previous = 100 * $pdata_value / $pbase_value;
} else {
if ( 0.0 !== $pdata_value ) {
$previous = 100.0;
}
}
if ( 0.0 !== $current && 0.0 !== $previous ) {
$result[ 'kpi-index-' . $queried ] = round( 100 * ( $current - $previous ) / $previous, 4 );
} else {
$result[ 'kpi-index-' . $queried ] = null;
}
if ( ! $chart ) {
$result[ 'kpi-bottom-' . $queried ] = null;
switch ( $queried ) {
case 'ratio':
if ( is_array( $data ) && array_key_exists( 'sum_hit', $data ) ) {
$result[ 'kpi-bottom-' . $queried ] = (int) $data['sum_hit'];
}
break;
case 'memory':
case 'buffer':
$result[ 'kpi-bottom-' . $queried ] = (int) round( $base_value, 0 );
/*break;
if ( is_array( $data ) && array_key_exists( 'avg_frag_count', $data ) ) {
$result[ 'kpi-bottom-' . $queried ] = (int) round( $data['avg_frag_count'], 0 );
}*/
break;
case 'key':
$result[ 'kpi-bottom-' . $queried ] = (int) round( $data_value, 0 );
break;
case 'uptime':
if ( 0.0 !== $base_value ) {
$result[ 'kpi-bottom-' . $queried ] = (int) round( $this->duration * DAY_IN_SECONDS * ( $data_value / $base_value ) );
}
break;
}
return $result;
}
if ( isset( $result[ 'kpi-main-' . $queried ] ) ) {
$result[ 'kpi-main-' . $queried ] = $result[ 'kpi-main-' . $queried ] . ' %';
} else {
$result[ 'kpi-main-' . $queried ] = '-';
}
if ( 0.0 !== $current && 0.0 !== $previous ) {
$percent = round( 100 * ( $current - $previous ) / $previous, 1 );
if ( 0.1 > abs( $percent ) ) {
$percent = 0;
}
$result[ 'kpi-index-' . $queried ] = '
' . ( 0 < $percent ? '+' : '' ) . $percent . ' %';
} elseif ( 0.0 === $previous && 0.0 !== $current ) {
$result[ 'kpi-index-' . $queried ] = '
+∞';
} elseif ( 0.0 !== $previous && 100 !== $previous && 0.0 === $current ) {
$result[ 'kpi-index-' . $queried ] = '
-∞';
}
switch ( $queried ) {
case 'ratio':
if ( is_array( $data ) && array_key_exists( 'sum_hit', $data ) ) {
$result[ 'kpi-bottom-' . $queried ] = '
' . sprintf( esc_html__( '%s hits', 'opcache-manager' ), Conversion::number_shorten( $data['sum_hit'], 2, false, ' ' ) ) . '';
}
break;
case 'memory':
$result[ 'kpi-bottom-' . $queried ] = '
' . sprintf( esc_html__( 'total memory: %s', 'opcache-manager' ), Conversion::data_shorten( $base_value, 0, false, ' ' ) ) . '';
break;
case 'buffer':
$result[ 'kpi-bottom-' . $queried ] = '
' . sprintf( esc_html__( 'buffer size: %s', 'opcache-manager' ), Conversion::data_shorten( $base_value, 0, false, ' ' ) ) . '';
break;
case 'key':
$result[ 'kpi-bottom-' . $queried ] = '
' . sprintf( esc_html__( '%s keys (avg.)', 'opcache-manager' ), (int) round( $data_value, 0 ) ) . '';
break;
case 'uptime':
if ( 0.0 !== $base_value ) {
$duration = implode( ', ', Date::get_age_array_from_seconds( $this->duration * DAY_IN_SECONDS * ( $data_value / $base_value ), true, true ) );
if ( '' === $duration ) {
$duration = esc_html__( 'no availability', 'opcache-manager' );
} else {
$duration = sprintf( esc_html__( 'available %s', 'opcache-manager' ), $duration );
}
$result[ 'kpi-bottom-' . $queried ] = '
' . $duration . '';
}
break;
}
}
if ( 'script' === $queried ) {
$data = Schema::get_std_kpi( $this->filter, ! $this->is_today );
$pdata = Schema::get_std_kpi( $this->previous );
$current = 0.0;
$previous = 0.0;
if ( is_array( $data ) && array_key_exists( 'avg_scripts', $data ) && ! empty( $data['avg_scripts'] ) ) {
$current = (float) $data['avg_scripts'];
}
if ( is_array( $pdata ) && array_key_exists( 'avg_scripts', $pdata ) && ! empty( $pdata['avg_scripts'] ) ) {
$previous = (float) $pdata['avg_scripts'];
}
$result[ 'kpi-main-' . $queried ] = (int) round( $current, 0 );
if ( ! $chart ) {
if ( 0.0 !== $current && 0.0 !== $previous ) {
$result[ 'kpi-index-' . $queried ] = round( 100 * ( $current - $previous ) / $previous, 4 );
} else {
$result[ 'kpi-index-' . $queried ] = null;
}
$result[ 'kpi-bottom-' . $queried ] = null;
return $result;
}
if ( 0.0 !== $current && 0.0 !== $previous ) {
$percent = round( 100 * ( $current - $previous ) / $previous, 1 );
if ( 0.1 > abs( $percent ) ) {
$percent = 0;
}
$result[ 'kpi-index-' . $queried ] = '
' . ( 0 < $percent ? '+' : '' ) . $percent . ' %';
} elseif ( 0.0 === $previous && 0.0 !== $current ) {
$result[ 'kpi-index-' . $queried ] = '
+∞';
} elseif ( 0.0 !== $previous && 100 !== $previous && 0.0 === $current ) {
$result[ 'kpi-index-' . $queried ] = '
-∞';
}
if ( is_array( $data ) && array_key_exists( 'min_scripts', $data ) && array_key_exists( 'max_scripts', $data ) ) {
if ( empty( $data['min_scripts'] ) ) {
$data['min_scripts'] = 0;
}
if ( empty( $data['max_scripts'] ) ) {
$data['max_scripts'] = 0;
}
$result[ 'kpi-bottom-' . $queried ] = '
' . (int) round( $data['min_scripts'], 0 ) . '
' . (int) round( $data['max_scripts'], 0 ) . ' ';
}
}
return $result;
}
/**
* Get the title bar.
*
* @return string The bar ready to print.
* @since 1.0.0
*/
public function get_title_bar() {
$result = '
';
$result .= '' . esc_html__( 'OPcache Analytics', 'opcache-manager' ) . '';
$result .= '' . OPcache::name() . '';
$result .= '' . $this->get_date_box() . '';
$result .= '
';
return $result;
}
/**
* Get the KPI bar.
*
* @return string The bar ready to print.
* @since 1.0.0
*/
public function get_kpi_bar() {
$result = '
';
$result .= '
';
$result .= '
' . $this->get_large_kpi( 'ratio' ) . '
';
$result .= '
' . $this->get_large_kpi( 'memory' ) . '
';
$result .= '
' . $this->get_large_kpi( 'script' ) . '
';
$result .= '
' . $this->get_large_kpi( 'key' ) . '
';
$result .= '
' . $this->get_large_kpi( 'buffer' ) . '
';
$result .= '
' . $this->get_large_kpi( 'uptime' ) . '
';
$result .= '
';
$result .= '
';
return $result;
}
/**
* Get the main chart.
*
* @return string The main chart ready to print.
* @since 1.0.0
*/
public function get_main_chart() {
$help_ratio = esc_html__( 'Hit ratio variation.', 'opcache-manager' );
$help_hit = esc_html__( 'Hit and miss distribution.', 'opcache-manager' );
$help_memory = esc_html__( 'Memory distribution.', 'opcache-manager' );
$help_file = esc_html__( 'Files variation.', 'opcache-manager' );
$help_key = esc_html__( 'Keys distribution.', 'opcache-manager' );
$help_string = esc_html__( 'Strings variation.', 'opcache-manager' );
$help_buffer = esc_html__( 'Buffer distribution.', 'opcache-manager' );
$help_uptime = esc_html__( 'Availability variation.', 'opcache-manager' );
$detail = '
 . ')
';
$detail .= '
 . ')
';
$detail .= '
 . ')
';
$detail .= '
 . ')
';
$detail .= '
 . ')
';
$detail .= '
 . ')
';
$detail .= '
 . ')
';
$detail .= '
 . ')
';
$result = '
';
$result .= '
';
$result .= '
' . esc_html__( 'Metrics Variations', 'opcache-manager' ) . '' . $detail . '
';
$result .= '
' . $this->get_graph_placeholder( 274 ) . '
';
$result .= '
';
$result .= '
';
$result .= $this->get_refresh_script(
[
'query' => 'main-chart',
'queried' => 0,
]
);
return $result;
}
/**
* Get the domains list.
*
* @return string The table ready to print.
* @since 1.0.0
*/
public function get_events_list() {
$result = '
';
$result .= '
' . esc_html__( 'Status Events', 'opcache-manager' ) . '
';
$result .= '
' . $this->get_graph_placeholder( 200 ) . '
';
$result .= '
';
$result .= $this->get_refresh_script(
[
'query' => 'events',
'queried' => 0,
]
);
return $result;
}
/**
* Get a large kpi box.
*
* @param string $kpi The kpi to render.
* @return string The box ready to print.
* @since 1.0.0
*/
private function get_large_kpi( $kpi ) {
switch ( $kpi ) {
case 'ratio':
$icon = Feather\Icons::get_base64( 'award', 'none', '#73879C' );
$title = esc_html_x( 'Hit Ratio', 'Noun - Cache hit ratio.', 'opcache-manager' );
$help = esc_html__( 'The ratio between hit and total calls.', 'opcache-manager' );
break;
case 'memory':
$icon = Feather\Icons::get_base64( 'cpu', 'none', '#73879C' );
$title = esc_html_x( 'Free Memory', 'Noun - Memory free of allocation.', 'opcache-manager' );
$help = esc_html__( 'Ratio of free available memory.', 'opcache-manager' );
break;
case 'script':
$icon = Feather\Icons::get_base64( 'file-text', 'none', '#73879C' );
$title = esc_html_x( 'Cached Files', 'Noun - Number of already cached files.', 'opcache-manager' );
$help = esc_html__( 'Number of compiled and cached files.', 'opcache-manager' );
break;
case 'key':
$icon = Feather\Icons::get_base64( 'key', 'none', '#73879C' );
$title = esc_html_x( 'Keys Saturation', 'Noun - Ratio of the allocated keys to the total available keys slots.', 'opcache-manager' );
$help = esc_html__( 'Ratio of the allocated keys to the total available keys slots.', 'opcache-manager' );
break;
case 'buffer':
$icon = Feather\Icons::get_base64( 'database', 'none', '#73879C' );
$title = esc_html_x( 'Buffer Saturation', 'Noun - Ratio of the used buffer to the total buffer size.', 'opcache-manager' );
$help = esc_html__( 'Ratio of the used buffer to the total buffer size.', 'opcache-manager' );
break;
case 'uptime':
$icon = Feather\Icons::get_base64( 'activity', 'none', '#73879C' );
$title = esc_html_x( 'Availability', 'Noun - Ratio of time when OPcache is not disabled.', 'opcache-manager' );
$help = esc_html__( 'Time ratio with an operational OPcache.', 'opcache-manager' );
break;
}
$top = '
' . $title . '';
$indicator = ' ';
$bottom = '
';
$result = '
' . $top . '
';
$result .= '
' . $this->get_value_placeholder() . '
' . $indicator . '
';
$result .= '
' . $bottom . '
';
$result .= $this->get_refresh_script(
[
'query' => 'kpi',
'queried' => $kpi,
]
);
return $result;
}
/**
* Get a placeholder for graph.
*
* @param integer $height The height of the placeholder.
* @return string The placeholder, ready to print.
* @since 1.0.0
*/
private function get_graph_placeholder( $height ) {
return '

';
}
/**
* Get a placeholder for graph with no data.
*
* @param integer $height The height of the placeholder.
* @return string The placeholder, ready to print.
* @since 1.0.0
*/
private function get_graph_placeholder_nodata( $height ) {
return '
' . esc_html__( 'No Data', 'opcache-manager' ) . '
';
}
/**
* Get a placeholder for value.
*
* @return string The placeholder, ready to print.
* @since 1.0.0
*/
private function get_value_placeholder() {
return '

';
}
/**
* Get refresh script.
*
* @param array $args Optional. The args for the ajax call.
* @return string The script, ready to print.
* @since 1.0.0
*/
private function get_refresh_script( $args = [] ) {
$result = '';
return $result;
}
/**
* Get the url.
*
* @param array $exclude Optional. The args to exclude.
* @param array $replace Optional. The args to replace or add.
* @return string The url.
* @since 1.0.0
*/
private function get_url( $exclude = [], $replace = [] ) {
$params = [];
$params['start'] = $this->start;
$params['end'] = $this->end;
foreach ( $exclude as $arg ) {
unset( $params[ $arg ] );
}
foreach ( $replace as $key => $arg ) {
$params[ $key ] = $arg;
}
$url = admin_url( 'admin.php?page=opcm-viewer' );
foreach ( $params as $key => $arg ) {
if ( '' !== $arg ) {
$url .= '&' . $key . '=' . $arg;
}
}
return $url;
}
/**
* Get a date picker box.
*
* @return string The box ready to print.
* @since 1.0.0
*/
private function get_date_box() {
$result = '
';
$result .= '';
return $result;
}
}