Skip to content

Instantly share code, notes, and snippets.

View colloquet's full-sized avatar

Colloque Tsui colloquet

View GitHub Profile
@colloquet
colloquet / text-php.php
Last active December 4, 2015 12:07
WordPress - execute php code in text widgets
<?php
// add this to your theme's functions.php
// execute php code in text widgets
add_filter('widget_text','execute_php',100);
function execute_php($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);
$html=ob_get_contents();
@colloquet
colloquet / editor_gform.php
Last active December 4, 2015 12:07
WordPress - give Editor Access to Gravity Forms
<?php
// add this to your theme's functions.php
// give Editor Access to Gravity Forms
function add_grav_forms(){
$role = get_role('editor');
$role->add_cap('gform_full_access');
}
add_action('admin_init','add_grav_forms');
@colloquet
colloquet / superscript.php
Last active December 4, 2015 12:08
WordPress - Add superscript and subscript buttons
<?php
// for superscript (e.g. 4th)
function my_mce_buttons_2($buttons) {
$buttons[] = 'superscript';
$buttons[] = 'subscript';
return $buttons;
}
add_filter('mce_buttons_2', 'my_mce_buttons_2');