View random-fact-string.php
<?php | |
/** | |
* Get a string containing a random fact. | |
* | |
* If a random fact cannot be fetched from the external service, a default is | |
* supplied instead. | |
* | |
* @return string | |
*/ |
View hide-events-tagged-with-x.php
<?php | |
/** | |
* Remove events tagged with any of the slugs listed below from | |
* event views. | |
* | |
* We deliberately avoid use of TEC functions and constants etc | |
* so that this doesn't break should that plugin temporarily be | |
* deactivated. | |
*/ | |
add_filter( 'pre_get_posts', function( $query ) { |
View ip-address-protected-map-key.tec-views-v2.php
<?php | |
/** | |
* Facilitates dictating a separate (IP-address protected) Google Maps | |
* API key for server-side geocoding requests. | |
*/ | |
class Server_Side_Google_Maps_Key { | |
/** | |
* @var string | |
*/ | |
private $key = ''; |
View fetch-csv-file.php
<? | |
/** | |
* Given a path to a valid CSV file, returns an array containing the data | |
* (an array of arrays, with outer arrays representing the rows and inner | |
* arrays representing the columns). | |
* | |
* @param string $path_to_csv | |
* | |
* @return array | |
*/ |
View woocommerce.get_or_create_attribute.php
<?php | |
namespace WooCommerce_Helpers { | |
/** | |
* Looks for an existing WooCommerce attribute with the same label, or else | |
* creates a new attribute using the provided information. | |
* | |
* If a new attribute is successfully created, or an existing attribute is | |
* matched, the attribute object will be returned. Otherwise, bool false is | |
* returned. | |
* |
View php-streams.http-basic-auth.php
<?php | |
/** | |
* Make an HTTP request with basic authentication, using 'pure PHP'. | |
* | |
* @see https://www.php.net/manual/en/wrappers.http.php | |
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication | |
*/ | |
$username = 'http_username'; | |
$password = 'http_password'; |
View password-reset-link-generator.wp-cli.php
<?php | |
/** | |
* Generates a password reset link for a user (which we can share directly). | |
* | |
* Run this script through WP CLI and supply the user email as the final arg. | |
* | |
* @see https://developer.wordpress.org/cli/commands/eval-file/ | |
*/ | |
if ( ! class_exists( 'WP_CLI' ) ) { |
View bbpress-topic-ordering.php
<?php | |
/** | |
* Order bbPress topic archives by post date (date created), not by last activity. | |
* | |
* This can be added either within a standalone plugin or to a theme's functions.php | |
* file. | |
* | |
* @param array $args | |
* | |
* @return array |
View nextcloud.sample-nginx-remediation.CVE-2019-11043.patch
location / { | |
- rewrite ^ /index.php$request_uri; | |
+ rewrite ^ /index.php; | |
} | |
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) { | |
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; | |
+ try_files $fastcgi_script_name =404; | |
include fastcgi_params; | |
fastcgi_param SCRIPTFILENAME $document_root$fastcgi_script_name; |
View plain-textify-html-links.php
<?php | |
/** | |
* Given a body of text, transforms HTML links to a comprehensible | |
* plain text alternative. | |
* | |
* For example, given: | |
* | |
* Today <a href="http://foo.bar">this important article</a> was published | |
* about <a class="baz" href="ftp://bar.baz" target="xyz">Jim</a>. Go read | |
* it now! |
NewerOlder