Skip to content

Instantly share code, notes, and snippets.

@Arifursdev
Arifursdev / remove-empty-p.php
Created December 10, 2020 14:32 — forked from ninnypants/remove-empty-p.php
Remove empty p tags from WordPress posts
<?php
add_filter( 'the_content', 'remove_empty_p', 20, 1 );
function remove_empty_p( $content ){
// clean up p tags around block elements
$content = preg_replace( array(
'#<p>\s*<(div|aside|section|article|header|footer)#',
'#</(div|aside|section|article|header|footer)>\s*</p>#',
'#</(div|aside|section|article|header|footer)>\s*<br ?/?>#',
'#<(div|aside|section|article|header|footer)(.*?)>\s*</p>#',
'#<p>\s*</(div|aside|section|article|header|footer)#',
@Arifursdev
Arifursdev / updated-fonts-filters.css
Created January 10, 2021 09:07 — forked from shopifypartners/updated-fonts-filters.css
Section of stylesheet showing how variables are assigned & how filters are applied - https://www.shopify.com/partners/blog/font-picker
{% assign header_font = settings.header_font_new %}
{% assign base_font = settings.base_font_new %}
{{ header_font | font_face }}
{{ base_font | font_face }}
{%- assign base_font_bold = base_font | font_modify: 'weight', 'bolder' -%}
{%- assign base_font_italic = base_font | font_modify: 'style', 'italic' -%}
{%- assign base_font_bold_italic = base_font_bold | font_modify: 'style', 'italic' -%}
@Arifursdev
Arifursdev / npmcrashcourse.txt
Created January 31, 2021 12:35 — forked from bradtraversy/npmcrashcourse.txt
NPM Crash Course Commands
# GET VERSION
npm -v (or --version)
# GET HELP
npm help
npm
# CREATE PACKAGE.JSON
npm init
npm init -y (or --yes)
@Arifursdev
Arifursdev / WP-HTML-Compression
Created June 24, 2021 16:05 — forked from sethbergman/WP-HTML-Compression
Minify HTML for WordPress without a Plugin - Add to function.php
<?php
class WP_HTML_Compression
{
// Settings
protected $compress_css = true;
protected $compress_js = true;
protected $info_comment = true;
protected $remove_comments = true;
// Variables
@Arifursdev
Arifursdev / Normalize String JS
Last active July 24, 2023 09:25
Normalize String JS
(function(root,factory){if(typeof define==="function"&&define.amd){define(factory)}else if(typeof exports==="object"){module.exports=factory()}else{root.latinize=factory()}})(this,function(){function latinize(str){if(typeof str==="string"){return str.replace(/[^A-Za-z0-9]/g,function(x){return latinize.characters[x]||x})}else{return str}}latinize.characters={"Á":"A","Ă":"A","Ắ":"A","Ặ":"A","Ằ":"A","Ẳ":"A","Ẵ":"A","Ǎ":"A","Â":"A","Ấ":"A","Ậ":"A","Ầ":"A","Ẩ":"A","Ẫ":"A","Ä":"A","Ǟ":"A","Ȧ":"A","Ǡ":"A","Ạ":"A","Ȁ":"A","À":"A","Ả":"A","Ȃ":"A","Ā":"A","Ą":"A","Å":"A","Ǻ":"A","Ḁ":"A","Ⱥ":"A","Ã":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ḃ":"B","Ḅ":"B","Ɓ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ć":"C","Č":"C","Ç":"C","Ḉ":"C","Ĉ":"C","Ċ":"C","Ƈ":"C","Ȼ":"C","Ď":"D","Ḑ":"D","Ḓ":"D","Ḋ":"D","Ḍ":"D","Ɗ":"D","Ḏ":"D","Dz":"D","Dž":"D","Đ":"D","Ð":"D","Ƌ":"D","DZ":"DZ","DŽ":"DZ","É":"E","Ĕ":"E","Ě":"E","Ȩ":"E","Ḝ":"E","Ê":"E","Ế":"E","Ệ":"E","Ề":"E","Ể":"E","Ễ":"E","Ḙ":"E","Ë":"E","Ė":"E","Ẹ":"
@Arifursdev
Arifursdev / theme-helper.php
Created January 22, 2022 07:16 — forked from josanua/theme-helper.php
Theme Dev Helper
<?php
// General info
https://codex.wordpress.org/Theme_Development
// Core info
https://wp-learner.com/wotdpress-development/wordpress-core-files-and-functions/
// Theme Handbook
https://developer.wordpress.org/themes/
// https://stackoverflow.com/a/53768622/13359236
if (!Element.prototype.trigger)
{
Element.prototype.trigger = function(event)
{
var ev;
try
{
@Arifursdev
Arifursdev / Disable WordPress Import Duplicate Checking.php
Created June 13, 2022 19:22
Disable WordPress Import Duplicate Checking
<?php
add_filter( 'wp_import_existing_post', function ( $post_exists ) {
$post_exists = false;
return $post_exists;
} );
@Arifursdev
Arifursdev / Force Remove the .git folder in windows
Created December 12, 2022 19:35
Force Remove the .git folder in windows
Force Remove the .git folder in windows
// working
rm -r .git -Force
// not working
rm -rf .git
<?php
function convertToWebp($imagePath) {
if(!file_exists($imagePath)) {
return false;
}
$info = getimagesize($imagePath);
$format = strtolower(substr($info['mime'], strpos($info['mime'], '/') + 1));