Skip to content

Instantly share code, notes, and snippets.

Avatar
🌟
Automating workflows.

Seth Carstens scarstens

🌟
Automating workflows.
View GitHub Profile
@scarstens
scarstens / part-siteoptions_builder.partial.class.php
Created Mar 15, 2012
whitelabel framework - build page function
View part-siteoptions_builder.partial.class.php
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 Mar 21, 2012
QR Code Generator - Part of Whitelabel Framework
View functions.qr.inc.php
<?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
WordPress Create Admin User in Functions File
View functions.add.admin.inc.php
//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 Jul 17, 2012
UFC Theme Updater Modified for WordPress 3.4.1 theme
View updater-plugin.php
<?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 Jul 18, 2012
WordPress - Display Filters in Footer (to debug adding and removing of actions and filters)
View print-filters.php
<?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 Jul 18, 2012
WordPress - Admin Function to Print Global $errors object using admin_notices
View enable-admin-notices-on-errors.php
<?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) {
View upgrader_source_selection_filter.inc.php
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 Aug 2, 2012
Download Monitor Plugin Extension - Inline Edit Button
View dlm_edit_button_shortcode.inc.php
//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 Aug 8, 2012
Footer Widget and Custom Count Widgets Class for WLFW
View part.theme-sidebars.widgets.inc.php
<?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 Sep 18, 2012
PHP Benchmark Timer
View timer.class.php
$timer = new timer(1); // constructor starts the timer, so no need to do it ourselves
/*
... mysql query ...
*/
$query_time = $timer->get();
/*
... page processing ...