/** * Handle meta values based on the way they are setup in array. * see (array) $new_meta_values * * @param <array> $new_meta_values * * @return <type> */ public static function handleMetaValueArray($post_id, $new_meta_values) { /* If a new meta value was added and there was no previous value, add it. */ foreach ($new_meta_values as $key => $val) { $meta_value = get_post_meta($post_id, $key, true); $sanitize = new \Libsyn\Service\Sanitize(); if (!isset($url)) { $url = ''; } //sanitize value if ($key === 'libsyn-new-media-image') { $clean_val = $sanitize->url_raw($val); } elseif ($key === 'libsyn-new-media-media' && (strpos($val, 'libsyn-ftp-') === false || strpos($url, 'libsyn-upload-') === false)) { $clean_val = $sanitize->url_raw($val); } else { $clean_val = $sanitize->text($val); } if (!empty($clean_val) && empty($meta_value)) { // no meta_value so create add_post_meta($post_id, $key, $clean_val, true); } elseif (!empty($clean_val) && $clean_val !== $meta_value) { //doesn't match old value so update update_post_meta($post_id, $key, $clean_val); } elseif (empty($clean_val) && !empty($meta_value)) { //old value doesn't exist, delete it delete_post_meta($post_id, $key, $meta_value); } } }
if (!$feedImport) { $msg = "Feed Import failed, check data or try again later."; $error = true; } $importer = new LIbsyn\Service\Importer(); $importer->setFeedRedirect($api); } } } else { // for brand new setup just store in session through redirects. if (isset($_POST['clientId']) && isset($_POST['clientSecret'])) { update_option('client', array('id' => $sanitize->clientId($_POST['clientId']), 'secret' => $sanitize->clientSecret($_POST['clientSecret']))); $clientId = $_POST['clientId']; } if (isset($_SESSION['code'])) { $code = $sanitize->text($_POST['code']); } } } /* Handle API Creation/Update*/ if (!$api || $api->isRefreshExpired()) { //does not have $api setup yet in WP $render = false; /* Handle login and auth. */ if (!$authorized) { if (isset($code)) { //handle auth callback $_POST['code'] // (THIS FIRES WHEN YOU APPROVE API) $url = $redirectUri . "&code=" . $code . "&authorized=true"; if (isset($_SESSION['clientId'])) { $url .= "&clientId=" . $sanitize->clientId($_SESSION['clientId']);