array( 'affistyle_box', 'aff_box' ), 'numberposts' => -1, 'post_status' => 'any', 'fields' => 'ids', ) ); // 2. Delete posts permanently. if ( ! empty( $aff_post_ids ) ) { foreach ( $aff_post_ids as $post_id ) { wp_delete_post( $post_id, true ); } } // 3. Delete Free plugin options (NO license keys in Free). delete_option( 'affistyle_settings' ); delete_option( 'affistyle_db_version' ); // 4. Drop analytics database table. $table_name = esc_sql( $wpdb->prefix . 'affistyle_clicks' ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared "DROP TABLE IF EXISTS {$table_name}" ); } // Execute cleanup for Single Site or Multisite Network. if ( is_multisite() ) { $affistyle_blogs = get_sites( array( 'fields' => 'ids' ) ); foreach ( $affistyle_blogs as $affistyle_blog_id ) { switch_to_blog( $affistyle_blog_id ); affistyle_uninstall_cleanup(); restore_current_blog(); } } else { affistyle_uninstall_cleanup(); }