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
[opcache] | |
; Determines if Zend OPCache is enabled | |
opcache.enable=1 | |
; Determines if Zend OPCache is enabled for the CLI version of PHP | |
;opcache.enable_cli=1 | |
; The OPcache shared memory storage size. | |
opcache.memory_consumption=512 |
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
// ref: https://stackoverflow.com/a/49228080 | |
$current_page = get_query_var('paged'); | |
$current_page = max( 1, $current_page ); | |
$per_page = 12; | |
$offset_start = 1; | |
$offset = ( $current_page - 1 ) * $per_page + $offset_start; | |
$post_list = new WP_Query(array( | |
'cat' => -15, |
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: Resize Original Upload | |
*/ | |
add_filter('wp_handle_upload', 'max_dims_for_new_uploads', 10, 2 ); | |
function max_dims_for_new_uploads( $array, $context ) { | |
// $array = array( 'file' => $new_file, 'url' => $url, 'type' => $type ) | |
// $context = 'upload' || 'sideload' |
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_filter( 'wp_image_editors', function( $editors ) { | |
if ( ! class_exists( '_WP_Image_Editor_GD' ) ) { | |
class _WP_Image_Editor_GD extends WP_Image_Editor_GD { | |
protected function _save( $image, $filename = null, $mime_type = null ) { | |
$saved = parent::_save( $image, $filename, $mime_type ); | |
if ( ! empty( $saved["mime-type"] ) && 'image/jpeg' == $saved["mime-type"] ) { | |
jpegoptim( $saved['path'] ); | |
} |
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: Photon CDN | |
* Version: 1.1 | |
* Description: Use the WP.com Photon image CDN without installing JetPack | |
* Author: Zachary Scott | |
*/ | |
namespace zacscott; |
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
METHOD 1 | |
ref: https://stackoverflow.com/a/41996977/1312563 | |
Disabling REST API was not a bad idea, after all. It actually opened a huge hole in all websites! | |
In wordpress 4.4 there was a way | |
Here, I've found a possible solution with .htaccess but should be carefully tested in combination with whatever else is in your .htaccess file (e.g., pretty-url rules added by wordpress itself): | |
# WP REST API BLOCK JSON REQUESTS | |
# Block/Forbid Requests to: /wp-json/wp/ |
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 | |
class WP_HTML_Compression | |
{ | |
// Settings | |
protected $compress_css = true; | |
protected $compress_js = true; | |
protected $info_comment = true; | |
protected $remove_comments = true; | |
// Variables |
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 | |
// Your functions.php content | |
function has_children() { | |
global $post; | |
$pages = get_pages('child_of=' . $post->ID); | |
return count($pages); |
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
<? | |
/** | |
* Repeatable Custom Fields in a Metabox | |
* Author: Helen Hou-Sandi | |
* | |
* From a bespoke system, so currently not modular - will fix soon | |
* Note that this particular metadata is saved as one multidimensional array (serialized) | |
*/ | |
function hhs_get_sample_options() { |
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 | |
$args = array( | |
'label' => '', // Text in Label | |
'class' => '', | |
'style' => '', | |
'wrapper_class' => '', | |
'value' => '', // if empty, retrieved from post meta where id is the meta_key | |
'id' => '', // required | |
'name' => '', //name will set from id if empty |
NewerOlder