Skip to content

Instantly share code, notes, and snippets.

View CapWebSolutions's full-sized avatar

Matt Ryan CapWebSolutions

View GitHub Profile
@CapWebSolutions
CapWebSolutions / reusable-block-admin-menu.php
Created October 14, 2025 21:11
Display reusable blocks in WP backend
/**
* Reusable Blocks accessible in backend
* @link https://www.billerickson.net/reusable-blocks-accessible-in-wordpress-admin-area
*
*/
function mrco_reusable_blocks_admin_menu() {
// Add under Appearence nav.
add_submenu_page( 'themes.php', 'Reusable Blocks', 'Reusable Blocks', 'edit_posts', 'edit.php?post_type=wp_block', '' );
// Remove it if still exists at top level.
remove_menu_page( 'edit.php?post_type=wp_block' );
@CapWebSolutions
CapWebSolutions / gist:3f210fd607e50eb59a9e3639019b3bae
Created September 10, 2025 20:24
Query parameter for WP Admin edit.php page to review patterns. Copy and paste to end of <mysite.com>/wp-admin/edit.php to display custom Patterns
?post_type=wp_block
@CapWebSolutions
CapWebSolutions / .gitignore
Last active April 18, 2024 14:22
Default gitignore for plugins
# -----------------------------------------------------------------
# .gitignore for WordPress plugins
# ver 20240417
#
# To ignore uncommitted changes in a file that is already tracked, use
# git update-index --assume-unchanged
#
# To stop tracking a file that is currently tracked, use
# git rm --cached
#
@CapWebSolutions
CapWebSolutions / capweb-screaming-frog-excludes.txt
Created March 15, 2022 14:41
Starting list of URLs to exclude when creating Screaming Frog config file for WordPress site.
/**
* WordPress URL Exclude List for Screaming Frog Spider
* @author Matt Ryan - https://capwebsolutions.com
* @date 2022-03-15
*/
// Nav: Configuration | Exclude
// Gets rid of:
// wp-content plugins, themes, mu-plugins, uploads, etc.
@CapWebSolutions
CapWebSolutions / capweb-screaming-frog-url-rewriting.txt
Last active March 15, 2022 14:42
Rules for basic WordPress URL rewriting in Screaming Frog.
/**
* WordPress URL rewriting rules for Screaming Frog Spider
* @author Matt Ryan - https://capwebsolutions.com
* @date 2022-03-15
*/
// Nav: Configuration | URL Rewriting
// Replacing:
// https://example/com/blog/page/2/
@CapWebSolutions
CapWebSolutions / dump-timezone.php
Last active September 22, 2021 20:15
Dump timezone in admin for debuging
add_filter('admin_menu','dump_timezone_choice');
function dump_timezone_choice($my_data) {
$my_data = wp_timezone_string();
var_dump($my_data);
return($my_data);
}
@CapWebSolutions
CapWebSolutions / the_copyright_year.php
Created September 16, 2021 20:34
Shortcode to insert in footer for auto adjusting copyright year. Tested in Elementor.
@CapWebSolutions
CapWebSolutions / change_rss_feed.php
Created July 7, 2021 16:17
Change RSS feed on main WordPress feed from 12 hrs down to 1 hr. ref: https://wordpress.stackexchange.com/questions/6569/decrease-rss-cache-time-in-plugin Use this in event that external services are not picking up blog posts quickly enough in low traffic sites.
add_filter('wp_feed_cache_transient_lifetime', 'cws_shorten_rss_feed_timeout');
function cws_shorten_rss_feed_timeout( $interval, $url ) {
if( 'https://<example.com>/feed' == $url )
return 3600;
return $interval;
}
@CapWebSolutions
CapWebSolutions / add-column.php
Created June 25, 2021 15:18
Add column to MainWP sites screen to display Last Security Scan date
<?php
/**
* Create Custom Column in the Manage Sites table for Last Secirty Scan date
* ref: https://meta.mainwp.com/t/solved-add-second-field-to-dashboard/3015
* ref: https://meta.mainwp.com/t/display-group-s-column-in-the-manage-sites-table/2932
* ref: https://meta.mainwp.com/t/create-custom-column-in-the-manage-sites-table-with-data-from-client-data/2877
*/
add_filter( 'mainwp_sitestable_getcolumns', 'mycustom_mainwp_sitestable_getcolumns', 10, 1 );
@CapWebSolutions
CapWebSolutions / Links
Created June 3, 2021 13:43 — forked from lukecav/Links
Speed Up Your WordPress Site with These 3 Advanced Techniques Workshop - WordSesh 2021