[ad_1] WordPress, the content management system the internet loves. You can use it for years without needing to tackle PHP, but eventually you’re finding yourself needing it. You go to Bing and search “php for beginners” and you find yourself here. The journey to learn PHP for WordPress development is long, but let’s start! We’ll kick off this WordPress coding tutorial with a little summary of PHP’s role in WordPress, and then start to build up from there. Using PHP in WordPress: Useful for Everyone, Necessary for Developers You don’t really need to ever write PHP code as a WordPress user, WordPress business owner, or other similar role. A minority of the people who use WordPress on a daily basis even know what PHP is, never mind know how to write code in it. But WordPress developers, WordPress developers must use PHP. But I’m getting ahead of myself… WordPress Runs atop PHP on the Server Before we jump fully into our PHP for beginners tutorial, some background: Web servers, it turns out, are just computers. And those computers need to have underlying layers they can run on. For most WordPress sites, that breaks down to be: Linux (the operating system, like Mac OS or Windows), Apache (the web server, thing your browser talks to), MySQL (the database, where posts live), and PHP (which coordinates with the database, OS, and files to build web pages). I wrote a lot more about this in our “WordPress LAMP” article: A WordPress LAMP?! An Introduction to WordPress Infrastructure PHP is a Programming Language So, hopefully the above made you aware that PHP is something that WordPress uses under the hood. It’s a programming language, and the language that WordPress server-side code is written in. (In the web browser of both administers and visitors, WordPress often also involves languages called HTML, CSS, and JavaScript). PHP was one of the first and most popular languages that people used to build HTML documents (aka “web pages.”) Its popularity is a little more complex than I want to cover here, but I did write a “Why PHP” article over on Thoughtful Code for those who are interested in that. In short: PHP is a logic-programming language which you can use to control which HTML a page shows, either in WordPress or outside of it. The files that make up both WordPress themes and plugins are mostly using PHP to build the pages that you see when you visit a WordPress site in your web browser. Learn PHP for WordPress and You’ll be Able to Modify Themes, Make Plugins As we just covered, both WordPress plugins and themes use a lot of PHP. (Though in 2022, the amount of PHP you’ll see in themes has just gone down…) Essentially, everything in a plugin is enabled by the PHP code you write. For a WordPress theme, some functionality is coming from WordPress PHP and some will be in HTML you write into your theme template files. You’ll generally need less PHP expertise to make good themes than good plugins for WordPress, but it’s an important skill in either case. While we won’t get into this much in this introductory PHP WordPress tutorial, for those wondering, the basic way that WordPress plugins work is with WordPress hooks: actions and filters. If you already understand what PHP function, variable, and strings are, you can jump right into that with this guide: WordPress Hooks, Actions, and Filters: What They Do and How They Work A Beginner’s PHP Tutorial for WordPress Alright, now that we’ve got that WordPress stuff out of the way, we can start in earnest on our short PHP programming for beginners tutorial. We’ll focus on a few core things: what PHP looks like, what things you must understand to make any sense of PHP, and what next steps make sense. PHP 101: Where We Start on a PHP Tutorial for Beginners So, PHP as we mentioned above started as a way to create more dynamic HTML. As such, you’ll know you’re writing PHP, and not HTML, in a .php file because it’ll be boxed in by what are most commonly called “PHP tags.” Those PHP tags are things that fence off PHP from your HTML, and vice-versa. Although there is still some interaction. Here’s an example: <!– file.php –> <html> <?php echo ‘Hi from PHP’; ?> </html> What would loading file.php up from your web server show you in your web browser? It’ll show the words, “Hi from PHP”. (The word echo in PHP essentially lets something exit PHP-interaction-land and show on the page. What’s more, if you viewed the page source in that browser, you’d also see that the <html> opening and closing tags come through. Where not controlled, all HTML from a PHP file just shows in your browser. Last note: that first line, which starts <!– is an HTML comment. Comments are lines in code which shouldn’t do anything, but may help you or another programmer make sense of the program later. In PHP, most comments are broken out with to forward slashes, // comment here, or fenced with /* */ characters, like this: <?php /* Nothing in these lines will show or do anything */ echo ‘Not a comment’; // What’s to the left will run, but this text itself won’t // Neither will this ?> You’ll also want to note that our echo line ends with a semicolon. All lines of PHP will generally end with a { (of which more later) or a semicolon ;. Statements like echo should always end with a semicolon. This is a kind-of-strange convention across many programming languages. Variables, Integers, and Strings, Oh My! We just showed your first PHP data type: the string. A “string” is a common programming-language term for a sequence of characters. In our specific case above, our string was the sequence of characters “Hi from PHP.” In PHP, a string can be differentiated from other words (the ones that are just the program
Continue readingTag Archives: WPShout
Jeremy Keith Resigns from AMP Advisory Committee • WPShout
[ad_1] As an AMP hater, I was gratified to see this headline from Sarah Gooding over on the Tavern. Here’s the core his very frank and pretty interesting resignation post: I can’t in good faith continue to advise on the AMP project for the OpenJS Foundation when it has become clear to me that AMP remains a Google product, with only a subset of pieces that could even be considered open source. If I were to remain on the advisory committee, my feelings of resentment about this situation would inevitably affect my behaviour. So it’s best for everyone if I step away now instead of descending into outright sabotage. It’s not you, it’s me. I’m linking (with the “main” link below) to Sarah’s story (rather than Keith’s post) because she puts this all in some context I wasn’t aware of. I loved her closing sentences: In the end, this may not be enough to convince critics that AMP is not simply a Google product with a fancy affiliation designed to make it more appealing to detractors. So far, the project’s new home at the OpenJS Foundation has done little to bolster public opinion in the face of allegations that identify AMP as having an important role in Google’s anti-competitive practices. Sarah Gooding Visit wptavern.com → [ad_2] Source link
Continue readingWirecutter’s Website Builder for 2021: Wix • WPShout
[ad_1] This is an interesting little tidbit for “the web industry” generally, and where it interfaces with real people with non-internet-focused lives and careers. The Wirecutter—the de facto site for time-starved yuppies to quickly find an acceptable-to-great version of a product category (aka, how I buy almost everything)—recommends Wix for those looking to make a website. Now, if you’re reading this site (WPShout) you probably know of another tool or service: WordPress. They did look at WordPress.com. They did not look at “a WordPress site on (your favorite host) with Elementor/Beaver Builder/etc.” And nor do they seem to have been particularly worried about “ease of porting your site” or “ease of augmenting the site with nerdy features.” And you won’t find the term “open source” or “license” anywhere on the page. For those not following me, the last paragraph is some of the reasons us WordPress folks tend to like to use it. But neither Melanie Pinola (the page’s author) nor its primary audience is thinking about those things. And that’s fine. Good even! And as “a WordPress professional” you benefit from always keeping that gap in mind. The arguments and benefits that lead Wix (and after that, Square—the payments people) to be the best for Wirecutter readers are places and spaces that WordPress (or whatever other nerdy CMS you’re into) can and should go to stay vital and relevant in the industry. I think the Gutenberg project is continuing to play out as a long-bet for the future of WordPress, and I remain bullish on it. But clearly winning all the battles for the home for “people needing a website” is something that WordPress has not beat the whole world at. (Yet.) (Hat tip to the Post Status Newsletter for this link) Visit nytimes.com → [ad_2] Source link
Continue readingWordPress Learning Curve in 2021 • WPShout
[ad_1] There’s been some worthwhile discussion of the WordPress learning curve lately. My “main link” here is the article from Courtney Robertson. Though I’d also point to the one of the topic from Justin Tadlock at WP Tavern. I thought Courtney’s summary rang true: While the block editor experience has improved the content creation and even website assembly side of this process, it can be said that the learning curve for developing with code for WordPress via plugins or themes has become more complex. This is especially true when planning training materials, and retraining developers who began without these extra layers of complexity. I feel like the amount of JavaScript, not to mention the need to be kind of good at both React/JS & PHP has changed the dynamics of WordPress deveopment from when I started learning around 2007. And though I’m not sure much could be done to avoid it, I don’t envy those starting out today. But I do think its possible. Mostly it just requires two things: more people sharing what they’re learning, and being patient while you’re learning. Image credit: Patrick Mize Visit courtneyengle.com → [ad_2] Source link
Continue readingUnderstanding theme.json • WPShout
[ad_1] One of the more consequential features of WordPress 5.8 I didn’t pay much attention to before it was released was theme.json. Which is “just another file in your WordPress theme” but also a whole lot more. I’ll just quote Jeff Ong from over on WordPress.org: Conceptually, [theme.json is] a major shift in how themes can be developed. Theme authors now have a centralized mechanism to tailor the WordPress experience for site authors and visitors. Theme.json provides theme authors fine-grained control over global styles, block styles, and the block editor settings. By providing these settings and controls in a single file, theme.json provides a powerful framework that brings together many aspects of theme design and development. And as the block editor matures and adds more features, theme.json will shine as the backbone for themes and the editor to work together. Definitely something to play with, even if you just make simple themes like me. I think it’s mostly clearly vital today as something for commercial themes (much like the “editor styling” from ~10 years about). But I love how centralized (a part, at least) of WordPress theme’s future will be. I’m expecting the importance of this file will only grow 🌱 Visit wordpress.org → [ad_2] Source link
Continue readingJustin Tadlock’s Take on WP Theming Today • WPShout
[ad_1] Those of you who are newer to the WordPress space, just let me tell you that Justin Tadlock is a real WordPress OG (in my ~15 years experience #OfficiallyOld), so I take his opinions pretty seriously. So I thought his whole take on the “state of WordPress theming” is surely a good place to ground your attention and energy if you care about this topic. WordPress themes are likely to change in the next year in ways they’ve never changed in their history. That’s both pretty exciting, but it’s also a little nerve-wracking. Will they be able to thread that needle. I sure hope so. And what I’ve seen over the years makes me think they will, eventually. Here’s one good paragraph, to hopefully hook you: The thing about blocks is that they put this veil over a lot of the messy legacy stuff, creating a new standard where anyone who wants to build a theme does not have to worry about a lot of the history that got us from Point A to Point B. That is a Good Thing. Standardization of the system was long overdue, but we are still in the process of making that final leap forward. It is a tough time to be a developer. It can also be an exciting new adventure if we stop thinking about themes from a traditional mindset. Visit wptavern.com → [ad_2] Source link
Continue readingSome Emoji-Accessibility Guidance • WPShout
[ad_1] I’m not an accessibility expert, but I am a big emoji fan (as frequent readers may be aware 🤪). So I took a pretty keen interest in a story from Ryan Kan purporting to make me better at accessibility with specific regard to emojis. A lot of this advice just feels right—emoji-only button labels are harder to make sense of. But some things I’d really never thought through, like the idea that you should always put words BEFORE emojis on things like buttons. Having heard it, I get it. But I have to admit I’ve likely done that backwards at least once in the past. Live and learn 😅 Visit uxdesign.cc → [ad_2] Source link
Continue readingGuide to the new Query Loop Block • WPShout
[ad_1] I was talking with the current students in the Up and Running Bootcamp last week about the new Query Block in WordPress 5.8. I had to admit I’d not really played with it much myself. For that reason, I was quite excited that when I sat down to look for posts to share this morning with you all, I found this great little guide to it that Justin Tadlock put together over on the WP Tavern a few weeks ago. For those who aren’t yet comfortable with the name of this block, here’s Justin’s great summary: The term “Query” is simpler than you might think. It merely means to “query” or “ask” for posts from the database according to a defined set of options. For example, one might attempt to get the last 10 blog posts. “Loop” is an even easier concept to grasp. It means to “loop” or “cycle” through each queried post and output it. Technically, a developer could do things other than displaying the posts during this process, but we are only concerned with what gets printed on the screen. The two things combined become the Query Loop block. It allows users to ask for a set of posts and display each one. Visit wptavern.com → [ad_2] Source link
Continue readingUnderstanding Block Plugins • WPShout
[ad_1] I loved reading this write-up from Rich Tabor about the what and why of Block Plugins. For those new to this whole thing, I’ll pull his opening summary: What are Block Plugins? If you’ve built blocks before, you may be asking what’s the big deal about block plugins. For the most part, you can think of block plugins as one block, registered and compiled completely in JavaScript, that serves a singular function. These plugins exist solely to distribute a block — and nothing more… and these plugins are meant to be included within the Block Directory. He goes in to way more besides that—how to make them, what they look like, and how make sure yours works—so be sure to give the whole thing a look. Visit richtabor.com → [ad_2] Source link
Continue readingWhat’s New in WordPress 5.8 • WPShout
[ad_1] Another version of WordPress, 5.8 is about to drop. Like literally it is scheduled to come out tomorrow. You’ve probably seen at least a few headlines about it if you follow WordPress news. And it’s a big one! What particular caught my eyes was this big (and maybe overwhelming) summary of the whole thing over at Kinsta by Carlo Daniele. Unlike the usual “Field Guide” on WordPress.org (this time done very well by Milana Cap), he included lots and lots of screenshots. Which I think is really helpful, because all the recent changes to widgets (make them actually block areas) and the first time we’ll have “Full-Site Editing” features in WordPress core requires a great deal of visual summary. While it’s hardly as consequential as Full-Site Editing for most non-technical people’s real attention, I’m also pretty into the fact that WebP is coming to WordPress. Anyway, give it a look and you’ll be less surprised when you upgrade 😎 Visit kinsta.com → [ad_2] Source link
Continue reading