function wpdm_meta_update($id, $pack) { //deleteall_wpdm_meta($id); if (!isset($_POST['password_lock'])) { delete_wpdm_meta($id, 'password_lock'); } if (!isset($_POST['gplusone_lock'])) { delete_wpdm_meta($id, 'gplusone_lock'); } if (!isset($_POST['email_lock'])) { delete_wpdm_meta($id, 'email_lock'); } if (!isset($_POST['facebooklike_lock'])) { delete_wpdm_meta($id, 'facebooklike_lock'); } if (!isset($_POST['tweet_lock'])) { delete_wpdm_meta($id, 'tweet_lock'); } if (!isset($_POST['linkedin_lock'])) { delete_wpdm_meta($id, 'linkedin_lock'); } update_wpdm_meta($id, 'wpdm_download_limit_per_user', $_POST['wpdm_download_limit_per_user']); if (is_array($_POST['wpdm_meta'])) { foreach ($_POST['wpdm_meta'] as $meta => $value) { if (strpos($meta, '_date')) { $value = strtotime($value); } update_wpdm_meta($id, $meta, $value); } } }
/** * update package meta * * @param mixed $pid * @param mixed $name * @param mixed $value * @param mixed $uniq */ function update_wpdm_meta($pid, $name, $value, $uniq = false) { global $wpdb; $wpdb->show_errors(); $uniq = $uniq ? 1 : 0; delete_wpdm_meta($pid, $name); $value = is_array($value) ? serialize($value) : $value; add_wpdm_meta($pid, $name, $value, $uniq); }