Skip to content

Instantly share code, notes, and snippets.

@cdmz
cdmz / get item menu wordpress
Created January 25, 2016 16:09
get item menu wordpress
function get_menu_items($menu){
$args = array(
'order' => 'ASC',
'orderby' => 'menu_order',
'post_type' => 'nav_menu_item',
'post_status' => 'publish',
'output_key' => 'menu_order',
'nopaging' => true,
'update_post_term_cache' => false
);
@cdmz
cdmz / remove core update wordpress
Created January 18, 2016 13:20
remove core update wordpress
add_action('after_setup_theme','remove_core_updates');
function remove_core_updates(){
if(! current_user_can('update_core')){return;}
add_action('init', create_function('$a',"remove_action( 'init', 'wp_version_check' );"),2);
add_filter('pre_option_update_core','__return_null');
add_filter('pre_site_transient_update_core','__return_null');
}
@cdmz
cdmz / disable update plugins wordpress
Created January 18, 2016 13:19
disable update plugins wordpress
remove_action('load-update-core.php','wp_update_plugins');
add_filter('pre_site_transient_update_plugins','__return_null');
@cdmz
cdmz / get param url javascript
Created January 17, 2016 18:11
get param url javascript
function getParam(url, param){
if (typeof url != 'string' || typeof param != 'string'){
return;
}
var regex = new RegExp('[\\?&]' + param + '=' + '(.+?)([&#]|$)', 'i');
return (value = (regex.exec(window.location.href)||[,null])[1])
? decodeURIComponent(value)
: null;
}
@cdmz
cdmz / get hash
Created January 17, 2016 18:09
get hash
function getHash(url){
if (typeof url != 'string'){
return null;
}
return url.replace(/^.*(#.*)$/, '$1');
}
@cdmz
cdmz / criando style e inserindo regras css
Created January 17, 2016 17:59
criando style e inserindo regras css
var sheet = (function() {
// Create the <style> tag
var style = document.createElement('style');
// Add a media (and/or media query) here if you'd like!
// style.setAttribute('media', 'screen')
// style.setAttribute('media', 'only screen and (max-width : 1024px)')
// WebKit hack :(
style.appendChild(document.createTextNode(''));
// Add the <style> element to the page
document.head.appendChild(style);
@cdmz
cdmz / tranformar nodeList em array javascript
Created January 17, 2016 17:31
tranformar nodeList em array javascript
var elements = document.querySelectorAll("p"); // NodeList
var arrayElements = [].slice.call(elements); // Array de Nodes
@cdmz
cdmz / calcular idade javascript
Created January 17, 2016 17:30
calcular idade javascript
ar birthday = +new Date(dateString);
r
@cdmz
cdmz / base64 files with javascript
Created January 4, 2016 12:28
base64 files with javascript
var handleFileSelect = function(evt) {
var files = evt.target.files;
var file = files[0];
if (files && file) {
var reader = new FileReader();
reader.onload = function(readerEvt) {
var binaryString = readerEvt.target.result;
console.log(btoa(binaryString));
@cdmz
cdmz / proportionalScale.js
Created January 4, 2016 11:28
proportionalScale
function proportionalScale(originalSize, newSize){
var ratio = originalSize[0] / originalSize[1];
var maximizedToWidth = {width : newSize[0], height: (newSize[0] / ratio) };
var maximizedToHeight = {width : newSize[1] * ratio, height: newSize[1]};
if(maximizedToWidth[1] > newSize[1]) {
return maximizedToHeight; }
else {
return maximizedToWidth;
}