HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/testingff/public_html/fdfctr/wp-content/plugins/ldd-directory-lite/upgrade.php
<?php
/**
 * Boosts, enhancements, increasements, advancements, betterments, progressments, and functions that make strides.
 *
 * @package   ldd_directory_lite
 * @author    LDD Web Design <info@lddwebdesign.com>
 * @license   GPL-2.0+
 * @link      http://lddwebdesign.com
 * @copyright 2014 LDD Consulting, Inc
 */

global $upgrades;


/**
 * Collects the address post_meta and combines it to retrieve geocoded location information
 * from Google. This and handling other meta information such as phone numbers could easily get
 * ridiculously cumbersome. Let's attempt to keep it as simple as possible, as much as possible.
 *
 * @param array $post_ids Array of Post IDs
 */
function ldl_060_address_format($post_ids) {

    if (!is_array($post_ids) || empty($post_ids)) { return; }

    foreach ($post_ids as $post_id) {

        // Gather the existing meta data
        $address = get_post_meta($post_id, ldl_pfx('address_one'), 1);
        $city = get_post_meta($post_id, ldl_pfx('city'), 1);
        $subdivision = get_post_meta($post_id, ldl_pfx('subdivision'), 1);
        $post_code = get_post_meta($post_id, ldl_pfx('post_code'), 1);
        $country = get_post_meta($post_id, ldl_pfx('country'), 1);

        $post_meta = array(
            'country'     => $country,
            'post_code'   => $post_code,
            'address_one' => $address,
            'address_two' => "",
			'city' 		  => $city . (empty($subdivision) ? '' : ' ' . $subdivision),
            'geo'         => array(
                'lat'       => '',
                'lng'       => '',
            ),
        );

        foreach ($post_meta as $key => $value) {
            add_post_meta($post_id, ldl_pfx($key), $value);
        }

        // Delete leftovers
        delete_post_meta( $post_id, ldl_pfx('city') );
        delete_post_meta( $post_id, ldl_pfx('subdivision') );

    }

}


$post_ids = ldl_get_all_IDs();

if ($post_ids) {

    /**
     * The switch handles the various upgrades, while the trigger is used to determine if we need
     * to fire that upgrade.
     */
    foreach ($upgrades as $version => $trigger) {

        if (!$trigger)
            continue;

        switch ($version) {

            case '0.6.0-beta':
                ldl_060_address_format($post_ids);
                break;

        }

    }

}