Skip to content

Instantly share code, notes, and snippets.

View kostiantyn-petlia's full-sized avatar

Kostiantyn Petlia kostiantyn-petlia

  • Ukraine
View GitHub Profile
@kostiantyn-petlia
kostiantyn-petlia / wp-simple-masonry.php
Last active September 1, 2017 11:12
WP, JS: Simple Masonry
<script type="text/javascript">
jQuery(window).load(function () {
var container = document.querySelector('#container-of-items');
var myMasonry = new Masonry(container, {
itemSelector: '.item',
columnWidth: '.item',
});
});
</script>
@kostiantyn-petlia
kostiantyn-petlia / .gitconfig
Last active August 29, 2015 14:27 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
jQuery.fn.exists = function() {
return $(this).length;
}
// Example:
if( $("#findID").exists() ) {
// exists
}
function customFunction(id) {
console.log(id);
}
function get_id_user_login(){
FB.api(
'/me',
{fields:'id'},
function(response){ customFunction(response.id); }
);
@kostiantyn-petlia
kostiantyn-petlia / all_my_facebook_photos.html
Last active August 29, 2015 14:27 — forked from cbosco/all_my_facebook_photos.html
Simple "get all of my facebook photos" facebook JS SDK + Graph API example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Photos with Friends!</title>
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script>
/**
* This is the getPhoto library
*/
// get current taxonomy-slug in template taxonomy-{taxonomy}.php
$term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
echo $term->slug;
// get full info of taxonomy
$the_tax = get_taxonomy( get_query_var( 'taxonomy' ) );
echo $the_tax->labels->name;
// get taxonomy-type current
echo get_query_var('taxonomy');
@kostiantyn-petlia
kostiantyn-petlia / WP: Advanced Custom Fields GoogleMap
Last active August 29, 2015 14:27
Render script for ACF GooglMap Field
//======================================================================================================================
// Google Maps Scripts <div id="acf-map" data-lat="12.345678" data-lng="12.345678"></div>
//======================================================================================================================
function render_map($map_div) {
// var
var lat = $map_div.attr('data-lat');
var lng = $map_div.attr('data-lng');
// coordinates to latLng
var latlng = new google.maps.LatLng(lat, lng);
// map Options
function get_post_by_slug($slug, $post_type){
$posts = get_posts(array(
'name' => $slug,
'posts_per_page' => 1,
'post_type' => $post_type,
'post_status' => 'publish'
));
if( !$posts ) {
throw new Exception("NoSuchPostBySpecifiedID");
//WordPress has a few useful options, you can get the homepage ID by using the following:
$frontpage_ID = get_option('page_on_front');
//or the Blog ID by using:
$blog_ID = get_option('page_for_posts');
//For the latest blog post:
<?php query_posts('showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_post_thumbnail(); ?>
<?php endwhile; ?>
//For a thumbnail from a particular page (in this case id =7 ):
<?php query_posts('page_id=7'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_post_thumbnail(); ?>