diff --git a/README.md b/README.md index 0cac87c..09b9f4d 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# useful-snippets \ No newline at end of file +# Useful Snippets +Just bits of code I may want to use again + +# Useful Links +## Wikis +https://www.markdownguide.org/basic-syntax/#headings diff --git a/accessibility/readme.md b/accessibility/readme.md new file mode 100644 index 0000000..89607de --- /dev/null +++ b/accessibility/readme.md @@ -0,0 +1,6 @@ +# Useful Links + +## Guides +- [Harvard's Web Accessibilty Site](https://accessibility.huit.harvard.edu) +- [Yale's Web Accessibilty Site](https://usability.yale.edu/web-accessibility/) +- [WebAim](https://webaim.org) diff --git a/cli/aws/S3.md b/cli/aws/S3.md new file mode 100644 index 0000000..dcaabb4 --- /dev/null +++ b/cli/aws/S3.md @@ -0,0 +1,25 @@ +# AWS CLI + +- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) +- [Installing AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) +- [AWS - Step 2: Create an IAM user account](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-prereqs.html#getting-started-prereqs-iam) +- [AWS - Step 3: Create an access key ID and secret access key](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-prereqs.html#getting-started-prereqs-keys) + +## Copying down to local machine +We off load wp-content/uploads to AWS using WPEngine's LargeFS +Sometimes we create a clone of a server for development and need to also copy the images +[AWS's documentation ](https://docs.aws.amazon.com/cli/latest/reference/s3/cp.html) + + +- Create a directory to store the files `mkdir s3-files` +- Navigate to that directory + + +### AWS Directory to your current directory +>$ aws s3 cp s3://bucket/folder/ . --recursive + +## AWS Genrate a list of bucket contents +>$ aws s3 ls s3://bucket/ > blockcontents.txt + +## AWS Move File matching pattern to subdirectory +>$ aws s3 mv s3://bucket/ s3://bucket/directory/ --exclude "*" --include "filename-\*" diff --git a/cli/readme.md b/cli/readme.md new file mode 100644 index 0000000..8f9cf65 --- /dev/null +++ b/cli/readme.md @@ -0,0 +1,9 @@ +# Misc CLI commands + +## Remove files in directory +> rm file-name-* + +## When rm file-name-* times out +> for f in filename-*; do rm "$f"; done +### Output filenames as they are deleted +>for f in filename-*; do echo rm "$f"; rm "$f"; done diff --git a/cli/regex/readme.md b/cli/regex/readme.md new file mode 100644 index 0000000..b2c3d68 --- /dev/null +++ b/cli/regex/readme.md @@ -0,0 +1 @@ +stuff and things diff --git a/js/addtabindex.js b/js/addtabindex.js new file mode 100644 index 0000000..aea35dc --- /dev/null +++ b/js/addtabindex.js @@ -0,0 +1,12 @@ +/* + * Add HTML attribute tabindex="0" to element with .CLASS_NAME + * @see - https://api.jquery.com/attr/ + * @see - https://api.jquery.com/jQuery.noConflict/ + */ + +jQuery(document).ready(function ($) { + $('.CLASS_NAME').each(function() { + var $element = $(this); + $element.attr("tabindex", "0"); + }); +}); diff --git a/js/readme.md b/js/readme.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/js/readme.md @@ -0,0 +1 @@ + diff --git a/wp/CAS/readme.md b/wp/CAS/readme.md new file mode 100644 index 0000000..ce9a781 --- /dev/null +++ b/wp/CAS/readme.md @@ -0,0 +1,6 @@ +# CAS Authentication + +## Useful plugins +- [College of Education, University of Hawaii at Manoa' Authorizer Plugin](https://github.com/uhm-coe/authorizer/) + * [WordPress Plugin Page for Authorizer]( https://wordpress.org/plugins/authorizer/) +- WPCassify diff --git a/wp/cli/thumbnail-manipulation.txt b/wp/cli/thumbnail-manipulation.txt new file mode 100644 index 0000000..aeb027f --- /dev/null +++ b/wp/cli/thumbnail-manipulation.txt @@ -0,0 +1,3 @@ +https://developer.wordpress.org/cli/commands/media/regenerate/ +# Re-generate only the thumbnails of "large" image size for all images. +$ wp media regenerate --image_size=large diff --git a/wp/cli/update-network.md b/wp/cli/update-network.md new file mode 100644 index 0000000..a3244d2 --- /dev/null +++ b/wp/cli/update-network.md @@ -0,0 +1,8 @@ +# WP Core +## force update or downgrade to a specific release +- [wp core update](https://developer.wordpress.org/cli/commands/core/update/) +> wp core update --version=x.x --force + +## Update database after core update +- [wp core update-db](https://developer.wordpress.org/cli/commands/core/update-db/) +> wp core update-db --network diff --git a/wp/cli/users.md b/wp/cli/users.md new file mode 100644 index 0000000..af86757 --- /dev/null +++ b/wp/cli/users.md @@ -0,0 +1,13 @@ +# WP-CLI Commands + +## WP User + +- [User Commands](https://developer.wordpress.org/cli/commands/user/) +- [wp user list](https://developer.wordpress.org/cli/commands/user/list/) +- [wp user update **user_id** --user_pass=**password_string**](https://developer.wordpress.org/cli/commands/user/update/) + +## WP Network Super Admins + +- [Super Admin Commands](https://developer.wordpress.org/cli/commands/super-admin/) +- [wp super-admin list](https://developer.wordpress.org/cli/commands/super-admin/list/) +- [wp super-admin **add user_id**||**user_name**](https://developer.wordpress.org/cli/commands/super-admin/add/) diff --git a/wp/multisite/recreate-deleted-subsite.md b/wp/multisite/recreate-deleted-subsite.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/wp/multisite/recreate-deleted-subsite.md @@ -0,0 +1 @@ + diff --git a/wp/plugins/plugins-list/shortcode-table-example.txt b/wp/plugins/plugins-list/shortcode-table-example.txt new file mode 100644 index 0000000..e8709d1 --- /dev/null +++ b/wp/plugins/plugins-list/shortcode-table-example.txt @@ -0,0 +1,10 @@ +
+ + + + + + + + +[plugins_list cache=60 format=""]
PluginDescription
{{LinkedTitle}}
by: {{LinkedAuthor}}
{{Description}}
PluginDescription
diff --git a/wp/readme.md b/wp/readme.md new file mode 100644 index 0000000..ab1f739 --- /dev/null +++ b/wp/readme.md @@ -0,0 +1,7 @@ +# Useful Wordpress Links + +## Customizer +- 2017 [Madison Designs - Customizer Developer Guide](https://maddisondesigns.com/2017/05/the-wordpress-customizer-a-developers-guide-part-1/) + +## Widgets +- [WordPress Developer Documentation Widgets](https://developer.wordpress.org/themes/functionality/widgets/) diff --git a/wp/sql/List-posts-by-type-display-last-editor.sql b/wp/sql/List-posts-by-type-display-last-editor.sql new file mode 100644 index 0000000..d58f51a --- /dev/null +++ b/wp/sql/List-posts-by-type-display-last-editor.sql @@ -0,0 +1,20 @@ +SELECT + wp_posts.post_date AS 'Post Date', + wp_posts.post_modified AS 'Post Modified', + wp_posts.post_title AS ' Post Title', + wp_posts.post_type AS 'Post Type', + wp_posts.post_parent AS 'Post parent id', + wp_posts.guid AS 'GUID', + author.user_email AS 'Author Email', + author.display_name AS 'Author Display Name', + editor.user_email AS 'Editor Email', + editor.display_name AS 'Editor Display Name' +FROM wp_posts, wp_postmeta, wp_users author, wp_users editor +WHERE wp_posts.post_type IN ('page','post','attachment') + AND wp_posts.post_status in ( 'publish', 'draft','private' ) + AND wp_posts.post_author = author.id + AND ( wp_postmeta.post_id = wp_posts.id + AND wp_postmeta.meta_key LIKE '%_edit_last%' + AND wp_postmeta.meta_value = editor.id + ) + ORDER BY wp_posts.post_type ASC, wp_posts.post_modified DESC diff --git a/wp/sql/count-content-by-year.sql b/wp/sql/count-content-by-year.sql new file mode 100644 index 0000000..f9a1b14 --- /dev/null +++ b/wp/sql/count-content-by-year.sql @@ -0,0 +1,8 @@ + # Source: https://wordpress.stackexchange.com/questions/178816/count-posts-for-each-year + + SELECT YEAR(post_date) AS `year`, count(ID) as `content count` + FROM wp_posts + WHERE post_type IN ('attachment', 'post', 'page', 'my-custom-post-type') + AND post_status IN ('publish') + GROUP BY YEAR(post_date) + ORDER BY post_date DESC diff --git a/wp/sql/post_content_author_editor.sql b/wp/sql/post_content_author_editor.sql new file mode 100644 index 0000000..bcdf21d --- /dev/null +++ b/wp/sql/post_content_author_editor.sql @@ -0,0 +1,22 @@ +SELECT + p.ID AS 'PostID', + p.post_type AS 'Post Type', + p.post_title AS ' Post Title', + p.post_status AS 'Post Status', + p.post_parent AS 'Post Parent ID', + p.guid AS 'GUID', + p.post_content AS 'Post Content', + p.post_date AS 'Post Date', + author.user_email AS 'Author Email', + author.display_name AS 'Author Display Name', + p.post_modified AS 'Post Modified', + editor.user_email AS 'Editor Email', + editor.display_name AS 'Editor Display Name' +FROM wp_posts p , wp_postmeta pm, wp_users author, wp_users editor +WHERE p.post_status in ( 'publish', 'draft','private' ) + AND p.post_author = author.id + AND ( pm.post_id = p.id + AND pm.meta_key LIKE '%_edit_last%' + AND pm.meta_value = editor.id + ) +ORDER BY p.post_status DESC, p.post_modified DESC diff --git a/wp/widgets/readme.md b/wp/widgets/readme.md new file mode 100644 index 0000000..8fa2136 --- /dev/null +++ b/wp/widgets/readme.md @@ -0,0 +1,2 @@ +# +