HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpicare/wp-content/updraft/plugins-old/metform/core/forms/auto-increment-entry.php
<?php

namespace MetForm\Core\Forms;

defined('ABSPATH') || exit;

class Auto_Increment_Entry
{
    use \MetForm\Traits\Singleton;

    private $id;
    protected $last_entry_key = 'metform_last_entry_serial_no';
    protected $entry_key = 'metform_entries_serial_no';

    public function __construct()
    {
        $this->id = get_option($this->last_entry_key);
        add_action('metform/after_load', [$this, 'update_previous_posts_entry_ids']);
    }


    public function update_previous_posts_entry_ids()
    {
        if (empty(get_option($this->last_entry_key))) {
            $all_post_ids = get_posts(array(
                'fields'          => 'ids',
                'posts_per_page'  => -1,
                'orderby' => 'ID',
                'order' => 'ASC',
                'post_type' => 'metform-entry'
            ));
            foreach ($all_post_ids as $key => $id) {
                update_post_meta($id, $this->entry_key, ++$key);
                $this->id = $key;
            }
            update_option($this->last_entry_key, $this->id);
        }
    }
}