Just a collection of SQL queries I find useful in WordPress management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <snippet> | |
| <content><![CDATA[ | |
| /** | |
| * Boilerplate and "right way to test" examples: | |
| * https://medium.freecodecamp.org/the-right-way-to-test-react-components-548a4736ab22 | |
| */ | |
| import React from 'react'; | |
| import { mount, shallow } from 'enzyme'; | |
| import ${1:${TM_FILENAME/(.+)\..+|.*/$1/:ComponentUnderTest}} from './${1:${TM_FILENAME/(.+)\..+|.*/$1/:ComponentUnderTest}}'; |
Good HTML semantics makes for good accessibility. This means using links, buttons, form elements, and labels appropriately, including:
<label>element for form controls with appropriatefor/htmlFor(React) andidpairings<fieldset>for groups of related inputs<button>elements for UI controls
More info on semantic HTML as basis for accessibility on this MDN article:
Assumptions:
- Using Sass with
&ersand selector, limited nesting, and modular / partials-based file organization - Using BEM convention with limited nesting
Two lines of thought here:
- Organize media queries to be "inline" i.e. colocated with the selectors.
- pro: close to the code, context is clear
- con: potentially lots of media query declarations scattered throughout the CSS file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT post_title, ID, post_status, post_name | |
| FROM wp_posts p | |
| LEFT JOIN wp_postmeta m | |
| ON p.ID = m.post_id | |
| WHERE (m.meta_key = '_wp_page_template' AND m.meta_value = 'default') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Change wp_ to your database prefix | |
| -- Change example.com to your domain | |
| -- Change string to the text you want to search for | |
| SELECT | |
| ID as 'Post ID', | |
| post_title as 'Title', | |
| CONCAT('http://example.com/',post_name) as 'URL' | |
| FROM `wp_posts` | |
| WHERE post_type = 'post' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UPDATE wp_posts | |
| SET post_content = replace(post_content, 'Existing string', 'Desired replacement string') | |
| WHERE post_type = 'post' | |
| -- can do a 'dry run' search, if the tool doesn't offer UI (phpMyAdmin does) | |
| SELECT * | |
| FROM wp_posts | |
| AND post_content LIKE '%Existing string%' | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // e.g. "write a simple function that logs out the factor of a given number" | |
| // input '4' should return '24' since 4 * 3 * 2 * 1 = 24 | |
| // input '6' should return '720' etc... | |
| // First, discuss and consider the basic utility of a `while` loop | |
| function factor(number) { | |
| let result = 1; | |
| let count = number; | |
| while (count > 1) { | |
| result *= count; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta name="description" content="Higher Order Function - Simple Demo"> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> |