 So ond felly, hynny'n fyddwch i ni bod addon o'r cwp yr annus Rhaid i'r credu yma Mae'r yda bod yn fighradd gwneud y gallu rwyda, maen nhw I ddim Catherine Cat-Reef, iddo oherwydd Bannuwg Y Cytn Rhywbeth Cresd ymlogrhaidd do am rhaid i gwybod y mongol a'r projektyn yma Yna bod y pwy o bwy o'r ymlogrhaidd Mae'r cyfrwyr addon yn yw'r cyfrwyr a'r cyfrwyr yn y gwaith yn eu digwydd i'w helpu'n gweld, Zen Frameworks, Zen Framework 2, the joined in conference site, and PHP Women's site, et cetera, and a few others as well. But from a day-to-day job, I'm a developer for a company called Reason Digital and that, in that day job, brings me to this particular site. So Reason Digital and the Trustal Trust, that's what I'm here to talk to you about. This is a showcase of the tech and the reasons behind the certain choices that we made to be able to bring the site forward. So if you want to visit and grab the slides, you can visit those two links there. The PDF is slightly out of date because it takes a lot longer to export to PDF than it does just to save the PowerPoint presentation into Dropbox. So has everybody got the link that wants to get the link? We'll move on. So a little bit about Trustal Trust. So Trustal Trust is a charity in the UK that deals with food banks and they have their main corporate and they have various different food banks across the UK. That's over 400 of them. So there is one pretty much for most towns and cities across England and the UK, et cetera, at large. So within those 400 food banks, they have approximately 42,000 people volunteering for them. So these are people that are giving up their own time, their own energy to help other people. And with that help, they've given over a million food packages to those people that need them within the April 2014 to 2015 timeframe. These are the latest stats. We've not got yet the 2015 to 2016 because it's only just hit April. But that million is up 171,466 from the same time the year before. And the Trustal Trust expects that there's going to be at least 1.5 million within the last year, if not more. So this is a growing problem with a growing site, et cetera. So please forgive my slides, it seems that the animations are a bit knocked out from bit, but we'll talk about this, talk about their site. So what they already had, they had a corporate site, they had a base template site and they had 400 food bank sites. These were all for different URLs, et cetera. So they came to us and they wanted us to produce a new site and be able to help them amalgamate their technologies, et cetera. So they still wanted their corporate site. They needed a better template site where they could enter base content so that they could then copy it across, et cetera. They still wanted a site for each of their 400 food banks. They needed a content delivery site for images, et cetera, and some ability for shared content so that they could have that across the sites. So to help them with this, we provided them with WordPress multi-site. We gave them four themes, five custom post types across the whole of the network. We gave them shared content for their sites, a clone system to be able to populate new sites, and a tutorial training area. I've not included everything that we've given them just because otherwise you'd be all sitting here sleeping and being rave aboard. So I've kept it to the base ones as much as possible. So the WordPress multi-site. Who here has used multi-site or knows exactly what it is? Who doesn't? Cool. So this slide is basically that. Multi-site is a WordPress feature which allows users to create a network of sites on a single WordPress installation. So you have one piece of code on one server and allows you to have multiple sites working from this. This is similar to WordPress.com and how they do bits and pieces, but they take it to a fferfer extreme. This has been available since WordPress 3, whereas before that it was an extension plugin, et cetera, and a few other bits. And it's a continuation of the WordPress multi-user. You might have heard of WPMU or as plugins, et cetera. MU plugins, which was repurposing of some of the technology from this. So for the multi-site, we needed to have a domain. So most of them have a primary domain or primary source. So we had a choice between two. We could either go with the Trussell Trust's corporate one or their food bank one. Trussell Trust really, really wanted to go with their corporate and we had to steer them towards the foodbank.org.uk. So this created some confusion because the corporate site became TrussellTrust.foodbank.org.uk. And of course this was not what they were expecting. So they really started to panic at this point and gone. But that's not our URL. That's not how we operate. So to help them with this and make sure they understood, we used the domain mapper plugin to map that over the hood. It made a lot more sense to use the foodbank site as the base because all of the other foodbank URLs are foodbankname.foodbank.org.uk. So once they'd got understood this, it helped them and we were able to work forward from that. So the next part is that we have four themes. Those that are astute, you'll only see that there's three ribbons there. That'll be explained in a moment. So for the foodbank route, this is therouterfoodbank.org.uk, we created an empty theme. And most people will go, why create an empty theme? But it allowed us to code in extra protection so that we could make sure that their primary domain is covered, etc. It allowed us to hide the setup so that way we've got nothing there displayed if somebody tries to gain access through that bit. And it provided basic admin support so we could tackle certain aspects of certain sites, etc. This allowed us to have a completely white site as soon as you hit foodbank.org.uk you get nothing, but it also allowed us to terminate it early so that way those anybody trying to hit it basically doesn't affect any of the other sites. So the next theme that we had was the corporate theme. This is the one that you'll see if you go to trusltrust.org. This gave us custom settings. So there's a lot of bits which are only available and only visible on the corporate site. So we put them into the theme setup, etc. So that it could work from there. We have a few extra custom post types which are included only in the corporate theme. So because they're only needed on that section. The corporate theme also comes with the ability to donate because they are a charity. They deal with donations of a monetary value and they thrive and need that. So if you've got five minutes and you've got your laptop open, go on, donate. It also provides the promoted content section so that they can then promote their content from the corporate site through to the others. And I'll cover that in more detail in a little bit. So the next theme is for the food bank sites. So this provides a way for unique data entry for the food banks themselves. So each one has their own way of certain dealing things. Most of the food banks are autonomous. So while they're under the trusltrust umbrella, they still take and manage themselves. So they needed a way of managing their own data, etc. uniquely. It comes with newsletters because everybody likes newsletters apparently. It has its own custom fields for entering certain pieces of data and certain configuration. And in the inverse from the promoted content, it has upstream posts. So they can then say, hey trusltrust, this post is quite nice. Would like you to copy it onto your site. So, and that basically gave us the ability to have that option in there. The fourth theme is the CDN and shared media. We called it CDN. It's not really a content delivery network as most people would do it, but it allowed the client's trusltrust to actually understand the technology a lot better. So this gave us a cut-down administration. We could basically tailor it, remove all of the extraneous data and page links, etc. So it only has the ability to switch back out and also to show the media library, etc. for that. So it also has a reduced front-end. It's not quite as empty as the root, of course, but it allows us to display the media in a way that allowed it to be viewed. And that allows us to have a custom image display so that they can go preview this image and have an idea of how it's going to render inside a web page before it gets copied across to the other sites. Okay. So, custom post types. The, as with anything, you need custom post types. So they wanted some news and some other post types, etc. So for the news, we basically, instead of creating a custom post type, we modified the posts type so that whenever it's displayed, it displayed news. It was a lot simpler and it meant that we weren't duplicating data because it just meant we could just show news, show it on the archive, and WordPress took ahead of it because we're just changing all the internal labels. But for the actual custom post types, we needed one for a food bank post. This is on the corporate site. Each food bank post represents a food bank and they can be then used later to create food bank sites or, and they basically are connected with it. There's a promoted content post which allows them to create it and be shared, etc. And of course, on the corporate site, they had jobs, internships and shops. So, not too bad for five custom post types across a 400 odd site network. So, this moves on to us, on to the shared content for sites. So, for that, we needed the promoted content post type. As with anything, when you register a post type, you can specify whether it has an admin UI or not. Based upon whether the site you were looking on was using a food bank theme or using the corporate theme, was whether it toggled UI on and off for the corporate and food banks. So, on the corporate theme, it said, yeah, show the admin for creating posts and editing and etc, etc. But on food banks, it doesn't have that. But the food banks, it still has the post type and that's because they're automatically included. So, whenever you request a list of posts, it automatically includes the promoted posts. That way, they can create a post and then populate it across to all the food bank sites and have it automatically included. When it does create a post, it goes through all the sites and creates the post. That's quite simple. But to make sure that we weren't having to search the site and if they go and do anything else, what it does is it stores the idea of the new post again with the site ID and stores that as post meta on the corporate site. So, that way, whenever a post is updated or if it's deleted, it knows exactly where to find it on each of the sites. That's because post IDs are non-sequential, especially when you have them running their own bits and they've created a post which has an extra ID, etc. So, that allowed them to create posts, populate it and actually send them across and include them within the content as if it was a standard post or a news post. So, that brings us on to the clone system. Yay, Dolly. So, can you spot the difference? So, the clone system, the clone system itself was a very complex and head scratching thing for me to kind of put together. So, the idea was that they can go into a certain part of the network admin and create a new site, which there is ability to create a new site already there, but when they created this new site, they wanted to be able to select a post on the corporate site and say, okay, copy all the details from there. So, in addition to this, we also given the ability to create the post on corporate because they don't always have the post there and rather than having to go and create the post in the corporate, then switch, then create the site, then do all the other bits. It's like, okay, let's create them both at the same time. They're data linked. So, when a site is created from a post or wherever it creates a post, it remembers that post ID on corporate and the site ID so that it can actually talk bidirectionally. So, when a food bank updates their address, like say they move from this office and they move to the other side of town because they get cheaper rent or whichever, or if they move from one church hall to another church hall, they can update that data and it automatically sends it through to the corporate's post. And when the clone system is enacted, it goes to the baseline content site and it copies the posts, the pages and the media, and when it does, it maps all the old post IDs and media, et cetera, et cetera, all the way through to new IDs. So, that way, when it comes through to doing the ACF update and because ACF stores all the IDs for every linked post, et cetera, it can kind of go, aha, that's what this one is and that's what this one is and so all the links then can correctly update. So, a shared media system. So, they have a single site which is in their network which the super admins can switch to and go into and they can upload their media to this one. So, in the food banks sites themselves, as part of the food bank theme, there is an extension to it to allow it to create a custom view for media. This effectively pulls all the media from the CDN site and lists it out with the ability to say copy this image or this file to this site and then when it copies it, it creates all the thumbnails and generates it, et cetera, for this. So, that allows it to be copied. So, the last bit is the tutorial system. I gave this talk at Leeds a couple of weeks ago and they were very interested in the tutorial system. I've not really got any slides for it, mainly because it's easier just to talk about, but we've got video content which is listed with searchable tags within a plug-in within each of the food bank admin areas. So, any of their volunteers can log in, find a tutorial of how to actually use the site, how to make it better for their search rankings and other bits and pieces. This allowed us to share that content without having to go to each food bank and train them individually, which saved us a lot of time and also gave them a lot of extra ability. So, this is how we use Multisite to build their website, Trust or Trust website, and here are the links again. Thank you. Did you say you was duplicating posts from the main site to all of the other sites? Yes, for the provided content. Okay, and were you not getting done for duplicate content for that? Each of the other sites are kind of independent and while they are posts, etc, they're unright, they are still unique content. It's the same as any site you can have duplicate content on. It's more that what penalties, etc, on an SEO can be mitigated by using kind of canonical linking, etc. So, on those particular posts, I believe the front-end team have added in saying this is an instance of a promoted post because we're using the custom post type and then they can output the canonical link to say this is this post over here on the corporate site. Cool. But if it's not in there, then it shall be within a week or so when I next working on the project. Nice one, thanks. Any more questions? I've got one over here towards the middle. Oh, sorry. Hi. What issues have you had with scaling it? So, where are you hosting it? Are you hosting it in the cloud? We're using a ByteMark big V server at the moment, which allows us to upscale the memory and CPU usage. Currently, we're not having a lot of it because of some of the preemptive processes that we've got in place, like instead of constantly checking the other databases or the other database tables for content, when you're looking across sites, say, for example, with a promoted post, we're effectively cloning content across to say that the site works exactly as it should do. So, each one effectively works as close to a standard WordPress site as possible without kind of doing too much. There's a few extra sections where we write out fixed content to HTML, and then that gets auto-included because it doesn't need to be pulled from a database. It doesn't need that. It just needs to include this content in a certain place. So, wherever possible, we try to reduce the overheads preemptively. And how about scaling the databases? Because you've got 400 sites. MySQL database, you can only have 1,000 tables on it, so you must be hitting limits on that as well. WordPress multi-site doesn't automatically include every table from every bit. There are, for example, the users table is shared, and there's a few options tables, etc, which are shared, etc. I'm not sure on the database table limit. We've not hit that with it, but it's something that I'll make a note of to make sure we cover it. I'm intrigued about the kind of shared content, and you seem to be saying that you'd create posts and media on the central site, and then you would duplicate them out to the individual sites. Is there a reason that you didn't or couldn't, for some technical reason, just have a link back from the individual site to the post on the corporate site? So, why were you doing that duplication, rather than having one copy of the post that was referenced? So, the main purpose was that they wanted their food bank sites to be autonomous. So, these promoted posts, for example, are used for important information. They're not just kind of corporate specific posts, but things that may be legislation that has come across that they need to put on the sites. Rather than have it like our link, which people tend to try and stay within the one site. If you're staying within the one site and the content's there, people are more likely to visit it. If you've got a link going across there, it might have worked, but the client wanted to make sure that all the content was in, for one site, was in one place. I think I meant at a data level, could you not have referenced the master post from the food bank site? We could have done, but then that would have meant that on every page load of each of the food bank sites, we would have had to link and pull the post from the other sites to pull that content in. When you're hitting 400 sites, you want to try and reduce the amount of cross-table joins and cross pieces of data as much as possible. Additionally, we wanted to make each food bank site and each site work as if it was its own independent site. So can food bank owners choose whether or not they publish that content that's promoted out to them? No. There's a hook on pre-get posts, which basically says it automatically includes the promoted content post type in the selection whenever you're getting posts. Okay, cool. Thank you. I just wanted to ask, I'm not too familiar with the multi-sites. In order to build the whole network, did you use some variation of existing plugins and things like that? Or did you code it all manually? Could you give us some popular plugins that you got off the shelf? For the actual WordPress multi-site itself, that's part of core. You have to follow through procedures to kind of set some settings into your WP config, et cetera, so that you can then get that ball rolling. But once you've got multi-site enabled, you can then create the other bits and sites. For common off-the-shelf plugins, we used ADCF Advanced Custom Fields, we used Gravity Forms, and a few other ones. I think they've got a couple of Yoast plugins in there as requested. Some of them are ones that they're particularly requested, so they came in with the brief. They said they wanted it to do X, and rather than us spending the time kind of doing all the plugins and everything, we used some of the off-the-shelf ones just to provide the basic functionality. But for majority, the sites are, as you would expect from any standalone website. Hi. I'm interested in the whole sharing content. It's kind of like an extension of what's already been asked. At the point where you clone content and share it across another site, technically, it's independent to that site so that it exists in two places. Is there a danger of the independent site changing that content from where it originated from, or does it go retro as well backwards the other way? There's, for the promoted content, the post type doesn't have UI on the food banks, so they can't go and edit it, et cetera. The content is hidden, and then we use a pre-get post to automatically include that content. Because they are linked, so the post on the corporate side knows its clones, for example, on the other sites and where they are, it can then say, okay, when I've edited, go and switch this site, update this post with the content, switch this site, update the post on that content, and then the same for when you delete that post, when you delete a promoted content post it goes through and goes, okay, switch this site, delete this post, switch this site, delete this post. With the clone system, there is the baseline site, and that has pretty much everything that's needed for a new food bank site to get up and running with images and everything else. All of that content is editable by the food bank, so they basically say, this is the basics, and if you want to go and change it, that's great. It just stays independent. So if you're updating on the original content, technically, if there's 400 sites, you're updating that post 400 times, is that right? If it changes for promoted content. Yes, but because that is far quicker to do that than it is to say, on every site request, pull in every promoted content post from this other site. We've kind of waded up and made the decision to do it that method rather than slow down the other sites and make extra database requests. Yes, sure. That's great. Thank you. I'm in a similar situation, so I'm aware of the content that needs to be centralised, so you update it once, but it's an interesting way. We are for one of the bits that we're having to change how the search works, and that's a new feature that we're working on. So at that point, we've got more data that's needed, so we're going to be, for that purpose, we're going to be creating a custom database table to house that data. So that will be done separately from it, but because this is effectively creating posts, we wanted to try and keep it within the WordPress ecosystem. But for this new, for the searching of food banks, that's a whole separate dataset, and rather than creating posts and having to marry them all up, et cetera, which we could do with posts to posts and various plug-ins, but all of that adds extra overhead. So we're trying to look at what may not be the quickest way for creation, but it's the quickest way for consumption. So that's a custom table? That will be yes. So it's central data? So, yeah, that's effectively what I do, actually. So okay, thank you. Hi. So I just wondered if you could, if there's anything in terms of like a development workflow that is different with multi-sites than with standard normal one WordPress install, so things like local development, version control, is there anything that you need to know that's different in terms of when you're working with multi-site from not? The only thing that I can think of is that we had to do a lot more editing of our host file, so that way we could get the subdomains working, because with multi-site there's two options that you can use. You can use a folder structure, or you can use the subdomain, so something.yourdomain, or your domain slash something. Because the way that they, the Trustal Trust already had their food bank set up, we went for the subdomain, and that meant that during our development and everything else, we had to have a load of entries in our host file to make sure that they all pointed to our test environment, our development environment. Additionally, we've got certain locks on some of those URLs so that they couldn't be removed accidentally, because clients love clicking delete buttons, and then when you've got such linchpin pieces that we needed, so we've basically put some prevention to say, don't delete these sites. So do you have a host file that you'd like transfer between your developers in for that site, because it's obviously quite unique, or? At work we use Jira and Confluence, so we had a shared content of how you get set up. We've got a virtual machine, similar to VVV, et cetera, but our own one that was created that automatically imports the database and sets the sites up after you've cloned it. So that's cloning as in cloning a Git repo rather than cloning as in our site. So that allowed us to have a standardised environment for everybody, so they just went vagrant up and brought the site in, and then they were able to work through a fixed URL system. Hi. You mentioned before that the default site had an empty theme. What was the reason for that? It's mainly because there is no content on that, so the base URL, the foodbank.org.uk, has no content or never have any content, so we basically put an empty theme on there because we could then say that as soon as it tries to go and render anything from that theme using a hook, just die, and it meant that we could cut it off really early. It means that anybody that tries to visit the site will have no negative impact on the server as a whole or less impact than, say, if we had a theme that had content, et cetera, especially when it's not meant to be there. Sure. We had similar promenades, actually. We basically just put a basic image that was something representative of that brand that we were working for. I was just curious what the reason was for having it as essentially a white page. Yeah, it was just because we didn't want to go through half the rendering parts of WordPress. We wanted to cut it off at the knees effectively because if we had content there, an image or even a base index PHP file that was just displaying it, that effectively takes processing away and memory from the other foodbank sites and the other parts of the network. So we kind of went, there's nothing meant to be displayed here. This is meant to be empty, so we just kind of displayed an empty theme. We could have done that via a plug-in in another bit, but the theme made it easier because some of the other ones allowed us to extend upon it. Again, it's just fitted how we wanted to implement it at the time. It's all I can say. Sure. I've got a second question as well if I'm allowed to ask it. So one of the problems that we get with multi-site that I've never been able to solve is our developers, most of which are sat here, all work off a shared database. We've all got a local web server, but we have a centralized database, so we can all work off essentially the same content for each of the sites. Now, when you're working with a single site, the techniques you can use in the WP conflict file for dynamically changing the site URL and the home URL. Are you familiar with anything like that, or is this something you have to do yourself? We basically don't have that because we don't share the database. We do share an updated SQL dump file, which is included in the project, at which point we just destroy our virtual machine and rebuild it, at which point it automatically pulls in that data. Yeah, so you've got a separate database that's essentially working off the same content? Yeah. It made it easy because we're not all working within the same office. Sometimes we're working externally, etc., and having a shared database kind of had it a bit complicated for us for it. So we do have a staging site. We do have other bits and pieces in the flow, as it were, but for most of the development, it's all done locally through a vagrant virtual machine. Yeah, it's probably not a really good question, but it's just interested about the image library you did. So if you could talk a bit more about that, how you set up your own theme for just the image library, and then they could pick the image and then it got transferred to their site. Is that how it was? Sort of. Basically, the one of the sites with the particular theme, it cut down the admin area so that it removed all of the bits that it didn't need because we didn't need them creating posts, we didn't need them creating pages, etc., just needed them to process media. So on that particular site, there is just the media library where they can upload media. When they go to view on the food bank site, the shared media library, which is a custom page within the admin, we basically took a lot of the HTML from the media library and reused it to create a similar feel and then links on there to copy that image across from the media library site to that food bank site. How did they access that? Do they go through URL and then chose the images and then clicked on them? Yeah, once they've copied, then they effectively are in the media library of that site. So there's two separate sections for that. I can show you after. Can we just have another round of applause for Cat?