Skip to content

Instantly share code, notes, and snippets.

View Zenger's full-sized avatar
⌨️
=

Dennis Zenger Zenger

⌨️
=
View GitHub Profile
@Zenger
Zenger / WP Utils.php
Last active May 10, 2022 07:43
A small class with usefull functions in it.
<?php
class Utils
{
public static function init()
{
self::header_cleanup();
}
public static function header_cleanup()
@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 / envato-class.php
Created January 23, 2014 07:37
Confirm user license key on envato marketplaces
<?php
class Envato
{
protected static $key = "";
protected static $username = "";
public static function verify( $code )
@Zenger
Zenger / elementaryos-peerflix-magnet
Created May 23, 2015 09:59
Peerflix Magnet Link Elementary OS Fix
#!/bin/bash
pantheon-terminal -e "peerflix \"$1\" -v --clean"
sleep 1
rm -rvf /tmp/torrent-stream/*
#Assuming that you're using panthon-terminal and you have installed nodejs and peerflix
#Save this file as a script, paste it anywhere, chmod u+x on it.
#In your browser click on a magnet link, point it to your new script and voila
#NOTE: !!! You can use xterm instead of pantheon-terminal if you like.
@Zenger
Zenger / move-files.php
Created January 23, 2014 07:32
Small class for moving whole directory structures. Unlike other solutions it builds up an array with directory structure. Possibly buggy :)
<?php
class LazyRecursiveMove
{
var $files = array();
var $dest = array();
var $from = "";
var $to = "";
function build_move_array( $from , $to, $parent = "" )
@Zenger
Zenger / gwf.php
Created January 23, 2014 07:20
Generate a list of webfonts from google.
<?php
define('APIKEY', 'your-api-key');
$request = file_get_contents('https://www.googleapis.com/webfonts/v1/webfonts?key='. APIKEY);
$fh = fopen('list.txt', 'w');
fwrite($fh, $request);
fclose($fh);
$content = json_decode($request) ;
@Zenger
Zenger / options.php
Created January 22, 2014 07:22
A class for the lazy to add options to the general screen
<?php
class sOption {
var $field;
public function __construct( $name = 'setting', $label = 'Your Setting', $type = 'text', $screen = 'general' )
{
$this->field->name = $name;
$this->field->type = $type;
$this->field->screen = $screen;
@Zenger
Zenger / search-replace-db.php
Last active December 29, 2015 17:19
Search and replace db 2 modified. A modified version of interconnectit.com tool. Modified to support json_encoded strings. Can search and replace in regular strings, serialized strings and json_encoded strings.
<?php
/**
* @modified: Zenger
* Safe Search and Replace on Database with Serialized Data v2.0.1b
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@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 / 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)