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 / object-property-loop.php
Created February 24, 2016 04:47
Looping through all the properties of object php
<?php
foreach ($obj as $key => $value) {
echo "$key => $value\n";
}
@hsleonis
hsleonis / wp-content-move.php
Created February 24, 2016 11:48
Move The wp-content Folder
<?php
/*
To change the location of the wp-content is quite simple as the location of this folder
can be configured in your wp-config.php file. One thing to note is that you need to add
these new constant variable above the line where WordPress includes the wp-settings.php.
*/
// All you have to do is add a new variable WP_CONTENT_DIR and change the location of your wp-content folder.
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/blog/content/wp-content' );
// To change the location of the wp-content URL there is another variable you can define in the wp-config.
define( 'WP_CONTENT_URL', 'http://www.paulund.co.uk/blog/content/wp-content' );
@hsleonis
hsleonis / wp-login-logo-title-change.php
Last active March 2, 2016 11:19
Change WordPress admin login logo, mouseover title and logo url.
<?php
// add this to your themes functions.php file
// change login image
add_action("login_head", "tmx_login_head");
function tmx_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_header_image()."') no-repeat scroll center top transparent;
height: ".get_custom_header()->height."px;
@hsleonis
hsleonis / wp-custom-post-archive-title.php
Created March 20, 2016 11:41
Display the Custom Post Type title
<?php
/*
This is optimized for archive.php and archive-{posttype}.php template files for displaying the title of the post type.
Usage:
<?php post_type_archive_title( $prefix, $display ); ?>
Parameters:
$prefix
(string) (optional) What to display before the title
Default: None
$display
@hsleonis
hsleonis / jquery-form-reset.js
Last active March 21, 2016 11:06
Jquery reset form
/*
Method 1: Reset
*/
$('#create-user-form')[0].reset();
// or
$('#create-user-form').get(0).reset()
// or inline
<input type="button" onclick="this.form.reset();">
/*
@hsleonis
hsleonis / bootboxjs-ajax.js
Created March 22, 2016 10:10
Dynamic content in Bootbox JS with AJAX request
bootbox.dialog({
title: "This is a AJAX Form from external file.",
data: {'user':'dc','task':'get'},
datauri: 'ajax.html',
buttons: {
success: {
label: "Save",
className: "btn-success",
callback: function () {
var name = $('#name').val();
@hsleonis
hsleonis / ini_set.php
Created March 22, 2016 12:23
Sets the value of a configuration option
<?php
/*
Pattern: string ini_set ( string $varname , string $newvalue )
Documentation: http://php.net/manual/en/function.ini-set.php
*/
echo ini_get('display_errors');
if (!ini_get('display_errors')) {
ini_set('display_errors', '1');
}
@hsleonis
hsleonis / image-rendering.css
Last active April 5, 2016 10:05
The image-rendering property defines how the browser should render an image if it is scaled up or down from its original dimensions.
/*
Chrome appears to render pixelated images in the same way that Firefox and Safari will render images with crisp-edges.
Reference:
https://css-tricks.com/almanac/properties/i/image-rendering
https://developer.mozilla.org/en/docs/Web/CSS/image-rendering
*/
img {
image-rendering: auto;
image-rendering: crisp-edges;
@hsleonis
hsleonis / text-unselectable.css
Created March 23, 2016 09:21
Make text unselectable
/*
This is useful in situations where you want to provide an easier/cleaner
copy-paste experience for users (not have them accidentally text-select
useless things, like icons or images). However it's a bit buggy. Firefox enforces
the fact that any text matching that selector cannot be copied. WebKit still
allows the text to be copied if you select elements around it.
Reference: https://css-tricks.com/almanac/properties/u/user-select
*/
.row-of-icons {
-webkit-user-select: none; /* Chrome all / Safari all */
@hsleonis
hsleonis / iphone-text-resizing-disable.css
Created March 23, 2016 10:16
Mobile Safari on iPhone will automatically increase the size of small text.The work around is ‑webkit‑text‑size‑adjust: 100%
/*
On mobile devices, the text-size-adjust property allows Web authors to control if and how
the text-inflating algorithm is applied to the textual content of the element it is applied to.
As this property is non-standard, it must be used prefixed: -moz-text-size-adjust,
-webkit-text-size-adjust, and -ms-text-size-adjust.
Reference:
http://blog.55minutes.com/2012/04/iphone-text-resizing
http://davemacaulay.com/webkit-text-size-adjust-doesnt-work-on-android-chrome
*/