Skip to content

Instantly share code, notes, and snippets.

@cornelRaiu
cornelRaiu / functions.php
Last active August 17, 2022 18:14
mwtsa_display_latest_searches shortcode with linked search terms
<?php
if ( ! function_exists( 'get_search_link_no_permastruct' ) ) {
function get_search_link_no_permastruct( $search_term ) {
return home_url( '?s=' . urlencode( stripslashes( $search_term ) ) );
}
}
add_filter( 'mwtsa_display_latest_searches_shortcode_list_item_output', 'mwtsa_display_latest_searches_shortcode_list_item_output_callback', 10, 2 );
function mwtsa_display_latest_searches_shortcode_list_item_output_callback( $output, $shortcode_attributes ) {
@cornelRaiu
cornelRaiu / functions.php
Created August 9, 2022 14:58
Add links to Search Analytics shortcode
<?php
add_filter('mwtsa_display_search_stats_shortcode_output', 'custom_mwtsa_display_search_stats_shortcode_output', 10, 3);
function custom_mwtsa_display_search_stats_shortcode_output( $html, $atts, $data ) {
ob_start();
?>
<div class="mwtsa-search-stats">
<ul>
<?php if ( count( $data['most_searched'] ) > 0 ) : ?>
@cornelRaiu
cornelRaiu / apply_shortcodes_function.php
Last active September 27, 2020 13:03
WP5.4 apply_shortcodes function
<?php
/**
* Search content for shortcodes and filter shortcodes through their hooks.
*
* This function is an alias for do_shortcode().
*
* @since 5.4.0
*
* @see do_shortcode()
*
@cornelRaiu
cornelRaiu / options-reading.php
Created July 24, 2020 22:54
Reading Settings page - Your homepage displays section
<?php if ( ! get_pages() ) : ?>
<input name="show_on_front" type="hidden" value="posts" />
<table class="form-table" role="presentation">
<?php
if ( 'posts' != get_option( 'show_on_front' ) ) :
update_option( 'show_on_front', 'posts' );
endif;
else :
if ( 'page' === get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {