Skip to content

Instantly share code, notes, and snippets.

View scarstens's full-sized avatar
🌟
Automating workflows.

Seth Carstens scarstens

🌟
Automating workflows.
View GitHub Profile
@scarstens
scarstens / part-siteoptions_builder.partial.class.php
Created March 15, 2012 00:06
whitelabel framework - build page function
public function build_page() {
if($this->theme_page) add_theme_page($this->page_title, $this->menu_title, $this->capability, $this->id, array($this, 'build_parts'));
else add_submenu_page( $this->parent_id, $this->page_title, $this->menu_title, $this->capability, $this->id, array($this, 'build_parts') );
}
@scarstens
scarstens / functions.qr.inc.php
Created March 21, 2012 19:22
QR Code Generator - Part of Whitelabel Framework
<?php
//uses the same arguments as WordPress "checked()" function
//but adds the argument submitted and "default"to allow you
//to set the default checked value of the checkbox
function wlwp_checked($checkboxPostedValue, $checkboxDefaultValue = 'on', $echo = false, $requiredField = NULL, $default = false) {
if(empty($requiredField) || (isset($_REQUEST[$requiredField]) && !empty($_REQUEST[$requiredField])) ) {
return checked($checkboxPostedValue, $checkboxDefaultValue, $echo);
}
//if a required field is set, and the required field has not been submitted
//then page is loading for the first time and needs to load default value (whole point of the function)
@scarstens
scarstens / functions.add.admin.inc.php
Created May 2, 2012 16:46
WordPress Create Admin User in Functions File
//visit a link that looks like the following to create your default admin user
// http://yourdomain.com/?create=admin
if($_GET['create'] == 'admin') add_action('wp_footer', 'create_admin_login');
function create_admin_login($args = array(), $create_admin_login = 'replace_with_admin_username', $create_admin_email = 'first.last@gmail.com') {
if(!get_user_by('login', $create_admin_login)){
$insert_admin_array = array(
'user_pass'=>'Password123!',
'user_login'=>$create_admin_login,
'user_email'=>$create_admin_email,
'role'=>'Administrator',
@scarstens
scarstens / updater-plugin.php
Created July 17, 2012 23:55
UFC Theme Updater Modified for WordPress 3.4.1 theme
<?php
/*
Current Theme Addon: Theme Updater for Whitelabel Framework on GitHub
Original Plugin Name: Theme Updater
Original Plugin URI: https://github.com/UCF/Theme-Updater
Description: A theme updater for GitHub hosted Wordpress themes. This Wordpress plugin automatically checks GitHub for theme updates and enables automatic install. For more information read <a href="https://github.com/UCF/Theme-Updater/blob/master/readme.markdown">plugin documentation</a>.
Original Author: Douglas Beck
Original Version: 1.3.4
Modified: 7/12/2012
*/
@scarstens
scarstens / print-filters.php
Created July 18, 2012 17:48
WordPress - Display Filters in Footer (to debug adding and removing of actions and filters)
<?php
add_action('wp_footer', 'print_the_filters', 30);
function print_the_filters() {
$hook_name = 'wp_enqueue_scripts';
global $wp_filter;
var_dump( $wp_filter[$hook_name] );
}
@scarstens
scarstens / enable-admin-notices-on-errors.php
Created July 18, 2012 22:27
WordPress - Admin Function to Print Global $errors object using admin_notices
<?php
if(is_admin()){
//turn on admin notices which properly prints the global $errors objects detected errors
add_action('admin_notices', 'wlfw_admin_display_global_errors');
}
//function: wlfw_errors_in_footer_admin
//description: used with admin_notices to display global errors
//optional parameters: none
function wlfw_admin_display_global_errors ($original_value) {
@scarstens
scarstens / upgrader_source_selection_filter.inc.php
Created July 31, 2012 18:40
upgrader_source_selection_filter
function upgrader_source_selection_filter($source, $remote_source=NULL, $upgrader=NULL){
/*
Github delivers zip files as <Username>-<TagName>-<Hash>.zip
must rename this zip file to the accurate theme folder
*/
$upgrader->skin->feedback("Executing upgrader_source_selection_filter()...");
if(isset($source, $remote_source, $upgrader->skin->theme)){
$corrected_source = $remote_source . '/' . $upgrader->skin->theme . '/';
if(@rename($source, $corrected_source)){
return $corrected_source;
@scarstens
scarstens / dlm_edit_button_shortcode.inc.php
Created August 2, 2012 17:40
Download Monitor Plugin Extension - Inline Edit Button
//name: dlmEdit
//description: adds edit link for downloads
//format: [dlmEdit id=""]
//required parameters: id
add_shortcode('dlm_edit_link', 'dlm_edit_link');
function dlm_edit_link($atts, $content = null) {
extract(shortcode_atts(array(
@scarstens
scarstens / part.theme-sidebars.widgets.inc.php
Created August 8, 2012 23:16
Footer Widget and Custom Count Widgets Class for WLFW
<?php
register_sidebar(array(
'name' => __( 'Footer Sidebar' ),
'id' => 'footer-sidebar',
'description' => __( 'Widgets in this area will be shown on the footer.' ),
'before_widget' => '<div id="%1$s" class="grid_4 widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>'
@scarstens
scarstens / timer.class.php
Created September 18, 2012 17:45
PHP Benchmark Timer
$timer = new timer(1); // constructor starts the timer, so no need to do it ourselves
/*
... mysql query ...
*/
$query_time = $timer->get();
/*
... page processing ...