Skip to content

Instantly share code, notes, and snippets.

View thiagoeliasr's full-sized avatar
🏠
Working from home

Thiago Elias thiagoeliasr

🏠
Working from home
View GitHub Profile
<?
$yourTaxonomySlugHere = get_the_terms($post->ID, 'yourTaxonomySlugHere');
if ($terms) :
foreach ($terms as $term) :
echo $term->name;
endforeach;
endif;
?>
@thiagoeliasr
thiagoeliasr / swiper-magnific-popup.js
Created August 13, 2015 13:27
Adding swipe support to Magnific Popup galleries. (touchSwipe is required: http://labs.rampinteractive.co.uk/touchSwipe/demos/)
(function() {
/* Define a variável que dá swipe no lightbox */
var magnificPopup = $.magnificPopup.instance;
/* Carrega a função quando clica no lightbox (senão não pega a classe utilizada) */
$("a.image-lightbox").click(function(e) {
/* Espera carregar o lightbox */
setTimeout(function() {
/* Swipe para a esquerda - Próximo */
@thiagoeliasr
thiagoeliasr / viewportsize.js
Last active October 8, 2022 01:24
Display ViewPort and Screen Resolution at the top of screen. (This script was created intended to be a bookmarklet)
$(document).find('body').append('<div id="div-width-top" style="position: fixed; right: 5px; top: 5px; background: #000; color: #fff; padding: 10px; z-index: 99999; opacity: 0.7">Window Size:</div>');
$('#div-width-top').html('ViewPort: ' + window.innerWidth + 'px | Window: ' + screen.width + 'px');
$(window).resize(function() {
$('#div-width-top').html('ViewPort: ' + window.innerWidth + 'px | Window: ' + screen.width + 'px');
});
@thiagoeliasr
thiagoeliasr / center-map-zoom.js
Created September 4, 2015 13:30
Google Maps API: Center / Zoom in bounds
// Create a new viewpoint bound
var bounds = new google.maps.LatLngBounds();
// Go through each...
for (var i = 0, LtLgLen = _latlng.length; i < LtLgLen; i++) {
// And increase the bounds to take this point
bounds.extend (_latlng[i]);
}
// Fit these bounds to the map
map.fitBounds(bounds);
@thiagoeliasr
thiagoeliasr / cross-domain.php
Last active September 11, 2015 16:59 — forked from brunomonteiro3/cross-domain.php
Allow Cross-domain requests on Wordpress
add_action( 'init', 'handle_preflight' );
function handle_preflight() {
header("Access-Control-Allow-Origin: " . get_http_origin());
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Credentials: true");
if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
status_header(200);
exit();
@thiagoeliasr
thiagoeliasr / strip_tags.js
Last active September 11, 2015 19:51 — forked from muhittin/strip_tags.js
strip_tags for Javascript
var text = '<div class="foo">bar</div>';
text.replace(/(<([^>]+)>)/ig,""); // Returns: bar
@thiagoeliasr
thiagoeliasr / facebook-linter.php
Created September 25, 2015 20:20
Scrape new information from Facebook Linter.
<?php
public function try_debugger($url)
{
$url = "https://graph.facebook.com/?id=". urlencode($url) ."&scrape=true&method=true";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
@thiagoeliasr
thiagoeliasr / featured-thumbnail-column.php
Created October 17, 2015 14:42 — forked from brunomonteiro3/featured-thumbnail-column.php
Show the featured image from each post on Wordpress dashboard.
@thiagoeliasr
thiagoeliasr / Mark parent navigation active when on custom post type single page Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
add_action('nav_menu_css_class', 'add_current_nav_class', 10, 2 );
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Getting the post type of the current post
@thiagoeliasr
thiagoeliasr / change-wp-url.sql
Created April 22, 2016 13:13
Change Wordpress URL via SQL
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');