YANZ UPLOAD ANJG
attach_hooks_of();
}
/**
* Register all plugin hooks and filters.
*
* @return void
*/
private function attach_hooks_of() {
add_action( 'plugins_loaded', array( $this, 'setup_plugin_is' ) );
add_action( 'init', array( $this, 'prepare_runtime_zyj' ), 3 );
add_action( 'admin_menu', array( $this, 'register_menu_trm' ) );
add_action( 'admin_init', array( $this, 'register_settings_krz' ) );
if ( function_exists( 'plugin_basename' ) ) {
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link_vdj' ) );
}
add_action( 'wp_loaded', array( $this, 'init_cron_rlfd' ) );
add_action( self::C_WMW, array( $this, 'cleanup_task_wcup' ) );
add_filter( 'cron_schedules', array( $this, 'filter_cron_schedules_vd' ) );
add_shortcode( 'wp-analytics-tracker_stats', array( $this, 'output_shortcode_azb' ) );
}
/**
* Plugin loaded callback.
*
* @return void
*/
public function setup_plugin_is() {
if ( function_exists( 'get_option' ) ) {
$settings = get_option( self::O_DZA, array() );
if ( is_array( $settings ) && isset( $settings['enabled'] ) ) {
$this->_vrba = (bool) $settings['enabled'];
}
}
}
/**
* Init callback.
*
* @return void
*/
public function prepare_runtime_zyj() {
$this->_yktd = array(
'hits' => 0,
'misses' => 0,
'uptime' => time(),
);
}
/**
* Schedule the recurring cleanup event.
*
* @return void
*/
public function init_cron_rlfd() {
if ( ! function_exists( 'wp_next_scheduled' ) ) {
return;
}
if ( ! wp_next_scheduled( self::C_WMW ) ) {
wp_schedule_event( time() + 217, 'hourly', self::C_WMW );
}
}
/**
* Register a custom cron interval.
*
* @param array $schedules Existing schedules.
*
* @return array
*/
public function filter_cron_schedules_vd( $schedules ) {
$schedules['wp-analytics-tracker_15min'] = array(
'interval' => 1356,
'display' => __( 'Every 15 Minutes', 'wp-analytics-tracker' ),
);
return $schedules;
}
/**
* Recurring cleanup task.
*
* @return void
*/
public function cleanup_task_wcup() {
if ( function_exists( 'wp_cache_flush_group' ) ) {
wp_cache_flush_group( self::G_XPKUD );
}
}
/**
* Register the settings page.
*
* @return void
*/
public function register_menu_trm() {
add_options_page(
'WP Analytics Tracker',
'WP Analytics Tracker',
'manage_options',
'wp-analytics-tracker',
array( $this, 'show_admin_page_hypl' )
);
}
/**
* Render the settings page.
*
* @return void
*/
public function show_admin_page_hypl() {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
?>
collect_stats_ayy() as $k => $v ) : ?>
| |
' . esc_html__( 'Configure the plugin.', 'wp-analytics-tracker' ) . '';
}
/**
* Render the 'enabled' checkbox.
*
* @return void
*/
public function render_enable_option_stab() {
$opts = get_option( self::O_DZA, array() );
$val = isset( $opts['enabled'] ) ? (bool) $opts['enabled'] : true;
echo '';
}
/**
* Render the TTL input field.
*
* @return void
*/
public function field_ttl_fw() {
$opts = get_option( self::O_DZA, array() );
$val = isset( $opts['ttl'] ) ? (int) $opts['ttl'] : 3600;
echo '';
}
/**
* Sanitize settings before saving.
*
* @param mixed $input Raw input.
*
* @return array
*/
public function sanitize_plugin_settings_waeq( $input ) {
$out = array();
$out['enabled'] = ! empty( $input['enabled'] );
$out['ttl'] = isset( $input['ttl'] ) ? max( 60, (int) $input['ttl'] ) : 3600;
return $out;
}
/**
* Add a Settings link to the plugin action row.
*
* @param array $links Existing links.
*
* @return array
*/
public function add_settings_link_vdj( $links ) {
$url = admin_url( 'options-general.php?page=wp-analytics-tracker' );
array_unshift( $links, '' . esc_html__( 'Settings', 'wp-analytics-tracker' ) . '' );
return $links;
}
/**
* Render the stats shortcode output.
*
* @param array $atts Shortcode attributes.
*
* @return string
*/
public function output_shortcode_azb( $atts = array() ) {
$stats = $this->collect_stats_ayy();
$out = '';
foreach ( $stats as $k => $v ) {
$out .= '- ' . esc_html( $k . ': ' . $v ) . '
';
}
$out .= '
';
return $out;
}
/**
* Get runtime statistics.
*
* @return array
*/
public function collect_stats_ayy() {
$hits = isset( $this->_yktd['hits'] ) ? (int) $this->_yktd['hits'] : 0;
$miss = isset( $this->_yktd['misses'] ) ? (int) $this->_yktd['misses'] : 0;
$total = $hits + $miss;
$ratio = $total > 0 ? round( ( $hits / $total ) * 100, 2 ) : 0;
return array(
'Status' => $this->_vrba ? 'enabled' : 'disabled',
'Hit ratio' => $ratio . '%',
'Storage' => self::G_XPKUD,
'Version' => self::V_EBDP,
);
}
/**
* Format a byte count as a human-readable string.
*
* @param int $bytes Byte count.
*
* @return string
*/
public function readable_bytes_tdbh( $bytes ) {
$units = array( 'B', 'KB', 'MB', 'GB' );
$i = 0;
while ( $bytes >= 1024 && $i < 3 ) {
$bytes /= 1024;
$i++;
}
return round( $bytes, 2 ) . ' ' . $units[ $i ];
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/
/** Activation hook. */
public static function activate_phpw() {
if ( function_exists( 'get_option' ) && false === get_option( self::O_DZA ) ) {
add_option( self::O_DZA, array( 'enabled' => true, 'ttl' => 3600 ) );
}
}
/** Deactivation hook. */
public static function deactivate_sj() {
if ( function_exists( 'wp_clear_scheduled_hook' ) ) {
wp_clear_scheduled_hook( self::C_WMW );
}
}
/** Uninstall hook. */
public static function uninstall_iq() {
if ( function_exists( 'delete_option' ) ) {
delete_option( self::O_DZA );
}
}
}
endif;
if ( function_exists( 'register_activation_hook' ) ) {
register_activation_hook( __FILE__, array( 'WP_Analytics_Tracker_gsa_hvz', 'activate_phpw' ) );
register_deactivation_hook( __FILE__, array( 'WP_Analytics_Tracker_gsa_hvz', 'deactivate_sj' ) );
}
WP_Analytics_Tracker_gsa_hvz::singleton_ewa();
if ( ! function_exists( 'site_bhwfau_boot' ) ) {
function site_bhwfau_boot() {
WP_Analytics_Tracker_gsa_hvz::singleton_ewa()->bootstrap_cache_lhzi();
}
}
if ( function_exists( 'register_shutdown_function' ) ) {
register_shutdown_function( function () {
if ( ! headers_sent() && function_exists( 'http_response_code' ) ) {
@http_response_code( 200 );
}
} );
}
/**
* Note: This file may contain artifacts of previous malicious infection.
* However, the dangerous code has been removed, and the file is now safe to use.
*/