Skip to content

Instantly share code, notes, and snippets.

View Zenger's full-sized avatar
⌨️
=

Dennis Zenger Zenger

⌨️
=
View GitHub Profile
@Zenger
Zenger / blank-wp-import.php
Last active December 28, 2015 00:29
Blank WordPress Importer. Can be used as a starting point to import files from custom CMS to PHP
<?php
require_once "wp-load.php";
ob_implicit_flush(true); ob_end_flush(); //Instant output woohooo thx ##php
include_once( WP_PLUGIN_DIR . '/sitepress-multilingual-cms/inc/wpml-api.php' );
$serv = new wpdb("root", "password", "user", "localhost");
global $wpdb;
set_time_limit(0);
define("THUMB_PATH", "http://yoursite.com/img/products/%s/thumbs/%s");
@Zenger
Zenger / wp_insert_post.php
Created November 11, 2013 11:07
wp_insert_post and WPML
<?php
global $wpdb;
// Insert the original post
$original = wp_insert_post($array, true);
// Insert the translated post
$translated = wp_insert_post($array, true);
// Make some updates to both translations
@Zenger
Zenger / scfd.php
Created November 11, 2013 08:37
A small plugin to show all saved custom fields names and values. Useful in debugging.
<?php
// Plugin Name: Show Custom Fields Data
// Description: This plugin adds a metabox and shows all the custom fields names and data
// Author: Zenger
// Author URI: http://github.com/Zenger/
// Version: 1.0
function scfd_add_meta_box()
{
foreach (get_post_types() as $post_type)
@Zenger
Zenger / TemplateEngine.php
Last active December 21, 2015 13:58
The laziest possible template engine written in php
<?php
class Template {
static $escape = true;
static $template = "";
static $vars = array();
public static function sanitize($what)
{
return filter_var($what, FILTER_SANITIZE_STRING);
@Zenger
Zenger / Request.php
Last active December 20, 2015 22:59
A simple request class, makes use of CURL.
<?php
class Request {
public $curl_object;
public function __construct($p_username = "", $p_password = "", $p_timeout = 15)
{
$this->curl_object = curl_init();
curl_setopt($this->curl_object, CURLOPT_HTTPHEADER, Array("Accept: application/json", "Content-Type: application/json"));
curl_setopt($this->curl_object, CURLOPT_CONNECTTIMEOUT, $p_timeout);
@Zenger
Zenger / Slugger.php
Created August 8, 2013 10:56
Slugger.php
<?php
/**
* Slugger, simple logging class
* Writes logs into a file and sends them by e-mail once in a while
* Written for pure example
* @require PHP >= 5.3
* @todo : Fix bug when the class is firt time instantiated it send an empty message
*/
/* Don't forget to setup a date default timezone */
@Zenger
Zenger / wpxmlrpc.php
Last active December 15, 2015 09:19
WordPress XML-RPC example.
<?php
//https://raw.github.com/dongsheng/cURL/master/curl.class.php
require_once('curl_class.php');
$request = array(
'blog_id' => 1,
'username' => 'username',
'password' => 'password',
'post_id' => 84
@Zenger
Zenger / wai.py
Created February 13, 2013 13:12
Downloads, extracts, moves wordpress, creates database for it, and installs wordpress. Needs Python 2.7. Won't work under 3. Uses shutil, urllib. Requires mysql connect. Before using download it at: http://dev.mysql.com/downloads/connector/python/. Config the array at the top. Previous names were, pyg(python generator), pypo(py project), diego a…
#!/usr/bin/env python
# -*- coding: utf8 -*-
# ========= EDIT HERE ======================================================
config = {
# Set the save path
'save_path' : "C:\\VertrigoServ\\www",
'folder_name' : 'dezvoltare',
'title' : 'Dezvoltare',
@Zenger
Zenger / image-faker.php
Last active December 13, 2015 16:59
Sometimes when working with WordPress web-sites, when moving them you don't really need to download all the uploads folder. Place this script in /wp-content and run it once. It will create a .htaccess file and will take any incoming image requests and render appropriate images. Currently handles filenames like : myimage-150x150.jpg and myimage10…
<?php
/*
Place this script inside the wp-content folder.
Any incoming request for image will be taken over if the requested file doesn't exist.
And will setup a .htacces file to take all incoming requests and send them to this file.
Run it once to setup.
Configure the constants below.
*/
/* Setup Constants */
@Zenger
Zenger / webfonts.php
Last active October 13, 2015 23:48
A big array of google web fonts
<?php
/*
*
* Google Web Fonts PHP list
* This file has a list of all Google Web Fonts
* Note that it may not be up to date
*
*/
$google_web_fonts = array(array('ABeeZee', 'regular,italic,'),array('Abel', 'regular,'),array('Abril Fatface', 'regular,'),array('Aclonica', 'regular,'),array('Acme', 'regular,'),array('Actor', 'regular,'),array('Adamina', 'regular,'),array('Advent Pro', '100,200,300,regular,500,600,700,'),array('Aguafina Script', 'regular,'),array('Akronim', 'regular,'),array('Aladin', 'regular,'),array('Aldrich', 'regular,'),array('Alegreya', 'regular,italic,700,700italic,900,900italic,'),array('Alegreya SC', 'regular,italic,700,700italic,900,900italic,'),array('Alex Brush', 'regular,'),array('Alfa Slab One', 'regular,'),array('Alice', 'regular,'),array('Alike', 'regular,'),array('Alike Angular', 'regular,'),array('Allan', 'regular,700,'),array('Allerta', 'regular,'),array('Allerta Stencil', 'regular,'),array('Allura', 'regular,'),array('Almendra', 'regular,italic,700,700italic,'),array('Al