Skip to content

Instantly share code, notes, and snippets.

@un1ko85
un1ko85 / new_gist_file.php
Created September 30, 2013 17:43
Get categories ordered by meta key on WordPress
get_categories('child_of=92&hide_empty=false&orderby=meta_value&meta_key=date&order=ASC');
//-----------------------------------------------------------------------
function category_custom_field_get_terms_orderby( $orderby, $args ){
if($args['orderby'] == 'category_custom_field' && isset($args['category_custom_field']))
return 'cv.field_value';
return $orderby;
}
function category_custom_field_get_terms_fields( $selects, $args ){
@un1ko85
un1ko85 / new_gist_file.php
Created September 30, 2013 17:48
Showing subcategories on WordPress category pages
if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<h1>Subcategories</h1>";
echo "<ul>";
wp_list_categories('orderby=id&show_count=0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_ID);
echo "</ul>";
}
}
@un1ko85
un1ko85 / HTML Emails with wp_mail() .php
Created October 17, 2013 19:54
HTML Emails with wp_mail()
<?php
function mail_from() {
$emailaddress = 'contact@1stwebdesigner.com';
return $emailaddress;
}
function mail_from_name() {
$sendername = "1stWebDesigner.com - Dainis";
return $sendername;
}
@un1ko85
un1ko85 / new_gist_file.php
Created October 24, 2013 09:06
How can I de-register ALL styles all at once
function pm_remove_all_scripts() {
global $wp_scripts;
$wp_scripts->queue = array();
}
add_action('wp_print_scripts', 'pm_remove_all_scripts', 100);
function pm_remove_all_styles() {
global $wp_styles;
$wp_styles->queue = array();
}
add_action('wp_print_styles', 'pm_remove_all_styles', 100);
@un1ko85
un1ko85 / vklike.js
Created October 25, 2013 08:08
Как узнать количество lik'ов во ВКонтакте
VK.init({apiId:"...", onlyWidgets: false});
VK.Api.call('likes.getList', {type: "sitepage", owner_id: "...[apiId]",page_url:pageuri},
function(r) {
if(r.response && r.response.count) {
$.getJSON('...?rating=vk&ratingvalue=' + r.response.count);
}
});
@un1ko85
un1ko85 / facebooklike.js
Created October 25, 2013 16:28
Facebook: как посчитать количество лайков
$.getJSON('https://graph.facebook.com/fql?q=select like_count, share_count from link_stat where url="' + encodeURI(page_url) + '"'
+ '&callback=?', function(response) {
var count = 0;
if (response.data !== undefined) {
if (response.data[0].like_count !== undefined) {
count += response.data[0].like_count;
}
if (response.data[0].share_count !== undefined) {
count += response.data[0].share_count;
}
server {
[...]
set $cache_uri $request_uri;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
server {
listen 127.0.0.1:80;
server_name nocache.domain.tld;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf|txt|ico)$ {
allow 127.0.0.1;
deny all;
root /path/to/fuse/filesystem;
}
}
@un1ko85
un1ko85 / new_gist_file.php
Created November 29, 2013 08:53
use email from SMTP hook
add_action( 'phpmailer_init', 'wpse8170_phpmailer_init' );
function wpse8170_phpmailer_init( PHPMailer $phpmailer ) {
$phpmailer->Host = 'your.smtp.server.here';
$phpmailer->Port = 25; // could be different
$phpmailer->Username = 'your_username@example.com'; // if required
$phpmailer->Password = 'yourpassword'; // if required
$phpmailer->SMTPAuth = true; // if required
// $phpmailer->SMTPSecure = 'ssl'; // enable if required, 'tls' is another possible value
$phpmailer->IsSMTP();
({
block : 'page',
title : 'grid',
head : [
{elem: 'css', url: '_grid.css'}
],
scripts: [{elem: 'js', url: '_grid.js'}],
content: [
{
block : 'content',