Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: My Custom Post Types
Description: Add post types for movies and movie reviews
Author: Liam Carberry
*/
// Hook <strong>lc_custom_post_movie()</strong> to the init action hook
add_action( 'init', 'lc_custom_post_movie' );
<?php
date_default_timezone_set('Etc/UTC');
require '../PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Tell PHPMailer to use SMTP
$mail->isSMTP();
//Enable SMTP debugging
// 0 = off (for production use)
// 1 = client messages
version: '2'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
<?php
$servername = "mysql.hostinger.com";
$username = "u266072517_user";
$database = "u266072517_name";
$password = "buystuffpwd";
// Create a new connection to the MySQL database using PDO
$conn = new mysqli($servername, $username, $password);
// Check connection
@domantasg
domantasg / gist:2cdb90d01f4ca410e1cfafb819223c27
Created May 29, 2017 12:54
WordPress functions.php Google Analytics Fuction
add_action('wp_head','my_analytics', 20);
function my_analytics() {
?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
// Display field value
the_field( 'FIELD NAME' );
// Return field value
get_field( 'FIELD NAME' );
/ Hook our custom function to the pre_get_posts action hook
add_action( 'pre_get_posts', 'add_reviews_to_frontpage' );
// Alter the main query
function add_reviews_to_frontpage( $query ) {
if ( is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'movie', 'review' ) );
}
return $query;
}
@domantasg
domantasg / Google Analytics Universal Tacking Code
Created May 29, 2017 12:51
Google Analytics Universal tracking code
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-00000000-1', 'auto');
ga('send', 'pageview');
</script>
<?php
ini_set( 'display_errors', 1 );
error_reporting( E_ALL );
$from = "testing@yourdomain.com";
$to = "recipient@emailaddress.com";
$mail->Host = "HOSTINGER_SMTP_HOST_HERE";
//Set the SMTP port number - likely to be 25, 465 or 587
$mail->Port = HOSTINGER_SMTP_PORT_HERE;
//Whether to use SMTP authentication
$mail->SMTPAuth = true;
//Username to use for SMTP authentication
$mail->Username = "YOUR_SMTP_USERNAME";
//Password to use for SMTP authentication
$mail->Password = "YOUR_SMTP_PASSWORD";
//Set who the message is to be sent from