Skip to content

Instantly share code, notes, and snippets.

View ryanhellyer's full-sized avatar

Ryan Hellyer ryanhellyer

View GitHub Profile
@ryanhellyer
ryanhellyer / disable-plugin-updates
Created November 29, 2012 19:04
Code to disable WordPress plugin updates
<?php
/*
* Disable plugin updates
*
* @param array $r Response header
* @param string $url The update URL
*/
function slug_hidden_plugin( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r; // Not a plugin update request. Bail immediately.
@ryanhellyer
ryanhellyer / disable theme updates
Created November 29, 2012 19:05
Code to disable WordPress theme updates
<?php
/*
* Disable theme updates
*
* @param array $r Response header
* @param string $url The update URL
*/
function slug_hidden_theme( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) )
@ryanhellyer
ryanhellyer / check_ajax_referer_example
Created October 21, 2012 12:42
check_ajax_referer() example
<?php
check_ajax_referer( 'random_nonce_name' );
?>
@ryanhellyer
ryanhellyer / nonce-urls
Created October 21, 2012 12:41
nonce URLs
<?php
$link = home_url();
$link = wp_nonce_url( $link, 'random_nonce_name' );
?>
<a href="<?php echo $link; ?>">link</a>
@ryanhellyer
ryanhellyer / wp-nonce-field-example
Created October 21, 2012 12:40
wp_nonce_field example
<form action="" method="POST">
<?php wp_nonce_field( 'random_nonce_name' ); ?>
...
</form>
@ryanhellyer
ryanhellyer / user-permissions-check
Created October 21, 2012 12:39
User permissions check
<?php if ( current_user_can( 'manage_options' ) ) {
update_option( 'random_option', $_POST['random_option'] );
}
?>
@ryanhellyer
ryanhellyer / update-option-without-user-check
Created October 21, 2012 12:38
Updating an option without checking user permission
<?php
update_option( 'random_option', $_POST['random_option'] );
?>
@ryanhellyer
ryanhellyer / option-update-b4-form-print
Created October 21, 2012 12:38
Option updated before form printing
<?php
update_option( 'random_option', $_POST['random_option'] )
?>
<form action="" method="POST">
<input type="text" name="random_option" value="" />
<input type=submit" value="Submit" />
</form>
@ryanhellyer
ryanhellyer / check_admin_referer example
Created October 21, 2012 12:42
check_admin_referer example
<?php
check_admin_referer( 'random_nonce_name' );
?>
@ryanhellyer
ryanhellyer / sanitized_php_self_link
Created October 7, 2012 14:07
Sanitized php_self link