$DOMDocument = new \DOMDocument();
$DOMDocument->loadHTML('<div>foo</div>');
$DOMXPath = new \DOMXPath($DOMDocument);
$DOMDocument->loadHTML(file_get_contents('tpl.html'));
<?php | |
// Prevent direct file access. | |
defined( 'ABSPATH' ) || die; | |
if ( ! class_exists( 'Mai_User_Role_Base' ) ): | |
/** | |
* The User Role Base class. | |
* | |
* @version 0.2.0 |
<?php | |
/** | |
* Fix Jetpack Subscriptions block to not uselessly enqueue Thickbox, which in turn enqueues jQuery. | |
*/ | |
function felixarntz_stop_jetpack_subscriptions_from_enqueuing_thickbox_without_any_usage() { | |
if ( wp_script_is( 'jetpack-block-subscriptions' ) && isset( wp_scripts()->registered['jetpack-block-subscriptions'] ) ) { | |
$script = wp_scripts()->registered['jetpack-block-subscriptions']; | |
$index = array_search( 'thickbox', $script->deps, true ); | |
if ( false !== $index ) { |
<?php | |
/** | |
* Block helpers | |
* add special classes when certain blocks appear, put this in your functions.php file or include it somewhere | |
*/ | |
// add block classes in body and post class | |
function blocks_body_class( $classes ) { | |
global $post; |
// Add genesis layout classes to the Block Editor. | |
// File lives in the theme's /js/ folder. | |
wp.domReady(function () { | |
yourTheme.updateLayoutClass(); | |
var layouts = document.querySelector(".genesis-layout-selector"); | |
if( layouts ) { | |
layouts.addEventListener("input", function (e) { | |
yourTheme.updateLayoutClass(); |
<?php | |
/* | |
Plugin Name: EDD Prompt Login On Checkout | |
Plugin URI: http://brianhogg.com/ | |
Description: Prompt login if email exists | |
Author: Dave Kiss | |
Version: 1.0.0 | |
Author URI: http://brianhogg.com | |
License: GPL2 | |
*/ |
// License: GPLv2+ | |
var el = wp.element.createElement, | |
registerBlockType = wp.blocks.registerBlockType, | |
ServerSideRender = wp.components.ServerSideRender, | |
TextControl = wp.components.TextControl, | |
InspectorControls = wp.editor.InspectorControls; | |
/* | |
* Here's where we register the block in JavaScript. |
<?php | |
/** | |
* This class handles downloading a remote image file and inserting it | |
* into the WP Media Library. | |
* | |
* Usage: | |
* $download_remote_image = new KM_Download_Remote_Image( $url ); | |
* $attachment_id = $download_remote_image->download(); | |
* |
<?php | |
add_action( 'pre_get_posts', 'leaven_search_hide_landing_page' ); | |
/** | |
* Remove landing pages from the search results. | |
* | |
* @param $query \WP_Query | |
* | |
* @return mixed | |
*/ |
<?php | |
/** | |
* Wrapper function: Applies WP Rocket’s LazyLoad to wp_get_attachment_image() | |
* | |
* @link https://developer.wordpress.org/reference/functions/wp_get_attachment_image/ | |
* @link https://github.com/wp-media/wp-rocket/blob/v2.10.9/inc/front/lazyload.php#L24-L47 | |
* | |
* @param int $attachment_id (Required) Image attachment ID. | |
* @param string|array $size (Optional) Image size. Accepts any | |
* valid image size, or an array of width |