Skip to content

Instantly share code, notes, and snippets.

View adrianosferreira's full-sized avatar
🛠️
Building something or thinking about build something

Adriano Ferreira adrianosferreira

🛠️
Building something or thinking about build something
View GitHub Profile
<?php
//Instanciando uma nova query sem parâmetros
$query = new WP_Query($args);

//Definindo o título que será base para o filtro
$titulo = "Meu Título";

$array = array();
#!/bin/bash
echo "Enter the plugin name that you want to clone"
read plugin
echo "Enter the branch name that you want to select"
read branch
rm -rf /users/adriano/toolset/$plugin
if [ "$plugin" == "toolset-packager" ]; then
git clone -b $branch ssh://git@git.onthegosystems.com:10022/layouts-themes/$plugin.git /users/adriano/toolset/$plugin
else
git clone -b $branch ssh://git@git.onthegosystems.com:10022/toolset/$plugin.git /users/adriano/toolset/$plugin
@adrianosferreira
adrianosferreira / ts_maps_zoom_marker.js
Last active November 27, 2020 07:26
Change the zoom if a particular marker is present
/*
* This snippet will change the map zoom if a particular marker is present.
* Used here: https://wp-types.com/forums/topic/change-what-a-map-shows-when-there-are-no-search-results/#post-374619
*/
jQuery( document ).on( 'js_event_wpv_addon_maps_init_map_started', function( event, data ) {
if (WPViews.view_addon_maps.maps_data[0].markers[0].marker == 'marker-123'){
data.map_options.single_zoom = 1;
}
});
@adrianosferreira
adrianosferreira / pagination_parametric_ajax_workaround.js
Created March 10, 2016 19:12
Clear the first pagination page once parametric search is triggered
/*
* This will set the historyP to 1 in the View ID 25. So when you filter something in the parametric search
* it will work just fine
*
* Used here: https://wp-types.com/forums/topic/pagination-scroll-transition-direction-is-incorrect/#post-374741
*/
jQuery( document ).on( 'js_event_wpv_parametric_search_triggered', function( event, data ) {
WPViews.view_pagination.historyP[25] = 1;
});
@adrianosferreira
adrianosferreira / layouts-beaver-workaround.php
Last active May 12, 2019 10:50
This will let Layouts work with Beaver page builder
/*
* This will let Layouts work with Beaver page builder
* This will let you add Beaver elements in cell that contains post body
* Without this workaround it will display the Beaver elements on every cell because of the_content()
*/
add_action( 'init', 'fix_beaver' );
function fix_beaver(){
$has_been_removed = false;
/*
* This will let you add a custom event for your notification
* If the custom field is equal today the notification will be triggered
*/
add_filter( 'cred_notification_event_type', 'my_custom_event_type', 99, 4);
function my_custom_event_type($notification_type, $form_id){
if( $form_id == '123' )
return 'data_custom_field';
}
var request = require('request');
var theRequest = function(i){
request('http://site.com/?page=' + i, function( err, res, body ) {
console.log('Finalizado ' + i);
});
}
for (var i = 0; i <= 1000; i++) {
theRequest(i);
var request = require('request');
var async = require('async');
var q = async.queue(function(task, callback){
request('http://site.com/?page=' + task.index, function( err, res, body ) {
console.log('Finalizado ' + i);
callback();
});
}, 1);
<?php
/**
* This code retrieves course data from an external API and displays it in the user's
* My Account area. A merchant has noticed that there's a delay when loading the page.
* 1) What changes would you suggest to reduce or remove that delay?
* 2) Is there any other code changes that you would make?
*/
public function add_my_courses_section() {
$api_user_id = get_user_meta( get_current_user_id(), '_external_api_user_id', true );
function LinkedList() {
this.head = null;
this.tail = null;
}
function Node( prev, next, value ) {
this.prev = prev;
this.next = next;
this.value = value;
}