Skip to content

Instantly share code, notes, and snippets.

View stefanbc's full-sized avatar
🖖
Do; or do not. There is no // TODO

Stefan Cosma stefanbc

🖖
Do; or do not. There is no // TODO
View GitHub Profile
@stefanbc
stefanbc / custom.js
Created May 9, 2013 19:30
Change select box options dynamically
// Change select box options based on value from another select box
$(document).ready(function(){
// If the user select a value from the select
$('#FIRST_SELECT').change(function(){
// Get the selected value
var get_eveniment = $(this).val();
@stefanbc
stefanbc / cron.php
Created May 9, 2013 10:38
Wordpress Cron Job
<?
echo '<h1>DirectAdmin</h1>';
echo '<i>php -q /home/DIRECTADMIN_USERNAME/domains/DOMAIN/public_html/wp-cron.php</i>';
echo '<hr>';
echo '<h1>cPanel</h1>';
echo '<i>php -q /home/CPANEL_USERNAME/public_html/wp-cron.php</i>';
@stefanbc
stefanbc / roles.php
Created April 4, 2013 11:48
Remove any Wordpress user role
<?php
require_once 'wp-load.php';
$wp_roles = new WP_Roles();
$wp_roles->remove_role("YOUR_ROLE"); // author, editor, contributor
$names = $wp_roles->get_names();
print_r($names);
?>
@stefanbc
stefanbc / mail.php
Created April 4, 2013 10:34
HTML wp_mail() with attachments
<?php
$headers = "MIME-Version: 1.0\r\n";
$headers .= 'From: ' . get_bloginfo('admin_email') . "\r\n";
$headers .= "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
$receiver = get_user_by('id', $receiver_id);
$giver = get_user_by('id', $giver_id);
$to = $receiver->user_email;
$subject = 'Subject';
@stefanbc
stefanbc / Headers
Created March 25, 2013 11:17
Cross Domain Ajax
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
?>
@stefanbc
stefanbc / Wordpress to Jekyll
Created January 8, 2013 20:19
If you need to migrate your blog from Wordpress to Jekyll there is a PHP code for it.
<?php
// This is the script I used to export my old blog out of WordPress and into a
// Jekyll friendly format. The first half exports posts, the second does pages.
// It's fairly specific to my needs, but maybe it'll be a good starting point
// for you. /RTH 2011-08-28
// https://twitter.com/#!/marcoarment/status/59089853433921537
date_default_timezone_set('America/Los_Angeles');
$db = mysql_connect('host', 'username', 'pass') or die(mysql_error());