Skip to content

Instantly share code, notes, and snippets.

const TIME_SENSOR = hmSensor.createSensor(hmSensor.id.TIME)
let getDateLocal = function () {
let utc = TIME_SENSOR.utc
let d2 = new Date();
let offsetHour = 0
if (TIME_SENSOR.day < d2.getDate() || TIME_SENSOR.hour < d2.getHours()) {
offsetHour = TIME_SENSOR.hour - (d2.getHours() + (d2.getDate() - TIME_SENSOR.day) * 24)
@bigdigital
bigdigital / function.php
Last active September 22, 2021 06:11
Bring back Elementor pro theme styles in The7
add_action( 'after_setup_theme', 'enable_kit_manager', 20 );
function enable_kit_manager() {
$kit_manager_control = The7_Elementor_Compatibility::instance()->kit_manager_control;
remove_action( 'elementor/init', [ $kit_manager_control, 'disable_elementor_kit_manager'] , 1 );
}
add_action( 'elementor/editor/footer', 'the7_elementor_editor_custom_html' );
function the7_elementor_editor_custom_html(){
@bigdigital
bigdigital / gist:926678b62319171401a46aba90264f8a
Last active February 14, 2020 15:31
The7 microsite metaboxes to custom page template
function dt_add_CPT_to_microsite_metabox() {
global $DT_META_BOXES;
if ( $DT_META_BOXES ) {
foreach($DT_META_BOXES as $id => $metabox) {
if ( isset( $metabox['id'] ) && ( $metabox['id'] == 'dt_page_box-microsite' ) ) {
$DT_META_BOXES[$id]['only_on']['template'][] = 'template-microsite2.php';
//template-microsite2.php is the copy of the microsite template
@bigdigital
bigdigital / function.php
Created September 27, 2019 11:43
The7 add featured image to the Team post type
add_action( 'presscore_before_post_content', function() {
global $post;
if ( get_post_type() !== 'dt_team' ) {
return;
}
echo '<div class="post-thumbnail">';
$img_args = array(
'img_id' => get_post_thumbnail_id(),
@bigdigital
bigdigital / function.php
Created February 21, 2019 09:14
The7 add download button in lightbox (since The7 v7.5.0)
add_filter( 'the7-popup-share-buttons-title', function( $texts ) {
$texts['download'] = __( 'Download image', 'the7mk2' );
return $texts;
} );
@bigdigital
bigdigital / gist:98d4925608650bdaf14302c0d9a1b7a4
Created October 30, 2018 14:31
The7 replace portfoilio slug with help of polylang
add_filter( 'dt_of_get_option', 'dt_get_options_rewrite', 10, 2 );
function dt_get_options_rewrite($saved_options, $name) {
if ($name !== 'general-post_type_portfolio_slug') return $saved_options;
if (!function_exists('pll_current_language')) return $saved_options;
$lang = pll_current_language('slug');
switch ($lang){
case "en":
$saved_options[$name] = 'englishslug';
break;
@bigdigital
bigdigital / modal.js
Last active December 26, 2019 19:24
Modal Element - Ultimate Addon's For Visual composer: Play YouTube video automatically when modal is opened.
<script>
function modalAutoPlayVideo(modalWrapper){
"use strict";
var $youtubeframe = modalWrapper.find(".ult_modal-body iframe");
if ($youtubeframe.length){
var videosrc = $youtubeframe.attr('videosrc');
if (videosrc == null)
{
var videosrc = $youtubeframe.attr('src');
@bigdigital
bigdigital / functions.php
Last active October 25, 2019 07:37
The7, assign page template to archive Custom Post Type
add_filter( 'the7_archive_page_template_id', function( $page_id ) {
if ( ! $page_id ) {
if (is_post_type_archive('tribe_events')) //"tribe_events" - it is cuttom post type
$page_id = 9999; //replace to template page id
}
return $page_id;
} );
@bigdigital
bigdigital / functions.php
Last active July 10, 2018 08:34
The7 add custom post types to microsite metaboxes
function dt_add_CPT_to_microsite_metabox() {
global $DT_META_BOXES;
if ( $DT_META_BOXES ) {
foreach($DT_META_BOXES as $id => $metabox) {
if ( isset( $metabox['id'] ) && ( $metabox['id'] == 'dt_page_box-microsite' ) || ( $metabox['id'] == 'dt_page_box-microsite_logo' ) ) {
$DT_META_BOXES[$id]['pages'][] = 'my_custom_postytype';
break;
}
@bigdigital
bigdigital / gist:d1b17aaa69564b066af0e5702e45e876
Created May 31, 2018 11:45
Wordpress remove all meta generators
//Remove All Meta Generators
function remove_meta_generators($html) {
$pattern = '/<meta name(.*)=(.*)"generator"(.*)>/i';
$html = preg_replace($pattern, '', $html);
return $html;
}
function clean_meta_generators($html) {
ob_start('remove_meta_generators');
}
add_action('get_header', 'clean_meta_generators', 100);