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 / 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 / facebook.comments.builder.php
Created October 10, 2012 21:23
Facebook Comments for SEO
<?php
// displays some comments for a certain url
$url = 'http://developers.facebook.com/docs/reference/fql/comment/';
// fql multiquery to fetch all the data we need to display in one go
$queries = array('q1' => 'select post_fbid, fromid, object_id, text, time from comment where object_id in (select comments_fbid from link_stat where url ="'.$url.'")',
'q2' => 'select post_fbid, fromid, object_id, text, time from comment where object_id in (select post_fbid from #q1)',
'q3' => 'select name, id, url, pic_square from profile where id in (select fromid from #q1) or id in (select fromid from #q2)',
);
@scarstens
scarstens / day_between_dates_and_utilities.inc.php
Created November 30, 2012 01:44
Days and Dates Calculation Functions
//pass the function the MySQL standardized date and retreive a date relative to wordpress GMT and wordpress date and time display options
if(!function_exists('sm_display_date')) { function sm_display_date($mysqldate) {
$display_date = date_i18n( get_option('date_format').' '.get_option('time_format'),strtotime($mysqldate), get_option('gmt_offset') );
return $display_date;
}}
//pass the function a UNIX TIMESTAMP or "Properly Formated Date/Time" and retreive a date formated for MySQL database date field type
//optionally pass a number of days to return a time XX days before or after the date/time sent
if(!function_exists('sm_mysql_date')) { function sm_mysql_date($time, $days = 0) {
$seconds = 60*60*24*$days;
@scarstens
scarstens / process-wp-image-uploads.php
Last active December 12, 2015 08:18
Process WordPress image uploads
// now upload the new images
$postvals = cp_process_new_image($_POST['ad_id']);
// associate the already uploaded images to the ad and create multiple image sizes
$attach_id = cp_associate_images($_POST['ad_id'], $postvals['attachment']);
//process each image thats being uploaded
function cp_process_new_image() {
global $wpdb;
$postvals = '';