Skip to content

Instantly share code, notes, and snippets.

View BenSibley's full-sized avatar

Ben Sibley BenSibley

View GitHub Profile
@BenSibley
BenSibley / functions.php
Created February 5, 2024 23:50
Add Apps to homepage
function founder_add_apps_to_homepage($query)
{
if (is_home() && $query->is_main_query()) {
$query->set('post_type', array( 'post', 'app'));
}
return $query;
}
add_filter('pre_get_posts', 'founder_add_apps_to_homepage');
@BenSibley
BenSibley / block-rest-api.php
Last active July 17, 2023 15:39
Block REST API except for Independent Analytics
function block_rest_api_except_ia( $access ) {
if (!is_user_logged_in() && $_SERVER['REQUEST_URI'] != '/wp-json/iawp/search') {
return new WP_Error( 'rest_disabled', __('The WordPress REST API has been disabled.'), array( 'status' => rest_authorization_required_code()));
}
return $access;
}
add_filter( 'rest_authentication_errors', 'block_rest_api_except_ia );
@BenSibley
BenSibley / top-ten.php
Last active January 13, 2023 21:37
Top Ten Pages
namespace IAWP;
function get_top_ten() : array
{
$start = new \DateTime('30 days ago');
$top_ten = [];
$query = new Resources([
'start' => $start
]);
@BenSibley
BenSibley / featured-image-blog.php
Created March 16, 2022 23:22
Output Featured Image on blog page
@BenSibley
BenSibley / style.css
Created March 6, 2022 15:31
WooCommerce categories block - style like Modern Store sections
.wc-block-product-categories-list {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.wc-block-product-categories-list li {
width: 24%;
margin: 0 !important;
text-align: center;
}
@BenSibley
BenSibley / functions.php
Created July 23, 2021 16:58
Disable Google Fonts
function ct_shift_child_disable_google_fonts() {
wp_dequeue_style( 'ct-shift-google-fonts' );
}
add_action( 'wp_enqueue_scripts', 'ct_shift_child_disable_google_fonts', 11 );
@BenSibley
BenSibley / pricing-redirect.php
Last active May 30, 2021 17:26
Freemius - redirect pricing page to checkout
function scc_redirect_freemius_pricing_to_checkout($url) {
return scc_freemius()->checkout_url();
}
scc_freemius()->add_filter( 'pricing_url', 'scc_redirect_freemius_pricing_to_checkout', 10, 1);
@BenSibley
BenSibley / date-fix.php
Created December 16, 2020 19:25
Mission News date fix
function ct_mission_news_post_byline( $author, $date, $categories ) {
if ( $author == 'no' && $date == 'no' && $categories == 'no' ) {
return;
}
if ( empty($author) ) {
$author = 'yes';
}
if ( empty($date) ) {
$date = 'yes';
@BenSibley
BenSibley / disable-sticky.php
Created November 6, 2020 16:12
Disable Elementor Pro's sticky feature
function mysite_remove_elementor_pro_sticky() {
// Dequeue and deregister elementor-pro-frontend
wp_deregister_script( 'elementor-pro-frontend' );
// Re-register elementor-frontend without the elementor-sticky dependency.
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_register_script(
'elementor-pro-frontend',
ELEMENTOR_PRO_URL . 'assets/js/frontend' . $suffix . '.js',
@BenSibley
BenSibley / coauthorsplus.php
Created June 1, 2020 17:35
Co-authors plus support
function ct_mission_news_post_byline( $author, $date ) {
if ( $author == 'no' && $date == 'no' ) {
return;
}
$post_author = get_the_author();
// add compatibility when used in header before loop
if ( empty( $post_author ) ) {
global $post;
$post_author = get_the_author_meta( 'display_name', $post->post_author );