Skip to content

Instantly share code, notes, and snippets.

Daniel Pataki danielpataki

Block or report user

Report or block danielpataki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@danielpataki
danielpataki / cd.sh
Last active Feb 12, 2018
Terminal Basics
View cd.sh
cd vvv/www/wordpress-default
cd /users/danielpataki/vvv/www/wordpress-default
@danielpataki
danielpataki / form.php
Last active Oct 7, 2018
Movie list with transients
View form.php
function form( $instance ) {
$title = ( empty( $instance['title'] ) ) ? '' : $instance['title'];
$director = ( empty( $instance['director'] ) ) ? '' : $instance['director'];
?>
<p>
<label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
View adding-provider.php
function __construct( $config ) {
$this->providers = $config['providers'];
$this->provider = $config['provider'];
// Actions and filters here
}
@danielpataki
danielpataki / chirp-basic.php
Last active Oct 7, 2018
Advanced WP: The Basics Of Object Oriented Programming
View chirp-basic.php
// Cut text down to required length
function get_chirp_text( $text ) {
return substr( $text, 0, 200 );
}
// Parse hashtags from text
function get_hashtags( $text ) {
preg_match_all("/S*#((?:\[[^\]]+\]|\S+))/", $text, $matches);
return $matches;
}
@danielpataki
danielpataki / action.js
Last active Mar 5, 2019
AJAX and WordPress
View action.js
(function($) {
$(document).on( 'click', '.love-button img', function(){
alert('Love is being given');
})
})( jQuery );
@danielpataki
danielpataki / admin-conditional.php
Last active Sep 11, 2016
Enqueueing Scripts In WordPress
View admin-conditional.php
function my_enqueue($hook) {
if ( 'edit.php' != $hook ) {
return;
}
wp_enqueue_script( 'my_custom_script', plugin_dir_url( __FILE__ ) . 'myscript.js' );
}
add_action( 'admin_enqueue_scripts', 'my_enqueue' );
@danielpataki
danielpataki / addClass.js
Last active Jul 10, 2016
Getting Started With jQuery
View addClass.js
jQuery('.post .entry-title').addClass('better-entry-title')
@danielpataki
danielpataki / constructor.js
Last active Oct 9, 2016
Thinking In Javascript: Objects
View constructor.js
function Tweet( text, username ) {
this.text = text;
this.username = username;
this.display = function() {
return this.text + ' - ' + this.username;
}
}
var tweet_1 = new Tweet( 'I love dogs, they are awesome!', '@danielpataki' ),
var tweet_2 = new Tweet( 'Coconut juice is the best thing to drink.', '@danielpataki' ),
@danielpataki
danielpataki / array.pop.js
Last active Oct 24, 2018
Thinking In Javascript: The basics
View array.pop.js
var animals = [ "dog", "cat", "bird" ];
console.log( animals.pop() ); // bird
console.log( animals ) // dog, cat
@danielpataki
danielpataki / copy.sh
Last active May 6, 2016
Terminal Basics
View copy.sh
cp /etc/hosts ~/hosts.txt
You can’t perform that action at this time.