Skip to content

Instantly share code, notes, and snippets.

View crizise's full-sized avatar

Kolomiitsev Olexii crizise

  • Kharkiv, Ukraine
View GitHub Profile
@crizise
crizise / crontab -e
Created October 9, 2019 11:21
certbot-auto renew
0 8 * * * /usr/local/bin/certbot-auto renew >/dev/null 2>&1 && /etc/init.d/apache2 restart && echo "`date`: Let's Encrypt certificate is updated" >> /var/log/openproject/cron-certbot-auto.log
@crizise
crizise / Custom_Meta_Box.php
Created October 28, 2018 12:50
Wordpress Metabox with image uploader
<?php
/*
*
*/
class Custom_Meta_Box
{
public static function add()
{
// define post types to show
@crizise
crizise / Custom_Meta_Box.php
Created October 27, 2018 16:31
Wordpress Custom Meta Box OOP inplementation.
<?php
/*
*
*/
class Custom_Meta_Box
{
public static function add()
{
// post types
@crizise
crizise / ShortcodeName.php
Last active October 20, 2018 10:32
Custom shortcode for Visual Composer WP Bakery. Just place ShortcodeName.php to your-theme/vc-elements folder and Include the file at functions.php
<?php
class ShortcodeName extends WPBakeryShortCode {
function __construct() {
add_action( 'init', [ $this, 'vc_ShortcodeName_mapping' ] );
add_action('wp_enqueue_scripts', [ $this, 'vc_register_ShortcodeName_assets' ] );
add_shortcode( 'vc_ShortcodeName', [ $this, 'vc_ShortcodeName_html' ] );
}
@crizise
crizise / functions.php
Created August 31, 2018 06:46
How to add custom CSS classes to WordPress menu items? It easy, just look the code below.
<?php
// Add css classes for standard WordPress menu items (<li>)
function menu_items_classes($classes, $item, $args) {
// Check is it that menu that we need
if($args->theme_location == 'header-menu') {
$classes[] = 'nav-item';
}
@crizise
crizise / functions.php
Last active July 26, 2018 20:01
WordPress Simple Countdown shortcode.
/**
* Register js
*/
function register_scripts() {
//Register countdown script
wp_register_script( 'simple-countdown', get_stylesheet_directory_uri() . 'simple-countdown.js', '', false, true );
}
add_action( 'wp_enqueue_scripts', 'register_scripts' );
@crizise
crizise / functions.php
Created July 19, 2018 09:56
For WordPress child theme functions.php file always starting with parent styles.
function child_theme_enqueue_styles() {
$parent_style = 'parent-style';
// parent and child styles load
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get('Version')
);
@crizise
crizise / gist:11d5b68294fa594cc076182a0fe11743
Created May 14, 2018 12:21
Load Google Fonts using Web Font Loader
<script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js"></script>
<script>
WebFont.load({
google: {
families: ["Work+Sans:400,700"]
}
});
</script>
@crizise
crizise / wget-download-googledrive-file
Created April 25, 2018 08:51
command for download any big file from google drive (for big file we need confirm download)
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt
@crizise
crizise / demo-menus.php
Last active February 25, 2018 14:31
Register locations, create menus with demo items, assign this menus to locations. Main idea was make a menu name dynamical. So when user want to rename menu it still be at same location and no new menu created.
add_action( 'after_setup_theme', 'generate_demo_menus' );
function generate_demo_menus() {
$locations = array(
'primary' => 'Header Navigation',
'footer_left' => 'Footer Left Menu',
'footer_right' => 'Footer Right Menu'
);
register_nav_menus( $locations );
foreach ( $locations as $location => $menu_name ) {