Skip to content

Instantly share code, notes, and snippets.

View carlitoescobar's full-sized avatar
👁️
Looking

Carlito carlitoescobar

👁️
Looking
View GitHub Profile
<?php // custom functions.php template @ digwp.com
// add feed links to header
if (function_exists('automatic_feed_links')) {
automatic_feed_links();
} else {
return;
}
@carlitoescobar
carlitoescobar / gravityforms-checkbox-checkall.js
Created February 7, 2015 00:00
Gravity Forms check all function (jQuery)
// Needed this for a client project, thanks! I improved upon it to make it more generic so you don't have to look up individual IDs on elements:
jQuery(document).ready(function(){
// Check all in Gravity Forms
jQuery('.checkall li:first-child input').click(function() {
jQuery(this).parent('li').parent('ul').find(':checkbox').attr('checked', this.checked);
});
});
// Just add a class "checkall" to your checkbox form item in Gravity Forms, it assumes the first item in the list will be the "All" option.
@carlitoescobar
carlitoescobar / filter_taxonomy_existing_loop.php
Last active September 30, 2015 14:32
Only return taxonomies that exist in current loop. Using it on another taxonomy terms archive page.
<?php
while (have_posts()) : the_post();
$taxonomy = 'your_taxonomy'; // change this to your taxonomy
//$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
$terms = wp_get_post_terms( $post->ID, $taxonomy, array( "fields" => "slugs" ) );
if( $terms ) $all_terms = array_merge($all_terms, $terms);
endwhile;
if ($all_terms) :
<?php
/**
* A new logo for the admin area and an own background color
* @author Andreas Hecht
*/
function ah_login_logo() {
?>
<style type="text/css">
#login h1 a, .login h1 a {
<?php
// Copy from here
//Deleting WordPress authentification
remove_filter('authenticate', 'wp_authenticate_username_password', 20);
// Placing new authentification - sign up via email and password only
add_filter('authenticate', function($user, $email, $password){
//Check for empty fields
<?php
/**
* Adding an ad after the second paragraph
*
*/
add_filter( 'the_content', 'tb_insert_post_ads' );
function tb_insert_post_ads( $content ) {
$ad_code = 'The ad code goes here. Both static ads and Google Adsense.';
@carlitoescobar
carlitoescobar / WordPress Header From Unnecessary Entries
Created February 25, 2018 20:43
WordPress loads a bunch of things via the wp_head() hook into the header of the WordPress themes. Some of them are very useful, some aren’t. Some just inflate the website unnecessarily. Here’s a small snippet to do some major cleaning up.
<?php
/**
* Frees the header from unnecessary entries
*/
add_action('init', 'evolution_remheadlink');
function evolution_remheadlink()
{
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_generator');
@carlitoescobar
carlitoescobar / Turn Off the jQuery Migrate Script
Created February 25, 2018 20:44
Query Migrate is a script meant to create a downward compatibility of older jQuery applications. The “normal” and modern jQuery version does not support all old applications anymore. While this won’t affect more than 5% of all WordPress website, WordPress loads the pretty sizeable script by default. Here’s an easy way to turn it off:
<?php
/**
* Dequeue jQuery Migrate Script in WordPress.
*/
if ( ! function_exists( 'evolution_remove_jquery_migrate' ) ) :
function evolution_remove_jquery_migrate( &$scripts) {
if(!is_admin()) {
$scripts->remove( 'jquery');
@carlitoescobar
carlitoescobar / Turn Off WP Emojis
Created February 25, 2018 20:44
Not everyone is a fan of the colorful emojis. If you don’t want to use emojis in your posts, you can deactivate this feature. Your blog’s performance will thank you.
<?php
/**
* Disable the emojis
*/
function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
describe('conditional testing', function() {
it('should be able to test conditionally', function() {
browser.get('http://www.angularjs.org');
element(by.css('.theresnowaythisclassexists')).then(
function elementExists() {
expect(false).toBe(true);
},
function elementDoesNotExist() {
expect(true).toBe(true);
}