Skip to content

Instantly share code, notes, and snippets.

View bi0xid's full-sized avatar
🏠
In Seville

Rafa Poveda bi0xid

🏠
In Seville
View GitHub Profile
@bi0xid
bi0xid / wp_meta_query.php
Last active August 29, 2015 14:01
WP_Query with meta query
<?php
// Ejemplo complejo. Post Type 'historia', con un campo 'fecha_de_entrega' numérico (YYYYMMDD), y otro campo 'pila'.
$args = array(
'post_type' => 'historia',
'meta_key' => 'fecha_de_entrega',
'orderby' => 'meta_value_num',
'nopaging' => 'true',
'order' => 'ASC',
@bi0xid
bi0xid / wg-change-email-alert.php
Last active August 29, 2015 14:01
WangGuard - Admin Email Alerts for WordPress
<?php
//** Admin Email Alerts for WordPress
// Original @ Josh Lobe - WP Admin Alerts For Profile Updates
// http://pastebin.com/XY4bgiZX
// WangGuard version @ Rafa Poveda
// https://gist.github.com/bi0xid/cd1896f7be881d02398f
/*
@bi0xid
bi0xid / no-hyphens.css
Created May 29, 2014 08:59
Eliminate hyphens in twenty thirteen and other WordPress themes
.entry-content {
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
}
@bi0xid
bi0xid / responsive-iframe.html
Created June 10, 2014 06:18
Responsive iframe
<html>
<head>
<title>TITLE</title>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0 maximum-scale=1.0" />
<style type="text/css">
body {width:100%;height:100%;margin:0;overflow:hidden;background-color:#252525;}
#iframe {position:absolute;left:0px;top:0px;}
</style>
</head>
<body>
@bi0xid
bi0xid / add-cpt-as-front-page.php
Created June 23, 2014 11:45
Add CPT as front page
<?php
add_filter( 'get_pages', 'add_my_cpt' );
function add_my_cpt( $pages )
{
$my_cpt_pages = new WP_Query( array( 'post_type' => 'my_cpt' ) );
if ( $my_cpt_pages->post_count > 0 )
{
$pages = array_merge( $pages, $my_cpt_pages->posts );
}
@bi0xid
bi0xid / wp_query.php
Last active August 29, 2015 14:05
WP Query
<?php
* The WordPress Query class.
* @link http://codex.wordpress.org/Function_Reference/WP_Query
*
*/
$args = array(
//Post & Page Parameters
'p' => 1,
'name' => 'hello-world',
@bi0xid
bi0xid / add_mimetype.php
Created August 19, 2014 15:54
Add mimetype
<?php
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes = array() ) {
// add your extension to the array
$existing_mimes['patch'] = 'text/plain';
$existing_mimes['diff'] = 'text/plain';
$existing_mimes['po'] = 'text/plain';
$existing_mimes['conf'] = 'text/plain';
$existing_mimes['mo'] = 'text/plain';
$existing_mimes['rtf'] = 'text/rtf';
@bi0xid
bi0xid / .gitignore
Last active August 29, 2015 14:05
Base .gitignore
.htaccess
wp-content/uploads/
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
sitemap.xml
*.log
wp-content/cache/
@bi0xid
bi0xid / sendform.js
Last active August 29, 2015 14:05
Send form using ctrl+enter / cmd+enter
window.onload = function () {
document.getElementById("commentform").onkeydown = function (e) {
if (e.keyCode == 13 && e.ctrlKey) { // keyCode 13 is Enter
document.getElementById("submit").click(); // submit the form by hitting ctrl + enter
// alert(e.keyCode); // to know other keyCodes of each keys
return false; // preventing default action
}
if (e.keyCode == 13 && e.metaKey) { // keyCode 13 is Enter
document.getElementById("submit").click(); // submit the form by hitting cmd + enter
// alert('test'); // to know other keyCodes of each keys
@bi0xid
bi0xid / basic-loop.php
Created September 4, 2014 16:10
Loop of 100 elements breaking every 10 elements
<?php
$contador = $_GET['c'];
// we can use any top number we need
if ( $contador >= 100 ) {
echo 'script terminado';
} else {
if ( $contador == '' )
$contador = 0;