Skip to content

Instantly share code, notes, and snippets.

View jeffikus's full-sized avatar
💻
Themes at Automattic.com

Jeffrey Pearce jeffikus

💻
Themes at Automattic.com
View GitHub Profile
<?php
// table, $where, $where_format
$wpdb->delete(
$wpdb->posts,
array(
'ID' => 5
),
array(
'%d'
)
<?php
// table, $data, $where, $format, $where_format
$wpdb->update(
$wpdb->postmeta,
array(
'meta_value' => 'false'
),
array(
'post_id' => 5,
'meta_key' => '_custom_meta_key',
<?php
// table, $data, $format
$wpdb->insert(
$wpdb->postmeta,
array(
'post_id' => '5',
'meta_key' => '_custom_meta_key',
'meta_value' => 'true'
),
array(
@jeffikus
jeffikus / gist:c920cbcc1581b0d974d5
Created October 1, 2014 22:22
SQL Injection example 2
<?php
global $wpdb;
$ID = "'; SELECT * FROM wp_users WHERE 1 = '1";
$sql = "SELECT post_title from $wpdb->posts WHERE ID = '$ID';";
?>
@jeffikus
jeffikus / gist:87b31c77cccbb89fcaa1
Created October 1, 2014 22:21
SQL Injection example 1
<?php
global $wpdb;
$ID = $_GET['ID'];
$sql = "SELECT post_title from $wpdb->posts WHERE ID = '$ID';";
?>
@jeffikus
jeffikus / gist:8661b9872dad343ac108
Last active August 29, 2015 14:06
For the Cause image slider full height - after
$style = '';
$featured_height = '';
if ( '' != $image_bg ) {
$featured_height_id = get_post_thumbnail_id();
$featured_height = wp_get_attachment_image_src( $featured_height_id, 'large' );
$featured_height = ' height: ' . $featured_height[ 2 ] . 'px;';
$style = ' style="background-size: cover; background-image: url(' . $image_bg . ');' . $featured_height . '"';
}
@jeffikus
jeffikus / gist:37dc918cecc9f5a5ecfa
Created September 15, 2014 12:37
For the Cause image slider full height - before
$style = '';
$featured_height = '';
if ( '' != $image_bg ) {
if ( '' == $title && '' == $content && '' == $embed ) {
$featured_height_id = get_post_thumbnail_id();
$featured_height = wp_get_attachment_image_src( $featured_height_id, 'large' );
$featured_height = ' height: ' . $featured_height[ 2 ] . 'px;';
}
$style = ' style="background-size: cover; background-image: url(' . $image_bg . ');' . $featured_height . '"';
}
@jeffikus
jeffikus / gist:b18a7d32736bc76e8609
Created July 18, 2014 14:42
Fix for deprecated function - get_theme_data() with wp_get_theme()
add_action( 'after_setup_theme', 'woothemes_setup' );
if ( ! function_exists( 'woothemes_setup' ) ) {
function woothemes_setup () {
// This theme styles the visual editor with editor-style.css to match the theme style.
if ( locate_template( 'editor-style.css' ) != '' ) { add_editor_style(); }
// Add default posts and comments RSS feed links to head
add_theme_support( 'automatic-feed-links' );
@jeffikus
jeffikus / gist:9342341
Created March 4, 2014 08:22
Modify Features Post Type to only allow publicly queryable posts, but disable archive and single feature posts
add_action( 'init', 'modify_existing_post_type', 50 );
/**
* Modify Existing post type.
*
* @access public
* @param string $token
* @param string 'Features'
* @param string 'Features'
* @param array $supports
* @return void
@jeffikus
jeffikus / gist:7114667
Created October 23, 2013 08:25
Filter WordPress Registration URL
add_filter('register', 'my_custom_registration_link');
function my_custom_registration_link($link) {
if(!is_user_logged_in()) {
// In this example there is a page with slug 'register' so the url would be http://mysite.com/register
$link = '<div class="status register"><a href="' . site_url('register') . '">' . __('Register') . '</a></div>';
}
return $link;
} // End my_custom_registration_link()