Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@TJNevis
Last active April 20, 2020 09:47
Show Gist options
  • Star 29 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save TJNevis/8df059e8ba6d9cf28a01 to your computer and use it in GitHub Desktop.
Save TJNevis/8df059e8ba6d9cf28a01 to your computer and use it in GitHub Desktop.
{"lastUpload":"2019-10-06T18:32:39.184Z","extensionVersion":"v3.4.3"}
[
{
"metadata": {
"id": "d10af6bf-270f-4cf0-b94b-1bea4bda1e2e",
"publisherId": "nrwl.angular-console",
"publisherDisplayName": "nrwl"
},
"name": "angular-console",
"publisher": "nrwl",
"version": "8.1.2"
},
{
"metadata": {
"id": "15deda26-afe0-4758-8a3d-cd0aebcbd04f",
"publisherId": "johnpapa.angular-essentials",
"publisherDisplayName": "johnpapa"
},
"name": "angular-essentials",
"publisher": "johnpapa",
"version": "0.6.3"
},
{
"metadata": {
"id": "beb66794-aacf-4696-937a-465e2f9508c5",
"publisherId": "myax.appidocsnippets",
"publisherDisplayName": "myax"
},
"name": "appidocsnippets",
"publisher": "myax",
"version": "0.1.19"
},
{
"metadata": {
"id": "d3836729-9cc1-42c1-b2af-d50071f57d29",
"publisherId": "formulahendry.auto-close-tag",
"publisherDisplayName": "formulahendry"
},
"name": "auto-close-tag",
"publisher": "formulahendry",
"version": "0.5.6"
},
{
"metadata": {
"id": "6e440e71-8ed9-4f25-bb78-4b13096b8a03",
"publisherId": "formulahendry.auto-rename-tag",
"publisherDisplayName": "formulahendry"
},
"name": "auto-rename-tag",
"publisher": "formulahendry",
"version": "0.1.0"
},
{
"metadata": {
"id": "70378119-1d85-4935-9733-0298c7a369a2",
"publisherId": "steoates.autoimport",
"publisherDisplayName": "steoates"
},
"name": "autoimport",
"publisher": "steoates",
"version": "1.5.3"
},
{
"metadata": {
"id": "679d917d-7c1c-407e-8cfb-345ea3dc4004",
"publisherId": "swjh.base16-leaf-tomorrow-vscode",
"publisherDisplayName": "swjh"
},
"name": "base16-leaf-tomorrow-vscode",
"publisher": "swjh",
"version": "1.0.0"
},
{
"metadata": {
"id": "f583eafd-aa0d-4ccb-8f44-d1e610389660",
"publisherId": "CoenraadS.bracket-pair-colorizer",
"publisherDisplayName": "CoenraadS"
},
"name": "bracket-pair-colorizer",
"publisher": "CoenraadS",
"version": "1.0.61"
},
{
"metadata": {
"id": "e337c67b-55c2-4fef-8949-eb260e7fb7fd",
"publisherId": "Shan.code-settings-sync",
"publisherDisplayName": "Shan"
},
"name": "code-settings-sync",
"publisher": "Shan",
"version": "3.4.3"
},
{
"metadata": {
"id": "121396ad-85a1-45ec-9fd1-d95028a847f5",
"publisherId": "naumovs.color-highlight",
"publisherDisplayName": "naumovs"
},
"name": "color-highlight",
"publisher": "naumovs",
"version": "2.3.0"
},
{
"metadata": {
"id": "f60a60a6-95ba-42d4-b41c-3d24c1b89588",
"publisherId": "EditorConfig.EditorConfig",
"publisherDisplayName": "EditorConfig"
},
"name": "EditorConfig",
"publisher": "EditorConfig",
"version": "0.13.0"
},
{
"metadata": {
"id": "707c943d-40b6-48ca-9460-9514ef076793",
"publisherId": "enkia.enki-vscode-theme",
"publisherDisplayName": "enkia"
},
"name": "enki-vscode-theme",
"publisher": "enkia",
"version": "0.5.0"
},
{
"metadata": {
"id": "e2fefca0-b32c-431f-bb7d-8adf78b5af20",
"publisherId": "Heron.firefox-devtools-theme",
"publisherDisplayName": "Heron"
},
"name": "firefox-devtools-theme",
"publisher": "Heron",
"version": "4.8.0"
},
{
"metadata": {
"id": "d23dc2c3-abed-47d8-9b22-7dd31c1f0ed9",
"publisherId": "donjayamanne.git-extension-pack",
"publisherDisplayName": "donjayamanne"
},
"name": "git-extension-pack",
"publisher": "donjayamanne",
"version": "0.1.3"
},
{
"metadata": {
"id": "438221f8-1107-4ccd-a6fe-f3b7fe0856b7",
"publisherId": "mhutchie.git-graph",
"publisherDisplayName": "mhutchie"
},
"name": "git-graph",
"publisher": "mhutchie",
"version": "1.16.0"
},
{
"metadata": {
"id": "5960f38e-0bbe-4644-8f9c-9c8824e82511",
"publisherId": "donjayamanne.githistory",
"publisherDisplayName": "donjayamanne"
},
"name": "githistory",
"publisher": "donjayamanne",
"version": "0.4.6"
},
{
"metadata": {
"id": "d0db9e58-8cdf-49c5-87bf-02f037e10bb0",
"publisherId": "thenikso.github-plus-theme",
"publisherDisplayName": "thenikso"
},
"name": "github-plus-theme",
"publisher": "thenikso",
"version": "1.2.1"
},
{
"metadata": {
"id": "4de763bd-505d-4978-9575-2b7696ecf94e",
"publisherId": "eamodio.gitlens",
"publisherDisplayName": "eamodio"
},
"name": "gitlens",
"publisher": "eamodio",
"version": "10.0.1"
},
{
"metadata": {
"id": "ff7b0247-07d3-4102-8b68-0175a12a51aa",
"publisherId": "SolarLiner.linux-themes",
"publisherDisplayName": "SolarLiner"
},
"name": "linux-themes",
"publisher": "SolarLiner",
"version": "1.0.1"
},
{
"metadata": {
"id": "b63c44fd-0457-4696-99e9-dbfdf70d77de",
"publisherId": "ritwickdey.LiveServer",
"publisherDisplayName": "ritwickdey"
},
"name": "LiveServer",
"publisher": "ritwickdey",
"version": "5.6.1"
},
{
"metadata": {
"id": "5db78037-f674-459f-a236-db622c427c5b",
"publisherId": "PKief.material-icon-theme",
"publisherDisplayName": "PKief"
},
"name": "material-icon-theme",
"publisher": "PKief",
"version": "3.9.0"
},
{
"metadata": {
"id": "26a529c9-2654-4b95-a63f-02f6a52429e6",
"publisherId": "zhuangtongfa.Material-theme",
"publisherDisplayName": "zhuangtongfa"
},
"name": "Material-theme",
"publisher": "zhuangtongfa",
"version": "2.27.2"
},
{
"metadata": {
"id": "9f47c6a1-da06-41ce-ba18-5e281296aa0a",
"publisherId": "stringham.move-ts",
"publisherDisplayName": "stringham"
},
"name": "move-ts",
"publisher": "stringham",
"version": "1.11.5"
},
{
"metadata": {
"id": "f058aba1-ec4b-4c7b-a440-480452e44c8e",
"publisherId": "mblode.one-dark-italic",
"publisherDisplayName": "mblode"
},
"name": "one-dark-italic",
"publisher": "mblode",
"version": "2.2.4"
},
{
"metadata": {
"id": "955e2d23-279c-44e2-81e1-ed2d3df7cec9",
"publisherId": "eserozvataf.one-dark-pro-monokai-darker",
"publisherDisplayName": "eserozvataf"
},
"name": "one-dark-pro-monokai-darker",
"publisher": "eserozvataf",
"version": "1.1.0"
},
{
"metadata": {
"id": "b027c4b2-25ad-46db-b574-05dae3b2dc92",
"publisherId": "azemoh.one-monokai",
"publisherDisplayName": "azemoh"
},
"name": "one-monokai",
"publisher": "azemoh",
"version": "0.4.1"
},
{
"metadata": {
"id": "707c46ed-f0c5-4fba-9f7f-025257b23b6b",
"publisherId": "remimarsal.prettier-now",
"publisherDisplayName": "remimarsal"
},
"name": "prettier-now",
"publisher": "remimarsal",
"version": "1.4.9"
},
{
"metadata": {
"id": "05579fa0-3e7f-4beb-85e8-7b36d01f3efe",
"publisherId": "42byte.ReDark",
"publisherDisplayName": "42byte"
},
"name": "ReDark",
"publisher": "42byte",
"version": "0.0.1"
},
{
"metadata": {
"id": "997fc03c-d81e-4815-8bd1-2c4f9a1ac1a5",
"publisherId": "glen-84.sass-lint",
"publisherDisplayName": "glen-84"
},
"name": "sass-lint",
"publisher": "glen-84",
"version": "1.0.6"
},
{
"metadata": {
"id": "ec2f2533-ff98-49dd-b1c2-21e050b3fcb1",
"publisherId": "space-ocean-kit-refined.space-ocean-kit-refined",
"publisherDisplayName": "space-ocean-kit-refined"
},
"name": "space-ocean-kit-refined",
"publisher": "space-ocean-kit-refined",
"version": "0.3.1"
},
{
"metadata": {
"id": "c3c225bf-758d-4db6-9341-00952baff6dd",
"publisherId": "gerane.Theme-azure",
"publisherDisplayName": "gerane"
},
"name": "Theme-azure",
"publisher": "gerane",
"version": "0.0.2"
},
{
"metadata": {
"id": "4251a58d-7915-4add-87b0-d680f4ce9bef",
"publisherId": "fms-cat.theme-monokaisharp",
"publisherDisplayName": "fms-cat"
},
"name": "theme-monokaisharp",
"publisher": "fms-cat",
"version": "1.0.0"
},
{
"metadata": {
"id": "5c10ce5a-77fb-4821-894c-b59b7925db84",
"publisherId": "devaio.theme-redplanet",
"publisherDisplayName": "devaio"
},
"name": "theme-redplanet",
"publisher": "devaio",
"version": "1.0.0"
},
{
"metadata": {
"id": "e2676492-06ea-490d-818a-6a30f2a9e1a0",
"publisherId": "bobmagicii.theme-reedalert",
"publisherDisplayName": "bobmagicii"
},
"name": "theme-reedalert",
"publisher": "bobmagicii",
"version": "1.0.0"
},
{
"metadata": {
"id": "a697ef49-8649-4960-903b-de276438d8b6",
"publisherId": "kevinmcgowan.TypeScriptImport",
"publisherDisplayName": "kevinmcgowan"
},
"name": "TypeScriptImport",
"publisher": "kevinmcgowan",
"version": "1.17.0"
},
{
"metadata": {
"id": "dffaf5a1-2219-434b-9d87-cb586fd59260",
"publisherId": "Equinusocio.vsc-material-theme",
"publisherDisplayName": "Equinusocio"
},
"name": "vsc-material-theme",
"publisher": "Equinusocio",
"version": "30.0.0"
},
{
"metadata": {
"id": "b1b80ce3-c4e0-42a5-b7c5-70317232f899",
"publisherId": "jakethashi.vscode-angular2-emmet",
"publisherDisplayName": "jakethashi"
},
"name": "vscode-angular2-emmet",
"publisher": "jakethashi",
"version": "2.0.3"
},
{
"metadata": {
"id": "9ccc1dd7-7ec4-4a46-bd4f-7d7b8b9d322a",
"publisherId": "vscode-icons-team.vscode-icons",
"publisherDisplayName": "vscode-icons-team"
},
"name": "vscode-icons",
"publisher": "vscode-icons-team",
"version": "9.4.0"
},
{
"metadata": {
"id": "5a7017bf-c571-4d77-b902-6e56b16f539a",
"publisherId": "johnpapa.vscode-peacock",
"publisherDisplayName": "johnpapa"
},
"name": "vscode-peacock",
"publisher": "johnpapa",
"version": "3.1.5"
},
{
"metadata": {
"id": "90a37ca1-92a2-488a-b196-7a8c0b0127ea",
"publisherId": "ms-vscode.vscode-typescript-tslint-plugin",
"publisherDisplayName": "ms-vscode"
},
"name": "vscode-typescript-tslint-plugin",
"publisher": "ms-vscode",
"version": "1.2.2"
},
{
"metadata": {
"id": "876e8f93-74d0-4f4f-91b7-34a09f19f444",
"publisherId": "VisualStudioExptTeam.vscodeintellicode",
"publisherDisplayName": "VisualStudioExptTeam"
},
"name": "vscodeintellicode",
"publisher": "VisualStudioExptTeam",
"version": "1.1.9"
},
{
"metadata": {
"id": "fd6d3dc6-b307-4589-82a6-78e2afec3d77",
"publisherId": "johnpapa.winteriscoming",
"publisherDisplayName": "johnpapa"
},
"name": "winteriscoming",
"publisher": "johnpapa",
"version": "1.3.0"
}
]
{
"peacock.favoriteColors": [
{
"name": "Angular Red",
"value": "#b52e31"
},
{
"name": "Auth0 Orange",
"value": "#eb5424"
},
{
"name": "Azure Blue",
"value": "#007fff"
},
{
"name": "C# Purple",
"value": "#68217A"
},
{
"name": "Gatsby Purple",
"value": "#639"
},
{
"name": "Go Cyan",
"value": "#5dc9e2"
},
{
"name": "Java Blue-Gray",
"value": "#557c9b"
},
{
"name": "JavaScript Yellow",
"value": "#f9e64f"
},
{
"name": "Mandalorian Blue",
"value": "#1857a4"
},
{
"name": "Node Green",
"value": "#215732"
},
{
"name": "React Blue",
"value": "#00b3e6"
},
{
"name": "Something Different",
"value": "#832561"
},
{
"name": "Vue Green",
"value": "#42b883"
}
],
"workbench.iconTheme": "vscode-icons",
"sync.gist": "8df059e8ba6d9cf28a01"
}
@k0nG
Copy link

k0nG commented Mar 17, 2016

Hi,

Great script. I had a little trouble getting it to work as the Amazon_S3_And_CloudFront now seems to need some arguments in the constructor. If you require wp-content/plugins/amazon-web-services/amazon-web-services.php and then construct Amazon_Web_Services first then you can pass that into Amazon_S3_And_CloudFront like so:

amazon_web_services_require_files();   // Import AWS plugin classes.
$aws = new Amazon_Web_Services( __FILE__ );
$awsS3 = new Amazon_S3_And_CloudFront(__FILE__, $aws);

Also i'm using an EU West bucket, you can also then get the bucket region using:

$region = $awsS3->get_setting('region');

And update the attachment meta data update to:

$pictureMetaData = serialize(array(
    'bucket'    => $bucket,
    'key'       => $folderPrefix . $picture->meta_value,
    'region'    => $region
));

@TJNevis
Copy link
Author

TJNevis commented Apr 19, 2016

Hey,

Awesome. Thanks for the revision. I made the adjustments and used it on one of my sites. Works perfect.

Thanks again for the update.

I've updated the snippet.

@UseDotCom
Copy link

This is amazing and it worked perfectly, thank you!

I was dreading figuring this out, you saved me a lot of time.

@phumpal
Copy link

phumpal commented Nov 4, 2016

Thanks for this @TJNevis.

I tested this on Xenial with PHP 7 and one thing I might add is that MySQL functions have been deprecated as of PHP 5.5.0.

Use of mysqli extensions is recommended.

To update in vim for example

:%s/mysql_/mysqli_/gc

One note:

mysqli expects two parameters otherwise there are warnings. For example continuing to use the procedural style on line 155

$db = mysqli_connect($dbHost, $dbUser, $dbPassword);
if($db) {

then on line 172

mysqli_query($db, $hrefMySQLUpdate)

and line 177

mysqli_query($db, $srcMySQLUpdate)

@duchu
Copy link

duchu commented Nov 30, 2016

remove query not working ? any idea why ?

@sidimar
Copy link

sidimar commented Jan 13, 2017

Hi,
Great script, it's working perfect.
I wondering if you had the same issue I am having with PDFs. It's changed the PDFs URL to amazon (perfect) but now I have to change the links to PDFs. I am truing figure out a quick way to do that instead go through one by one.
Regards,

@atlasnetwork
Copy link

atlasnetwork commented Feb 6, 2017

Not sure if its a plugin that is causing this or what, but in some cases /wp-content/uploads is repeated in the replacement so it reads s3bucketurl.com/wp-content/uploads//wp-content/uploads/filename (with the two slashes).

Any idea on how to fix this?

Can I run a search and replace on the database for /wp-content/uploads//wp-content/uploads/ and replace with /wp-content/uploads/ ? What table/column would I run this on?

This seems to happen only when the file is in the wp-content/uploads root directory

** I ended up fixing this with UPDATE wp_postmeta SET meta_value = replace(meta_value, '/wp-content/uploads/', '');

@leedotpang
Copy link

You sir, are a gentleman, and a scholar. Thank you for sharing!

@vumhoang
Copy link

vumhoang commented Mar 7, 2017

@TJNevis: Have you tried this with Offload S3 Lite? I am trying to do the same job but the php file doesn't work.

@Silvercast
Copy link

I have the same interest. Let me know if it works with Lite @vumhoang

@vumhoang
Copy link

@Silvercast: so far I couldn't make it work. :(

@robalves-tpro
Copy link

Great! It's working perfectly.

@dokomade99
Copy link

I want to ask

How to setting amazon s3 in wordpress so it does not automatically to my cdn? I want to directly use a bucket that like ditutorial. But instead automatically to my cdn croudfront. Please help
I see the tutorial from your blog

@rand-fu
Copy link

rand-fu commented May 17, 2017

This was a huge help. I was literally just discussing doing this for a client of mine. I had to modify a bit for my situation but miles simpler than starting from scratch. Great work you put into this! Many thanks my man.

@crankeye
Copy link

crankeye commented Jul 6, 2017

Much appreciated. Though the https://$bucket.s3.amazonaws.com/$folderPrefix will not work if you are using cloud front. Should be https://$bucket.cloudfront.net/$folderPrefix. Other that that worked perfect. 👍

@soter19
Copy link

soter19 commented Aug 3, 2017

Well done! It was very useful!!!

@bluemalkin
Copy link

Wonderful script which saved my bacon, thank you !

@diegodurante
Copy link

Awesome! It works like a charm!

FYI I had to disable Maintenance Mode to let it works properly ;)

Many many thanks!

@gregshep
Copy link

Perfect! Worked for me too!
I added this bucket policy to my media bucket:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AddPerm",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::BUCKETNAMEHERE/*"
        }
    ]
}

Thank you for maintaining this great utility.

@xgiadmin
Copy link

Awesome script! Thank you for providing. Any ideas on how we could we modify this to move from one AWS Bucket to another? Say all files exist in a bucket for development then we want to move those to another AWS bucket for production.

@gbot
Copy link

gbot commented Sep 18, 2018

In case it's useful to others, I have rewritten this script to work correctly with the latest version of WP Offload S3 Lite, which no longer requires the AWS plugin (https://wordpress.org/plugins/amazon-web-services/).

I have also tried to make it easier to use (and look a little prettier).

Please do let me know if you have any suggestions for improvement.

https://gist.github.com/gbot/0c10f03df28315fbe9ad8968ab110285

@stormcrow85
Copy link

Does anyone have any experience with doing this on large databases?
On a smaller site this works perfectly. However on a large db it breaks / timeouts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment