sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
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 version works with CF WAF (using zone rulesets) and obsoletes previous | |
# versions. This works will all CF account types. This action depends on curl | |
# and jp and will add/remove IPs from the $known_hostile_ips list. Creating the | |
# WAF rules need only be done once per zone. Creating the list need only be done | |
# once per account. | |
# | |
# Author: Bernard Dickens III (Xunnamius) | |
# | |
# Inspired by work from: Mike Rushton | |
# https://github.com/fail2ban/fail2ban/blob/master/config/action.d/cloudflare.conf |
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
add_action( 'save_post', 'custom_featured_image_size', 10, 2 ); | |
function custom_featured_image_size( $post_id, $post ) { | |
$image_size_name = 'my-custom-image-size'; | |
$cpt = 'my-cpt'; | |
$width = 1600; | |
$height = 1600; | |
$crop = false; | |
// Only for my CPT. |
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 | |
/* | |
Solution based on a Stack Overflow answer by patrickzdb: | |
https://stackoverflow.com/a/24514985/470480 | |
Tax query solution for hidden products based on a WordPress Stack Exchange answer by kalle: | |
https://wordpress.stackexchange.com/a/262628/19105 | |
Please note: | |
This file includes two functions/filters. |
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_action( 'add_meta_boxes', 'add_page_scripts' ); | |
/** | |
* Register the metabox | |
*/ | |
function add_page_scripts() { | |
add_meta_box( 'page-scripts', __( 'Page Scripts & Styles', 'textdomain' ), 'add_page_metabox_scripts_html', 'page', 'advanced' ); | |
} |
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 | |
function bit_crp_add_fields( $fields, $post_id ) { | |
global $wpdb; | |
$match_title = strip_tags( get_the_title( $post_id ) ); | |
$match_content = bit_get_the_matcher($post_id); | |
$field_score = ", ( ( MATCH($wpdb->posts.post_title) AGAINST ('%s') *5 ) + ( MATCH($wpdb->postmeta.meta_value) AGAINST ('%s') *10 ) ) as score "; | |
$field_score = $wpdb->prepare( $field_score, $match_title, $match_content ) ; |
This is a basic custom Gutenberg block. Files explained below.
block.js
— We register Custom Gutenberg block here.editor.css
_ Block CSS for the editor.style.css
— Block CSS for the front end.index.php
— Enqueue block's assets for editor and the front end.
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 | |
/** | |
* Recursively get taxonomy and its children | |
* | |
* @param string $taxonomy | |
* @param int $parent - parent term id | |
* @return array | |
*/ | |
function get_taxonomy_hierarchy( $taxonomy, $parent = 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
class WP_Query_Geo extends WP_Query { | |
private $lat = NULL; | |
private $lng = NULL; | |
private $distance = NULL; | |
/** | |
* Constructor - adds necessary filters to extend Query hooks | |
*/ | |
public function __construct( $args = array() ) { | |
// Extract Latitude |
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 | |
/** | |
* This changes logging to only log fatal errors. This file should go in your mu-plugins directory. | |
*/ | |
// Set the error logging to only log fatal errors | |
error_reporting( E_ERROR ); | |
// Optional: change the location of your error log, it might be wise to put it outside your WP content dir. | |
// If you don't change it, the default place for this log is debug.log in your WP_CONTENT_DIR. |
NewerOlder