Skip to content

Instantly share code, notes, and snippets.

View hsleonis's full-sized avatar
🏝️
Travellers unite.

Hasan Shahriar hsleonis

🏝️
Travellers unite.
View GitHub Profile
@hsleonis
hsleonis / wp-list-terms-in-taxonomy.php
Created February 8, 2016 04:44
Print list of all terms of a given taxonomy with link
<?php
$args = array( 'hide_empty=0' );
$terms = get_terms( 'status', $args );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
$count = count( $terms );
$i = 0;
$term_list = '<ul class="spec-project-cat-ul">';
foreach ( $terms as $term ) {
$i++;
$term_list .= '<li class="col-xs-4 remove-padding"><a href="' . esc_url( get_term_link( $term ) ) . '" alt="' . esc_attr( sprintf( __( 'View all %s projects', 'themeaxe' ), $term->name ) ) . '">' . $term->name . '</a></li>';
@hsleonis
hsleonis / wp-custom-submenu-page.php
Last active February 8, 2016 07:20
Create custom submenu in wordpress admin
<?php
/*
Reference:
https://developer.wordpress.org/reference/functions/add_submenu_page/
http://shibashake.com/wordpress-theme/add_menu_page-add_submenu_page
https://premium.wpmudev.org/blog/creating-wordpress-admin-pages/
*/
add_action( 'admin_menu', 'themeaxe_menu' );
function themeaxe_menu() {
@hsleonis
hsleonis / wp-custom-admin-list-column.php
Last active February 8, 2016 08:03
Create custom column in wordpress admin post or page list
<?php
if (function_exists( 'add_theme_support' )){
add_filter('manage_posts_columns', 'posts_columns', 5); // All posts column list
add_action('manage_posts_custom_column', 'posts_custom_columns', 5, 2); // Cloumn content
add_filter('manage_pages_columns', 'posts_columns', 5); // All pages column list
add_action('manage_pages_custom_column', 'posts_custom_columns', 5, 2); // Cloumn content
add_filter('manage_projects_posts_columns', 'posts_columns', 1); // Only custom post 'project' column list
add_action('manage_projects_posts_custom_column', 'posts_custom_columns', 1, 2); // Column content
}
@hsleonis
hsleonis / wp-mail-title-from.php
Created February 9, 2016 18:29
Change the Email Sender in WordPress
<?php
function ec_mail_name( $email ){
return 'Joe Doe'; // new email name from sender.
}
add_filter( 'wp_mail_from_name', 'ec_mail_name' );
function ec_mail_from ($email ){
return '[email protected]'; // new email address from sender.
}
add_filter( 'wp_mail_from', 'ec_mail_from' );
@hsleonis
hsleonis / only-css-ellipsis.css
Created February 10, 2016 09:24
Give paragraph a ellipsis (...) when it overflows text
.add-ellisis {
width: 250px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
@hsleonis
hsleonis / ios-responsive-zoom-in-fix.html
Created February 10, 2016 10:51
ios Safari / Web App Viewport Problem (expands to fit all elements in view) Solution
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, shrink-to-fit=no" />
@hsleonis
hsleonis / php-sanitize.php
Last active February 11, 2016 06:37
This PHP filters is used to validate and filter data coming from insecure sources, like user input. PHP 5.2
<?php
// Reference: http://www.w3schools.com/php/php_ref_filter.asp
$bool = filter_var($bool, FILTER_VALIDATE_BOOLEAN);
$email = filter_var($email, FILTER_SANITIZE_EMAIL);
$newstr = filter_var($str, FILTER_SANITIZE_STRING);
$url = filter_var($var, FILTER_SANITIZE_URL);
// Example: Mail validation
$email = "[email protected]";
// Remove all illegal characters from email
@hsleonis
hsleonis / better-font-smoothing.css
Last active January 12, 2025 12:26
Better font smoothing in cross browser
html {
/* Adjust font size */
font-size: 100%;
-webkit-text-size-adjust: 100%;
/* Font varient */
font-variant-ligatures: none;
-webkit-font-variant-ligatures: none;
/* Smoothing */
text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale;
@hsleonis
hsleonis / wp-featured-image-box-change.php
Created February 20, 2016 09:41
Wordpress move Featured Image box from side to main column or anywhere!
@hsleonis
hsleonis / .htaccess
Created February 22, 2016 06:02
Forcing files to download in apache
<Files *.*>
ForceType application/octet-stream
</Files>