Skip to content

Instantly share code, notes, and snippets.

@ahmedch1
ahmedch1 / model4_css_style.css
Created June 20, 2020 12:41
Build ecommerce design
body, h1, h2, h3, h4, h5, h6, p, ul, li, ol {
padding: 0;
margin: 0;
}
.header-1 {
position: absolute;
left: 0;
top: 0;
width: 100%;
@ahmedch1
ahmedch1 / elegant-contact-form.markdown
Created August 12, 2022 20:16
Elegant Contact Form
<?php
// Add FieldName MetaBox
abstract class FieldName_Meta_Box {
/**
* Set up and add the meta box.
*/
public static function add() {
$screens = [ 'posttypename' ];
* Use Defer in javascript (Load Js scripts in order)
* Load Js in the Footer
* Use Tiny Png for optimizing images (useful in static and quasi static websites)
* Use CloudFlare
* Use LiteSpeedCache Server
* Use Litespeed Cache Plugin (Wordpress)
* Tools to Test Speed
## VARVY_SCRIPT
<script type="text/javascript">
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "defer.js";
document.body.appendChild(element);
}
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
if ( !is_user_logged_in() ) {
function sanitize_output($buffer) {
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\</s', // strip whitespaces before tags, except space
'/(\s)+/s' // shorten multiple whitespace sequences
);
$replace = array(
'>',
'<',
/**
* Callback function that returns true if the current page is a WooCommerce page or false if otherwise.
*
* @return boolean true for WC pages and false for non WC pages
*/
function is_wc_page() {
return class_exists( 'WooCommerce' ) && ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() );
}
add_action( 'template_redirect', 'conditionally_remove_wc_assets' );
add_action('wp_enqueue_scripts', 'customize_cf7_dequeue');
function customize_cf7_enqueue($content)
{
if (has_shortcode($content, 'contact-form-7') && function_exists('wpcf7_enqueue_styles')) {
$content = '<link href="' . esc_url(wpcf7_plugin_url('includes/css/styles.css') . '?ver=' . WPCF7_VERSION) . '" rel="stylesheet" type="text/css">' .
$content;
wpcf7_enqueue_scripts();
}
return $content;
@ahmedch1
ahmedch1 / Load Webp Version if exists
Created September 4, 2022 18:17
Load Webp Version if exists
<?php
// directory
$directory=__DIR__ . '\gif';
function replace_extension($filename, $extension) {
if (($pos = strrpos($filename , '.')) !== false) {
$filename = substr($filename, 0, $pos);
}
return $filename . '.' . $extension;
In Style style.css add
Text Domain: ahmedsite
ahmedsite : the name of the theme
In functions.php
add_action('init', function() {
pll_register_string('ahmedsite', 'We are Testing Here');