Skip to content

Instantly share code, notes, and snippets.

View drinkmaker's full-sized avatar
🏠
Working from home

Alexander Khmelnitskiy drinkmaker

🏠
Working from home
View GitHub Profile
@drinkmaker
drinkmaker / functions.php
Created December 8, 2021 15:46
Remove 'Elementor' state from Pages in admin area.
<?php
/**
* Remove 'Elementor' state from pages in admin area.
*
* @since 1.0.0
* @access public
*
* @param string[] $post_states An array of post display states.
* @param WP_Post $post The current post object.
@drinkmaker
drinkmaker / devtools-detect.js
Created July 6, 2021 08:50
Developer Tools Detection
/**
* Disable Developer Tool, HotKeys: Ctrl+Shift+I, ⌘+⌥+I, F12
* Disable to View Source Code of Page by Developer Tools.
**/
function disableDeveloperTool() {
hotkeys( 'command+option+j,command+option+i,command+shift+c,command+option+c,command+option+k,command+option+z,command+option+e,f12,ctrl+shift+i,ctrl+shift+j,ctrl+shift+c,ctrl+shift+k,ctrl+shift+e,shift+f7,shift+f5,shift+f9,shift+f12', function( event, handler ) {
event.preventDefault();
} );
@drinkmaker
drinkmaker / index.html
Created February 8, 2020 08:04
Content Protector: What if the user disables JavaScript in the browser settings?
<noscript>
<div id="t42-content-protector-js-disabled">
<div><h3>Please Enable JavaScript in your Browser to Visit this Site.</h3></div>
</div>
<style>
#t42-content-protector-js-disabled {
position: fixed;
top: 0;
left: 0;
height: 100%;
@drinkmaker
drinkmaker / wp-get-widget-instance.php
Created February 3, 2020 15:20 — forked from cyberhobo/wp-get-widget-instance.php
Get a WordPress registered widget instance settings.
<?php
function get_widget_instance( $widget_id ) {
global $wp_registered_widgets;
if ( empty( $wp_registered_widgets[$widget_id]['callback'] ) )
return array();
/** @var WP_Widget $widget */
$widget = $wp_registered_widgets[$widget_id]['callback'][0];
@drinkmaker
drinkmaker / junction.html
Last active January 24, 2020 17:55
Junction Example
Hey guys, check out the
<a href="https://alexander.khmelnitskiy.ua/evil-hacker/" target="_blank">latest post</a>
in the blog of my buddy.
@drinkmaker
drinkmaker / str_truncate.php
Created July 19, 2019 08:02
A PHP function to truncate a string either it contains HTML or not
/**
* Truncates text.
*
* Cuts a string to the length of $length and replaces the last characters
* with the ending if the text is longer than length.
*
* @param string $text String to truncate.
* @param integer $length Length of returned string, including ellipsis.
* @param string $ending Ending to be appended to the trimmed string.
* @param boolean $exact If true, $text will not be cut mid-word
<?php
global $wp_embed;
$video_url = 'https://www.youtube.com/watch?v=b7mixrO2lzA';
echo $wp_embed->run_shortcode( '[embed]' . $video_url . '[/embed]' );
@drinkmaker
drinkmaker / functions.php
Created July 20, 2016 08:51
stop wp removing some html tags in editor (So stupid feature)
<?php
// stop wp removing some html tags in editor (So stupid feature)
function esta_tinymce_fix($init) {
// html elements being stripped
$init['extended_valid_elements'] = 'div[*], article[*], span[*], strong[*], pre[*], h1[*], h2[*], h3[*], h4[*], h5[*], h6[*], b[*], i[*], tt[*], em[*], font[*], a[*], p[*], br[*], blockquote[*], dt[*], dd[*], ol[*], li[*], ul[*], li[*], img[*], hr[*], form[*], select[*], option[*], textarea[*] input[*], table[*], tr[*], td[*], th[*]';
// don't remove line breaks
$init['remove_linebreaks'] = false;
@drinkmaker
drinkmaker / comments.html
Created March 21, 2016 07:58
Подпись с банером Эста
<p><a href="http://support.torbara.com"><img src="http://www.googledrive.com/host/0Bxtm5PidFyMoMnVUN2t5ME45dVE"></a><a href="http://themeforest.net/item/esta-responsive-real-estate-wordpress-theme/14292309"><img src="http://www.googledrive.com/host/0Bxtm5PidFyMoUGNqZ3hwTXlGaWc"></a></p>
@drinkmaker
drinkmaker / loaction.html
Created December 22, 2015 07:49
MaxxFitness WP location slide
<img src="/wp-content/uploads/demo/visuals/slide-contacts.jpg" width="800" height="400" alt="Contacts - Slide">
<div class="uk-overlay-panel uk-flex uk-flex-center uk-flex-bottom tm-contacts">
<div>
<div class="uk-grid">
<div class="uk-width-medium-1-2 uk-width-large-1-4">
<h5 class="tm-uppercase uk-position-relative">
<i class="tm-circle">1</i>
Central Fitness Club
</h5>