SUBBUINDESIGN Blog

How to integrate WordPress template with CodeIgniter?

First step is to move CodeIgniter and the WordPress files in their own directory. After that, put the following line at the top of your CodeIgniter’s index.php file. Change the path to wp-blog-header.php as needed to...

Get WordPress Post ID from Post title

Found a solution if anyone else struggles with this. Only posted the question out of desperation after 4 hours testing/Googling! function get_post_by_title($page_title, $output = OBJECT) { global $wpdb; $post = $wpdb->get_var( $wpdb->prepare( “SELECT ID...

How to parse and process HTML/XML with PHP?

I prefer using one of the native XML extensions since they come bundled with PHP, are usually faster than all the 3rd party libs and give me all the control I need over the markup. DOM...

Can I put a html button inside the canvas?

Given that the canvas element has a transparent content model, it may contain fallback elements which are displayed in the event that the canvas element is unsupported. They will not be displayed if the canvas is supported. If you display a list of controls in...

How to show popup message using CSS and jQuery?

Here’s how  does it: This is the markup, initially hidden so we can fade it in: <div id=’message’ style=”display: none;”> <span>Hey, This is my Message.</span> <a href=”#” class=”close-notify”>X</a> </div> Here are the styles applied:...

Can scripts be inserted with innerHTML?

I tried to load some scripts into a page using innerHTML with a div. It appears that the script loads into the dom, but it is never executed (at least in ff and chrome)....

How to copy to the clipboard in JavaScript?

Automatic copying to clipboard may be dangerous, therefore most browsers (except IE) make it very difficult. Personally, I use the following simple trick: function copyToClipboard (text) { window.prompt (“Copy to clipboard: Ctrl+C, Enter”, text);...

How to Compress CSS with PHP code?

Start your CSS files with this PHP (and name it style.php): <?php ob_start (“ob_gzhandler”); header(“Content-type: text/css; charset: UTF-8”); header(“Cache-Control: must-revalidate”); $offset = 60 * 60 ; $ExpStr = “Expires: ” . gmdate(“D, d M...

How to move CMSms installation to a new server

It is a simple, four step process to move your installation from one server to another. Step 1 Clear the Cache: Login to admin, go to Site Admin/System Maintenance and clear the cache. This...

How to Convert a static website to CMS Made Simple?

Step 1 Install CMSms on your production hosting: So you have a internet domain for your site, say website.com. Your old plain HTML pages are available at website.com/aboutus.html, website.com/products.html, website.com/solutions.html etc. And your old...

Basics of Google Font API (Application Program Interface)

Link to CSS files You essentially hotlink directly to CSS files on Google.com. Through URL parameters, you specificity which fonts you want, and what variations of those fonts. <head> <link rel=”stylesheet” type=”text/css” href=”http://fonts.googleapis.com/css?family=Tangerine:bold,bolditalic|Inconsolata:italic|Droid+Sans”> </head>...

How to avoid Java Code in JSP-Files?

The use of scriptlets (those <% %> things) in JSP is indeed highly discouraged since the birth of taglibs (like JSTL) and EL (Expression Language, those ${} things) over a decade ago. The major disadvantages of scriptlets are: Reusability: you can’t reuse scriptlets. Replaceability: you can’t make...

Simple Auto-Playing Slideshow using CSS3

HTML Wrapper with div’s as the “slides”, which can contain any content. <div id=”slideshow”> <div> <img src=”http://farm6.static.flickr.com/5224/5658667829_2bb7d42a9c_m.jpg”> </div> <div> <img src=”http://farm6.static.flickr.com/5230/5638093881_a791e4f819_m.jpg”> </div> <div> Pretty cool eh? This slide is proof the content can be...

Protecting Your Phone from Malware

While not all that common today, malware on phones is increasing, and you should get to know what puts your security at risk. Dealing with a virus or malware has long been accepted as...

How can i solve this php errorr“Notice: Undefined variable”?

Relying on the default value of an uninitialized variable is problematic in the case of including one file into another which uses the same variable name. It is also a major security risk with register_globalsturned on. E_NOTICE level error...

How can I get query string values?

You don’t need jQuery for that purpose. You can use the pure JavaScript: function getParameterByName(name) { name = name.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”); var regexS = “[\\?&]” + name + “=([^&#]*)”; var regex = new RegExp(regexS);...

How to prevent SQL injection in PHP?

Use prepared statements and parameterized queries. These are SQL statements that are sent to and parsed by the database server separately from any parameters. This way it is impossible for an attacker to inject malicious...

How make Accessibility/SEO Friendly CSS Hiding code?

#content { position: absolute; top: -9999px; left: -9999px; } Removes an item from the page, without affecting page flow or causing scrollbars. Much better than display: none; or even visibility: hidden;  

How to Empty an Array using jQuery?

This is one of the fastest and easiest ways of emptying an array. Of course there are may other ways, but those usually include creation of a new array. This way you reuse the...

How to Turn on WordPress Error Reporting

Comment out the top line there, and add the rest to your wp-config.php file to get more detailed error reporting from your WordPress site. Definitely don’t do this live, do it for local development and testing....

Different Stylesheet Pending the Time of Day

<script> <!– function getStylesheet() { var currentTime = new Date().getHours(); if (0 <= currentTime&&currentTime < 5) { document.write(“<link rel=’stylesheet’ href=’night.css’ type=’text/css’>”); } if (5 <= currentTime&&currentTime < 11) { document.write(“<link rel=’stylesheet’ href=’morning.css’ type=’text/css’>”); }...

How get Year Shortcode for a wordpress website?

For the functions.php file: function year_shortcode() { $year = date(‘Y’); return $year; } add_shortcode(‘year’, ‘year_shortcode’); Usage Use [year] in your posts.

HTML Radio Buttons using PHP coding

A Radio Button is a way to restrict users to having only one choice. Examples are : Male/Female, Yes/No, or answers to surveys and quizzes. Here’s a simple from with just two radio buttons...

What are the important CSS Rules

A Cascading Stylesheet rule tells the browser what the HTML looks like, and what it should do. A rule can dictate what just one HTML tag should look like, or you can construct your own...

How to create Dropdown Lists using jquery

The code to check the dropdown list is more or less the same as for radio buttons. Here it is: The only difference is in the IF Statement. Between the round brackets we have...