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 / 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"]
@wolffe
wolffe / tinywp.php
Created April 14, 2013 09:24
Tiny WordPress (tinywp.php) is a quick PHP script which auto-installs WordPress on any host. Just upload it via FTP and run it.
<?php
$n = basename($_SERVER['SCRIPT_NAME']);
unlink($n);
copy('http://wordpress.org/latest.zip', 'wordpress.zip');
$b = new ZipArchive;
$b->open('wordpress.zip');
for($i = 0; $i < $b->numFiles; $i++) {
$f = $b->getNameIndex($i);
$b->renameName($f, str_replace('wordpress/', '', $f));
}
@wolffe
wolffe / functions-1365759470.php
Last active December 16, 2015 03:38
Show category posts in page, two-column formatting, cleared floats.
<?php
function pp_custom_content($atts) {
extract(shortcode_atts(array(
'type' => '',
'cat' => '',
), $atts));
$am_display = '';
$loop = new WP_Query(array('post_type' => $type, 'posts_per_page' => 10, 'category_name' => $cat));
while($loop->have_posts()) : $loop->the_post();
<?php
function basic_bs_register_settings() {
register_setting('basic_bs_settings_group', 'basic_bs_settings');
}
add_action('admin_init', 'basic_bs_register_settings');
$basic_bs_options = get_option('basic_bs_settings');
function business_tools_admin_menu() {
@wolffe
wolffe / Woocommerce Cleaner
Created March 15, 2013 21:25
Remove all products from Woocommerce (SQL query)
DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type = 'product');
DELETE FROM wp_posts WHERE post_type = 'product';
<?php
/**
* Plugin Name: Delay post publishing
* Plugin URI: http://unserkaiser.com
* Description: Only allows publishing a post if the user registered one week ago.
* Version: 0.1
* Author: Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Not a WordPress context? Stop. Why? Ask @toscho
@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);