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
// 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:e95f2bc43c82a227787e8ae0d8a87432
Last active July 11, 2024 19:15
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.
@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 / gist:2b203f0336ba5d17837c35f1a087c8f6
Created February 16, 2022 06:46
Remove WPBakery elements from the builder.
add_action( 'vc_after_init', function() {
$elements = array(
// Remove core wpbakery elements
'vc_single_image',
// Remove total elements
'vcex_heading',
);
foreach ( $elements as $element ) {
if ( function_exists( 'vc_remove_element' ) ) {
vc_remove_element( $element );
@wpexplorer
wpexplorer / gist:ac48b7b0a234140ce5dd80f4067c6671
Created February 7, 2022 03:39
Exclude Category (red) from Related Posts | Total WordPress Theme
// Exclude "red" term from related blog posts.
add_filter( 'wpex_blog_post_related_query_args', function( $args ) {
$exclude_terms = array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'red' ),
'operator' => 'NOT IN',
@wpexplorer
wpexplorer / gist:49f7c63a2ca3bfe7224c2db760bd37d2
Last active February 4, 2022 06:34
Customize lightbox video output | Total WordPress Theme
add_filter( 'wpex_lightbox_settings', function( $settings ) {
$settings['video']['tpl'] = '<video class="fancybox-video" controls controlsList="nodownload" poster="{{poster}}" loop>
<source src="{{src}}" type="{{format}}">
Sorry, your browser doesn\'t support embedded videos, <a href="{{src}}">download</a> and watch with your favorite video player!
</video>';
return $settings;
} );
@wpexplorer
wpexplorer / gist:96951068a6c8de1e618639d002341337
Last active December 13, 2021 23:22
Include all post galleries in the lightbox.
add_action( 'wp_footer', function() {
wp_enqueue_script( 'jquery' );
?>
<script>
document.addEventListener( 'click', function( event ) {
var target = event.target.closest( '.gallery-item a' );