By: Jonas Nordström, @windyjonas
Date: 2013-04-16
esc_attr( $text );
Encodes the <, >, &, " and ' (less than, greater than, ampersand, double quote and single quote) characters. Will never double encode entities.
Example:
| <?php | |
| // first get two related time settings | |
| $zone = get_option('timezone_string'); | |
| $gmto = get_option('gmt_offset'); | |
| // is it a name based timezone selection? then create the offset | |
| if (!empty($zone)) { | |
| $zone = new DateTimeZone($zone); | |
| $offs = $zone->getOffset(new DateTime); |
| # BEGIN wp-login.php blocks | |
| <Files wp-login.php> | |
| order allow,deny | |
| deny from 31.184.238.38 | |
| deny from 178.151.216.53 | |
| deny from 91.224.160.143 | |
| deny from 195.128.126.6 | |
| deny from 85.114.133.118 | |
| deny from 177.125.184.8 | |
| deny from 89.233.216.203 |
| <?php | |
| // enqueue the script, | |
| // this fails gracefully if no 'heartbeat' script is registered | |
| wp_enqueue_script('heartbeat'); |
| <?php | |
| // Read the original blog post here to understand what this is: | |
| // http://simple-fields.com/2013/status-board-panel-to-show-wordpress-plugin-downloads/ | |
| define('WP_USE_THEMES', false); | |
| define("WP_CACHE", false); // i get 404 if enabled | |
| require('../wordpress/wp-blog-header.php'); | |
| class panic_dashboard_wp_plugin_stats { |
| <?php | |
| /* | |
| * Solution to order first by date, then by start time (both are meta values) | |
| * http://wordpress.stackexchange.com/a/67391/5045 | |
| * */ | |
| add_action( 'pre_get_posts', 'pre_get_posts_programpunkter' ); | |
| function pre_get_posts_programpunkter( $query ) { | |
| if( !is_admin() && is_post_type_archive( 'programpunkt' ) && $query->is_main_query() ) { |
| <?php | |
| function create_onetime_nonce( $action = -1 ) { | |
| $time = time(); | |
| $nonce = wp_create_nonce( $time . $action ); | |
| set_transient( '_nonce_' . $time, 1, 60*60 ); // adjust the lifetime of the transient | |
| return $nonce . '-' . $time; | |
| } | |
| function verify_onetime_nonce( $_nonce, $action = -1 ) { | |
| @list( $nonce, $time ) = explode( '-', $_nonce ); |
| <?php | |
| /* | |
| Plugin Name: Heartbeat API Demo | |
| Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo | |
| Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6. | |
| Version: .1 | |
| Author: strangerstudios | |
| If logged in as a user and viewing the frontend of your website, | |
| every 15 seconds you should see the following in your Javascript console: |
| <?php | |
| /* | |
| * Plugin Name: Commercial Client | |
| * Plugin URI: http://pento.net/ | |
| * Description: A sample client plugin for showing updates for non-WordPress.org plugins | |
| * Author: pento | |
| * Version: 0.1 | |
| * Author URI: http://pento.net/ | |
| * License: GPL2+ | |
| */ |