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 / activate.php
Created March 21, 2017 17:21 — forked from eteubert/activate.php
WordPress: Find Users by Last Login Activity
<?php
register_activation_hook( __FILE__, 'add_last_activity_for_all_users' );
function add_last_activity_for_all_users() {
global $wpdb;
$sql = $wpdb->prepare( "
SELECT
u.ID
FROM
$wpdb->users AS u
@wolffe
wolffe / anonymous.php
Created March 21, 2017 17:20 — forked from eteubert/anonymous.php
WordPress: Thoughts on Filtering by Time
<?php
$age_filter = function ( $where = '' ) use ( $options ) {
$where .= " AND post_date > '" . date( 'Y-m-d', strtotime( '-' . $options[ 'max_post_age' ] ) ) . "'";
return $where;
};
add_filter( 'posts_where', $age_filter );
$query = new WP_Query( $args );
remove_filter( 'posts_where', $age_filter );
<?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() {
<?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