Categories

Find out if a domain name exists

You can user CURL to request a page and evaluate the response to determine if the page exists.

function verify_domain($domain='') {
	$url = "http://" . $domain;
	$ch = curl_init($url);
	curl_setopt($ch, CURLOPT_NOBODY, true);
	curl_exec($ch);
	$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
 
	if($code >= 400) {
		return false;
	}
 
	return true;
}

Render jQuery Mobile on Desktop Computers

If you designed a jQuery Mobile site that it is intended for small size screens, that does not mean that someone will never open your app from a desktop computer. Obviously, an app that was design for an actual screen size of 320 px will not look right if it is opened on a desktop computer.

To prevent the app from looking awful, we can apply CSS to restrict the jQuery Mobile pages from rendering at a width higher that, let’s say, 480 px.

@media only screen and (min-width : 480px) {
 
	div[data-role="page"] > *[data-role="header"],
	div[data-role="page"] > *[data-role="footer"] {
	    width: 480px !important;
        left: 50%;
        margin-left: -240px;
	}
 
	div[data-role="page"] {
	    width: 480px !important;
        left: -240px !important;
        margin-left: 50%;
	}
 
	/* add your favorite image to the background */
	body {
		background-image: url('my-favorite-background.jpg');
		background-attachment: fixed;
		}
}

Setting Up The Default Values Of The jQueryMobile Preloader

Here is a quick example that shows how to setup the default values of the jQueryMobile preloader:

?View Code JAVASCRIPT
$(document).on("mobileinit", function () {
    $.mobile.loader.prototype.options.text = "loading";
    $.mobile.loader.prototype.options.textVisible = false;
    $.mobile.loader.prototype.options.theme = "a";
    $.mobile.loader.prototype.options.html = "";
});

Get individual value from a Post or Page

/**
 * for $value you can use any post field (i.e. post_description, post_title, etc.
 */ 
function get_post_value($id_or_name, $value='post_title') {
	global $wpdb;
	if(is_int($id_or_name)) {
		$field = 'ID';
	} else {
		$field = 'post_name';
	}
 
	$value = $wpdb->get_var("SELECT $value FROM $wpdb->posts WHERE $field = '".$post_name."'");
	return $value;
}