Skip to content

Instantly share code, notes, and snippets.

View danielpataki's full-sized avatar

Daniel Pataki danielpataki

View GitHub Profile
@danielpataki
danielpataki / content.php
Last active March 11, 2020 03:45
Basics Of Theme Development
<h2><a href='<?php the_permalink() ?>'><?php the_title() ?></a></h2>
<div class="content">
<?php the_excerpt() ?>
</div>
@danielpataki
danielpataki / basic.php
Last active September 29, 2017 17:19
Beginner PHP
if it is before 10am {
<h1>Good Morning</h1>
}
if it is after 6pm {
<h1>Good Evening</h1>
}
otherwise {
<h1>Good Day</h1>
}
@danielpataki
danielpataki / actions.js
Last active October 1, 2017 15:44
Select And Tweet
// actions when the user starts the selection
$('.entry-content').mousedown(function (event) {
// take the position of the mouse where the user starts the selection
// we need this for showing the share button in the middle of the selection
$('body').attr('mouse-top',event.clientY+window.pageYOffset); //-> sets up the top value as attribute on body tag.
$('body').attr('mouse-left',event.clientX); //-> sets up the left value as attribute on body tag.
// remove share button and the old selection - ! Just if the user clicks the left button of the mouse. For right click we must show the genuine browser menu.
if(!getRightClick(event) && getSelectionText().length > 0) {
$('.twtshare').remove(); //-> remove share button
@danielpataki
danielpataki / srcset.php
Created November 21, 2015 10:01
WordPress 4.4
<?php
$img_src = wp_get_attachment_image_url( $attachment_id, 'medium' );
$img_srcset = wp_get_attachment_image_srcset( $attachment_id, 'medium' );
?>
<img src="<?php echo esc_url( $img_src ); ?>"
srcset="<?php echo esc_attr( $img_srcset ); ?>"
sizes="(max-width: 50em) 87vw, 680px" alt="A rad wolf">
@danielpataki
danielpataki / acf-options.php
Last active November 16, 2015 00:07
Document Diary
<?php
if( function_exists('acf_add_local_field_group') ):
acf_add_local_field_group(array (
'key' => 'group_56474888a8e7f',
'title' => 'Attachment Options',
'fields' => array (
array (
'key' => 'field_56474b42cc2ed',
$token = get_transient( 'twitter_access_token' );
$token = ( empty( $token ) ) ? get_twitter_access_token() : $token;
$request = wp_remote_get('https://api.twitter.com/1.1/followers/ids.json?screen_name=danielpataki&count=5', array(
'headers' => array(
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8'
),
'httpversion' => '1.1'
));
$token = json_decode( $request['body'] );
@danielpataki
danielpataki / cached-posts.php
Last active July 24, 2019 10:57
WordPress REST API
public function get_remote_posts() {
$posts = get_transient( 'remote_posts' );
if( empty( $posts ) ) {
$response = wp_remote_get( 'http://mysite.com/wp-json/wp/v2/posts/' );
if( is_wp_error( $response ) ) {
return array();
}
$posts = json_decode( wp_remote_retrieve_body( $response ) );
@danielpataki
danielpataki / admin-style.php
Last active September 22, 2015 03:24
Travel Diary
function td_admin_assets() {
wp_enqueue_style( 'td-admin-post-list', get_stylesheet_directory_uri() . '/admin-style.css', false, '1.0.0' );
}
add_action( 'admin_enqueue_scripts', 'td_admin_assets' );
@danielpataki
danielpataki / countries.php
Created September 1, 2015 10:59
Country Array
$countries = array("Afghanistan" => "Afghanistan", "Albania" => "Albania", "Algeria" => "Algeria", "American Samoa" => "American Samoa", "Andorra" => "Andorra", "Angola" => "Angola", "Anguilla" => "Anguilla", "Antarctica" => "Antarctica", "Antigua and Barbuda" => "Antigua and Barbuda", "Argentina" => "Argentina", "Armenia" => "Armenia", "Aruba" => "Aruba", "Australia" => "Australia", "Austria" => "Austria", "Azerbaijan" => "Azerbaijan", "Bahamas" => "Bahamas", "Bahrain" => "Bahrain", "Bangladesh" => "Bangladesh", "Barbados" => "Barbados", "Belarus" => "Belarus", "Belgium" => "Belgium", "Belize" => "Belize", "Benin" => "Benin", "Bermuda" => "Bermuda", "Bhutan" => "Bhutan", "Bolivia" => "Bolivia", "Bosnia and Herzegowina" => "Bosnia and Herzegowina", "Botswana" => "Botswana", "Bouvet Island" => "Bouvet Island", "Brazil" => "Brazil", "British Indian Ocean Territory" => "British Indian Ocean Territory", "Brunei Darussalam" => "Brunei Darussalam", "Bulgaria" => "Bulgaria", "Burkina Faso" => "Burkina Faso", "Burund
@danielpataki
danielpataki / add_shortcode.php
Last active September 17, 2015 16:16
Google Maps Shortcode
add_shortcode( 'map', 'mgms_map' );
function mgms_map( $args ) {
$id = substr( sha1( "Google Map" . time() ), rand( 2, 10 ), rand( 5, 8 ) );
return "<div class='map' id='map-$id'></div>";
}