Skip to content

Instantly share code, notes, and snippets.

@bMinaise
bMinaise / gf-hide-show.php
Created October 18, 2013 18:40
Hide field from logged in users Hide field from logged out users #repurpose for loading in titles headers through js http://code.johnpbloch.com/2011/11/gravity-forms-snippet/
<?php
/**
* Filter out the html for fields if they should be hidden from users logged in or out.
*/
function _avm_dym_gform_field_content( $content, $field, $value, $zero, $form_id ) {
if( is_admin() )
return $content;
if( !empty( $field['hideIfLoggedIn'] ) && is_user_logged_in() )
return '';
@bMinaise
bMinaise / hide-modal-ajax.js
Created October 15, 2013 22:22
Hide Modal on Ajax Submit - Gravity Forms
// hide modal on ajax submit
$('#gform_id').on('submit', function(){
$.post("/#gf_id", $(this).serialize(), function(){
var delay = 6000;
setTimeout(function(){
$("#modalID").modal('hide');
//window.location.href = 'success.php';
@bMinaise
bMinaise / wp-enqueue-scripts.php
Last active December 25, 2015 14:59
Load Scripts in Wordpress 'the WRITE way'
<?php
/*
* WordPress Sample function and action
* for loading scripts in themes
*/
add_action( 'wp_enqueue_scripts', 'wptuts_styles_with_the_lot' );
function wptuts_styles_with_the_lot()
@bMinaise
bMinaise / visible-script.js
Created October 15, 2013 01:00
Background Change - Visible Script
// jQuery isVisible script - bg color swap
var win = $(window);
var allMods = $(".featurette");
allMods.each(function(i, el) {
var el = $(el);
if (el.visible(false, true)) {
//el.addClass("colorize");
}
});
<?php
/* Determining the domain - DO NOT EDIT */
$host = $HTTP_HOST;
$parts = explode('.',$host);
if ($parts[3] = "") {
$domain = $parts[0];
} else {
$domain = $parts[1];
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
}
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
@bMinaise
bMinaise / show-gallery-urls.php
Created September 26, 2013 00:45
Get Gallery Image URLs Sample plugin illustrating how to retrieve all image URLs of gallery images in a post Author: Pippin Williamson
public static function get_form_summary(){
global $wpdb;
$form_table_name = self::get_form_table_name();
$lead_table_name = self::get_lead_table_name();
$sql = "SELECT l.form_id, count(l.id) as unread_count
FROM $lead_table_name l
WHERE is_read=0 AND status='active'
GROUP BY form_id";
@bMinaise
bMinaise / gallery-query.php
Created September 11, 2013 17:14
Wordpress Category Query