Skip to content

Instantly share code, notes, and snippets.

View ryanhellyer's full-sized avatar

Ryan Hellyer ryanhellyer

View GitHub Profile
@ryanhellyer
ryanhellyer / SharePulse.php
Last active August 29, 2015 14:05
Allow for addition of extra post-types by providing a filter on the get_posts() arguments.
--- <SharePulse.php>
+++ <SharePulse.php>
@@ -159,14 +159,16 @@
$options = $this->get_sp_options();
- $ids = get_posts(array(
- 'orderby' => 'comment_count',
- 'posts_per_page' => -1,
- 'cache_results' => false,
@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 / 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 / check_ajax_referer_example
Created October 21, 2012 12:42
check_ajax_referer() example
<?php
check_ajax_referer( 'random_nonce_name' );
?>
@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 / 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>