This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Select the count of posts grouped by year, month, day, hour, even minutes and seconds! | |
SELECT | |
-- Number of posts on the specified time range | |
COUNT(*) as "count", | |
-- Time values to return | |
-- These should also be listed under "group by" | |
-- If sorting is necessary, also include these in "order by" | |
YEAR(p.post_date) as "year", | |
MONTH(p.post_date) as "month", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ---------------------------- | |
Parse a string with percent-signed wildcards, where the wildcards are PHP date characters. | |
Example: | |
$string = "Today is %F %j%S" | |
Returns: Today is January 1st | |
*/ | |
function parse_date($string, $date = false) { | |
if ( !$date ) $date = time(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
--- Send mail using SMTP | |
Parameters: | |
to (string - required, email address of recipient) | |
to_name (string -optional, name of recipient | |
from (string - required, email address of sender) | |
from_name (string - optional, name of sender) | |
subject (string - optional, inherits 40 char from body if blank) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function change_wp_mail_sender( $phpmailer ) { | |
$from_name = 'My Website'; | |
$from_email = get_option('admin_email'); // The same email seen in Settings > General | |
if ( | |
// We should always have these parameters, but it doesn't hurt to avoid errors in the future | |
property_exists( $phpmailer, 'From' ) | |
&& property_exists( $phpmailer, 'FromName' ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$image = abjj_upload_image('profile_picture', $existing_image, 'abjj_process_profile_picture' ); | |
echo '<pre style="font-size: 11px;">RESULT: ---------------------------', "\n", | |
htmlspecialchars( print_r( $image, true)), | |
'</pre>'; | |
exit; | |
// Other functions | |
// Either process and upload a new image, or retrieve the old image | |
// $process is a callback that allows the image to be processed once uploaded via Wordpress' image editor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wpsc_get_owned_products( $user_id = false ) { | |
global $user_purchases, $wpdb; | |
// Get current user by default | |
if ( !$user_id ) { | |
$current = wp_get_current_user(); | |
if ($current) $user_id = $current->ID; | |
else return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomstr( length, digits ) { | |
if ( typeof length == 'undefined' ) length = 6; | |
if ( typeof digits == 'undefined' ) digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; | |
var str = ''; | |
for( i = 0; i < length; i++ ) str += digits.charAt( Math.floor( Math.random() * digits.length ) ); | |
return str; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* -------------------------------------------------- | |
/ If used within a plugin, you will want to run this function on plugin activation | |
/ For development, you can simply call the function below . To do this, uncomment | |
/ the line below, then visit any page. | |
-------------------------------------------------- */ | |
// custom_user_roles(); | |
function custom_user_roles() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This script prevents a function from running too frequently. | |
// Pick one of these three variations, then copy the code to a function of your choice. Do not copy the entire script. | |
// VARIATION A: Simply ignore any excessive function calls | |
// VARIATION B: Ignore excessive function calls, but call the function again once the limiter has expired. Ignore parameters. | |
// VARIATION C: Like variation B, call the function after limiter expired - but pass in function's parameters. | |
// Variation A ---------------- | |
// Replace 150 with the rate limit amount of your choice. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Accompanying CSS is commented below. | |
Example Usage: | |
show_lightbox("Hello World", "Good morning, friend", {ok_button: true}); | |
--- | |
show_lightbox( title, content, [options] ) | |
Title: The title of the lightbox. Optional. If only title is specified, the title will be used as content instead. |
OlderNewer