Skip to content

Instantly share code, notes, and snippets.

@goliver79
goliver79 / style.css
Created August 3, 2015 08:18
[CSS] Perfect background image with CSS3
/*
https://css-tricks.com/perfect-full-page-background-image/
*/
.jumbotron {
height: 800px;
background: url('https://s3.amazonaws.com/codecademy-content/projects/broadway/bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
@goliver79
goliver79 / functions.php
Created July 29, 2015 10:11
[WORDPRESS] Contact Form 7. Edit mail data before send
<?php
// define the wpcf7_mail_components callback
function filter_wpcf7_mail_components( $components, $number )
{
/*
$components = compact( 'subject', 'sender', 'body',
'recipient', 'additional_headers', 'attachments' );
*/
// make filter magic happen here...
$components[ 'subject' ] = 'New subject changed in filter';
@goliver79
goliver79 / functions.php
Created July 19, 2015 08:53
[WORDPRESS] Get wp-admin menus information.
<?php
add_action( 'admin_init', 'wpse_136058_debug_admin_menu' );
function wpse_136058_debug_admin_menu() {
// position $value[ 2 ] is the menu slug
echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
}
@goliver79
goliver79 / queries.sql
Created July 5, 2015 11:18
[WORDPRESS] SQL Query. Custom post or user meta fields in columns
# reference: http://subharanjan.com/sql-query-to-get-post-and-its-meta_values-as-one-row-of-record-single-data-grid/
# ONLY USERS/POSTS WITH VALUES
SELECT wp_posts.ID, wp_posts.post_title, pm1.meta_value as field1, pm2.meta_value as field2, pm3.meta_value as field3
FROM wp_posts
LEFT JOIN wp_postmeta AS pm1 ON (wp_posts.ID = pm1.post_id AND pm1.meta_key='metakey1')
LEFT JOIN wp_postmeta AS pm2 ON (wp_posts.ID = pm2.post_id AND pm2.meta_key='metakey2')
LEFT JOIN wp_postmeta AS pm3 ON (wp_posts.ID = pm3.post_id AND pm3.meta_key='metakey3')
WHERE wp_posts.post_type = 'post'
AND wp_posts.post_status = 'publish'
AND ((pm1.meta_key = 'metakey1') OR (pm2.meta_key = 'metakey2') OR (pm3.meta_key = 'metakey3'))
@goliver79
goliver79 / wp-errors.php
Created June 18, 2015 11:14
[WORDPRESS] When Wordpress don't load
<?php
// upload this file in the same directory where wordpress index.php is.
// load this file in a browser.
ini_set('display_errors','1');
ini_set('display_startup_errors','1');
error_reporting (E_ALL);
include('index.php');
@goliver79
goliver79 / functions.php
Created June 10, 2015 06:54
[WORDPRESS] Display all posts within a dropdown menu
<form action="<? bloginfo('url'); ?>" method="get">
<select name="page_id" id="page_id">
<?php
global $post;
$args = array( 'numberposts' => -1);
$posts = get_posts($args);
foreach( $posts as $post ) : setup_postdata($post); ?>
<option value="<? echo $post->ID; ?>"><?php the_title(); ?></option>
<?php endforeach; ?>
</select>
@goliver79
goliver79 / gist:f3870e34459ecba2c91a
Last active August 29, 2015 14:22
[PHP] php.ini xdebug configuration
[xdebug]
xdebug.remote_enable = 1
xdebug.remote_host = 10.0.2.2 #vagrant
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
@goliver79
goliver79 / gist:a2bf40927e2c882a7462
Created April 30, 2015 06:19
[VISUAL STUDIO] Install nuget OpenCV.Net package
PM> Install-Package OpenCV.Net -Source http://168.62.110.126/api/v2
@goliver79
goliver79 / functions.php
Last active August 29, 2015 14:19
[WORDPRESS] Enqueue child style in child theme
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array('parent-style')
);
}
@goliver79
goliver79 / functions.php
Last active August 29, 2015 14:15
[WORDPRESS] qTranslate slug for custom taxonomies
<?php
/**
*
* http://www.computersolutions.cn/blog/2013/01/custom-taxonomies-in-wordpress-and-qtranslate-translation-problem-resolution/
*
* Works with mqTranslate, qTranslate
*
*/
function qtranslate_edit_taxonomies(){
$args=array(