This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function remove_http($url) { | |
$disallowed = array('http://', 'https://'); | |
foreach($disallowed as $d) { | |
if(strpos($url, $d) === 0) { | |
return str_replace($d, '', $url); | |
} | |
} | |
return $url; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// --------------------------------------------------------- | |
// Back to Top | |
// --------------------------------------------------------- | |
$(window).scroll(function () { | |
if ($(this).scrollTop() > 100) { | |
$('#back-top').fadeIn(); | |
} else { | |
$('#back-top').fadeOut(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="section"> | |
<header class="section--header"> | |
<div class="container"> | |
<h1 class="section--title">Section Title</h1> | |
</div> | |
</header> | |
<main class="section--content"> | |
<div class="container"> | |
<!-- ... --> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: https://codepen.io/marcelo-ribeiro/pen/OJmVOyW | |
const accentsMap = new Map([ | |
["A", "Á|À|Ã|Â|Ä"], | |
["a", "á|à|ã|â|ä"], | |
["E", "É|È|Ê|Ë"], | |
["e", "é|è|ê|ë"], | |
["I", "Í|Ì|Î|Ï"], | |
["i", "í|ì|î|ï"], | |
["O", "Ó|Ò|Ô|Õ|Ö"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function send_email() { | |
$site_name = 'Company Name'; | |
$site_email = '[email protected]'; | |
$to = "$site_name <$site_email>"; | |
$name = $_POST['name']; | |
$email = $_POST['email']; | |
$subject = "$site_name - " . $_POST['subject']; | |
$message = $_POST['message']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
var paged = 1, | |
isLoading = false, | |
posts = $('.posts'), | |
button = $('.read_more'), | |
foundPosts = button.attr('data-found-posts'); | |
(function() { | |
hasMoreItens() && button.fadeIn(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$http({ | |
method: 'JSONP', | |
url: $sce.trustAsResourceUrl(url), | |
jsonpCallbackParam: 'callback' | |
}) | |
.then(function(response) { | |
console.log(response); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var settings = { | |
"async": true, | |
"crossDomain": true, | |
"url": "http://www.marcelo-ribeiro.tk/wp-json/wp/v2/media/48", | |
"method": "POST", | |
"headers": { | |
"authorization": "Basic bWFyY2Vsb3JpYmVpcm86QDg1ODM1OTU0Iw==", | |
"content-type": "application/json" | |
}, | |
"processData": false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Access-Control-Allow-Origin | |
add_action( 'rest_api_init', function() { | |
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' ); | |
add_filter( 'rest_pre_serve_request', function( $value ) { | |
$origin = get_http_origin(); | |
if ( $origin && in_array( $origin, array( | |
'http://localhost' | |
) ) ) { | |
header( 'Access-Control-Allow-Origin: ' . esc_url_raw( $origin ) ); | |
header( 'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = [ | |
'taxonomy' => 'category', | |
'hide_empty' => 0, | |
'parent' => 0 | |
]; | |
function _get_child_terms( $items ) { | |
foreach ( $items as $item ) { | |
$item->children = get_terms( 'category', array( 'child_of' => $item->term_id, 'hide_empty' => 0 ) ); | |
if ( $item->children ) _get_child_terms( $item->children ); |
OlderNewer