Skip to content

Instantly share code, notes, and snippets.

View goranseric's full-sized avatar

Goran Šerić goranseric

View GitHub Profile
@goranseric
goranseric / Shared Taxonomy Post Count
Created June 14, 2014 20:26
Shared taxonomy across 2 or more custom post types, correct posts count
// Create a function that will count posts
function gs_get_term_post_count_by_type($term,$taxonomy,$type){
$args = array(
'fields' =>'ids',
'numberposts' => -1,
'post_type' => $type,
'tax_query' => array(
array(
<?xml version="1.0" encoding="UTF-8"?>
<forms version="1.6.12">
<form labelPlacement="top_label" useCurrentUserAsAuthor="1">
<title><![CDATA[GF Form 1 Test - Top aligned labels, Descriptions below inputs]]></title>
<description><![CDATA[We would love to hear from you! Please fill out this form and we will get in touch with you shortly.]]></description>
<confirmation type="message">
<message><![CDATA[Thanks for contacting us! We will get in touch with you shortly.]]></message>
</confirmation>
<button type="text">
<text><![CDATA[Submit]]></text>
jQuery(document).ready(function ($) {
'use strict';
function doneResizing() {
if (Modernizr.mq('screen and (min-width:768px)')) {
// action for screen widths including and above 768 pixels
} else if (Modernizr.mq('screen and (max-width:767px)')) {
// action for screen widths below 768 pixels
}
}
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
<?php
$posts = array(5, 2, 43, 12);
// Get the posts
$my_loop = new WP_Query(array(
'post__in' => $posts,
'post_type' => 'any',
'posts_per_page' => -1,
));
@goranseric
goranseric / PHP.sublime-settings
Created October 12, 2015 19:11 — forked from joshearl/PHP.sublime-settings
To enable double-clicking to select PHP variables (including the `$` prefix), save this file as `Data/Packages/User/PHP.sublime-settings`.
{
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?"
}
@goranseric
goranseric / fix-wordpress-permissions.sh
Created October 16, 2015 10:54 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@goranseric
goranseric / stream-filter-v1.php
Created October 17, 2015 03:53 — forked from bhwebworks/stream-filter-v1.php
Prevent unwanted results from appearing in (future) Stream records
<?php
// Prevent unwanted results from appearing in (future) Stream records - v 1.x
add_filter( 'wp_stream_record_array', 'bhww_core_wp_stream_filter_record_array', 10, 1 );
function bhww_core_wp_stream_filter_record_array( $recordarr ) {
// BackupBuddy (iThemes) entries
$context = 'settings';
$option = 'ithemes-updater-cache';
@goranseric
goranseric / analytics-regexp.js
Created October 20, 2015 20:07 — forked from faisalman/analytics-regexp.js
Regular Expression snippets to validate Google Analytics tracking code (in PHP, JavaScript)
/**
* Regular Expression snippets to validate Google Analytics tracking code
* see http://code.google.com/apis/analytics/docs/concepts/gaConceptsAccounts.html#webProperty
*
* @author Faisalman <movedpixel@gmail.com>
* @license http://www.opensource.org/licenses/mit-license.php
* @link http://gist.github.com/faisalman
* @param str string to be validated
* @return Boolean
*/
if ( $post->post_parent )
{
wp_redirect( get_permalink( $post->post_parent ), 301 );
}
else
{
wp_redirect( site_url(), 301 ) );
}
die();