Skip to content

Instantly share code, notes, and snippets.

@pniaps
pniaps / validate.js
Created November 25, 2016 13:51
Jquery Validate with suppor to array of fields
if ($.validator) {
//returns all elements, even with the same name (default returns only the first element for each name)
$.validator.prototype.elements = function() {
var validator = this;
// select all valid inputs inside the form (no submit or reset buttons)
return $( this.currentForm )
.find( "input, select, textarea" )
.not( ":submit, :reset, :image, [disabled], [readonly]" )
.not( this.settings.ignore )
@pniaps
pniaps / index.php
Created January 29, 2016 08:43
Replace domain in wordpress configuration
//Insert here serialized string from wp_options table
$str = '';
function change(&$data)
{
if(is_string($data) && json_decode($data)){
$json = json_decode($data);
if(is_array($json) || is_object($json)){
foreach($json as &$jsonvalue){
change($jsonvalue);
@pniaps
pniaps / jquery.exists.js
Created December 29, 2015 08:20
jQuery run code if element exists
/**
* Tiny jQuery Plugin
* by Chris Goodchild
* https://css-tricks.com/snippets/jquery/check-if-element-exists/
*
*/
$.fn.exists = function(callback) {
if (this.length) {
var args = [].slice.call(arguments, 1);
callback.call(this, args);