Skip to content

Instantly share code, notes, and snippets.

View danielpataki's full-sized avatar

Daniel Pataki danielpataki

View GitHub Profile
@danielpataki
danielpataki / post-list-template-acf-options.php
Last active August 29, 2015 14:07
Custom Post List Template
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_post-list-options',
'title' => 'Post List Options',
'fields' => array (
array (
'key' => 'field_543f8a046d65e',
'label' => 'Authors',
'name' => 'authors',
@danielpataki
danielpataki / custom.php
Last active August 29, 2015 14:08
Editor Style Examples
function my_editor_styles() {
add_editor_style( 'admin/editor.css' );
}
add_action( 'after_setup_theme', 'my_editor_styles' );
@danielpataki
danielpataki / commentcount.php
Last active August 29, 2015 14:08
Dahsboard Widgets
global $wpdb;
for( $i=1; $i <= 5; $i++ ) {
$this_week = 7 * $i;
$last_week = 7 * ( $i - 1);
$comment_counts[] =
$wpdb->get_var( "SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_date > '" . date('Y-m-d H:i:s', strtotime('-' . $this_week . ' days')) . "' AND comment_date < '" . date('Y-m-d H:i:s', strtotime('-' . $last_week . ' days')) . "'" ) ;
@danielpataki
danielpataki / basic-shortcode.php
Last active August 29, 2015 14:08
Grid Shortcode
function my_code_output( $atts, $content ) {
return '<pre><code>' . $content . '</code></pre>';
}
add_shortcode('code', 'my_code_output');
@danielpataki
danielpataki / admin-targeting-hook.php
Last active August 29, 2015 14:08
Common WordPress Code Mistakes
function user_edit_script( $hook ) {
if ( 'profile.php' != $hook ) {
return;
}
wp_enqueue_script( 'my-user-edit', plugin_dir_url( __FILE__ ) . 'js/my-user-edit.js' );
}
add_action( 'admin_enqueue_scripts', 'user_edit_script' );
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.77.77"
config.vm.provision :shell, :path => "install.sh"
@danielpataki
danielpataki / wp-cli.sh
Created November 24, 2014 18:56
W-CLI Script
#!/bin/bash
# Setup Variables
DBNAME=blog
DBUSER=root
DBPASS=root
DBHOST=localhost
DBPREFIX=9239jej9md_
URL=http://blog.local
@danielpataki
danielpataki / title-tag.php
Created November 27, 2014 13:52
Title Tag Support
function theme_slug_setup() {
add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'theme_slug_setup' );
if ( ! function_exists( '_wp_render_title_tag' ) ) :
function theme_slug_render_title() {
echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
}
add_action( 'wp_head', 'theme_slug_render_title' );
@danielpataki
danielpataki / meta-query.php
Created November 27, 2014 13:59
WP_Meta_Query In 4.1
$query = new WP_Query( array(
'meta_query' => array(
'relation' => 'OR',
array(
'relation' => 'AND',
array(
'key' => 'city',
'value' => 'Miami',
),
array(
@danielpataki
danielpataki / full.php
Last active August 29, 2015 14:10
Custom Taxonomies
add_action( 'init', 'create_athlete_taxonomy' );
function create_athlete_taxonomy() {
$labels = array(
'name' => 'Athletes',
'singular_name' => 'Athlete',
'search_items' => 'Search Athletes',
'all_items' => 'All Athletes',
'edit_item' => 'Edit Athlete',
'update_item' => 'Update Athlete',