Skip to content

Instantly share code, notes, and snippets.

Adrian Maleska Hexodus

  • Wiesbaden - Germany
Block or report user

Report or block Hexodus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View create-nuxt-app
yarn create nuxt-app <my-project>
@Hexodus
Hexodus / wp_custom_excrept_length.php
Created Aug 2, 2017
Wordpress set custom excrept length in words.
View wp_custom_excrept_length.php
<?php
//custom excrept length in words
add_filter( 'excerpt_length', function(){ return 40; }, 999 );
?>
@Hexodus
Hexodus / get_site_thumbnail_instead_of_post.php
Created Aug 2, 2017
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.
View get_site_thumbnail_instead_of_post.php
<?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 Aug 2, 2017
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.
View wordpress_change_image_compression.php
<?PHP
add_filter('jpeg_quality', function($arg){return 90;});
?>
@Hexodus
Hexodus / reactivate_admin_toolbar.php
Last active Aug 2, 2017
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)
View reactivate_admin_toolbar.php
<?php
if( current_user_can('administrator'))
add_filter( 'show_admin_bar', '__return_true' , 1000 );
?>
@Hexodus
Hexodus / add_custom_image_sizes_2wordpress.php
Last active Aug 2, 2017
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)
View add_custom_image_sizes_2wordpress.php
<?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 / htaccess_ssl_wp
Last active Jul 27, 2017
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…
View htaccess_ssl_wp
#Force SSL
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
View htaccess_rewrite_to_https
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
@Hexodus
Hexodus / globals_vs_constants_vs_define.php
Last active Apr 23, 2017
$GLOBALS vs define() vs const; It depends. I would go for `define()` because it has a more compact syntax in usage. But `define()` can only hold scalar values in PHP < 7.0 In case you need i.e. an associative array you have no other choice then to go for ` $GLOBALS` or use PHP >=7.0. From http://stackoverflow.com/questions/10691404/php-best-way-…
View globals_vs_constants_vs_define.php
// Storing a single value works fine with define
define( 'ROOT_DIR', dirname(dirname(__FILE__)) . '/' );
// But not for complex data types like this array
$USERPIC_PARAMS = array(
"user_root" => "images/users",
"padding_length" => 8,
"split_length" => 4,
"hash_length" => 12,
"hide_leftover" => false
You can’t perform that action at this time.