This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: My Plugin | |
* Plugin Description: Settings API Demo | |
*/ | |
add_action( 'admin_menu', 'my_admin_menu' ); | |
function my_admin_menu() { | |
add_options_page( 'My Plugin', 'My Plugin', 'manage_options', 'my-plugin', 'my_options_page' ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Static Templates | |
* | |
* If most of your site content is in .php template files, and you're tired of | |
* creating new pages, assigning them page templates, creating page templates | |
* then doing it all over again on production, this plugin is for you. | |
* | |
* Examples: | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function __array_append( $item ) { | |
return function( $array ) use ( $item ) { | |
$array[] = $item; | |
return $array; | |
}; | |
} | |
function __array_set( $key, $value ) { | |
return function( $array ) use ( $key, $value ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Image shortcode callback | |
* | |
* Enables the [kovshenin_image] shortcode, pseudo-TimThumb but creates resized and cropped image files | |
* from existing media library entries. Usage: | |
* [kovshenin_image src="http://example.org/wp-content/uploads/2012/03/image.png" width="100" height="100"] | |
* | |
* @uses image_make_intermediate_size | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Dirty, easy to miss a ' or " or . | |
echo '<a href="' . get_permalink() . '" class="link">' . get_the_title() . '</a>'; | |
// Clean, easier to read | |
printf( '<a href="%s" class="link">%s</a>', get_permalink(), get_the_title() ); | |
// Almost as clean, and more secure, maybe a little paranoic :) | |
printf( '<a href="%s" class="link">%s</a>', esc_url( get_permalink() ), esc_html( get_the_title() ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'muplugins_loaded', function() { | |
if ( defined( 'WP_CLI' ) && WP_CLI ) { | |
return; | |
} | |
if ( empty( $_SERVER['HTTP_HOST'] ) ) { | |
return; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: My Plugin | |
*/ | |
class My_Plugin_Test_AJAX_Scripts { | |
function __construct() { | |
add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) ); | |
add_action( 'wp_head', array( $this, 'wp_head' ), 99 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inside the server {} block | |
location @imgproxy { | |
proxy_ssl_server_name on; | |
proxy_ssl_name imgproxy.ondigitalocean.app; | |
proxy_set_header Host imgproxy.ondigitalocean.app; | |
proxy_set_header If-Modified-Since ""; | |
proxy_set_header ETag ""; | |
proxy_set_header Cache-Control ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In the main {} context | |
map $http_user_agent $imgproxy { | |
"~imgproxy" 1; | |
default 0; | |
} | |
map $http_accept $webp_suffix { | |
"~image/webp" "@webp"; | |
default ""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Pressjitsu Remote HTTP Cache | |
* | |
* Many plugins like to perform remote HTTP requests for front-end visits, | |
* sometimes without even employing transient caching. We think that *all* HTTP | |
* requests should run in the background, and thus be always served from cache, | |
* even if the cache is stale. | |
* | |
* Configure cachable hosts via the pj_http_cache_hosts filter. |
NewerOlder