Categories
Apply to

Full-width-height-of-viewport

// global vars
var winWidth = $(window).width();
var winHeight = $(window).height();

// set initial div height / width
$('div').css({
    'width': winWidth,
'height': winHeight,
});

// make sure div stays full width/height on resize
$(window).resize(function(){
    $('div').css({
    'width': winWidth,
    'height': winHeight,
});
});

Source: https://coderwall.com/p/nsv3cq/div-full-width-height-of-viewport

Categories
Apply to

Beginners-guide-regular-expressions

No programming concept frightens programmers more than regular expressions. For a lot of us, seeing code with regular expressions in it can bring a sense of dread and anxiety. We often have no idea what’s going on or how a regular expression does what it does.

Source https://carlalexander.ca/beginners-guide-regular-expressions/

Categories
Apply to

how-show-hidden-files-folders-mac

In MacOS Sierra Apple added a Finder keyboard shortcut that makes it possible to quickly show all the hidden files and folders. You just need to do the following:

  1. Open the Finder
  2. Go to your Macintosh HD folder (access this from Devices in the left column)
  3. Hold down CMD-Shift-. (dot)
  4. All the hidden files will become visible
  5. Hold down CMD-Shift-. (dot) a second time to hide the files again

The easiest way to find your hidden ~/Library/ folder is to do the following:

Categories
Apply to

Centering CSS Complete guide

Centering in CSS: A Complete Guide


.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}

Categories
Apply to

Plugin API/Filter Reference/login redirect « WordPress Codex

/** * Redirect user after successful login. * * @param string $redirect_to URL to redirect to. * @param string $request URL the user is coming from. * @param object $user Logged user’s data. * @return string */function my_login_redirect( $redirect_to, $request, $user ) { //is there a user to check? if ( isset( $user->roles ) && is_array( $user->roles ) ) { //check for admins if ( in_array( ‘administrator’, $user->roles ) ) { // redirect them to the default place return $redirect_to; } else { return home_url(); } } else { return $redirect_to; }}add_filter( ‘login_redirect’, ‘my_login_redirect’, 10, 3 );

Source: Plugin API/Filter Reference/login redirect « WordPress Codex

Categories
Apply to

WP Snippet: Block access to the mainsite dashboard in WordPress multisite – WPcustoms Codes

if you are running a WordPress Multisite and want to restrict the access to the dashboard of the main site to everyone apart from the super admin use this snippet

Source: WP Snippet: Block access to the mainsite dashboard in WordPress multisite – WPcustoms Codes

 

 

add_filter('body_class','browser_body_class');
function browser_body_class($classes) {

global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone;

if($is_lynx) $classes[] = 'lynx';

elseif($is_gecko) $classes[] = 'gecko';

elseif($is_opera) $classes[] = 'opera';

elseif($is_NS4) $classes[] = 'ns4';

elseif($is_safari) $classes[] = 'safari';

elseif($is_chrome) $classes[] = 'chrome';

elseif($is_IE) $classes[] = 'ie';

else $classes[] = 'unknown';

if($is_iphone) $classes[] = 'iphone';

return $classes;
}

Categories
Apply to

Form Submit button

https://www.tjvantoll.com/2013/01/01/enter-should-submit-forms-stop-messing-with-that/

 

Therefore, if you have a form with more than one input field, always include a submit button. Specifically an <input> with the type="submit" attribute, or a <button> element should be present. (Note: IE7 has a bug where the typeattribute of a <button> defaults to button instead of submit. Therefore for IE7 compatibility you’ll need <button type="submit">.)

Categories
Apply to

Understanding Bootstrap Modals

Read Bootstrap 3 – JavaScript Components for more JavaScript plugins available from Bootstrap and if you’re new to Bootstrap, you can check out my Bootstrap 3 Tutorial.

Source: Understanding Bootstrap Modals

Categories
Apply to

php – Preserve Line Breaks – Simple HTML DOM Parser – Stack Overflow

realized there was actually a built in option to turn off the removal of line breaks. No need to go editing the source.The PHP Simple HTML Dom Parser’s load function supports multiple useful parameters:load($str, $lowercase=true, $stripRN=false, $defaultBRText=DEFAULT_BR_TEXT)When calling the load function, simply pass false as the third parameter.$html = new simple_html_dom();$html->load(“stuff”, true, false);If using file_get_html, it’s the ninth parameter.file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT)Edit: For str_get_html, it’s the fifth parameter (Thanks yitwail)str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)

Source: php – Preserve Line Breaks – Simple HTML DOM Parser – Stack Overflow

Categories
Apply to

using jquery serialize in ajax operation for plugin

Provided that your server receives data in the form of a string which it should if you’re using the jQuery serialize() function.

It will be something like:

name1=value&name2=value&name3=value

You just need to parse the string into an array as follows:

$parameters = array();
parse_str($_GET, $parameters);

See the following for more information: http://www.php.net/manual/en/function.parse-str.php

shareimprove this answer

Source: using jquery serialize in ajax operation for plugin