Skip to content

Instantly share code, notes, and snippets.

@Dragooon
Dragooon / Sentence.php
Last active December 27, 2015 19:11
DI example
<?php
class Sentence
{
public function getWordsFromString($sentence)
{
$words = explode(' ', $sentence);
foreach ($words as $k => $word) {
$words[$k] = new Word($word); // I want this to not be hardcoded, but injected
}
<?php
/*
Plugin Name: 2Checkout Payment Gateway
Plugin URI:
Description: Allows you to use 2Checkout payment gateway with the WooCommerce plugin.
Version: 0.0.1
Author: Craig Christenson
Author URI: https://www.2checkout.com
*/
<?php
/**
* This file is the main Package Manager.
*
* Simple Machines Forum (SMF)
*
* @package SMF
* @author Simple Machines http://www.simplemachines.org
* @copyright 2014 Simple Machines and individual contributors
function constructPageIndex($base_url, &$start, $max_value, $num_per_page, $flexible_start = false, $show_prevnext = true)
{
global $modSettings, $context, $txt, $smcFunc;
// Save whether $start was less than 0 or not.
$start = (int) $start;
$start_invalid = $start < 0;
// Make sure $start is a proper variable - not less than 0.
if ($start_invalid)
@Dragooon
Dragooon / poc.php
Last active August 29, 2015 13:57
Proof of Concept for per-post roles and capabilities
<?php
/**
* Proof of concept for per-post roles and capabilities
*
* The meta is stored for a page under _post_capabilities postmeta as an array having ->
* [<user_id>] => array(
* 'user_id' => ID of the user
* 'role' => <name of the role>
* 'capabilities' => (array) <list of custom capabilities an admin might want to assign>
@Dragooon
Dragooon / poc.php
Last active August 29, 2015 13:57
Proof of Concept for bbPress' per forum moderation
<?php
/**
* Proof of concept for per-forum moderation
*
* Place this under wp-content/plugins/poc, activate it via Plugins section of WP Admin
* Add a row in postmeta table having the post_id of the forum you want to assign the moderator(s) to,
* meta_key as "_bbp_forum_moderators" and a comma separated list of the user's IDs you want
* to make moderators for the said forum
*
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
/*
* LimeSurvey (tm)
* Copyright (C) 2011 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant