Skip to content

Instantly share code, notes, and snippets.

@jeweltheme
jeweltheme / gist:1106d5845db0e81a43c32e57ebd2d1ab
Created May 17, 2017 04:29 — forked from wwdboer/gist:4730303
WordPress: Get image attachments
function get_image_attachments( $size = 'thumbail', $ID ) {
$featured_image_id = get_post_thumbnail_id( $ID );
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
'post_parent' => $ID,
'exclude' => $featured_image_id
@jeweltheme
jeweltheme / gist:72c51fa5639bd29dd3570e68ffe1f876
Created May 17, 2017 04:18 — forked from wwdboer/gist:4353522
WordPress: Twitter time ago
<?php
// Twitter date format example: "created_at": "Mon Jun 27 19:32:19 +0000 2011"
function from_apachedate( $date ) {
list( $D, $M, $d, $h, $m, $s, $y ) = sscanf( $date, "%s %s %2d %2d:%2d:%2d +0000 %4d" );
return strtotime( "$d $M $y $h:$m:$s" );
}
// human_time_diff is a WordPress function
echo human_time_diff( from_apachedate( $item->created_at ), current_time( 'timestamp' ) );
@jeweltheme
jeweltheme / Video generator
Created May 15, 2017 20:31 — forked from jimmylatreille/Video generator
Youtube, Vimeo and Dailymotion script
<?php
if(preg_match('/vimeo/', $data['url'])){
$url = '//player.vimeo.com/video/'.end(explode('/', $data['url']));
echo "<iframe src='$url' width='560' height='315' frameborder='0' webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
echo "<img src='".unserialize(file_get_contents("http://vimeo.com/api/v2/video/".end(explode('/', $data['url'])).".php"))[0]['thumbnail_medium']."' />";
@jeweltheme
jeweltheme / gist:0b60a01c09c0fbc9318fb776b7c1a2ed
Created May 13, 2017 19:51 — forked from mattboon/gist:1275191
WordPress - Query Custom Post Type and taxonomy term by ID
<?php
// gets the ID from a custom field to show posts on a specific page
$buildType = get_post_meta($post->ID, 'build_type_id', true);
// run query
query_posts(array(
'post_type' => 'portfolio',
'showposts' => -1,
'tax_query' => array(
array(
@jeweltheme
jeweltheme / Simple Ajax Login Form.php
Created May 11, 2017 04:07 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">
@jeweltheme
jeweltheme / get_ip_address_php
Last active May 5, 2017 19:28 — forked from mrkpatchaa/get_ip_address_php
Get user ip address in php
<?PHP
function getUserIP()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(filter_var($client, FILTER_VALIDATE_IP))
{
<?php
// Example 1
$show_after_p = 2;
$content = apply_filters('the_content', $post->post_content);
if(substr_count($content, '<p>') > $show_after_p)
{
$contents = explode("</p>", $content);
$p_count = 1;
foreach($contents as $content)
{
[text* your-name placeholder "Name*"]
[email* your-email placeholder "Email*"]
[text your-subject placeholder "Subject*"]
<div class="message-body">
[textarea* your-message placeholder "Message*"]
</div>
<div class="submit-button">
function elevation_google_fonts_url() {
$font_url = '';
if ( 'off' !== _x( 'on', 'Google font: on or off', 'elevation' ) ) {
$font_url = add_query_arg( 'family', urlencode( 'Montserrat:400,700,800|Open Sans:400,300,600,700,800|Roboto:300,400,500,700' ), "//fonts.googleapis.com/css" );
}
return $font_url;
}
function elevation_scripts() {
wp_enqueue_style( 'elevation-google-fonts', elevation_google_fonts_url() );
@jeweltheme
jeweltheme / Galaxy Of Tutorial Torrents
Created September 1, 2016 15:46 — forked from iHassan/Galaxy Of Tutorial Torrents
Ultimate Galaxy Of Tutorial Torrents
=============================
**http://kickass.to/infiniteskills-learning-jquery-mobile-working-files-t7967156.html
**http://kickass.to/lynda-bootstrap-3-advanced-web-development-2013-eng-t8167587.html
**http://kickass.to/lynda-css-advanced-typographic-techniques-t7928210.html
**http://kickass.to/lynda-html5-projects-interactive-charts-2013-eng-t8167670.html
**http://kickass.to/vtc-html5-css3-responsive-web-design-course-t7922533.html
*http://kickass.to/10gen-m101js-mongodb-for-node-js-developers-2013-eng-t8165205.html
*http://kickass.to/cbt-nuggets-amazon-web-services-aws-foundations-t7839734.html