Skip to content

Instantly share code, notes, and snippets.

<?php
add_action('phpmailer_init', 'phpmailerSMTP');
/**
* @param \PHPMailer $phpmailer
*/
function phpmailerSMTP($phpmailer)
{
$phpmailer->IsSMTP();
<?php
add_action('init', 'my_theme_init');
function my_theme_init() {
if (!is_plugin_active()) {
return;
}
//do things here, plugin is active.
@BinaryKitten
BinaryKitten / xkcd-password.php
Created March 22, 2016 21:17
xkcd-password-wordpress.php
<?php
/*
* Generate xkcd style password from /usr/share/dict/words
*
* http://xkcd.com/936/
* apt-get install wamerican
*/
if (!function_exists('wp_generate_password')) :
$filesize = @filesize('/usr/share/dict/words');
if ($filesize !== false):
jQuery(function ($) {
var $mainContent = $('#main-content'),
$cat_links = $('.category-filters li a')
;
$cat_links.on('click', function (e) {
e.preventDefault();
var $el = $(this),
value = $el.attr("href")
;
<?php
function insertPost( $post ) {
$wp_post = (array) $post;
$wp_postId = $wp_post['ID'];
unset($wp_post['ID']);
$wp_post['post_author'] = $this->user_id;
$wp_post['guid'] = str_replace( $baseUrl, $newUrl, $wp_post['guid'] );
@BinaryKitten
BinaryKitten / functions.php
Created January 11, 2016 15:50
functions.php
<?php
add_action('plugins_loaded', function() {
if (is_plugin_active($pluginFile) {
add_action('wp_head', function() {
echo '<style>/** correction for plugin **/ stupid.override { display: annoyed; }</style>';
});
});
})
@BinaryKitten
BinaryKitten / autoloader.php
Created December 4, 2015 11:23
ThemeAutoloader
<?php
spl_autoload_register( 'my_theme_autoloader' );
function my_theme_autoloader( $class_name ) {
if ( substr( $class_name, 0, 6 ) == 'theme_' ) {
$cur_theme_file = get_stylesheet_directory() . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_name . '.php';
$parent_theme_file = get_template_directory() . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . $class_name . '.php';
if ( file_exists( $cur_theme_file ) ) {
require_once $cur_theme_file;
} elseif ( file_exists( $parent_theme_file ) ) {
<?php
return [
'version' => '1.0.0',
'table' => 'table_name',
'info' => [
'item' => [
'name' => 'cherry',
'value' => 'pick'
]
<?php
$email = new Input();
$notEmptyEmailValidator = new NotEmpty();
$notEmptyEmailValidator->setMessages([
NotEmpty::INVALID => 'Please enter an Email Address',
NotEmpty::IS_EMPTY => 'Please enter an Email Address',
]);
<?php
$range = range(1, $rc);
$qs = implode(',', array_fill(0,$rc, '?'));
$titleQuery = $db->prepare('SELECT tablename_id, tablename_title, table_type, table_attribute FROM tablename WHERE tablename_id IN (' . $qs . ') ORDER BY tablename_title;');
$titleQuery->execute($range);
$tableNames = $titleQuery->fetchAll(PDO::FETCH_ASSOC);
//$rc is a variable that stores the row count of the particular table
foreach($tableNames as $tablename_data) {