Skip to content

Instantly share code, notes, and snippets.

@bruno-barros
bruno-barros / elementor-video-youtube-enablejsapi.php
Created March 14, 2024 13:37 — forked from EdenK/elementor-video-youtube-enablejsapi.php
Filter to add enablejsapi to Elementor youtube video
<?php
/**
* Filter to add enablejsapi to Elementor youtube video
*/
function add_youtube_jsapi($iframe_html, $video_url, $frame_attributes) {
if(strpos($video_url, 'youtube') !== false) {
$src = esc_attr($frame_attributes['src']);
$new_src = esc_attr(add_query_arg(array('enablejsapi' => '1'), $frame_attributes['src']));
$iframe_html = str_replace($src, $new_src, $iframe_html);
}
<?php
//Insert ads after second paragraph of single post content.
add_filter( 'the_content', 'prefix_insert_post_ads' );
function prefix_insert_post_ads( $content ) {
$ad_code = '<div>Ads code goes here</div>';
if ( is_single() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}
return $content;
}
@bruno-barros
bruno-barros / aliases.sh
Last active December 20, 2023 16:35
aliases.sh
alias wp='php wp'
alias gs='git status'
alias gb='git branch'
alias gt='git tag'
alias ggo='git checkout'
alias gp='git push'
alias gpm='git push origin master:master'
alias gpd='git push origin develop:develop'
alias gpall='gpm && gpd && gp --tags'
alias gpupm='git push upstream master'
@bruno-barros
bruno-barros / bitbucket-pipelines.yml
Created January 6, 2019 00:53 — forked from mcnamee/bitbucket-pipelines.yml
Bitbucket Pipelines - Deploy via FTP to shared hosting
# Installation ---
# 1. In Bitbucket, add $FTP_USERNAME $FTP_PASSWORD and $FTP_HOST as environment variables.
# 2. Commit this file to your repo
# 3. From Bitbucket Cloud > Commits > Commit Number > Run Pipeline > Custom:Init (this will
# push everything and initial GitFTP)
#
# Usage ---
# - On each commit to master branch, it'll push all files to the $FTP_HOST
# - You also have the option to 'init' (from Bitbucket Cloud) - pushes everything and initialises
# - Finally you can also 'deploy-all' (from Bitbucket Cloud) - if multiple deploys fail, you
<style>
.wrapliner {
background: yellow;
display: block;
margin-bottom: 5px;
}
</style>
@bruno-barros
bruno-barros / acf-map.php
Created October 13, 2015 03:46 — forked from nmyers/acf-map.php
ACF Static google map with link
<?php
$location = get_field('location');
if( !empty($location) ):
?>
<a href="http://www.google.com/maps/preview#!q=<?=urlencode( $location['address'] )?>">
<img src="http://maps.googleapis.com/maps/api/staticmap?center=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&zoom=15&format=png&sensor=false&size=397x297&maptype=roadmap&visual_refresh=true&style=visibility:off&style=feature:road|element:geometry|visibility:simplified&style=feature:landscape|element:geometry|visibility:simplified&style=element:labels|visibility:on&markers=color:red|<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>"/>
</a>
<?php endif; ?>
html {
font-size: calc(12px + 9 * ( (100vw - 420px) / 860));
}
@media screen and (max-width: 420px) {
html {
font-size: 12px;
}
}
@bruno-barros
bruno-barros / WelAjaxForm
Last active December 12, 2015 02:57
jQuery plugin to send ajax request using library Ajax (https://gist.github.com/bruno-barros/98db76c8d777caa3c414)
/**
* WelAjaxForm
*
* Example:
* $('.news-signin').WelAjaxForm({
action: 'form_newsletter_signin', // string | false
fields: [
{'name' : {'selector': '#field_name_ft', validation: 'required'}},
{'email' : {'selector': '#field_email_ft', validation: 'required'}}
],
@bruno-barros
bruno-barros / wordpress-ajax.js
Created January 16, 2015 00:18
WordPress AJAX object
/**
* Ajax.send();
*
* Usage: Ajax.send('my-handler', {"data": "value"}, ajaxurl).then(function(response){ //... });
*
* Ajax handler to send messages to WordPress AJAX API
*/
(function ($, window, document, undefined) {
window.Ajax = (function () {
@bruno-barros
bruno-barros / keep git repos synced
Last active August 29, 2015 14:10
keep git repos synced
# fork and clone
git clone <repo name>
# keep synk with remote origin
git remote add origin https://<repo name>
# fetch updates from upstream
git checkout master
git fetch upstream
git merge upstream/master