Skip to content

Instantly share code, notes, and snippets.

View wpexplorer's full-sized avatar
✍️
We create themes & plugins and run a popular blog about WordPress.

WPExplorer wpexplorer

✍️
We create themes & plugins and run a popular blog about WordPress.
View GitHub Profile
@wpexplorer
wpexplorer / gist:e95f2bc43c82a227787e8ae0d8a87432
Last active February 8, 2024 02:32
Sample Filter HTML - Total WP Theme - IMPORTANT SEE EXAMPLE SHORTCODE IN THE COMMENTS!
/*** IMPORTANT ****/
You need to make sure the AJAX script is loaded on the page which is done via PHP using the following:
<?php totalthemecore_call_non_static( 'Vcex\Ajax', 'enqueue_scripts' ); ?>
/**** SAMPLE FILTER HTML ****/
@note: You can have multiple filter elements with the same target - for example if you want to have a search element that targets a filter above the grid and then the rest of the filter options to the side.
$string = WPSEO_Meta::get_value( 'title', $post_id );
if ( ! empty( $string ) {
$replacer = new WPSEO_Replace_Vars();
return $replacer->replace( $string, get_post($post_id) );
}
// Add link option to columns.
add_action( 'vc_after_init', function() {
vc_add_param( 'vc_column', array(
'type' => 'textfield',
'param_name' => 'link',
'heading' => esc_html__( 'Link', 'total'),
) );
} );
// Insert link into columns.
@wpexplorer
wpexplorer / gist:a222a8a579fb5c62c2dfe8741d7a59c3
Last active April 4, 2023 00:28
WordPress Options Panel Helper Class
class WPEX_Options_Panel {
/**
* Options panel arguments.
*/
protected $args = [];
/**
* Options panel title.
*/
@wpexplorer
wpexplorer / gist:90c3f290d12f44304564bd8eb8ecb627
Created March 15, 2023 08:00
Mobile Image Select Button JS
( function() {
const button = document.querySelector( '.wpex-mobile-image-select' );
const field = document.querySelector( '#wpex-mobile-image-input' );
const onButtonClick = ( event ) => {
event.preventDefault();
let send_attachment_bkp = wp.media.editor.send.attachment;
const currentImage = field.value;
@wpexplorer
wpexplorer / gist:a87c173082a0070c5c463f9df8715229
Created March 15, 2023 07:58
WPEX_Mobile_Thumbnails PHP Class
class WPEX_Mobile_Thumbnails {
/**
* Class constructor.
*/
public function __construct() {
add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] );
add_action( 'save_post', [ $this, 'save_meta_box' ] );
add_filter( 'wp_get_attachment_image_attributes', [ $this, 'attachment_image_attributes' ], 10, 3 );
}
@wpexplorer
wpexplorer / gist:0e9c050238ecb69b79c8cd3e34eb8f5d
Created October 20, 2022 20:17
Site overlay, menu items hover | Total Theme
// Open a new overlay wrapper around the main content and the footer.
add_action( 'wpex_hook_main_before', function() {
echo '<div class="myprefix-overlay-wrapper">';
} );
// Close overlay wrapper.
add_action( 'wpex_hook_wrap_bottom', function() {
echo '</div>';
}, 999 );
@wpexplorer
wpexplorer / wordpress-remove-post-type-slug
Last active October 7, 2022 01:27
Remove Custom Post Type Slug
<?php
/**
* Remove the slug from published post permalinks for our custom post types.
*/
add_filter( 'post_type_link', function( $post_link, $post, $leavename ) {
$post_types = array(
'post_type_1',
'post_type_2'
);
<?php
/**
* Modern Skin Class
*
* @package Total
* @subpackage Skins
* @author Alexander Clarke
* @copyright Copyright (c) 2014, Symple Workz LLC
* @link http://www.wpexplorer.com
*/
// Add the overlay cart code for the overlay in the site footer
// Only needed if you don't have it enabled for the main menu
add_action( 'wp_footer', function() {
get_template_part( 'partials/cart/cart-overlay' );
} );
// Create new topbar_cart shortcode to be used as [topbar_cart] in the top bar content area (or anywhere really)
function my_cart_shortcode() {
// Needed functions