Skip to content

Instantly share code, notes, and snippets.

View cheh's full-sized avatar

Dima Chekhovskyi cheh

View GitHub Profile
@cheh
cheh / gist:0391770c27101e9190129067a58f8137
Created January 5, 2019 11:36
WooCommerce simple widget based on ACF
<?php
defined( 'ABSPATH' ) || exit;
class BikeRide_Simple_Widget extends WC_Widget {
private $meta_key = '';
private $meta_prefix = '_bike_';
/**
* Constructor.
==> php
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
@cheh
cheh / gist:49b9aab8069df589ab2797b52c730deb
Created November 9, 2017 11:49
WP CLI commands for starting project
1. wp core download
2. wp config create --dbname=altr --dbuser=admin --dbpass=1 --extra-php <<PHP
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
PHP
3. Open wp-config.php and change $table_prefix
4. wp db create
5. wp core install --url=http://localhost:8888/lifeisgood/altr_fe/ --title=altr --admin_user=admin --admin_password=1 --admin_email=admin@demolink.org
add_filter( 'the_content', 'prefix_change_hello_to_morning' );
function prefix_change_hello_to_morning( $content ) {
if ( is_admin() ) {
return $content;
}
$post_id = get_the_ID();
$post_type = get_post_type( $post_id );
JPEG
find . -iname "*.jpg" -exec jpegoptim --strip-all -m85 -o -p {} \; - ok
find ./ -name "*.jpg" -type f -exec jpegtran -copy none -optimize -progressive -outfile {} {} \;
jpegoptim.exe --strip-all -m85 -o -p *.jpg
PNG
add_filter( 'cherry_services_default_icon_format', 'foo_cherry_services_default_icon_format' );
function foo_cherry_services_default_icon_format( $icon_format ) {
return '<i class="linearicon %s"></i>';
}
@cheh
cheh / gist:424a7ba485496ba524fd57ff5ee5c0c6
Created March 3, 2017 13:22
Cherry5: Cherry Sidebars on Custom Post Types
add_filter( 'cherry_sidebar_post_type', 'my_prefix_add_custom_sidebars_support' );
function my_prefix_add_custom_sidebars_support( $post_types ) {
$post_types[] = 'my-post-type-name-slug'; // tm-property
return $post_types;
}
@cheh
cheh / gist:1b61175101d6330e8c415d06d77c8df5
Created February 28, 2017 11:23
Update jQuery Cherry Framework
// Add code below in your theme `includes/custom-function.php` file.
add_action( 'wp_enqueue_scripts', 'theme55574_back_latest_jquery', 10 );
function theme55574_back_latest_jquery() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
wp_deregister_script( 'jquery' );
wp_deregister_script( 'migrate' );
wp_enqueue_script( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4' );
@cheh
cheh / gist:07914fa20aba67080752e1bee192c2d4
Created February 21, 2017 11:07
Relocate Testimonials slider nav
/* hooks.php*/
// Remove navigation for Testimonials slider.
add_filter( 'tm_testimonials_loop_after', '__tm_remove_testi_slider_nav', 1, 2 );
function __tm_remove_testi_slider_nav( $inner, $args ) {
remove_filter( 'tm_testimonials_loop_after', array( 'TM_Testimonials_Hook', 'slider_navigation' ), 10 );
return $inner;
}
if ( class_exists( 'Cherry_Callback_Likes' ) && class_exists( 'Cherry_Callback_Dislikes' ) ) {
$like = Cherry_Callback_Likes::get_instance();
$dislike = Cherry_Callback_Dislikes::get_instance();
echo $like->get_likes();
echo $dislike->get_dislikes();
}