Skip to content

Instantly share code, notes, and snippets.

View nicholasohrn's full-sized avatar

Nicholas Ohrn nicholasohrn

  • OhrnVentures LLC
  • Las Vegas, NV
View GitHub Profile
@nicholasohrn
nicholasohrn / gist:1448671
Created December 8, 2011 21:25 — forked from anonymous/gist:1447077
Custom Query - Pagination Doesn't Work
<?php
/*
Template Name: Fuel Landing Page
*/
get_header();
$fuel_options = get_option('fuel_theme_options');
?>
<div id="pageWrap">
<h1 class="pageTitle alt_font fademe"><span>Fuel</span> Network</h1>
@nicholasohrn
nicholasohrn / ridiculously-naive-image-protection.php
Created March 2, 2014 04:05
Ridiculously Naive Image Protection Plugin
<?php
/*
Plugin Name: Ridiculously Naive Image Protection
Description: Enables ridiculously naive image protection. Disables contextmenu and dragstart on images using jQuery's event handling. That's it!
Version: 1.0.0.B.1
Author: Nick Ohrn
Author URI: http://nickohrn.com/
*/
function image_protector_wp_enqueue_scripts() {
@nicholasohrn
nicholasohrn / registered-users-comment-filter.php
Created March 2, 2014 18:59
Only display comments from registered users
<?php
function registered_users_only_comment_feed_where($where, $query) {
return $where . " AND user_id > 0";
}
add_filter('comment_feed_where', 'registered_users_only_comment_feed_where', 10, 2);
@nicholasohrn
nicholasohrn / reassign-posts-on-delete-user.php
Created March 4, 2014 17:42
Reassign posts from user being deleted
<?php
function reassign_post_on_delete_user($user_id) {
global $wpdb;
// Replace the following with whatever ID you want to reassign to
$replacement_id = 1;
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $user_id));
$wpdb->update($wpdb->posts, array('post_author' => $replacement_id), array('post_author' => $user_id));
@nicholasohrn
nicholasohrn / automatically-title-post.php
Created March 4, 2014 18:17
Automatically title a post based on its type and category
<?php
/*
Plugin Name: Automatically Title Post
Description: Automatically title post based on post type and taxonomy.
Version: 1.0.0.RC.1
Author: Nick Ohrn of Plugin-Developer.com
Author URI: http://plugin-developer.com/
*/
function automatically_title_post($post_id, $post, $update) {
@nicholasohrn
nicholasohrn / dribbble-shot-embedder.php
Last active July 30, 2020 16:55
Automatically embed Dribbble shots into WordPress content
<?php
/*
Plugin Name: Dribbble Shot Embed
Description: Automatically embed a shot into your WordPress site just by dropping the URL in place.
Version: 1.0.0.RC.1
Author: Nick Ohrn of Plugin-Developer.com
Author URI: http://plugin-developer.com/
*/
function dribbble_shot_embed_callback($matches, $attr, $url, $rawattr) {
<?php
function admin_menu_change_posts_link_to_pending_review() {
global $submenu;
$submenu['edit.php'][5][2] = 'edit.php?post_status=pending&post_type=post';
}
add_action('admin_menu', 'admin_menu_change_posts_link_to_pending_review');
<?php
function at_a_glance_override() {
ob_start();
wp_dashboard_right_now();
$contents = ob_get_clean();
echo preg_replace('#.*themes\.php.*#', '', $contents);
}
@nicholasohrn
nicholasohrn / force-cpt-template-for-search.php
Last active August 29, 2015 14:01
Force CPT template for search on CPT
function force_cpt_template_for_search($template) {
if(is_search() && is_post_type_archive() && ($_template = get_post_type_archive_template())) {
$template = $_template;
}
return $template;
}
add_filter('template_include', 'force_cpt_template_for_search');