HOW TO CONVERT FORMDATA TO JSON OBJECT

Recently, whilst working on a project I needed to take HTML FormData and then convert it to JSON to be sent off to an API. By default the FormData object does not work in the way you would want it to for JSON.

Using the for..of syntax introduced in ECMAScript 2015, we can access the form data entries and iterate over them to get key and value pairs. This will be the verbose solution, scroll to the bottom to get the cleaner solution using .reduce below.

Read More

BULK LINUX CHMOD COMMANDS FOR FILES & DIRECTORIES

Recently in Ubuntu which I use for my hosting operating system of choice I needed to bulk change permissions on a bunch of folders and files. I needed to set permissions on folders within a WordPress installation to 755 and all files in theme, plugin and asset directories to 644.

Read More

Posts Permalink: Force Rewrite WordPress URLs to Use /blog/ in Posts Permalink Structure

This tutorial will show you ways to force rewrite WordPress URLs to use /blog/ in posts permalink structure. Websites that have an outsized number of pages, custom post types, posts, and posts categories may benefit by using the prefix “blog” within the URL rather than the blog category name slug. Most importantly, blogs that have posts in multiple categories, or categories that get removed or changed, should use this type of URL structure.

Read More

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 SQL.

Read More

HTML 5 Notes For Professional – Chapter – 12 (Linking Resources)

AttributeDetails
charsetSpecifies the character encoding of the linked document
crossoriginSpecifies how the element handles cross origin requests
hrefSpecifies the location of the linked document
hreflangSpecifies the language of the text in the linked document
mediaSpecifies on what device the linked document will be displayed, often used with selecting stylesheets based on the device in question
relRequired. Specifies the relationship between the current document and the linked document
revSpecifies the relationship between the linked document and the current document
sizesSpecifies the size of the linked resource. Only when rel="icon"
targetSpecifies where the linked document is to be loaded
typeSpecifies the media type of the linked document
integritySpecifies a base64 encoded hash (sha256, sha384, or sha512) of the linked resource allowing the browser to verify its legitimacy.

While many scripts, icons, and stylesheets can be written straight into HTML markup, it is best practice and more efficient to include these resources in their own file and link them to your document. This topic covers linking external resources such as stylesheets and scripts into an HTML document.

Read More

HTML 5 Notes For Professional – Chapter – 11 (Data Attributes)

ValueDescription
some valueSpecifies the value of the attribute (as a string)

Older browsers support

Data attributes were introduced in HTML5 which is supported by all modern browsers, but older browsers before HTML5 don’t recognize the data attributes.

However, in HTML specifications, attributes that are not recognized by the browser must be left alone and the browser will simply ignore them when rendering the page.

Web developers have utilized this fact to create non-standard attributes which are any attributes not part of the HTML specifications. For example, the value attribute in the line bellow is considered a non-standard attribute because of the specifications for the <img> tag don’t have a value attribute and it is not a global attribute:

<img src="sample.jpg" value="test" />

Read More

Key Maintenance Tasks for Your WordPress Website

For your WordPress web site to be successful, you’ll got to target quite simply its content and style. Regular maintenance is additionally needed, to stay your website secure and running swimmingly. Over time, however, these maintenance tasks will begin to accumulate and feel a small amount overwhelming.

Read More

HTML 5 Notes For Professional – Chapter – 10 (Classes and IDs)

ParametersDetails
classIndicates the Class of the element (non-unique)
idIndicates the ID of the element (unique in the same context)

Classes and IDs make referencing HTML elements from scripts and stylesheets easier. The class attribute can be used on one or more tags and is used by CSS for styling. IDs however are intended to refer to a single element, meaning the same ID should never be used twice. IDs are generally used with JavaScript and internal document links, and are discouraged in CSS. This topic contains helpful explanations and examples regarding proper usage of class and ID attributes in HTML.

Read More

Pin It on Pinterest