Skip to content

Instantly share code, notes, and snippets.

View wolffe's full-sized avatar
🏠
Working from home

Ciprian Popescu wolffe

🏠
Working from home
View GitHub Profile
@wolffe
wolffe / Pagination.php
Last active September 1, 2017 01:55
Pagination class for custom WordPress tables
<?php
/*
* Pagination class for WordPress 4.7+ and PHP 7+
*/
class Pagination {
var $total_pages = -1;
var $limit = 20;
var $target = '';
var $page = 1;
var $adjacents = 1;
@wolffe
wolffe / chip-scan.php
Created February 1, 2016 12:58
base64 Scanner
<html>
<head>
<title>Find String</title>
</head>
<body>
<?php
ini_set('max_execution_time', '0');
ini_set('set_time_limit', '0');
find_files('.');
@wolffe
wolffe / functions-1424101035.php
Last active August 29, 2015 14:15
Numbered siblings (child page navigation)
<?php
// the menu_order parameter has been added to account for custom page ordering
function numbered_siblings($link) {
global $post;
$siblings = get_pages('child_of=' . $post->post_parent . '&parent=' . $post->post_parent . '&sort_column=menu_order');
foreach($siblings as $key=>$sibling) {
if($post->ID == $sibling->ID) {
$ID = $key;
}
}
<?php
// add a shortcode to place on the submission page (or post)
add_shortcode('videowizard', 'videowizard_main'); // shortcode, function
// create attachments column
function videodjin_custom_column($column_name, $post_id) {
global $wpdb;
if($column_name == 'attachments') {
$query = "SELECT post_title, ID FROM $wpdb->posts WHERE post_type='attachment' AND post_parent='$post_id'";
$attachments = $wpdb->get_results($query);
@wolffe
wolffe / butterflies.css
Last active December 30, 2015 18:59
CSS normalization addon (fonts, box sizing and hardware acceleration).
* {
/**
* Improve font rendering and readability/legibility on MacOS and Windows
*/
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-moz-font-feature-settings: "liga=1, dlig=1";
@wolffe
wolffe / functions-1373297449.php
Created July 8, 2013 15:32
This function emulates WordPress wpautop() function for custom PHP scripts, parses URL addresses and adds smilies/emoticons.
<?php
function smilieMe($text) {
$smiliesFind = array(
'/:\)/',
'/:P/',
'/:D/',
'/:S/',
'/:\(/',
'/:8/',
'/:tea/',
@wolffe
wolffe / wpf-guestinfo.php
Created July 1, 2013 17:19
Mingle Forum Guest Info allows you to enable guest posts to Mingle Forum without registration while still collecting contributor's email info. This version is an update from the original, outdated 1.0.1.
<?php
/*
Plugin Name: Mingle Forum Guest Info
Plugin URI: http://wpweaver.info/plugins/
Description: This is an add on to the Mingle Forum. It allows you allow geust posts without registration while requiring a name and e-mail to make posts easier to track.
Version: 1.0.2
Author: Bruce Wampler
Author URI: http://wpweaver.info
Text Domain: mingleforumguest
Copyright: 2009-2011, Bruce Wampler
@wolffe
wolffe / addon-contact-form.php
Created July 1, 2013 08:30
PHP contact form with spam check and honeypot features.
<?php if(!isset($_POST['send'])) { ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<noscript><input type="hidden" name="havejs" id="havejs"></noscript>
<input type="hidden" name="send" value="send">
<!-- spam bait - if the bcc field contains anything, this email is rejected -->
<!--<input type="text" name="bcc" />-->
<!--<label for="bcc">Bcc</label>-->
<p><input type="text" name="name" required><label for="name">Name</label></p>
<p><input type="text" name="phone" required><label for="phone">Phone</label></p>
@wolffe
wolffe / find-string.php
Created June 7, 2013 12:48
This file searches for a particular string inside your files. Replace "wso" in line 31 with anything you want and it will search all your files for that string. A list of possible patterns is commented at the top.
<?php
/*
* POSSIBLE PATTERNS="passthru|shell_exec|system|phpinfo|base64_decode|popen|exec|proc_open|pcntl_exec|python_eval|fopen|fclose|readfile"
*/
ini_set('max_execution_time', '0');
ini_set('set_time_limit', '0');
find_files('.');
function find_files($seed) {
if(!is_dir($seed)) return false;
$files = array();
@wolffe
wolffe / functions-1367499210.php
Last active December 16, 2015 21:48
[WordPress] Show Page Content Inside Page
<?php
function my_show_page($atts) {
extract(shortcode_atts(array('page_id' => 0), $atts));
$page = get_page($page_id);
return apply_filters('the_content', $page->post_content);
}
add_shortcode('my_show_page', 'my_show_page');
// [my_show_page page_id="999"]