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
/** | |
* Scans all CSS rules in the current document to find the most | |
* specific definiton of a single CSS property for a given element. | |
* | |
* Usage: getStyleDef('#my-element', 'width'); | |
* --> returns the most specific "width" defintiion, e.g. "27em". | |
* | |
* @param {HTMLElement} element - The HTML Element to inspect. | |
* @param {string} prop - The CSS property to inspect. | |
* @return {string} The most specific CSS definition, |
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 | |
// https://stackoverflow.com/a/6041773/313501#answer-6041773 | |
function test1( $value ) { | |
if ( ! is_scalar( $value ) ) { | |
return null; | |
} | |
json_decode( $value ); | |
return ( json_last_error() == JSON_ERROR_NONE ); |
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
// This JS file is loaded by the theme: | |
(function() { | |
// The button with the CSS class "get-support" loads the form. | |
jQuery('.get-support').on('click', load_support_form); | |
// The form is displayed in a div tag with the CSS class "support-form". | |
function load_support_form() { | |
jQuery.get('/wp-admin/admin-ajax.php?action=my_get_support') | |
.then(function(response) { |
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 | |
/** | |
* Passwordless login for development environments. | |
* | |
* Setup: | |
* 1. Make sure that the "wp-contents/mu-plugins" folder exists. Create it if needed. | |
* 2. Save this file as "wp-contents/mu-plugins/wp-dev-login.php" | |
* 3. Check the conditions in line 29 - 30 and adjust them to your requirements. | |
* | |
* Once installed, all default WP login forms will display a dropdown list of all |
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 | |
/** | |
* Custom Block to output Code. | |
*/ | |
namespace MailPoet\Newsletter\Renderer\Blocks; | |
// Exit if accessed directly. | |
defined( 'ABSPATH' ) || exit; |
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
/** | |
* Recursively searches the startObject for the given value. | |
* | |
* All matches are displayed in the browser console and stored in the global variable "gsResults" | |
* The function tries to simplify DOM element names by using their ID, when possible. | |
* | |
* Usage samples: | |
* | |
* globalSearch( document, 'someValue' ); // Search entire DOM document for the string value. | |
* globalSearch( document, '^start' ); // Simple regex search (function recognizes prefix/suffix patterns: "^..." or "...$"). |
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
// Detects the browser locale for Date translations. | |
const locale = (navigator.languages && navigator.languages.length) ? | |
navigator.languages[0] : | |
navigator.language ? | |
navigator.language : | |
'en'; | |
// Date formatter with php-compatible format syntax | |
export const formatDate = (format, date) => { | |
if (format === undefined) { |
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 | |
/** | |
* The base configuration for WordPress | |
* | |
* @link https://codex.wordpress.org/Editing_wp-config.php | |
* | |
* @package WordPress | |
*/ | |
// Defines the environment (prod|stage|dev) |
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 | |
/** | |
* Output the current action name and priority. | |
*/ | |
function pst_action_and_priority() { | |
global $wp_filter, $wp_current_filter; | |
// Find the currently running WP action/filter name. | |
$action = end( $wp_current_filter ); |