Skip to content

Instantly share code, notes, and snippets.

View mattclements's full-sized avatar

Matt Clements mattclements

View GitHub Profile
@mattclements
mattclements / app.js
Created January 8, 2017 09:37
Doorbell
function send_pushover_notification() {
var push = require( 'pushover-notifications' );
var p = new push( {
user: "xxxx",
token: "xxxx"
});
var msg = {
@mattclements
mattclements / function.php
Last active April 16, 2024 17:04
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
@mattclements
mattclements / DB.php
Created September 24, 2015 08:05
DB Class
<?php
class DB
{
private $_dbname;
private $_dbhost;
private $_dbuser;
private $_dbpass;
private $_dbcon;
<?php
//MODIFIED HEADER DATE
##################################################################################
function set_headerdate() {
$format = "%a, %d %b %Y %H:%M:%S %z";
// First check if there is a blog post date
if (function_exists('perch_blog_post_field') && function_exists('perch_get') && perch_blog_post_field(perch_get('s'), 'postDateTime', true)) {
$result = perch_blog_post_field(perch_get('s'), 'postDateTime', true);
header("Last-Modified: ".strftime($format, strtotime($result)));
<section class="section // section--base // section--fixed">
<div class="container">
<?php
//Array (Feature Title, Feature Description, Icon Class);
$adverts = array (
array('No Call Out Charge','Free quotation for all jobs','no-callout'),
array('Qualified Plumbers','Qualified Gas Safe Engineers','tick'),
array('Free Quotations','No obligation free quotations','contract'),
@mattclements
mattclements / .editorconfig
Created January 2, 2015 15:50
DFC Editor Config
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
@mattclements
mattclements / functions.php
Created November 10, 2014 20:43
Completely Disable Wordpress Comments (add to functions.php)
<?php
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
@mattclements
mattclements / changing_php_version.md
Last active August 29, 2015 14:08
Changing PHP Version

#Changing PHP Version on Plesk

Server currently runs on 5.4.33, however we have configured an additional version of PHP 5.3 for a site which requires a PHP 5.3 Depreciated Function. This is installed in /usr/local/php53-cgi/. We can switch Domains over to this version manually if requires as follows. The guide below uses example.com as the domain.

First we create a PHP wrapper.

cd /var/www/vhosts/example.com/cgi-bin
mkdir .cgi_wrapper
cd .cgi_wrapper
touch .phpwrapper
@mattclements
mattclements / functions.php
Last active August 29, 2015 14:07
Testimonial Custom Post Type
<?php
/**
* http://generatewp.com/post-type/
*/
//Add Testimonial Posts
if ( ! function_exists('testimonial_post_type') ) {
// Register Custom Post Type
function testimonial_post_type() {
@mattclements
mattclements / vhost.conf
Last active April 14, 2018 17:58
Apache VHOST File
ServerName [% vhost.servername %]
[% IF vhost.serveralias_array.size -%]
[% FOREACH alias IN vhost.serveralias_array -%]
ServerAlias [% alias %]
[% IF alias == 'www.' _ vhost.servername -%]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
[% END -%]