Skip to content

Instantly share code, notes, and snippets.

View jayllellis's full-sized avatar

Jason Ellis jayllellis

View GitHub Profile
<?php
function my_customize_rest_cors() {
remove_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );
add_filter( 'rest_pre_serve_request', function( $value ) {
header( 'Access-Control-Allow-Origin: *' );
header( 'Access-Control-Allow-Methods: GET' );
header( 'Access-Control-Allow-Credentials: true' );
header( 'Access-Control-Expose-Headers: Link', false );
header( 'Access-Control-Allow-Headers: X-Requested-With' );
@jayllellis
jayllellis / .htaccess
Created August 12, 2019 18:22 — forked from RafaelFunchal/.htaccess
Exclude the files ajax, upload and WP CRON scripts from authentication
# Exclude the files ajax, upload and WP CRON scripts from authentication
<FilesMatch "(admin-ajax\.php|media-upload\.php|async-upload\.php|wp-cron\.php|xmlrpc\.php)$">
Order allow,deny
Allow from all
Satisfy any
</FilesMatch>
// original from: http://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
// original gist: https://gist.github.com/willpatera/ee41ae374d3c9839c2d6
function doGet(e){
return handleResponse(e);
}
// Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";
@jayllellis
jayllellis / image-crop.php
Created October 31, 2017 19:35
Simple PHP image crop
<?php
/* Thanks to https://polyetilen.lt/en/resize-and-crop-image-from-center-with-php for this script */
//resize and crop image by center
function resize_crop_image($max_width, $max_height, $source_file, $dst_dir, $quality = 80){
$imgsize = getimagesize($source_file);
$width = $imgsize[0];
$height = $imgsize[1];
$mime = $imgsize['mime'];
@jayllellis
jayllellis / page-ids.php
Last active February 4, 2019 16:34
Get page IDs for certain kinds of pages
<?php
// Special pages -----------------
$frontpage_id = get_option( 'page_on_front' );
$blog_id = get_option( 'page_for_posts' );
// Page templates -----------------
$about_templates = get_pages(array(
'meta_key' => '_wp_page_template',
'meta_value' => 'page-about.php'
@jayllellis
jayllellis / placeholder.css
Last active September 20, 2018 19:08
Change placeholder colour
input[type="text"]::-webkit-input-placeholder{ /* Chrome/Opera/Safari */
color: pink;
}
input[type="text"]::-moz-placeholder { /* Firefox 19+ */
color: pink;
}
input[type="text"]:-ms-input-placeholder { /* IE 10+ */
color: pink;
}
input[type="text"]:-moz-placeholder { /* Firefox 18- */
@jayllellis
jayllellis / custom-action-url.php
Last active August 3, 2021 08:34
Custom Contact Form 7 action URL
<?php
// Place this in your functions.php file
add_filter('wpcf7_form_action_url', 'wpcf7_custom_form_action_url');
function wpcf7_custom_form_action_url(){
return 'send.php';// replace this with the new action url (excluding the 'http://')
}
?>
@jayllellis
jayllellis / add-google-analytics.php
Created March 24, 2016 16:06
Add Google Analytics via functions.php
<?php
/* Google Analytics */
add_action('wp_head','add_google_analytics');
function add_google_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)
@jayllellis
jayllellis / load-style-last.css
Last active March 21, 2016 17:08
Load style.css last
function load_custom_styles() {
wp_enqueue_style('style-css', get_template_directory_uri().'/style.css');// custom styles
}
add_action( 'wp_enqueue_scripts', 'load_custom_styles', 999 );
@jayllellis
jayllellis / infinite-zoom.css
Last active February 22, 2023 23:45
Infinite slow zoom CSS animation
.infinite-zoom{
-webkit-animation: zoomSlow 60s infinite linear;
-moz-animation: zoomSlow 60s infinite linear;
animation: zoomSlow 60s infinite linear;
}
@-webkit-keyframes zoomSlow {
0% {
-moz-transform: scale(1);
-webkit-transform: scale(1);