Skip to content

Instantly share code, notes, and snippets.

View danyj's full-sized avatar
💭
I may be slow to respond.

Dragan Todorovic danyj

💭
I may be slow to respond.
View GitHub Profile
@danyj
danyj / ThzelGetElementSettings.php
Created May 17, 2019 11:41
Pull any Elementor options outside of Elementor
/**
* @package Thz Framework
* @author Themezly
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
* @websites http://www.themezly.com | http://www.youjoomla.com | http://www.yjsimplegrid.com
*/
class ThzelGetElementSettings {
@danyj
danyj / yjsg.site.js
Created March 14, 2019 12:34
yjsg.site tooltip check
/**
* @package YJSG Framework
* @copyright Copyright(C) since 2007 Youjoomla.com. All Rights Reserved.
* @author YouJoomla
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
* @websites http://www.youjoomla.com | http://www.yjsimplegrid.com
*/
;window.onerror = function(msg, url, line, col, error) {
var extra = !col ? '' : '\ncolumn: ' + col;
extra += !error ? '' : '\nerror: ' + error;
@danyj
danyj / thz_opengraph.php
Created March 12, 2019 12:10
thz_opengraph
<?php
function thz_opengraph() {
if (defined('WPSEO_VERSION')) {
// if Yoast
if (get_post_type() == 'docs') {
$og_img = 'CUSTOM IMAGE IF DOCS';
@danyj
danyj / script.js
Created March 4, 2019 12:08
Creatus Sections Slider Horizontal Demo
$('body').on('mousewheel DOMMouseScroll', function(e){
if(typeof e.originalEvent.detail == 'number' && e.originalEvent.detail !== 0) {
if(e.originalEvent.detail > 0) {
console.log('Down');
$('.thz-sections-slider .slick-next').trigger('click');
} else if(e.originalEvent.detail < 0){
console.log('Up');
$('.thz-sections-slider .slick-prev').trigger('click');
}
} else if (typeof e.originalEvent.wheelDelta == 'number') {
@danyj
danyj / admin.js
Created November 24, 2018 19:16
Add info about WordPress featured image
(function($) {
$(document).ready(function() {
$('<span class="featured-img-info">Use an image 500x500px or larger</span>').appendTo('#postimagediv');
});
})(jQuery);
@danyj
danyj / thz_cpt_items_single_view_redirect.php
Created November 16, 2018 22:21
Register WordPress custom post type and tax, where single items view is redirected to 404 page but item archives are still accessible.
<?php
// post type
function cpt_items_register() {
$cpt_labels = array(
'name' => _x( 'Items', 'Post Type General Name', '{domain}' ),
'singular_name' => _x( 'Item', 'Post Type Singular Name', '{domain}' ),
'menu_name' => esc_html__( 'Items', '{domain}' ),
'name_admin_bar' => esc_html__( 'Page Block', '{domain}' ),
@danyj
danyj / thz_disable_gutenberg.php
Created October 25, 2018 09:15
Disable Gutenberg globally or for specific post types for WordPress 5.0 and UP
<?php
/*
* Disable Gutenberg globally
* use this if you prefer one-liner
* add_filter('use_block_editor_for_post', '__return_false');
*/
function _thz_filter_disable_block_editor(){
return false;
}
add_filter( 'use_block_editor_for_post', '_thz_filter_disable_block_editor' );
@danyj
danyj / gist:797e36ddaceac64cffc7481717b6aa25
Last active October 15, 2018 12:05
Creatus WordPress Theme open popup on posts title click
<script type="text/javascript">
(function($) {
$(document).ready(function($) {
$('.thz-grid-item-title').on('click',function(e){
e.preventDefault();
$(this).parents('.thz-grid-item-in').find('.thz-hover-icon').trigger('click');
});
});
<?php
/**
* @package Thz Framework
* @author Themezly
* @websites http://www.themezly.com | http://www.youjoomla.com | http://www.yjsimplegrid.com
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access
}
@danyj
danyj / gist:009783f1513f342d318d73c993e2a36a
Last active July 23, 2018 08:45
Add Google Analytics
/**
* GA
*/
function _thz_action_add_ga(){
$GAcode = 'XX-XXXXXX-X'; // change with your GA tracking code
echo '<script async src="https://www.googletagmanager.com/gtag/js?id=UA-63305981-2"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag(\'js\', new Date()); gtag(\'config\', \''.$GAcode.'\'); </script>';
}
add_action('wp_footer', '_thz_action_add_ga');