Skip to content

Instantly share code, notes, and snippets.

View Hexodus's full-sized avatar

Adrian Maleska Hexodus

  • Wiesbaden - Germany
View GitHub Profile
@Hexodus
Hexodus / count_total_project_code_lines_in_sublime
Created September 8, 2013 17:06
Count total code lines in project using Sublime texteditor
// Go to menue:
// find->find in files
// Switch on reg_ex button
// Find:
^(.*)$
// Where:
c:\your_folder\,*.php,*.phtml,*.js,*.inc,*.html, -*/folder_to_exclude/*
// Then click on the find button
// Be careful to not click on Replace!!!
yarn create nuxt-app <my-project>
@Hexodus
Hexodus / wp_custom_excrept_length.php
Created August 2, 2017 16:51
Wordpress set custom excrept length in words.
<?php
//custom excrept length in words
add_filter( 'excerpt_length', function(){ return 40; }, 999 );
?>
@Hexodus
Hexodus / get_site_thumbnail_instead_of_post.php
Created August 2, 2017 14:48
Wordpress. Method to get the site features image instead of the loop ones. Useful for blogs where usually the_post_thumbnail() would call the first loop image thumbnail.
<?php
$img = wp_get_attachment_image_src(get_post_thumbnail_id(get_option('page_for_posts')),'full');
$featured_image = $img[0];
?>
@Hexodus
Hexodus / wordpress_change_image_compression.php
Last active August 2, 2017 10:14
Change Wordpress default image compression percentage. I'm most happy with 90% ;) Keep in mind that it applies only to new uploaded images - old ones have to be regenerated.
<?PHP
add_filter('jpeg_quality', function($arg){return 90;});
?>
@Hexodus
Hexodus / add_custom_image_sizes_2wordpress.php
Last active August 2, 2017 09:36
Add custom images sizes to Wordpress and Admin area. Found solution here: https://havecamerawilltravel.com/photographer/wordpress-resize-thumbnails Place this code in your functions.php (i.e. in your child theme's folder)
<?php
add_image_size( 'homepage-thumb', 270, 175, false ); //soft crop = resize
add_image_size( 'search-thumb', 150, 150, true ); //hard crop
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'homepage-thumb' => __( 'Homepage Thumb' ),
'search-thumb' => __( 'Search Thumb' ),
) );
@Hexodus
Hexodus / reactivate_admin_toolbar.php
Last active August 2, 2017 09:36
Reactivate Wordpress admin toolbar when it was hidden by the parent theme (idiots are everywhere!). In this case I reactivate it only for admins. Place this code in your functions.php (i.e. in your child theme's folder)
<?php
if( current_user_can('administrator'))
add_filter( 'show_admin_bar', '__return_true' , 1000 );
?>
@Hexodus
Hexodus / htaccess_ssl_wp
Last active July 27, 2017 11:07
Force SSL for Wordpress via htaccess. Works for both single Blogs or Multisite. Just add below RewriteEngine On RewriteBase / #Force SSL code here On shared hosting it could produce to much redirections - when you convert from http to https. So it's better to rewrite all url's first (but after switching ssl on your hosting on) to reduce them. Th…
#Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@Hexodus
Hexodus / unity_find_inactive_game_object
Last active June 15, 2017 12:55
Find inactive Game Objects in Unity 3D. The right method to go is to search over the parents transform for a script on the child like this.
var theParentGO = GameObject.Find("ParentName");
theParentGO.transform.GetComponentInChildren<ScriptOnTheChild>(true).gameObject;
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]