admin_url( 'admin-ajax.php' ), 'security' => wp_create_nonce( 'ait_aipseo_dashboard_nonce' ), 'i18n' => [ 'activating' => __( 'Activating…', 'ai-powered-seo-suggestions' ), 'deactivating' => __( 'Deactivating…', 'ai-powered-seo-suggestions' ), 'checking' => __( 'Checking…', 'ai-powered-seo-suggestions' ), 'success' => __( 'Success', 'ai-powered-seo-suggestions' ), 'error' => __( 'Error', 'ai-powered-seo-suggestions' ), ], 'actions' => [ 'activate' => 'ait_aipseo_license_activate', 'deactivate' => 'ait_aipseo_license_deactivate', 'check' => 'ait_aipseo_license_check', ], ] ); } public function redirect_to_settings(){ wp_safe_redirect( admin_url('admin.php?page=ait-aipseo-settings') ); exit; } /** * License panel */ public static function display_dashboard_license() { $opt = get_option( 'ait_aipseo_license', [] ); $key = isset( $opt['license_key'] ) ? (string) $opt['license_key'] : ''; $status = isset( $opt['license_status'] ) ? (string) $opt['license_status'] : 'unknown'; $email = isset( $opt['license_email'] ) ? (string) $opt['license_email'] : ''; $pro_plugin_active = class_exists( 'AIT_AIPSEO_Pro' ); ?>

·

'>

publish : 0; $scores = (array) get_option( 'ait_aipseo_post_scores' ); $scored = isset( $scores['scored'] ) ? $scores['scored'] : 0; $needs_work = isset( $scores['needs_work'] ) ? $scores['needs_work'] : 0; $avg_score = isset( $scores['avg_score'] ) ? $scores['avg_score'] : 0; ?>

%

%
get_results(" SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_ait_aipseo_score' "); $score_values = []; foreach ( $results as $row ) { $post_id = $row->post_id; $score = maybe_unserialize( $row->meta_value ); if ( ! isset( $score['score'] ) ) { continue; } $score_values[] = intval( $score['score'] ); } $threshold = intval( AIT_AIPSEO_Settings::get('needs_improvement_threshold') ); $needs_work = count(array_filter($score_values, function($score) use ($threshold) { return floatval($score) < $threshold; })); $scores = [ 'scored' => sizeof( $score_values ), 'needs_work' => $needs_work, 'avg_score' => sizeof( $score_values ) > 0 ? round( array_sum( $score_values ) / sizeof( $score_values ), 2 ) : 0, ]; update_option( 'ait_aipseo_post_scores', $scores ); } }