Skip to content

Instantly share code, notes, and snippets.

Avatar

Priscilla Chapman priscillamc

View GitHub Profile
@priscillamc
priscillamc / wp-attachment-links
Created Jul 17, 2014
WordPress snippet. Link images and documents to the file instead of the attachment page. This also changes the 'View' link in the Media Library admin screen. Add to a new plugin file or to the functions.php in your theme.
View wp-attachment-links
@priscillamc
priscillamc / wp-debug.md
Last active Jul 18, 2016
Enable WordPress debugging mode
View wp-debug.md

How to Enable Debug Mode in WordPress

  1. Open wp-config.php and comment out line: define('WP_DEBUG', false);

  2. Paste in the lines below to enable WP_DEBUG mode. This will create a debug.log file in the wp-content folder. Rememeber to turn off debugging when you've finished.

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@priscillamc
priscillamc / gitignore
Last active Apr 22, 2019
Common gitignore
View gitignore
Thumbs.db
.DS_Store
*.orig
node_modules
.npm-debug.log
@priscillamc
priscillamc / list category post page attachments
Created Mar 4, 2015
Shortcode to list page attachments using the WordPress List Category Posts plugin https://wordpress.org/plugins/list-category-posts/
View list category post page attachments
<!-- Replace CURRENT_PAGE_ID for the post_parent to only display attachments of a certain page -->
[catlist post_type="attachment" post_parent="CURRENT_PAGE_ID" numberposts=-1 post_status="publish,inherit" orderby="title" order="ASC" no_posts_text="No files found"]
View custom plugin templates
// Use custom template pages in a WordPress plugin
function my_cpt_templates( $template_path ){
// Change template for CPT single pages
if( is_singular('my_cpt') ){
$template_path = plugin_dir_path( __FILE__ ) . 'templates/single-cpt.php';
}
// Change template for CPT archive pages for a certain taxonomy
@priscillamc
priscillamc / git-email-fix
Created Apr 15, 2015
Git fix email settings in branch
View git-email-fix
git config --global user.email
git config --global user.email "username@users.noreply.github.com"
git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "email@example.com" ];
then
GIT_AUTHOR_NAME="username";
GIT_AUTHOR_EMAIL="username@users.noreply.github.com";
git commit-tree "$@";
View jquery.js
<script type="text/javascript">
jQuery(function($){
// Your jQuery code here, using the $
});
</script>
View wp-auto-update-plugins-themes
<?php
/*
Plugin Name: Auto Update
Description: Enables automatic background updates for core, plugins, and themes. See <a href="https://codex.wordpress.org/Configuring_Automatic_Background_Updates" target="_blank">Configuring Automatic Background Updates</a> for more details.
Version: 1.0.0
*/
// Enable automatic updates for core major releases
add_filter( 'allow_major_auto_core_updates', '__return_true' );
@priscillamc
priscillamc / wp-hide-customizer-admin-links
Created Aug 13, 2015
Remove WordPress Customizer links from the Admin Toolbar and dashboard by changing the body class back to 'no-customize-support'. This is a way to show only the original admin toolbar links for themes that don't support the Customizer.
View wp-hide-customizer-admin-links
View wp-simcal-gce-widget
<!-- Simple Calendar 3.0.4 - UF Template -->
<div class="event item">
<div class="eventdate event-date">
<div class="month">[start-date format="M"]</div>
<div class="day">[start-date format="j"]</div>
</div>
<div class="eventtitle">
<h4>[link][title][/link]</h4>
[if-whole-day]<div class="time">All Day</div>[/if-whole-day]
[if-not-whole-day]<div class="time">[start-date format="g:i A"] - [end-date format="g:i A"]</div>[/if-not-whole-day]