Skip to content

Instantly share code, notes, and snippets.

View silentworks's full-sized avatar

Andrew Smith silentworks

View GitHub Profile
@silentworks
silentworks / disqus.php
Created February 24, 2011 20:38
fix issue within Wordpress 3.1 edit panel and frontend view.
// Mark entries in index to replace comments link.
/* Patched with version check for WP 3.1 */
function dsq_comments_number($count) {
global $post, $wp_version;
$ver_check = explode('.', $wp_version);
if($ver_check[0] <= 3 && $ver_check[1] < 1){
if ( dsq_can_replace() ) {
return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">'.$count.'</span>';
} else {
<?php if( ! empty($feed)): ?>
<?php foreach ($feed as $row):?>
<?php if ($row->content_category == 'news') { ?>
<li class="news">
<a class="title" href="<?php echo site_url('news') . '/' . $row->content_id . '/' . $row->content_url; ?>"><h2><?php echo $row->content_title; ?></h2></a>
<p class="created">News from <a href="<?php echo creator($row->content_parent, 'url'); ?>"><?php echo creator($row->content_parent, 'title'); ?></a></p>
function mywild($userid = '', $offset = 0)
{
/* find favourites for this user */
$rels = $this->db->select('rel_parent')->where('rel_child', $userid)->where('rel_type', 'favourite')->from('content_relationships')->get();
print_r($rels);
if ($rels->num_rows() > 0) {
@silentworks
silentworks / gist:976515
Created May 17, 2011 14:01 — forked from anonymous/gist:976409
Select Query from MySQL with OR
SELECT *
FROM `content`
WHERE (content_finish >= '2011-05-17 23:00:00' OR content_finish IS NULL)
AND `content_status` = 'published'
AND `content_parent` IN ('17', '38', '54', '10', '34', '66', '68', '67', '76', '77', '75', '79', '86', '79', '18')
ORDER BY `content_updated` desc
$sql = "SELECT *
FROM `content`
WHERE (content_finish >= " . $now . " OR content_finish IS NULL)
AND `content_status` = 'published'
AND `content_parent` IN (" . $content_ids . ")
ORDER BY `content_updated` desc";
$this->db->query($sql);
$rels = $this->db->select('rel_parent')->where('rel_child', $userid)->where('rel_type', 'favourite')->from('content_relationships')->get();
foreach ($rels->result_array() as $row)
{
$content_ids[] = $row['rel_parent'];
}
$rels = $this->db->select('rel_parent')->where('rel_child', $userid)->where('rel_type', 'favourite')->from('content_relationships')->get();
$content_ids = '';
$i = 0;
foreach ($rels->result_array() as $row)
{
if($rels->num_rows() === $i)
{
$content_ids .= $row['rel_parent'];
}
$data = array(
'first_name' => $this->form_validation->error('first_name'),
'last_name' => $this->form_validation->error('last_name'),
'country' => $this->form_validation->error('country'),
'region' => $this->form_validation->error('region'),
'email' => $this->form_validation->error('email'),
'email_confirm' => $this->form_validation->error('email_confirm'),
'dob_day' => $this->form_validation->error('dob_day'),
'dob_month' => $this->form_validation->error('dob_month'),
@silentworks
silentworks / _more.scss
Created June 30, 2011 14:26 — forked from idan/_more.scss
More is Less
$less-column-width: 68px;
$less-gutter-width: 24px;
@function column-width($columns) {
@return ($less-column-width * $columns) + ($less-gutter-width * ($columns - 1));
}
@function grid-padding-px($columns) {
@if $columns == 10 {
@return 48px;
@silentworks
silentworks / base.html
Created December 9, 2011 18:29
Twig and Slim integration
<html>
<head>
<meta charset="utf-8">
<title>Slim Tasks Project</title>
</head>
<body>
<header>
<h1>Slim Tasks Project</h1>
</header><!-- /header -->