Skip to content

Instantly share code, notes, and snippets.

View andrezrv's full-sized avatar

Andrés Villarreal andrezrv

View GitHub Profile
<?php // Ignore this line.
add_action( 'save_post', 'nice_fix_yoast_seo_loading', -999 );
add_action( 'delete_post', 'nice_fix_yoast_seo_loading', -999 );
function nice_fix_yoast_seo_loading() {
if ( ! class_exists( 'WPSEO_Link_Watcher' ) ) {
return;
}
nice_loader( 'includes/public/theming/' );
@andrezrv
andrezrv / fix-demo-importer-toggle.css
Created July 26, 2017 13:40
Fix toggle inner in demo importer.
body.nice-framework-page-demos .nice-toggle .nice-toggle-inner {
height: auto !important;
border: 2px solid transparent !important;
}
@andrezrv
andrezrv / airplane-mode-google-fonts.php
Created February 2, 2017 15:10
For WordPress, prevent Airplane Mode plugin from blocking Google Fonts.
<?php
// Prevent Airplane Mode from blocking Google Fonts.
add_filter( 'airplane_mode_parse_style', function( $value, $parsed ) {
if ( 'fonts.googleapis.com' === $parsed ) {
$value = false;
}
return $value;
}, 10, 2 );
@andrezrv
andrezrv / get-admin-path.php
Created October 30, 2014 21:18
Obtain path to wp-admin directory in WordPress.
<?php
/**
* Obtain the path to the admin directory.
*
* @return string
*/
function my_plugin_get_admin_path() {
// Replace the site base URL with the absolute path to its installation directory.
$admin_path = str_replace( get_bloginfo( 'url' ) . '/', ABSPATH, get_admin_url() );
@andrezrv
andrezrv / submodules.sh
Created July 3, 2014 15:15
Using Git submodules.
# CREATE: On the root folder of a Git repository:
$ git submodule add git@bitbucket.org:nicethemes/<repo>.git location/of/submodule
# Cloning a repo that contains submodules:
$ git clone --recursive git@bitbucket.org:nicethemes/<repo>.git location/of/repo
# Or:
$ git clone git@bitbucket.org:nicethemes/<repo>.git location/of/repo
$ git submodule init
$ git submodule update
@andrezrv
andrezrv / remove-query-args.php
Last active August 29, 2015 14:01
Remove query arguments from any enqueued scripts.
<?php
/**
* Remove query arguments from any enqueued scripts.
*/
function remove_query_args( $src ) {
if ( strpos( $src, 'ver=' ) ) {
$src = remove_query_arg( 'ver', $src );
}
return $src;
}
<?php
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
add_action( 'wp_ajax_wpsc_migrate_anonymous_user', '_wpsc_meta_migrate_anonymous_user_worker' );
add_action( 'wp_ajax_nopriv_wpsc_migrate_anonymous_user', '_wpsc_meta_migrate_anonymous_user_worker' );
function _wpsc_meta_migrate_anonymous_user_worker() {
global $wpdb;
<?php
// Remove users and meta data.
function fix_wpsc_clear_customer_meta() {
global $wpdb;
require_once( ABSPATH . 'wp-admin/includes/user.php' );
$purge_count = 200;
$sql = "
SELECT user_id
FROM {$wpdb->usermeta}
WHERE
<?php
add_filter( 'option_active_plugins', 'activate_local_plugins' );
/**
* Add our local plugins to the list of active plugins.
*/
function activate_local_plugins( $plugins ) {
if ( defined( 'WP_STAGE' ) && 'local' == WP_STAGE ) {
$local_plugins = array(
'wordpress-beta-tester/wp-beta-tester.php',
'wordpress-importer/wordpress-importer.php',
@andrezrv
andrezrv / wp-config.php
Created April 21, 2014 04:33
Basic model of a wp-config.php file for different stages
<?php
/**
* Load different configuration files for different stages.
*/
if ( file_exists( $local_config = dirname( __FILE__ ) . '/local-config.php' ) ) {
require $local_config; // Configurations for your local stage only.
define( 'WP_STAGE', 'local' );
} elseif ( file_exists( $staging_config = dirname( __FILE__ ) . '/staging-config.php' ) ) {
require $staging_config; // Configurations for your testing stage only.
define( 'WP_STAGE', 'staging' );