Skip to content

Instantly share code, notes, and snippets.

<?php
// Initilise cURL
$ch = curl_init();
// Set the cURL Options
$optArray = array(
CURLOPT_URL => 'https://example.com/api/getInfo/',
CURLOPT_RETURNTRANSFER => true
);
## START EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
<?php # https://keithgreer.uk/wordpress-code-completely-disable-comments-using-functions-php
/* PURPOSE
* Disable comments on ALL post types
* remove/hide any existing comments
* from displaying and hide forms.
*/
/* INSTALL
* Add into your active theme's functions.php file.
.eucookie-pop-up { display:none; position:fixed; z-index:9999; bottom:0; left:0; right:0; background:#dc143c; color:#fff; margin:1em; padding:0.5em; text-align:center; }
.eucookie-pop-up .dismiss { float:right; width:7% text-align:center; padding-top:1em; }
.eucookie-pop-up .dismiss a { color:#fff; cursor:pointer; font-weight:bold; font-size:150%; padding:1em; }
.eucookie-pop-up .content { float:left; width:92%; text-align:center; }
.eucookie-pop-up .content a { text-decoration: underline;color:#fff }
@keithgreer
keithgreer / indexer.php
Last active December 23, 2021 10:25
Stand alone script to reindex Magento 2 - https://keithgreer.dev/magento-2-reindex-script-indexer
<?php
use Magento\Framework\App\Bootstrap;
include('app/bootstrap.php'); // Update as required, this line will work if placed in the Magento Root Directory
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
<?php
use Magento\Framework\App\Bootstrap;
include('app/bootstrap.php'); // Update as required, this line will work if placed in the Magento Root Directory
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
?><div style='top:45%; position:absolute; width:75%; text-align:center; color:#666; font-weight:bold; font-size:1.8em; '><?php
try{
{% for post in site.posts limit:1 %}
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
{{ post.content | strip_html | truncatehtml | truncatewords: 40 }}
{% endfor %}
{% for post in site.posts offset:1 limit:4 %}
<h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
{% comment %}{% for option in product.options %}
{% if option == 'Weight' %}
{% assign index = forloop.index0 %}
{% for variant in product.variants %}
{{ variant.options[index] }}
{% endfor %}
{% endif %}
{% endfor %}{% endcomment %}
@keithgreer
keithgreer / shopify-homepage-settings.json
Last active December 23, 2021 10:25
First we grab and display the variables from the Settings section of the JSON - https://keithgreer.dev/setting-up-a-multipurpose-cmsed-liquid-homepage-section-for-shopify
{
"name": "Video & Testimonial",
"max_blocks": 5,
"settings": [
{
"id": "video_title",
"type": "text",
"label": "Heading",
"default": "Learn 'How to' with our video"
},