Skip to content

Instantly share code, notes, and snippets.

View carlosonweb's full-sized avatar

Carlos Velasco carlosonweb

View GitHub Profile
# Error Message:
#
# Access to Font at '...' from origin '...' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header
# is present on the requested resource. Origin '...' is therefore not allowed access.
#
# --------------------------------------
<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
@carlosonweb
carlosonweb / bb-bg-image-cdn.php
Created August 8, 2017 22:03
Fix BB Background Image not fetching from CDN
function fl_builder_rewrite_cdn_urls( $css ) {
return str_ireplace( 'example.com', 'example-5782.kxcdn.com', $css );
}
add_filter( 'fl_builder_render_css', 'fl_builder_rewrite_cdn_urls' );
@carlosonweb
carlosonweb / bb-contact-form-modify.js
Last active October 9, 2017 03:07
Modify the Labels, Placeholders and Error Messages on the BB Contact Form
// In BB, you can embed this to the page by going to Tools > Layout CSS/JavaScript > JavaScript
jQuery(document).ready(function($){
// Change the Labels
$('#mybb-contact-form label[for="fl-name"]').text('NAME Label here...');
$('#mybb-contact-form label[for="fl-email"]').text('EMAIL Label here...');
$('#mybb-contact-form label[for="fl-phone"]').text('PHONE Label here...');
$('#mybb-contact-form label[for="fl-message"]').text('MESSAGE Label here...');
// Change the placeholders
@carlosonweb
carlosonweb / bb-themer-sticky-topbar.js
Last active March 2, 2018 04:39
How to make a sticky Topbar in Beaver Themer.
/**
* First, you need to setup this CSS
*******************************************
.fl-sticky {
position: fixed !important;
width: 100% !important;
left: 0 !important;
top: 0 !important;
z-index: 9999 !important;
border-top: 0 !important;
@carlosonweb
carlosonweb / post-top-meta.php
Last active August 28, 2017 03:17
Beaver Builder Customer Request: Modify the Schema Object for the author by removing the author URI
<?php
if( !function_exists('bblocal_post_schema_meta')){
// Copied from FLTheme::post_schema_meta();
// This function is invoked at the last line of this file.
function bblocal_post_schema_meta()
{
// General Schema Meta
echo '<meta itemscope itemprop="mainEntityOfPage" itemid="' . get_permalink() . '" />';
echo '<meta itemprop="datePublished" content="' . get_the_time('Y-m-d') . '" />';
echo '<meta itemprop="dateModified" content="' . get_the_modified_date('Y-m-d') . '" />';
@carlosonweb
carlosonweb / font-awesome-render-blocking.php
Created September 16, 2017 07:56
Fix Font Awesome Render Blocking Issue on Beaver Builder Theme
add_action( 'wp_print_scripts', function(){
wp_dequeue_script( 'font-awesome' );
});
add_action('wp_head', function(){
?>
<script id="bblocal-font-awesome" type='text/javascript'>
var fontAwesomeURL = <?php echo "'" . FL_THEME_URL . "/css/font-awesome.min.css" . "';"; ?>
function loadCSS(e, t, n) {
@carlosonweb
carlosonweb / bb-content-slider-text-on-mobile.css
Created September 20, 2017 03:38
Beaver Builder Content Slider Move the Text Content Up When on Mobile Screen
@media (max-width: 768px){
#bblocal-content-slider .fl-slide-foreground{
margin-top: -200px;
}
#bblocal-content-slider .fl-slide-content{
background-color: rgba(0,0,0,0.2);
}
}
@carlosonweb
carlosonweb / bb-fix-cdn.php
Created September 28, 2017 02:16
Fix URL References for Background Images used on Beaver Builder Modules and Rows
add_filter( 'fl_builder_render_css', function( $css ) {
return str_ireplace( 'example.com', 'cdn-url.example.com', $css );
});
@carlosonweb
carlosonweb / cpt-navigation-shortcode.php
Created September 30, 2017 07:29
Display Previous Next Navigation Links via Shortcode
//
// For simplicity, the code below assumes that the CPT is 'project'
//
// TODO: Improve further.
// ------------------------------------------------
add_shortcode('project-navigation', function(){
$html = '';
$prev_post_link = '';
$next_post_link = '';
@carlosonweb
carlosonweb / random-start-bb-content-slider.js
Created October 2, 2017 07:26
Make the Beaver Builder's Content Slider Start Playing in Random Slide Number
//
// Content Slider ID = "bbcw-content-slider"
//
jQuery(document).ready(function($){
var $slider = $('#bbcw-content-slider .fl-content-slider-wrapper').data('bxSlider')
var slideCount = $slider.getSlideCount();
$slider.goToSlide( Math.floor( Math.random() * slideCount ) );
});