Simple Tutorial Showing How To Use Composer in Your WordPress Plugin or Theme
I love Composer. It just makes including libraries or scripts in your app incredibly easy. So easy that it’s stupid not to use it (in many, if not most cases).
The number of libraries/scripts available on Packagist is astounding, all of which can be included in your plugin with Composer. Packagist is the main Composer repository. It basically aggregates all types of PHP packages that can be installed via Composer.
I’d never used Composer with a proprietary WordPress plugin before. The plugin is for a client so it’ll never be available to the public.
Here’s the steps I took to make this WordPress plugin compatible with Composer so that I can easily bring in third-party libraries.
We’ll be using mailgun-php throughout this example, as the plugin that inspired this post uses Mailgun to send all sorts of emails.
Back in September of 2014 I wrote about using the StanleyWP WordPress theme for a portfolio site. After I added some projects, I noticed the grid on the Portfolio page template wasn’t displaying rows correctly. I even noted it in my original post, towards the end.
I’ve had a few people contact me about how to fix the StanleyWP portfolio grid issue, and earlier today Arun left a comment asking how to fix the grid issue.
You need to be using a child theme for this, it’s just good practice. If you don’t know how to create a child theme, read my post on creating a child theme. It’s really easy to do, but may require you to reset your menu or some widgets after changing to the child theme.
Just save that code as template-portfolio.php and put it in your child theme directory. Your portfolio should now show three projects per row. No CSS or anything else needs to be modified, just that one page template.
I’ve exhausted all my invites. If you want one, leave a comment anyway, others have been sending invites to people here, too. Or, check the Designer News thread. A guy there is offering invites if you send him your email address.
Real Final Update
I’m out of invites, but post your email if you want one. A number of kind individuals have been sending invites to people leaving their emails in the comments.
Update Jan 22, 2015
I now have 9 more invites to send out for those of you that still want an invitation to Inbox by Gmail. Just leave a comment and I’ll get one sent to you.
Stop receiving copyright infringement notices from your ISP because of BitTorrent
I like BitTorrent a LOT. I’ve used it since it’s release around 2001 or 2002. Recently, however, it’s become more risky to download torrents from your home internet connection.
Disclaimer: I am absolutely not condoning downloading copyrighted material, of any kind. This is aimed at giving casual BitTorrent users some things to consider and nothing more
A number of my friends have received copyright infringement notices from their ISP’s for downloading a movie, music album, or any copyrighted material, for that matter. Most ISP’s will terminate your service if you continue to infringe.
When you download a torrent to your computer, and you aren’t using a VPN, your IP address will be reported to the BitTorrent tracker (that’s just how BitTorrent works). Various groups (including anti-piracy groups) can gather IP addresses of people downloading any given torrent, so having your ISP provided IP show up there could result with you receiving a copyright infringement notice.
That’s where having a VPN comes into play. If you’re connected to a VPN while downloading a torrent on your computer, the IP address of the VPN server will be reported to the BitTorrent tracker, instead of your ISP provided IP.
You have a few options that offer various levels of protection, depending on how much money you want to spend, or how paranoid you are. 🙂 Three pretty simple options are detailed below. These methods aren’t guaranteed to keep you safe, but should be sufficient for most “casual” pirates. You’re still at risk using these methods, please read the clarification on protection part at the end of this post.
Option 1. Use a VPS for a personal VPN (aka: Poor Mans VPN)
Once you have the VPS, just follow the steps I outlined in my Poor Man’s VPN post and you’ll be all set.
Option 2. Get a Paid VPN
A good way to hide the IP provided by your ISP is to use a VPN. There are many paid VPN services available, like IPVanish and ExpressVPN. I know a few folks who use IPVanish and are very happy with the service.
Option 3. Use Put.io
I’ve been using Put.io for around a year now and will never go back to running a BitTorrent client on any of my machines. Put.io is a cloud-based BitTorrent client, plus much more.
That means I can stream videos straight from Put.io to my Chromecast, without the need to ever download them to my computer. I’ve often explained it to friends as a sort of personal Netflix.
Put.io also has a feature that will download your torrent immediately. If another Put.io user has already downloaded the torrent you’re downloading, the files will be copied to your account, so you never even connect to the BitTorrent tracker to download data. It’s pretty awesome.
Another benefit of Put.io is that it frees up your home internet connection bandwidth, all the downloading and seeding is done on the Put.io network. This means you’d no longer have to waste your bandwidth to seed the torrents you’ve downloaded. This is a major factor for some people, especially those who don’t have very fast upload speeds at home (like me).
I’m surprised that Put.io hasn’t tried to hire Steven Schoen to bring his app under the Put.io umbrella, making it an official Android client. Maybe the have, who knows.
A couple screenshots from the Put.io Android app are below.
So, which method should I use?
If you have a Chromecast and an Android device, I’d suggest using Put.io. It’s a nice all-in-one solution, and plans start at only $9.99 a month, which gets you 50GB of storage. I have yet to find a Put.io iOS client that has Chromecast support, however there are Put.io clients for iOS, just not with Chromecast support.
Even if you don’t have a Chromecast, or don’t have the ability to stream from a Put.io client to a Chromecast, you can still benefit from Put.io. After a torrent is finished downloading in Put.io, you can download the files from Put.io to your computer. Just like downloading a file from your Dropbox account using the Dropbox website.
If you want to download torrents to your computer using a more conventional BitTorrent client, like Transmission, I’d advise using a VPN. A paid VPN or the Poor Mans VPN setup will work.
Most paid VPN services have multiple VPN servers that you can connect to, so the IP being reported to the BitTorrent tracker can be changed pretty easily, just by connecting to a different VPN server. IPVanish has plans starting at $10/month and have hundreds of servers located around the world.
If you went the Poor Mans VPN route, changing your IP would be slightly more difficult because your VPS would likely have a static IP. But it’s still not your IP from your ISP. The BitTorrent tracker would see the IP address of your VPS instead of the IP provided by your ISP, giving you some level of protection. There’s still the possibility that a copyright holder could send a copyright infringement notice to your VPS host. Worst case there is you’d lose your VPS, which is far better than having your ISP terminate your internet service.
Just some things to take into consideration before you decide what the best solution is for you.
Especially if you have an Android device and a Chromecast. Even if you don’t have a Chromecast or Android device to stream to the Chromecast, you can still download the files from Put.io to your computer.
Put.io is a bit more expensive than the other options, but is well worth it in my opinion. Put.io offers 4 plans:
50GB of storage for $9.99 a month
200GB of storage for $19.99 a month
500GB for $29.99 a month
1000GB for $49.99 a month
A Quick Poll
Now, On To The New Put.io
A couple months ago, Put.io released a new interface to their website, which also implements aspects of Google Material Design. The new interface is still being built and tested, but can be previewed at http://soon.put.io/.
Here’s a screenshot of the new Put.io interface (it’s the featured image for this post, too).
And here’s a screenshot of the old Put.io interface, which is still the default.
The new interface is much easier to use than the old. It makes extensive use of AJAX, which makes for a much nicer user experience as far as not having to wait for a new page to load. It’s also much more visually appealing.
The new interface and the Put.io Android client from Steven Schoen look very similar to each other, providing a consistent look across the put.io website and the Android client. Not really important for functionality, but it’s nice to have a consistent look across the board for a specific service.
This post covered a lot of material and was written without much revising. If I’ve gotten something wrong, I’d really appreciate you letting me know.
If anyone knows of a Put.io client for iOS that supports Chromecast, please let me know! I’m an Android guy but my daughter has an iPad mini, and I’d love if she could cast from a Put.io client on her iPad to the Chromecast.
Comments are open if you have any questions or anything else to add.
Clarification on Protection
The protection methods listed aren’t full proof, something I thought was quite obvious. All methods listed can lead to your IP address being discovered, but they all add an additional step that law enforcement must do to find your IP. Some scenarios that would result in your IP address being discovered are covered below.
Scenario 1. A law enforcement agency could demand user information from a VPN provider, which would reveal your identity if the VPN provider complied. Same deal with the Poor Man’s VPN solution. Law enforcement could request information from your VPS host, and if your VPS host complied, your identity would be revealed.
Scenario 2. A Law Enforcement agency could demand user info from Put.io, which would also reveal your identity, provided Put.io complies with the request. Put.io says they respect the privacy of their users, but there’s still absolutely no way to prove that they wouldn’t hand over user information if it was requested. However, I tend to trust Put.io more than most companies, simply because they’re not based in the United States and the owner is a genuinely good guy.
In both scenarios listed above, your home IP would be revealed. But why not make law enforcement jump through some hoops to get your IP? Instead of just handing it to them like you do when downloading a torrent from a public tracker without using a VPN.
If you’re uploading new movies to public trackers or are downloading massive amounts (think terabytes a month) of copyrighted material, none of the protection options I’ve outlined will offer you enough protection. Those of you who would draw the attention of anti-piracy groups who would get law enforcement involved should be able to figure out better ways to protect your identity. And that’s not something I care to cover.