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 / dataTablejsfix.js
Created February 1, 2016 19:57
DataTables.js TypeError: c is undefined fix
var table = ''; // Variable in global scope to store the data table instance
if ( $.fn.dataTable.isDataTable( '#data-table' ) ) {
table.destroy(); // Destroy old instance
}
$scope.json = data.data; // Get json data with angular $http service
var target = $('#data-table thead'); // Data table thead
var target2 = $('#data-table tbody'); // Data table tbody
@hsleonis
hsleonis / wpStylesheet.php
Last active January 26, 2024 02:21
WordPress change default stylesheet location
<?php
/*
Add these code to your functions.php
This will only change the stylesheet/stylesheet dir uri
But will not add theme info from the new location
To fix you must place another style.css with theme information in theme root directory (i.e: wp-content/themes/twintysixteen/)
*/
add_filter('stylesheet_uri','wpi_stylesheet_uri',10,2);
@hsleonis
hsleonis / phpStrictStandards.php
Created February 2, 2016 11:25
Remove PHP Strict Standards message
<?php
/*
Using php.ini file:
error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING & ~E_STRICT & ~E_DEPRECATED
Warning! : This may cause 500 internal error on some server, contact provider
*/
/*
Using php
*/
@hsleonis
hsleonis / ngDirectiveProcessing.js
Created February 2, 2016 11:29
Angular [an error occurred while processing this directive] solution
Check your code you might have wrote a comment <!--#some comment--> then add space,
<!--[add space ] #some comment [add space] --> Like this <!-- #some comment -->
Also check Folder permission must be 644 or 744 or 755.
You can also use 'chown'
@hsleonis
hsleonis / angularElementScope.js
Created February 2, 2016 12:23
Get angular scope with jQuery
angular.element(document.getElementById('yourElementId')).scope();
@hsleonis
hsleonis / varSwap.php
Created February 3, 2016 05:01
Swap variables in PHP
<?php
// Way 1
$a = $b + $a - ($b = $a);
// Way 2
list($b, $a) = array($a, $b);
// Way 3
function swap(&$a, &$b) {
$tmp = $a;
@hsleonis
hsleonis / wpTitle.php
Created February 3, 2016 05:21
Wordpress dynamic title
<?php
add_filter( 'wp_title', 'wpdocs_hack_wp_title_for_home' );
function wpdocs_hack_wp_title_for_home( $title )
{
if ( empty( $title ) && ( is_home() || is_front_page() ) ) {
$title = __( 'Home', 'themeaxe' ) . ' | ' . get_bloginfo( 'description' );
}
return $title;
}
@hsleonis
hsleonis / subpixel-rendering.css
Last active February 4, 2016 09:49
Better Font Smoothing in Chrome & Safari
/*
The typeface, regardless of how it is being served (Typekit, Google, @font-face) is loaded and then computed at a sub pixel level.
The smoothing happens in a space we can't see easily. Because of this, some browsers (looking at you Chrome & Firefox)
take beautiful, slender fonts and bloat them, making the edges appear jagged, losing the quality of beautiful,
crisp shapes designers crave in web type.
This only works in Chrome on Mac OS X
*/
/* First, remove sub pixel antialiasing by using the antialiased property. */
html {
@hsleonis
hsleonis / wp-post-next-previous-link.php
Created February 7, 2016 07:05
Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the current post.
<?php
/*
previous_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' );
*/
previous_post_link('%link', 'Previous in category', TRUE, '12');
previous_post_link( '%link', 'Previous post in category', TRUE, ' ', 'post_format' );
// Using font-awesome icon in link custom buttom
previous_post_link( '%link', '<i class="sprite sprite-left-arrow"></i>', TRUE, ' ', 'status' );
@hsleonis
hsleonis / wp-custom-taxonomy-loop.php
Created February 7, 2016 07:19
Custom Taxonomy not showing posts solution
<?php
/*
Even though it's tied to the custom post,
it still assumes you want to query normal post so I added this to my template and it works:
*/
global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => 'portfolio' ) );
$post = query_posts( $args ); // All posts in query