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 | |
/** | |
* Implements hook_query_TAG_alter(). | |
* | |
* Orders the search results by the changed date in descending order. | |
* | |
* @param \Drupal\Core\Database\Query\AlterableInterface $query | |
*/ | |
function mymodule_query_search_node_search_alter(\Drupal\Core\Database\Query\AlterableInterface $query): void | |
{ |
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
#!/bin/bash | |
# | |
# A simple backup script to back up the database, files, or both. | |
# | |
# Usage: ddev backup {db|files|full} | |
# | |
# db: Export the database and save it to the backups/db directory. | |
# files: Zip the public_html folder and save it to the backups/files directory. | |
# full: Export the database, save it to the site folder, zip the |
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
#!/usr/bin/php | |
<?php | |
/** | |
* USAGE: | |
* | |
* (optional) Download script: | |
* "wget https://gist.githubusercontent.com/pelmered/2ee27f1cb18b8c73a0205ded580e3195/raw/convert-to-composer.php" | |
* | |
* Basic usage: | |
* php convert-to-composer.php |
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( 'elementor/frontend/the_content', 'MYPREFIX_add_role_to_elementor_overlay' ); | |
/** | |
* Find the <div class="elementor-background-overlay"></div> element and add the role="img" attribute | |
* to meet accessibility guidelines. | |
* | |
* @since 1.0.0 | |
* | |
* @param $content | |
* @return string |
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 | |
if ( ! function_exists( 'PREFIX_abbreviate_num' ) ) { | |
/** | |
* Converts the given number to an abbreviated version of it and returns that value. | |
* | |
* Ex: PREFIX_abbreviate_num( 100000 ) would output 100K. | |
* | |
* @since 1.0.0 | |
* | |
* @param $num int |
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
SELECT 'autoloaded data in KiB' as name, ROUND(SUM(LENGTH(option_value))/ 1024) as value FROM wp_options WHERE autoload='yes' | |
UNION | |
SELECT 'autoloaded data count', count(*) FROM wp_options WHERE autoload='yes' | |
UNION | |
(SELECT option_name, length(option_value) FROM wp_options WHERE autoload='yes' ORDER BY length(option_value) DESC LIMIT 10) |
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( 'paginate_links', 'wpfixpagination_remove_page_1_deadlinks', 10, 2 ); | |
/** | |
* Finds any instance of a /page/1/ link in the navigation and removes it cause SEO people and search engines | |
* don't like redirects apparently. :) Thanks StackOverlow! @see below | |
* | |
* @see https://stackoverflow.com/questions/46195352/woocommerce-pagination-prevent-301-redirect-on-page-1 | |
* | |
* @since 1.0.0 | |
* |
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
/** | |
* Function that returns the YouTube ID when given the YouTube URL. | |
* | |
* @param url string | |
* @return int|null | |
*/ | |
function get_youtube_id_from_url(url) { | |
const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/; | |
const match = url.match(regExp); |
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 | |
/** | |
* @file wp-limit-search-results.php | |
* | |
* Limits the website search results to just searching posts. | |
* | |
* @package wplsr | |
* @since 1.0.0 | |
*/ |
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: WP HTML Buffer | |
* Description: Uses output buffering to add a new filter that parses the entire final HTML output of each page. | |
* Plugin URI: https://briannadeleasa.com | |
* Version: 1.0.0 | |
* Author: Brianna Deleasa | |
* Author URI: https://briannadeleasa.com | |
* Text Domain: wp-html-buffer | |
*/ |
NewerOlder