Skip to content

Instantly share code, notes, and snippets.

@OzzyCzech
OzzyCzech / imageHelper.php
Created Aug 24, 2010
Image helper with automatic image resize and cache for nette
View imageHelper.php
<?php
/**
* Image helper with automatic image resize and cache
*
* @author Roman Ozana, ozana@omdesign.cz
* @link www.omdesign.cz
*
*
* add to presenter before render function
*
@OzzyCzech
OzzyCzech / twitter.php
Created Nov 25, 2010
Twitter like next post load for Wordpress
View twitter.php
<?php
add_action('wp_ajax_and_action', 'add_next_post');
add_action('wp_ajax_nopriv_and_action', 'add_next_post');
function add_next_post()
{
$pagged = $_POST['paged'];
query_posts("paged=$pagged&post_status=publish");
get_template_part('loop', 'index');
die();
@OzzyCzech
OzzyCzech / usefull_regexp.php
Created Jan 25, 2011
Collection of usefull regexp for PHP
View usefull_regexp.php
<?php
// remove all empty span tags
preg_match_all('#<span[^>]*(?:/>|>(?:\s|&nbsp;)*</span>)#im', $html, $result);
@OzzyCzech
OzzyCzech / wordpress_ant.xml
Created Jan 25, 2011
Wordpress Apache ANT script
View wordpress_ant.xml
<?xml version="1.0" encoding="UTF-8"?>
<project basedir=".">
<property name="mysql" value="c:\Program Files\wamp\bin\mysql\mysql5.5.8\bin\" description="path to Mysql"/>
<property name="yuicompressor" value="c:\Program Files\yuicompressor-2.4.2\build\yuicompressor-2.4.2.jar" description="Path to yuicompressor-2.4.2.jar"/>
<property name="database" value="wp" description="Local database name"/>
<property name="url.production" value="http://www.blogs.com/wp" description="Production URL" />
<property name="url.local" value="http://localhost/blog" description="Local url" />
@OzzyCzech
OzzyCzech / ftp.php
Created May 29, 2011
FTP Connection
View ftp.php
<?php
/**
* Generuje ID FTP pripojeni na zaklade zadane URL
* ftp://username:password@sld.domain.tld:21/path1/path2/
*/
function getFtpConnection($uri)
{
preg_match("/(?P<protocol>ftps?:\/\/)(?P<username>.*?):(?P<password>.*?)@(?P<url>.*?):?(?P<port>[1-9]+)?(?<dir>\/.*)/i", $uri, $match);
$conn = ftp_connect($match['url'], empty($match['port']) ? 21 : (int)$match['port']) or die("Couldn't connect to " . $match['url']);
@OzzyCzech
OzzyCzech / FtpSync.php
Created Aug 21, 2011
Sync local files with FTP
View FtpSync.php
<?php
require_once realpath(__DIR__) . '/RecursiveFilter.php';
// can be replace with http://www.php.net/manual/en/class.recursivecallbackfilteriterator.php
// https://github.com/nette/nette/tree/master/Nette/Iterators
/**
* Copyright (c) 2011 Roman Ožana (http://omdesign.cz).
*
* @author Roman Ožana <ozana@omdesign.cz>
* @link http://omdesign.cz
@OzzyCzech
OzzyCzech / Presenter.php
Created Oct 2, 2011
Nativní Gettext translator v Nette
View Presenter.php
<?php
namespace Base;
use Nette\Environment;
abstract class Presenter extends \Nette\Application\UI\Presenter
{
/** @persitent */
public $lang;
@OzzyCzech
OzzyCzech / om.php
Created Jan 26, 2012
Show paginator in wordpress without plugin
View om.php
<?php
/**
* Generate pagination link from $wp_query
* @param $wp_query
* @return string
*/
public static function paginator($wp_query)
{
$pagination = array(
@OzzyCzech
OzzyCzech / toggleArea.js
Created Feb 25, 2012
Tooggle area plugin pro jQuery
View toggleArea.js
/** @author Roman Ozana */
!function( $ ) {
// Zobrazeni skryte oblasti po kliknuti na element
var ToggleArea = function(element, options) {
this.init(element, options);
}
ToggleArea.prototype = {
@OzzyCzech
OzzyCzech / wpbclean.php
Created Jun 10, 2012
Clean Wordpress database
View wpbclean.php
<?php
/**
* Copyright (c) 2011 Roman Ožana. All rights reserved.
*
* @author Roman Ožana <ozana@omdesign.cz>
* @link www.omdesign.cz
*/
class WpSqlHelper {
/**
* @var \wpdb
You can’t perform that action at this time.