Skip to content

Instantly share code, notes, and snippets.

Avatar

taricco

  • Seattle, WA
View GitHub Profile
View Show what template file is being used.php
/* Shows entire path */
function wsv_which_template_is_loaded()
{
if (is_super_admin()) {
global $template;
print_r($template);
}
}
add_action('wp_footer', 'wsv_which_template_is_loaded');
View GenerateBlocks Media Queries.php
add_action( 'wp', function() {
add_filter( 'generateblocks_media_query', function( $query ) {
$query['desktop'] = '(min-width: 1025px)';
$query['tablet'] = '(max-width: 1024px)';
$query['tablet_only'] = '(max-width: 1024px) and (min-width: 768px)';
$query['mobile'] = '(max-width: 767px)';
return $query;
} );
}, 20 );
View Use phpMyAdmin to update domain.txt
@link https://betterstudio.com/blog/search-and-replace-phpmyadmin/
From the phpMyAdmin toolbar, click on SQL and type in the code below:
UPDATE wsv_options SET option_value = replace(option_value, 'https://olddomain.com', 'https://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wsv_posts SET post_content = replace(post_content, 'https://olddomain.com', 'https://newdomain.com');
UPDATE wsv_postmeta SET meta_value = replace(meta_value,'https://olddomain.com','https://newdomain.com');
UPDATE wsv_usermeta SET meta_value = replace(meta_value, 'https://olddomain.com','https://newdomain.com');
UPDATE wsv_links SET link_url = replace(link_url, 'https://olddomain.com','https://newdomain.com');
View Shortcode to display URL parameter.php
/** Shortcode to display URL parameter
Shortcode: [URLVar param='firstname']
Plugin: https://www.warrenchandler.com/2021/09/11/wordpress-shortcode-to-get-text-from-url-vars-parameters/
–––––––––––––––––––––––––––––––––––––––––––––––––– **/
function wsv_show_url_variable($atts)
{
extract(
shortcode_atts(
array(
'param' => 'param'
View Gravity Forms Form Validation.php
@link https: //gist.github.com/anythinggraphic/c5d9da935697df703ddd79883b1865f1
/**
* Gravity Forms: Form Validation.
*
* The below looks for the words 'http' and 'https' upon after the user tries to submit the form.
* During form validation, if the words appear within the form, the form will not submit.
* The user will then be presented with a custom, informative, and actionable message.
*
* @author Anything Graphic
View Sticky Header with Fade.txt
@link https://www.youtube.com/watch?v=oanr6o_Ty1c
/*** CSS
@link https://gist.github.com/gutenberghub/b278a76419c9f84b73c911b62156d2d4
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
.sticky-wrapper {
position: fixed;
top: 3%;
left: 0%;
z-index: 2;
View Add Categories to Pages.php
function wsv_add_categories_to_pages() {
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'wsv_add_categories_to_pages' );
View Insert Reusable Blocks into Post Template.php
<?php
$gblock = get_post(1234);
echo apply_filters('the_content', $gblock->post_content);
?>
View Inject GenerateBlocks for Reusable Blocks.php
/*** Inject GenerateBlocks for Reusable Blocks
@link https://docs.generateblocks.com/article/adding-content-sources-for-dynamic-css-generation/
Set the CSS Print Method in "GenerateBlocks > Settings" to "Inline Embedding"
–––––––––––––––––––––––––––––––––––––––––––––––––– ***/
add_filter('generateblocks_do_content', function ($content) {
$post_ids = array();
if (is_page_template('block-editor-template1.php')) {
$post_ids = array(12);
} /* With Sponsor Reusuable Block */