Skip to content

Instantly share code, notes, and snippets.

View jimboobrien's full-sized avatar

Jimobrien jimboobrien

View GitHub Profile
@jimboobrien
jimboobrien / sample.php
Created September 20, 2017 23:43 — forked from ajmorris/sample.php
Return Vimeo Video Embedded
<?php
// http://vimeo.com/75577633 could replace $xml->video[$post_content]->url
public function skbp_vimeo_player( $post_content = 0 ) {
$xml = simplexml_load_string( self::skbp_vimeo_support_url() );
// echo '<pre>'; print_r($xml->video[0]->url); echo '</pre>';
$post_content = 0;
$output = '';
<?php
// First, make sure Jetpack doesn't concatenate all its CSS
add_filter( 'jetpack_implode_frontend_css', '__return_false' );
// Then, remove each CSS file, one at a time
// You probably won't need them all, unless you use all the modules, and all the themes! :)
// Some of these are also only loaded on specific admin pages, so it wouldn't affect your readers
function jeherve_remove_all_jp_css() {
wp_deregister_style( 'AtD_style' ); // After the Deadline
@jimboobrien
jimboobrien / kill_updates.php
Created September 20, 2017 23:38 — forked from ajmorris/kill_updates.php
Snippets of Killing Auto Updates for WordPress
<?php
// This constant allows different options: true, false, 'minor'. We need to have minor selected.
// Will auto update only minor releases, e.g. 4.3.2, 4.3.3, 4.3.4, etc.
define( 'WP_AUTO_UPDATE_CORE', 'minor' );
// This would disable ALL updates: WP core, plugins, and themes.
// We shouldn't need this unless we wanted to disable auto updates to everything.
define( 'AUTOMATIC_UPDATER_DISABLED', true );
<script type="text/javascript">
jQuery(document).ready(function($) {
var ref = $.cookie( 'affwp_ref' );
var visit = $.cookie( 'affwp_ref_visit_id' );
// If a referral var is present and a referral cookie is not already set
if( ref && visit ) {
// Fire an ajax request to log the hit
@jimboobrien
jimboobrien / functions.php
Created September 20, 2017 23:37 — forked from ajmorris/functions.php
Login Redirect
/**
* Redirects users away from login page if they're already logged in
* or Redirects to /store/ if they log out.
*
* @since 0.4.0
*
* @return void
*/
function login_out_page_redirect() {
if ( is_user_logged_in() && 'login' == $this->_current_view ) {
@jimboobrien
jimboobrien / wp-plugin-settings-link.php
Created September 20, 2017 23:33 — forked from wpscholar/wp-plugin-settings-link.php
Add a settings link to your WordPress plugin
@jimboobrien
jimboobrien / wp-snapshot-shortcode.php
Created September 20, 2017 23:33 — forked from wpscholar/wp-snapshot-shortcode.php
Shortcode displays snapshots of remote sites on your WordPress site.
<?php
/**
* This shortcode will allow you to create a snapshot of a remote website and post it
* on your WordPress site.
*
* [snapshot url="http://www.wordpress.org" alt="WordPress.org" width="400" height="300"]
*/
add_shortcode( 'snapshot', function ( $atts ) {
$atts = shortcode_atts( array(
@jimboobrien
jimboobrien / remove-admin-menu-items.php
Created September 20, 2017 23:32 — forked from wpscholar/remove-admin-menu-items.php
Remove unwanted pages from the WordPress admin menu
<?php
/**
* Remove unwanted pages from the WordPress admin menu
*/
function my_admin_menu() {
remove_menu_page('link-manager.php');
}
add_action( 'admin_menu', 'my_admin_menu' );
@jimboobrien
jimboobrien / members-only-shortcode.php
Created September 20, 2017 23:32 — forked from wpscholar/members-only-shortcode.php
WordPress shortcode will only display content to registered users.
<?php
/**
* WordPress shortcode only displays content to registered users. Could be improved by
* passing role as an attribute to only allow certain types of users.
*
* Example: [member]This text will be only displayed to registered users.[/member]
*/
function members_only_shortcode( $atts, $content = null ) {
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() )
@jimboobrien
jimboobrien / load-pdf.php
Created September 20, 2017 23:32 — forked from wpscholar/load-pdf.php
WordPress shortcode loads a PDF file on your site in an iframe using Google Docs
<?php
/**
* WordPress shortcode loads a PDF file on your site in an iframe using Google Docs.
*
* Example: [embed_pdf width="600px" height="500px"]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf]
*/
function embed_pdf($attr, $url) {
return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>';
}