Skip to content

Instantly share code, notes, and snippets.

View carmoreira's full-sized avatar

Carlos Moreira carmoreira

View GitHub Profile
@carmoreira
carmoreira / slow_redirect.js
Created May 22, 2019 16:04
slow redirect for Advisor Quiz results
// slow redirect
jQuery('.advq_profile_box').each(function() {
var redirect = jQuery(this).attr('data-redirect');
jQuery(this).attr('data-slow-redirect', redirect);
jQuery(this).attr('data-redirect', '');
});
jQuery('.advq_checkanswers .advq_button').on('click', function() {
setTimeout(function() {
jQuery('.advq_profile_box').each(function() {
@carmoreira
carmoreira / create_user.php
Created May 22, 2019 16:35
Create user from email submitted
add_action('adqv_email_submitted', 'advq_create_new_user_from_email');
function advq_create_new_user_from_email( $email_address ){
if( null == username_exists( $email_address ) ) {
// Generate the password and create the user
$password = wp_generate_password( 12, false );
$user_id = wp_create_user( $email_address, $password, $email_address );
// Set the nickname
@carmoreira
carmoreira / fix.php
Last active November 8, 2022 11:24
Fix themes ui js interfeering with switch buttons on advisor quiz
// All Elated Themes
add_action('admin_enqueue_scripts','kendal_advisor_quiz_fix', 100);
function kendal_advisor_quiz_fix() {
$current_screen = get_current_screen();
if( $current_screen->id === "advquiz" ) {
wp_deregister_script('eltd-ui-admin');
wp_dequeue_script('eltd-ui-admin');
wp_deregister_script('eltdf-ui-admin-skin');
wp_dequeue_script('eltdf-ui-admin-skin');
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@carmoreira
carmoreira / query.php
Created May 24, 2019 14:46
Advisor Quiz: filter query args
add_filter( 'advq_query_args', 'my_custom_quiz_order' );
function my_custom_quiz_order( $args ){
$args['meta_key'] = 'quiz_order';
$args['orderby'] = 'meta_value_num';
$args['order'] = 'DESC';
return $args;
}
@carmoreira
carmoreira / mapdemo.html
Created June 10, 2019 21:35
World Map Demo Embed Code - Interactive Maps Generator
<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript'>google.charts.load('42', {'packages':['geochart']});
google.charts.setOnLoadCallback(drawVisualization);
function drawVisualization() {var data = new google.visualization.DataTable();
data.addColumn('string', 'Country');
data.addColumn('number', 'Value');
data.addColumn({type:'string', role:'tooltip'});var ivalue = new Array();
@carmoreira
carmoreira / metro codes
Last active June 10, 2019 21:59
metro codes
501 New York
803 Los Angeles
602 Chicago
504 Philadelphia
506 Boston (Manchester)
807 San Francisco - Oakland - San Jose
623 Dallas - Fort Worth
511 Washington DC (Hagerstown)
524 Atlanta
618 Houston
@carmoreira
carmoreira / iwm_cpt.php
Last active January 28, 2020 17:25
Interactive World Maps plugin - read from Custom Post Type
<?php
/*
* With this approach, you would need to add "my_custom_map_data" to the map's advanced tab for the Interactive Regions
* the map would then read from the custom post type and the fields specified below
*/
add_filter('iwm_input','my_custom_map_input');
@carmoreira
carmoreira / bytitle.php
Created June 12, 2019 18:17
team showcase search by title only
<?php
add_action( 'pre_get_posts', 'team_search_by_name_only' );
function team_search_by_name_only( $query ) {
global $wp_query;
if ( ! is_admin() && in_array ( $query->get( 'post_type' ), array( 'tshowcase' ) ) && $query->is_search() ) {
$query->set( 'meta_key', '_ts_lastname' );
$query->set( 'meta_value', $query->get( 's' ) );
@carmoreira
carmoreira / onlynumbers.js
Created July 1, 2019 13:23
only allow numbers on input field (telephone field in advisor quiz)
jQuery('.advq_askinfo_2 input').on('keypress keyup blur',function (event) {
jQuery(this).val(jQuery(this).val().replace(/[^\d].+/, ''));
if ((event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});