Skip to content

Instantly share code, notes, and snippets.

View digisavvy's full-sized avatar

Alex Vasquez digisavvy

View GitHub Profile
@digisavvy
digisavvy / register-beaver-themer-field.php
Last active November 14, 2017 20:20
Register Beaver Themer Field
/* Get the external link for each post, crate a new connection for custom post template */
add_action( 'fl_page_data_add_properties', function() {
FLPageData::add_post_property( 'canonical_url', array(
'label' => 'Post external link',
'group' => 'posts',
'type' => 'html',
'getter' => 'dgs_get_canonical_url',
) );
/* Get the external link for each post, crate a new connection for custom post template */
add_action( 'fl_page_data_add_properties', function() {
FLPageData::add_post_property( 'canonical_url', array(
'label' => 'Post external link',
'group' => 'posts',
'type' => 'html',
'getter' => 'dgs_register_canonical_url_connector',
) );
@digisavvy
digisavvy / script_loading.php
Created May 10, 2017 02:39
Functions to boos script loading performance
add_filter( 'script_loader_tag', 'wsds_defer_scripts', 10, 3 );
function wsds_defer_scripts( $tag, $handle, $src ) {
$id = get_the_ID();
// The handles of the enqueued scripts we want to defer
$defer_scripts = array(
'jquery-waypoints',
"fl-builder-layout-$id",
'devicepx',
'tmls_ba_throttle_debounce',
'tmls_mousewheel',
@digisavvy
digisavvy / button.css
Created March 24, 2017 15:54
button snippet
.sumome-react-wysiwyg-popup-container button {
background: rgba(193, 34, 18, 0.98) !important;
}
@digisavvy
digisavvy / wp-cli-terminus
Created March 21, 2017 22:40
Terminus WP CLI deactivate plugin
//The -- indicates that everything that follows should be sent to wp-cli.
terminus wp innov8in.dev -- plugin deactivate profile-builder-pro
@digisavvy
digisavvy / automagic-login.php
Created December 28, 2016 05:19
Programmatically Login a WP User
/**
* Programmatically logs a user in
*
* @param string $username
* @return bool True if the login was successful; false if it wasn't
*/
function programmatic_login( $username ) {
if ( is_user_logged_in() ) {
wp_logout();
}
// Add Beaver Builder Templates to main product loop
add_action( 'fl_content_close', 'dg_add_bb_templates' );
function dg_add_bb_templates() {
if ( is_woocommerce() ) {
// Replace numbers with your own template IDs
$templates = array( 1344, 1345, 1346 );
foreach ($templates as $template) {
FLBuilder::render_query( array(
@digisavvy
digisavvy / render-template.php
Last active August 28, 2016 19:49
Render Beaverbuilder Template
<?php
/**
* The template for displaying Archive pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package some_like_it_neat
*/
get_header(); ?>
@digisavvy
digisavvy / pods-metabox-title-filter.php
Created July 29, 2016 19:53
change pods metabox title name
add_filter( 'pods_meta_default_box_title', 'slug_pods_metabox_title' );
function slug_pods_metabox_title( $title ) {
if ( get_post_type() == 'services' ) : {
$title = __( 'Service Details', 'pods' );
return $title;
} elseif ( get_post_type() == 'project' ) : {
$title = __( 'Project Details', 'pods' );
return $title;
} else : {
add_action( 'pre_get_posts', 'some_like_it_neat_filter_expired_posts' );
function some_like_it_neat_filter_expired_posts( $query ) {
// doesn't affect admin screens
if ( is_admin() )
return;
// check for main query
$key = 'some_like_it_neat_expire_post';
$expire_date = get_post_meta( get_the_id(), $key, true );