Skip to content

Instantly share code, notes, and snippets.

View mathetos's full-sized avatar
🪐
Working on @stellarwp Stuff

Matt Cromwell mathetos

🪐
Working on @stellarwp Stuff
View GitHub Profile
@mathetos
mathetos / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mathetos
mathetos / ssl-for-images.php
Last active July 3, 2018 08:21
Force http/s for images in WordPress
/**
*
* Force http/s for images in WordPress
*
* Source:
* https://core.trac.wordpress.org/ticket/15928#comment:63
*
* @param $url
* @param $post_id
*
@mathetos
mathetos / functions.php
Created November 5, 2014 04:39
Conditional Custom Login Redirects in WordPress
function wip_login_redirect( $url, $request, $user ){
// Define referrer
$slug = $_SERVER["REQUEST_URI"];
// Define slugs of any referrers you want here
// For example, if they page you want to target
// is www.testsite.com/hello-world
// you'll want this:
// $islogin = strpos($slug, 'hello-world');
$islogin = strpos($slug, 'log-in');
@mathetos
mathetos / feed-offset
Last active October 22, 2020 17:36
WordPress Custom RSS Feed with Offset
<?php
/**
* RSS2 Feed Template for displaying RSS2 Posts feed.
* Adds an offset of "1" to display all but most recent
* Full details at: https://wordimpress.com/anatomy-advanced-wordpress-blog-notification-email
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$more = 1;
@mathetos
mathetos / custom-wordpress-feed
Created December 9, 2014 03:30
Custom WordPress RSS Feed with Featured Image Enclosure
<?php
/**
* Custom WordImpress RSS2 Feed
* Integrates Featured Image as "Enclosure"
* See http://www.rssboard.org/rss-2-0-1#ltenclosuregtSubelementOfLtitemgt
* for RSS 2.0 specs
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
@mathetos
mathetos / plugin-activation
Last active August 29, 2015 14:11
Plugin Redirect on Activation
function detect_plugin_activation( $plugin ) {
if( $plugin == 'path-to-my-plugin') {
wp_redirect("options-general.php?page=my-plugin-settings-page");
exit;
} else {}
}
add_action( 'activated_plugin', 'detect_plugin_activation', 10, 2 );
@mathetos
mathetos / smart-excerpts
Last active May 17, 2016 19:43
Smart Excerpts
<?php
/*
* This asks first for a Yoast SEO meta description,
* If that's not present, then it asks for the excerpt of the post,
* If that's not present, then it strips the content
* In this case, I have an excerpt length setting in the Customizer
* Both the excerpt and content stripping, also strip shortcodes
* @author Matt Cromwell <[email protected]>
* @copyright Copyright (c) 2014, Matt Cromwell
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
@mathetos
mathetos / functions.php
Created January 23, 2015 06:18
User-Friendly Styled Content in the WordPress Editor
<?php
/*
* Add "Formats" dropdown to TinyMCE Editor
*/
function matt2015_mce_formats($buttons) {
array_unshift($buttons, 'styleselect');
return $buttons;
}
add_filter('mce_buttons_2', 'matt2015_mce_formats');
@mathetos
mathetos / give-centered-styles.css
Last active October 26, 2015 23:35
Give Center Form Styles
div[class*="give-form-wrap"] {
text-align: center;
}
.give-total-wrap,
#give-final-total-wrap {
display: inline-block;
margin: 0 auto;
}
@mathetos
mathetos / plugin.php
Last active April 13, 2023 16:48
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/