Posts

How to add links to Javascript files in Wordpress Child Theme using wp_enqueue_script

Took some to figure this out. In your "functions.php" file in your child theme directory add this code function wpb_adding_scripts() { if (!is_admin()) { wp_register_script('my_amazing_script', get_stylesheet_directory_uri() . '/js/scroller.js', array('jquery'),'1.1', true); wp_enqueue_script('my_amazing_script'); } } add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' ); This function checks that you are not logged in as an administrator. my_amazing_script can be named anything you like get_stylesheet_directory_uri() is important if you're doing this in your child theme functions.php file 1.1 is your version number and can be anything true is to load the JS file at the bottom of the page, false is to load the JS file at the top of the page

Sanitize Form Input in PHP to Prevent SQL Injection and Spam

I had to create a custom form recently for my website in Wordpress and had to ensure I cleaned up the input to prevent SQL injection and SPAM.  I could use the Contact Form 7 plugin but I had to format the input before sending via email. I used the strip_tags() and trim() PHP functions to sanitize the input $name = strip_tags(trim($name)); So if the input in the form field for name was:  <a href="www.scam.com" target="_blank">    WIN</a> The output after using these two functions would just be WIN The trim() function cleared the whitespace before the word "win" and the HTML or PHP tags were removed completely

Add Google Conversion Tracking Code to Prestashop CMS page

If you've created a custom thank you or confirmation page in Prestashop and need to place Google Conversion Tracking code in this page follow these steps: In your "themes" folder locate your active theme folder and download the Smarty template file named "cms.tpl" This is the one template file for all CMS pages Because Prestashop uses Smarty the coding differs slightly from PHP Add the following code to the end of the "cms.tpl" file {if $cms->id == 1} {literal} Google Conversion Tracking Code Snippet Goes Here {/literal} {/if} Change 1 to the corresponding ID number in your Prestashop admin site when you create your page. Upload "cms.tpl" back into theme folder

Syncing iTunes playlist on Windows PC to iPhone

After you've installed iTunes on your Windows PC (I use Windows 7 Professional) go to your Music folder and inside the iTunes folder create a folder to store all your media for your phone i.e.: Music, Videos, Tones, eBooks  You can name the folder "Data Store" Open iTunes and go to the relevant media tab e.g.: Music Click on File->Add File to Library... Locate your folder, in this case Data Store and choose the file Once the file is in your iTunes library you sync your library with your iPhone The files in my iTunes library are only for syncing with my phone.  I use VLC Media Player for all my media on my PC otherwise. Connect your iPhone USB data cable.  iTunes will detect your iPhone In iTunes click on the mobile phone icon (top left) Under "Settings" on the left-hand-side ensure you have the Sync option selected for your media types Under "On My Device" on the left-hand-side click on your media type and click "Sync" ...

Generate SALT Keys for Wordpress

When setting up your Wordpress site make sure you add SALT keys to your wp-config.php file. Get these keys generated here: https://api.wordpress.org/secret-key/1.1/salt/ Just copy and paste the 8 lines from the page above into your config file Refresh to generate new keys

Move Wordpress Site to New URL and Web Host

Moving a website and changing your domain name or URLs (i.e. from http://example.com/site to http://example.com , or http://example.com to http://example.net ) requires the following steps - in sequence. Download your existing site files. Export your database - go in to MySQL and export the database. Move the backed up files and database into a new folder - somewhere safe - this is your site backup. Log in to the site you want to move and go to Settings -> General, then change the URLs. (ie from http://example.com/ to http://example.net ) - save the settings and expect to see a 404 page . Download your site files again. Export the database again. Edit wp-config.php with the new server's MySQL database name, user and password. Upload the files. Import the database on the new server. When your domain name or URLs change there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the datab...

How To Write your Own Wordpress Plugin

Create your own PHP script usng the following template: <?php /* Plugin Name: Your Own Plugin Name Description: What your plugin does Version: 0.1 License: GPL Author: Brendan Cornelius Author URI: http://br3nd4nc.blogspot.com */ ?> You can add your own PHP code in this file and upload to the "plugins" folder on your server via FTP Once you upload your file go to your plugins section in your Wordpress Dashboard and activate the plugin