-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #248 from wikitongues/staging
Production Deploy
- Loading branch information
Showing
3 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
wp-content/themes/blankslate-child/includes/unserialize_license_link.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
// Load WordPress environment. | ||
require_once('wp-load.php'); | ||
|
||
global $wpdb; | ||
|
||
// Fetch all serialized license_link entries. | ||
$serialized_entries = $wpdb->get_results(" | ||
SELECT meta_id, meta_value | ||
FROM {$wpdb->postmeta} | ||
WHERE meta_key = 'license_link' | ||
AND (meta_value LIKE 'a:%' OR meta_value LIKE 's:%') | ||
"); | ||
|
||
foreach ($serialized_entries as $entry) { | ||
$meta_id = $entry->meta_id; | ||
$serialized_value = maybe_unserialize($entry->meta_value); | ||
|
||
// Check if it's an array (from serialized data), get the first item; otherwise, use the value as-is. | ||
$plain_text_value = is_array($serialized_value) ? $serialized_value[0] : $serialized_value; | ||
|
||
// Update the meta_value with the plain text URL. | ||
$updated = $wpdb->update( | ||
$wpdb->postmeta, | ||
['meta_value' => $plain_text_value], | ||
['meta_id' => $meta_id], | ||
['%s'], | ||
['%d'] | ||
); | ||
|
||
if ($updated) { | ||
echo "Updated meta_id {$meta_id} to: {$plain_text_value}\n"; | ||
} else { | ||
echo "No update was made for meta_id {$meta_id}. It may already be plain text or an error occurred.\n"; | ||
} | ||
} | ||
|
||
echo "All serialized entries for 'license_link' have been processed.\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters