Replace the URL of all my rev sliders inside images to work with new domain - mysql

I have migrated my website to a new URL and I'm wondering if there's a way to replace all the instances of the old URL with the new one using MySQL.
The images show in the Media tab but aren't linked to the slides.
Is there a way to achieve that?

If you did migrate by editing Settings → General, Site URL and Wordpress URL, it might be that some plugin stored the full URL instead of the media attachment ID. In this case, you can use the WP Cli ( https://wp-cli.org/ ) to do a search-replace on the entire database. Use it like so:
wp search-replace 'http://old.url' 'http://new.url' --path /your/wordpress/directory/
on the command line of your choice (replace "wp" with the executable of your wp-cli).
Just to be on the safe side: do a backup before:
wp db export --add-drop-table
This will generate an SQL file you can use to restore your database in case anything breaks replacing the URLs.

Related

Keyboard short for uploading two files in PhpStorm

The problem
In PhpStorm I have a style.css- and a app.js-file that I have to upload to a server over and over again. I'm trying to automate it.
They're compiled by Webpack, so they are generated/compiled. Which means that I can't simply use the 'Tools' >> 'Deployment' >> 'Upload to...' (since that file isn't and won't every be open).
What I currently do
At the moment, every time I want to see the changed I've done, then I do this (for each file):
Navigate to the files in the file-tree (using the mouse)
Select it
The I've set up a shortcut for Main menu >> Tools >> Deployment >> Upload to..., where-after I select the server I want to upload to.
I do this approximately 100+ times per day.
The ideal solution
The ideal solution would be, that if I pressed a shortcut like CMD + Option + Shift + G
That it then uploaded a selection of files (a scope?) to a predefined remote server.
Solution attempts
Open and upload.
Changing to those files (using CMD + p) and then uploading them (once they're open). But the files are generated, which means that it takes PhpStorm a couple of seconds to render the content (which is necessary before I can do anything with the file) - so that's not faster.
Macro.
Recording a macro, uploading the two files, looking like this:
If I go to the menu and trigger the Macro, then it works. So far so good.
But if I assign a shortcut key and trigger that shortcut while in a file, then it shows me this:
And if I press '1' (for it to upload to number 1 on the list), then it uploads the file that I'm currently in(!?), and not the two files from my macro.
I've tried several different shortcuts (to rule out some kind of keyboard-shortcut-clash):
CMD + Option + CTRL + 0
CMD + Shift 0
CMD + ;
... Same result.
And the PhpStorm Macro's doesn't seem to give me that many options anyways.
Keyboard Maestro.
I've tried doing it using Keyboard Maestro.
But I can't get it setup right. Because if it can't find the folders (if they're off-screen or if I'm in a different project and forgot to adjust they shortcuts), then it blasts through the rest of the recorded actions, resulting in chaos. Ideally it should stop, if it can't find the file on the screen.
Update1 - External program
Even if it's not possible to do in PhpStorm, - are there then another program that I could achieve this with?
Update2 - Automatic Deployment in PhpStorm
I've previously used this, - but I've had happen a few times that I started sync'ing waaaay to many files, overwriting critical core files. It seems smart, but can possibly tear down walls if I've forgotten to define an ignore properly.
I wish there was an 'Automatic Deployment for theses files'-function.
Update3 - File Watchers
I looked into file-watchers ( recommendation from #LazyOne ). Based on this forum thread, then file watchers cannot be used to upload files.
It is possible to accomplish it using external program scp (Secure Copy Protocol):
Steps:
1. Create a Scope (for compiled files app.js and style.css)
2. Create a Custom File Watcher with scp over that Scope
Start with Scope:
Create a Local Scope with name scp files for your compiled files directory (I will assume that your webpack compiles into dist directory):
Then, to add dist directory into Scope, select that folder and click on Include Recursively. Apply and Move to File Watchers
Create a custom template for File Watcher:
Choose a Name
Choose File type as Any
Choose Scope as scp files(created earlier)
Choose Program as scp
Choose Arguments as $FileName$ REMOTE_USER#REMOTE_HOST:/REMOTE_DIR_PATH/$FileName$
Choose Working directory as $FileDir$
That's it, basically what we have done is every time when a file in that scope changes, that file is copied with scp to the remote server to the corresponding path.
Voila. Apply Everything and recompile your project and you will see that everything is uploaded to the server.
(I assumed that you have already set up your ssh client; Generated public/private keys; Added a public key in your remote server; And, know ssh credentials to connect to your remote server)
I figured this out myself. I posted the answer here.
The two questions are kind of similar but not identical.
This way I found is also not the best, since it stores the server password in clean text. So I'll leave the question open, in case someone can come up with a better way to achieve this.

How can I duplicate a folder and change the name?

I'm trying to setup a signup form on my webpage, once the user creates there account, I would like to automatically create a folder of what the user typed in a input with the ID of cfinput, the problem i'm running into, is I am not experienced in the jQuery zones, I focus on creating front-end design using CSS and HTML languages. Summarization, I can't figure out how to create a copy of a folder named base_org and change it's name to what the user wrote in the input listed above,
Any help is greatly appreciated, if you have any questions just comment and I will try to re-edit my post to make it more clear.
JavaScript cannot do this on the client side. You need a backend which processes the signup form submission and creates a copy of your base directory.
A general solution is to call the system's copy command. On Linux, you can copy a directory like this:
cp -r /path/to/base_org /path/to/new_folder
You can execute the shell command in your preferred backend language. For example in PHP, you can use shell_exec:
// process the form first and put username in $username
shell_exec("cp -r /path/to/base_org /path/to/$username");
Make sure the username won't contain any invalid or special characters or other shell commands.
Another option would be to use the backend language's API to copy the directory.

MySQL Replace Breaks Wordpress Template

I am making a copy of a WordPress website on another server. Everything is OK in copying the database.
However, I need to replace the old domain name "old.com" with "new.com" in some MySQL tables. I am using the following query:
UPDATE wp_options SET option_value = REPLACE(option_value, 'https://old.com/', 'http://new.com/')
This works for a lot of things (like the site URL), however, it breaks all my CSS modifications to the template and all my options, it's sort of restored into default settings directly after I run the previous command.
What could be the reasons?
When moving a Wordpress table the Database Search and Replace Script by interconnect/it does the job very well.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
The software is designed for exactly the purpose of replacing olddomain.com with newdomain.com.
All you do is extract Search Replace DB to it's own directory off the root of the Wordpress installation. You then run
newdomain.com/Search-Replace-DB-master
This will automatically find your Wordpress database and will provide search and replace field. It allows a dry run where you can check the results before doing the live run.
Hope this is useful. I have used this many times when changing the domain for a Wordpress installation and it works every time.
Never manually replace URL use https://wordpress.org/plugins/velvet-blues-update-urls/ plugin to safely search & replace old URL with new one.

Moodle - where are URLs/links stored in database?

I'm exporting an old release 1.9.2 and importing to 3.0.2.
Each module has dozens of videos that I play via an URL/link, which points to my own .PHP program on the site (and that wraps a Camtasia video).
I found that in 3.0.2, the link opens on a separate page, unless I edit each link by going to "Appearance", then "Display" and setting it to "Embed".
So I would like to write a mySQL update script to automatically set this flag for all such links (I will add a where clause to my script name).
I checked database in PHP/MyAdmin, and didn't see any likely table names.
You should attempt to use the admin tools to update everything, go to your moodle installation's main URL.
Then go to the site administration. After /admin in the url, add /tool/replace and go there.
You can there enter what you want to find in the db, and replace it with another value. Just be carefull with this tool and make a backup before you begin.

MySQL Search / Replace - Switching root domain on Wordpress Multisite

I have a Wordpress Multisite installation, and the root domain is set to root-domain.com. I would like to switch it with one of the sites of the network (site-in-network.com), and make it a root domain.
This way site-in-network.com would become the root domain, and root-domain.com would become one of the sites in the network (100+ sites).
I've done search and replace on a database before, and it worked, but I was dropping a domain all together, so I just replaced domain-a.com with domain-b.com. This time it is different, I want to keep both of them, and just switch the positions in the database.
I guess I would need to run a MySQL query. As far as I know, the root domain was set to something like "www.root-domain.com", and all other sites in the network were like "site-in-network.com" (without the .www part)
The database is about 0.5GB, so it would be good to get it right the first time.
Thank you in advance for any info.
It can be done with a search and replace, but mind you that wordpress is also storing site information in a serialized form in the tables. That means that a default search and replace will break a lot of stuff, so be careful with that.
There is however a script that takes this into account: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Download it and put it in your root folder. (And afterwards, delete it!!)
Using this script you could change root-domain.com to root-domain.tmp.com and then site-in-network.com to root-domain.com. After that you could rename root-domain.tmp.com to site-in-network.com. Basicly what Plamen Nikolov suggested to do in the first place.
Here is a little bit of a craftily solution:
You can still workaround the situation with the find and replace technique using fake domain name:
Replace site-in-network.com with some-fake-unique-name.com
Replace root-domain.com with site-in-network.com
Finally some-fake-unique-name.com with root-domain.com.
There is also solution without changing the database, by definining HOME and SITE URL like here: Changing the Site URL