Skip to content

Instantly share code, notes, and snippets.

@freddielore
freddielore / public-defer-javascript.html
Created June 28, 2019 02:46
[Defer Third Party Scripts] Defer third party scripts #javascript #html #public
<script type="text/javascript">
var app = {
init: function() {
window.addEventListener('scroll', function() {
if (window.__he == undefined) {
app.load();
}
});
window.addEventListener('mousemove', function() {
@freddielore
freddielore / functions.php
Last active June 5, 2019 02:37
[export-custom-fields] Exporting Custom Fields data for bulk editing #seo
<?php
add_filter( 'smart_seo_export_fields', 'my_theme_export_other_custom_fields', 8, 1 );
function my_theme_export_other_custom_fields( $fields ){
$fields[] = 'class_type'; // class_type will exported to CSV as well
$fields[] = 'fees'; // fees will exported to CSV as well
$fields[] = 'class_description'; // class_description will exported to CSV as well
return $fields;
}
add_action( 'smart_seo_import_update', 'my_theme_update_more_custom_fields', 10, 2 );
@freddielore
freddielore / smart_seo_export_fields.php
Created January 13, 2019 03:15
[Smart SEO Export Fields] Lets you export other custom fields to include in bulk editing
<?php
add_filter( 'smart_seo_export_fields', 'child_export_other_custom_fields', 8, 1 );
function child_export_other_custom_fields( $fields ){
$fields[] = '_custom_field_name'; // _custom_field_name will exported to CSV as well
$fields[] = '_another_custom_field'; // _another_custom_field will exported to CSV as well
return $fields;
}
?>
@freddielore
freddielore / smart_seo_import_update.php
Last active March 14, 2022 01:52
[Smart SEO Import Update] A hook that lets you perform additional update operation during import #wordpress #smartseo
<?php
add_action( 'smart_seo_import_update', 'child_update_more_custom_fields', 10, 3 );
function child_update_more_custom_fields($post_id, $data, $headings){
// Where
// $post_id is post ID,
// '_custom_field_name' is the custom field name,
// 'column name' is column name found in CSV file
update_post_meta( $post_id, '_custom_field_name', sanitize_text_field( $data['column name']) );
}
?>
@freddielore
freddielore / getQueryString.js
Last active February 5, 2018 15:03
Get query string from URL via Javascript #javascript
// e.g URL: https://google.com/?id=foo
// getQueryString('id') // retruns "foo"
getQueryString: function(field, url){
var href = url ? url : window.location.href;
var reg = new RegExp( '[?&]' + field + '=([^&#]*)', 'i' );
var string = reg.exec(href);
return string ? string[1] : null;
}
@freddielore
freddielore / smart_seo_export_size.php
Last active January 13, 2019 03:15
Smart SEO CSV Export Size
<?php
add_filter( 'smart_seo_export_size', 'my_custom_csv_export_limit', 9, 1 );
function my_custom_csv_export_limit($size){
// reducing it to 25 to avoid server timeouts
return 25;
}
?>
@freddielore
freddielore / smart_seo_import_size.php
Last active January 13, 2019 03:04
Smart SEO CSV Import Size
<?php
add_filter( 'smart_seo_import_size', 'my_custom_csv_import_limit', 9, 1 );
function my_custom_csv_import_limit($size){
// reducing it to 5 to avoid server timeouts
return 5;
}
?>
@freddielore
freddielore / scroll_to_id.js
Last active August 29, 2015 14:27
Scroll to specific ID. Must be added in the footer area.
<script type="text/javascript">
jQuery(document).ready(function($){
var scroll_delay = 4000;
var top = 230;
var app = {
init: function(){
var sel = window.location.hash;
// only autoscroll if ID is detected in the URL
RewriteEngine On
RewriteBase /
RewriteRule .* - [E=noabort:1]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]