Skip to content

Instantly share code, notes, and snippets.

View hitautodestruct's full-sized avatar

Yotam hitautodestruct

View GitHub Profile
<ul>
<?php if(have_posts()): while(have_posts()): the_post();
?><li><?php the_title(); ?></li><?php
endwhile; endif; ?>
</ul>
@hitautodestruct
hitautodestruct / add-scripts.php
Last active February 20, 2017 12:51
Manage Javascript dependencies in wordpress.
<?php
function register_scripts() {
if (!is_admin()){
wp_deregister_script('jquery'); // Lets use the most modern version rather than the one packaged with Wordpress
wp_deregister_script( 'l10n' ); // Unneccessary http request made by WP
// Add scripts to this array as neccessary
$scripts = array(
@hitautodestruct
hitautodestruct / wp-ajax-request.php
Last active August 29, 2015 13:56
Backend ajax functionality in wordpress
<?php
function request_post(){
$nonce = $_POST['nonce'];
// check to see if the submitted nonce matches with the
// generated nonce we created earlier
if ( ! wp_verify_nonce( $nonce, 'my-nonce' ) )
die ( 'Please dont');
@hitautodestruct
hitautodestruct / sublime-text-2.json
Last active August 29, 2015 13:56
Default sublime text 2 settings
{
"font_size": 11.0,
"ignored_packages": [ "Vintage" ],
"auto_complete": true,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages": [],
"line_padding_bottom": 1,
"line_padding_top": 1,
"overlay_scroll_bars": "enabled",
@hitautodestruct
hitautodestruct / micro-clearfix.css
Created February 15, 2014 15:03
Micro clear fix hack for floated content
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
@hitautodestruct
hitautodestruct / .htaccess
Created February 25, 2014 13:26
Wordpress htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@hitautodestruct
hitautodestruct / wordpress-ajax.php
Last active November 19, 2015 11:48
The basics of creating an internal wordpress ajax request.
<?php
// Inside functions.php
function get_category_posts(){
$nonce = $_POST['nonce'];
// check to see if the submitted nonce matches with the
// generated nonce we created earlier
if ( ! wp_verify_nonce( $nonce, 'my-nonce' ) )
@hitautodestruct
hitautodestruct / related.html
Last active August 29, 2015 14:01
Gets the related youtube videos based on the inputted id.
@hitautodestruct
hitautodestruct / httpd-vhosts.conf
Created September 17, 2014 12:27
Apache virtual hosts config for a local site
<VirtualHost dev.mysite.co.il:80>
ServerAdmin webmaster@localhost
DocumentRoot C:/my-site
ServerName dev.mysite.co.il
<Directory "C:/my-site">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
@hitautodestruct
hitautodestruct / preloader.js
Created November 11, 2014 12:34
A javascript image preloader. Accepts an array of image paths and then initiates a callback when done loading.
// Accepts array of image paths relative to the current page.
var preLoadImages = function( srcs, callback ) {
if ( srcs.length ) {
var cache = [],
args_len = srcs.length;
for (var i = args_len; i--;) {