This file contains hidden or 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 | |
| // Drop-in replacement for apache_request_headers() when it's not available | |
| if ( ! function_exists( 'apache_request_headers' ) ) { | |
| function apache_request_headers() { | |
| static $arrHttpHeaders; | |
| if ( ! $arrHttpHeaders ) { | |
| // Based on: http://www.iana.org/assignments/message-headers/message-headers.xml#perm-headers | |
| $arrCasedHeaders = array( |
This file contains hidden or 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
| #!/bin/bash | |
| # this file is related to a series of posts on my website, see | |
| # https://remonpel.nl/2012/10/semi-automatically-rebuild-apache-vhost-configuration/ | |
| # this script is ANYTHING BUT optimal | |
| # it works as it is very well on macOS, Ubuntu and "Bash on Ubuntu on Windows with WSL" | |
| # WSL is a seriously crippled way to use anything linux related, but if you are brave enough, you should try it. | |
| # If you have better ways of doing things, send me a note :) |
This file contains hidden or 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 | |
| /** | |
| * Adds a divi builder to given custom post types and globalize all section templates | |
| * | |
| * @return array All post-type-names | |
| * @uses get_post_types() | |
| */ | |
| function divi_overrule_post_types() { | |
| return get_post_types(); | |
| } |
This file contains hidden or 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_shortcode('label_link', 'label_link'); | |
| function label_link($atts, $content='') { | |
| $field = $text = $target = $href = false; | |
| extract( shortcode_atts( compact('field', 'text', 'target', 'href' ), $atts ) ); | |
| if (!$field || !$text || !$href) { | |
| return false; | |
| } |
This file contains hidden or 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
| --- wp-paginate.php 2017-01-18 09:54:43.000000000 +0100 | |
| +++ wp-paginate-fixed.php 2017-01-18 10:00:56.000000000 +0100 | |
| @@ -537,17 +537,17 @@ | |
| <table class="form-table"> | |
| <tr valign="top"> | |
| <th scope="row"><?php _e('Pagination Label:', 'wp-paginate'); ?></th> | |
| - <td><input name="title" type="text" id="title" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['title'])); ?>"/> | |
| + <td><input name="title" type="text" id="title" size="40" value="<?php echo esc_attr(stripslashes(htmlspecialchars($this->options['title']))); ?>"/> | |
| <span class="description"><?php _e('The optional text/HTML to display before the list of pages.', 'wp-paginate'); ?></span></td> | |
| </tr> |
This file contains hidden or 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 wp_add_image_id_to_img_tags( $content ) { | |
| if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) { | |
| return $content; | |
| } | |
| $selected_images = array(); | |
| /*array*/$uploads = wp_upload_dir(); | |
| /*fullpath*/$uploads = $uploads['basedir']; |
This file contains hidden or 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 | |
| // this gist is an example for updating a custom array-meta-data whenever EMR replaces a media file and renames it. | |
| add_action('enable-media-replace-upload-done', 'more_to_do_emr'); | |
| function more_to_do_emr( $new_guid ) { | |
| global $wpdb; | |
| // get attachments meta data | |
| $attachment_id = (int) $_POST["ID"]; | |
| if (!$attachment_id) | |
| return; | |
| $meta_ids = $wpdb->get_col("SELECT meta_id FROM {$wpdb->postmeta} where meta_key = 'attachments' AND meta_value LIKE '%i:{$attachment_id};%'"); |
This file contains hidden or 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 | |
| // put this below the database definitions and the $table_prefix line in wp-config.php. | |
| // functionnames are random hashes to prevent with almost certainty any conflict. | |
| // this is not intended as security by obscurity, the original functionnames are in comment | |
| // requires PDO | |
| // written for wordpress, but easily adapted for use in any other PHP framework. | |
| function func46CA242BADDB4B579F2BC69A4BF300AB($set=null) { // store_or_get_error_handler_name | |
| static $error_handler; |
This file contains hidden or 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
| var localStorageEnabled = false; | |
| if ('localStorage' in window) { | |
| localStorageEnabled = true; | |
| try { | |
| localStorage.setItem('localStorage', 1); | |
| localStorage.removeItem('localStorage'); | |
| } catch (e) { | |
| localStorageEnabled = false; | |
| Storage.prototype._setItem = Storage.prototype.setItem; | |
| Storage.prototype.setItem = function() {}; |
This file contains hidden or 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
| #!/usr/bin/env php | |
| <?php | |
| ini_set('memory_limit', '256M'); | |
| if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { | |
| die('CLI only!'); | |
| } | |
| $pwd = getcwd(); |