Skip to content

Instantly share code, notes, and snippets.

@alkrauss48
alkrauss48 / custom_post_type_cf7_dropdown.php
Last active May 24, 2021 16:50
Adding a custom Wordpress shortcode for building a dynamic dropdown of post type titles with Contact Form 7
wpcf7_add_shortcode('postdropdown', 'createbox', true);
function createbox(){
global $post;
extract( shortcode_atts( array( 'post_type' => 'some_post_type',), $atts ) );
$args = array('post_type' => $post_type );
$myposts = get_posts( $args );
$output = "<select name='postType' id='postType' onchange='document.getElementById(\"postType\").value=this.value;'><option></option>";
foreach ( $myposts as $post ) : setup_postdata($post);
$title = get_the_title();
$output .= "<option value='$title'> $title </option>";
@alkrauss48
alkrauss48 / ie_gradients.css
Last active January 30, 2019 21:39
Examples of CSS gradient filters for IE
/* Here's some examples of IE filters for backgrounds with opacity. The first 2 chars of the hex value are the
* opacity values. There are 10 classes to help narrow down which opacity value you might need.
*/
.dark-90 {
background-color: rgba(0, 0, 0, 0.9);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#E6000000,endColorstr=#E6000000);
}
.dark-80 {
@alkrauss48
alkrauss48 / webgl_support.js
Created May 24, 2014 15:21
Full Test for WebGL Support
function webgl_support() {
try{
var canvas = document.createElement( 'canvas' );
return !! window.WebGLRenderingContext && (
canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) );
}catch( e ) { return false; }
};
@alkrauss48
alkrauss48 / form_fillers.jquery.js
Last active August 29, 2015 14:01
jQuery Form Fillers for instant (basic) form-filling action. Run through the browser console.
// Set text fields
$('input[type=text]').val('test');
// Set email fields
$('input[type=email]').val('test@test.com');
// Set combo boxes to 2nd index (in case first is blank)
$('select').prop('selectedIndex', 1);
// Set all checkboxes to checked
@alkrauss48
alkrauss48 / hr_base_styles.css
Created May 30, 2014 17:08
HR Base Styles - As seen in HTML5 Boilerplate
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
padding: 0;
}
@alkrauss48
alkrauss48 / font_face_format.css
Created June 4, 2014 15:12
Proper font face format for maximum browser support
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@alkrauss48
alkrauss48 / cookies.js
Created June 11, 2014 16:38
Setting and Retrieving Cookies with JS
function getCookie(c_name) {
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x==c_name){
return unescape(y);
}
@alkrauss48
alkrauss48 / video_embed.html
Created June 11, 2014 20:25
Responsive Iframe Video Embeds
<div class="videoWrapper">
<!-- Copy & Pasted from YouTube -->
<iframe width="560" height="349" src="http://www.youtube.com/embed/n_dZNLr2cME?rel=0&hd=1" frameborder="0" allowfullscreen></iframe>
</div>
@alkrauss48
alkrauss48 / .htaccess
Created June 13, 2014 20:13
Good .htaccess Settings
# prevent directory browsing
Options All -Indexes
# prevent folder listing
IndexIgnore *
@alkrauss48
alkrauss48 / jquery.placeholder_support.js
Created June 16, 2014 21:26
Gives your form fields placeholder support for IE8
/* Fake placeholder support in browsers that do not support the HTML input placeholder attribute. Ideally this would be paired with a javascript function that prevents form submit if the a given input's value is equivalent to the placeholder attribute. */
/* Requires both jQuery and Modernizr */
function initPlaceholderSupport() {
if( ! Modernizr.input.placeholder ) {
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');