Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Hellyer ryanhellyer

View GitHub Profile
@ryanhellyer
ryanhellyer / SharePulse.php
Last active Aug 29, 2015
Allow for addition of extra post-types by providing a filter on the get_posts() arguments.
View SharePulse.php
--- <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 Nov 29, 2012
Code to disable WordPress theme updates
View disable 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 Nov 29, 2012
Code to disable WordPress plugin updates
View disable-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 Oct 21, 2012
check_ajax_referer() example
View check_ajax_referer_example
<?php
check_ajax_referer( 'random_nonce_name' );
?>
View check_admin_referer example
<?php
check_admin_referer( 'random_nonce_name' );
?>
View nonce-urls
<?php
$link = home_url();
$link = wp_nonce_url( $link, 'random_nonce_name' );
?>
<a href="<?php echo $link; ?>">link</a>
View wp-nonce-field-example
<form action="" method="POST">
<?php wp_nonce_field( 'random_nonce_name' ); ?>
...
</form>
View 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 Oct 21, 2012
Updating an option without checking user permission
View update-option-without-user-check
<?php
update_option( 'random_option', $_POST['random_option'] );
?>
@ryanhellyer
ryanhellyer / option-update-b4-form-print
Created Oct 21, 2012
Option updated before form printing
View option-update-b4-form-print
<?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>