Skip to content

Instantly share code, notes, and snippets.

View toddlahman's full-sized avatar

Todd Lahman toddlahman

View GitHub Profile
@toddlahman
toddlahman / gist:8974532
Created February 13, 2014 12:51
API Manager api_manager_extra_software_status_data filter hook function usage example
<?php
function api_manager_example_get_activation_info( $activation_info ) {
return $activation_info;
}
add_filter( 'api_manager_extra_software_status_data', 'api_manager_example_get_activation_info' );
@toddlahman
toddlahman / gist:6302280
Created August 22, 2013 01:35
Save Plugin Error Messages in the database for The Plugin Generated x Characters of Unexpected Output During Activation errors
<?php
function tl_save_error() {
update_option( 'plugin_error', ob_get_contents() );
}
add_action( 'activated_plugin', 'tl_save_error' );
/* Then to display the error message: */
@toddlahman
toddlahman / gist:6302114
Last active January 18, 2020 09:40
Prevent Duplicate Form Submissions with jQuery
jQuery(function() {
$("form").submit(function() {
// submit more than once return false
$(this).submit(function() {
return false;
});
// submit once return true
return true;
});
});
@toddlahman
toddlahman / gist:8974365
Last active July 4, 2017 00:30
API Manager api_manager_extra_software_activation_data filter hook function usage example
<?php
function api_manager_example_get_sku( $post_id, $data ) {
global $wpdb;
$sku = $wpdb->get_var( $wpdb->prepare( "
SELECT meta_value FROM {$wpdb->prefix}postmeta
WHERE post_id = %s
AND meta_key = '_sku'
LIMIT 1
@toddlahman
toddlahman / gist:6302252
Last active December 21, 2015 11:58
Wordpress Delete All Spam Comments
/* This SQL statement will remove all the unapproved comments at once: */
DELETE FROM wp_comments WHERE comment_approved = '0';
/* This SQL statement will remove all the spam comments at once: */
DELETE FROM wp_comments WHERE comment_approved = 'spam';
/* This SQL statement will remove all pingbacks and trackbacks: */
/**
* This goes in the main/root plugin file
*/
function my_plugin_url() {
return plugins_url( '/', __FILE__ );
}
@toddlahman
toddlahman / gist:8974499
Created February 13, 2014 12:48
API Manager api_manager_extra_software_status_data filter hook data array example.
Array
(
[status_check] => active
[status_extra] => Array
(
[order_key] => wc_order_52f8c4c896636_am_6wcotdeElO4l
[instance] => FIT0DTcFYUgd
[product_id] => API Manager Example
[activation_time] => 2014-02-13 02:40:46
[activation_active] => 1
@toddlahman
toddlahman / gist:8974260
Last active August 29, 2015 13:56
API Manager api_manager_extra_software_activation_data filter hook data array example.
Array
(
[activated] => 1
[instance] => wL3qHpt8HYJ7
[activation_extra] => Array
(
[user_id] => 2
[order_id] => 18
[order_key] => wc_order_52f8c4c896636
[license_email] => toddlahman@todds-macbook-pro.local
@toddlahman
toddlahman / gist:8974133
Last active August 29, 2015 13:56
API Manager Status Query String
http://localhost/toddlahman/?wc-api=am-software-api&email=toddlahman%40todds-macbook-pro.local&licence_key=wc_order_52ac24ebed6b0_am_HxntrDLPdYsM&request=status&product_id=API+Manager+Example&instance=gueGHcbrkdBQ&platform=localhost%2Ftoddlahman
0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58 * * * * wget -q -O - http://www.mydomainname.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1