Skip to content

Instantly share code, notes, and snippets.

class ET_Builder_Module_Blog extends ET_Builder_Module {
function init() {
$this->name = __( 'Blog', 'et_builder' );
$this->slug = 'et_pb_blog';
$this->whitelisted_fields = array(
'fullwidth',
'posts_number',
'include_categories',
<?php
class ET_Builder_Module_Blog_CPT extends ET_Builder_Module {
function init() {
$this->name = esc_html__( 'CPT Blog', 'et_builder' );
$this->slug = 'et_pb_blog_cpt';
$this->fb_support = true;
$this->whitelisted_fields = array(
'fullwidth',
'post_type',
<?php if ( have_rows( 'pe_accordian_item' ) ) : ?>
<?php while ( have_rows( 'pe_accordian_item' ) ) : the_row(); ?>
<?php the_sub_field( 'pe_accordian_item_item_title' ); ?>
<?php if ( have_rows( 'pe_accordian_item_item_content' ) ): ?>
<?php while ( have_rows( 'pe_accordian_item_item_content' ) ) : the_row(); ?>
<?php if ( get_row_layout() == '100%' ) : ?>
<?php the_sub_field( 'pe_accordian_item_content_100_wide' ); ?>
<?php elseif ( get_row_layout() == '50%' ) : ?>
<?php the_sub_field( 'pe_accordian_item_content_50_wide' ); ?>
<?php elseif ( get_row_layout() == '33%' ) : ?>
function my_acf_admin_head() {
echo "<script>
(function($){
acf.add_action('ready append', function() {
acf.get_fields({ type : 'color_picker'}).each(function() {
$(this).iris({
palettes: ['#111111', '#333333', '#555555', '#777777', '#999999', '#cccccc'],
change: function(event, ui) {
$(this).parents('.wp-picker-container').find('.wp-color-result').css('background-color', ui.color.toString());
}
<?php
/***
* Change Hex to RGBA
* Change the number after each variable for each usage
* Change the sub_field ID each time.
* use 'echo $color*' for Hex
* use 'echo $rgba*' for RGBA
***/
$color1 = the_sub_field( 'pe_5050_image_grid_title_background_colour' );
$rgba1 = hex2rgba($color1, 0.82);
//remove wordpress authentication
remove_filter('authenticate', 'wp_authenticate_username_password', 20);
add_filter('authenticate', function($user, $email, $password){
//Check for empty fields
if(empty($email) || empty ($password)){
//create new error object and add errors to it.
$error = new WP_Error();
<?php
/* hex to rgba - place in functions.php */
function hexToRgb($hex, $alpha = false) {
$hex = str_replace('#', '', $hex);
$length = strlen($hex);
$rgb['r'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
$rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
$rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
if ( $alpha ) {
$rgb['a'] = $alpha;
<?php
/*
Plugin Name: Your Plugin's Name
Plugin URI: http://plugin-homepage
Description: A description of your plugin.
Version: 0.1
Author: Your Name
Author URI: http://author-homepage
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@BHWD
BHWD / redirect-user-ip.php
Created May 17, 2017 11:31
Redirect users based on IP. USeful for hiding websites from clients
<?php
$visitor = $_SERVER['REMOTE_ADDR'];
if (preg_match("/192.168.0.1/",$visitor)) {
header('Location: http://www.yoursite.com/thank-you.html');
} else {
header('Location: http://www.yoursite.com/home-page.html');
};
?>
ALTER TABLE `[table name]`
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY (`id`);