Skip to content

Instantly share code, notes, and snippets.

View DevWael's full-sized avatar
👨‍💻
WordPress-ing

Ahmad Wael DevWael

👨‍💻
WordPress-ing
View GitHub Profile
@DevWael
DevWael / php design principles.md
Created May 25, 2023 03:59
PHP design principles, patterns, and standards

Here are some design principles, patterns, and standards that you should consider when developing software:

Design Principles

  • Single responsibility principle: A class should have only one responsibility. This makes the class easier to understand, test, and maintain.
  • Open/closed principle: Classes should be open for extension but closed for modification. This means that you should be able to add new features to a class without having to modify the existing code.
  • Liskov substitution principle: Any subclass should be substitutable for its superclass. This means that you should be able to use a subclass in place of its superclass without having to change the code that uses it.
  • Interface segregation principle: Clients should not be forced to depend on methods they do not use. This means that you should not expose methods in an interface that are not needed by all clients.
  • Dependency inversion principle: A.K.A SOLID principle. Depend upon abstractions, not concretions. This means
@DevWael
DevWael / nginx.conf
Created March 27, 2023 02:42
Nginx configuration for imgproxy https://imgproxy.net/
location @imgproxy {
proxy_set_header Host localhost:8080;
proxy_set_header If-Modified-Since "";
proxy_set_header ETag "";
proxy_set_header Cache-Control "";
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_ignore_headers Expires;
@DevWael
DevWael / php-extensions.sh
Created August 10, 2021 20:29
WordPress PHP 7.4 required extensions
apt install php-curl php7.4-xml php7.4-common php-imagick php7.4-json php7.4-mbstring php7.4-mysqli php7.4-zip php7.4-bcmath php7.4-gd php7.4-iconv php7.4-intl php7.4-simplexml php7.4-xmlreader php7.4-ssh2 php7.4-ftp php7.4-sockets
@DevWael
DevWael / tracking.html
Created July 12, 2021 14:24
tracking code snippet
<script>
var imgTag = document.createElement('img');
imgTag.height = '1';
imgTag.width = '1';
imgTag.style = 'border-style:none;';
imgTag.alt = '';
imgTag.src = 'https://pubads.g.doubleclick.net/activity;dc_iu=/21835097498/DFPAudiencePixel;ord=1;dc_seg=6575133568?';
</script>
woocommerce emails id
customer_processing_order
customer_completed_order
customer_invoice
customer_new_account
customer_note
customer_on_hold_order
customer_refunded_order
customer_reset_password
@DevWael
DevWael / allow_svg.php
Created June 4, 2020 09:54
Allow SVG Upload in WordPress Media Uploader
<?php
//Allow SVG upload
add_filter( 'upload_mimes', 'inn_mime_types' );
function inn_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
}
@DevWael
DevWael / product.php
Last active August 15, 2021 19:29
get all products in opencart 3.0 api
<?php
class ControllerApiProduct extends Controller {
public function index() {
$this->load->language( 'api/cart' );
$this->load->model( 'catalog/product' );
$this->load->model( 'tool/image' );
$json = array();
$json['products'] = array();
$filter_data = array();
@DevWael
DevWael / data.txt
Created January 5, 2020 17:13
serialized_data
a:669:{s:8:"last_tab";s:0:"";s:20:"show-loading-overlay";s:0:"";s:7:"wrapper";s:4:"wide";s:6:"layout";s:9:"fullwidth";s:7:"sidebar";s:12:"blog-sidebar";s:14:"header-wrapper";s:4:"full";s:14:"banner-wrapper";s:4:"wide";s:19:"breadcrumbs-wrapper";s:4:"full";s:12:"main-wrapper";s:4:"wide";s:14:"footer-wrapper";s:4:"full";s:14:"sticky-sidebar";s:1:"1";s:19:"show-mobile-sidebar";s:1:"1";s:22:"show-content-type-skin";s:1:"1";s:18:"show-category-skin";s:1:"1";s:8:"gmap_api";s:39:"AIzaSyDTVOtdFjlQjNx-jbJZb3vtgglwqLKhXbQ";s:8:"html-top";s:0:"";s:11:"html-banner";s:0:"";s:16:"html-content-top";s:0:"";s:22:"html-content-inner-top";s:0:"";s:25:"html-content-inner-bottom";s:0:"";s:19:"html-content-bottom";s:0:"";s:11:"html-bottom";s:0:"";s:9:"logo-type";s:0:"";s:9:"logo-text";s:0:"";s:4:"logo";a:9:{s:3:"url";s:102:"https://package.innoshop.org/wp-content/uploads/2019/12/innoshop-first-theme-low-products-2-needs1.png";s:2:"id";s:4:"3132";s:6:"height";s:3:"417";s:5:"width";s:4:"1427";s:9:"thumbnail";s:110:"https://package.i
@DevWael
DevWael / allowed_html_tags.php
Created November 19, 2019 16:11
array list of allowed html tags to use with wp_kses() function
<?php
function dw_allowed_html_tags() {
$allowed_tags = array(
'a' => array(
'class' => array(),
'href' => array(),
'rel' => array(),
'title' => array(),
),
@DevWael
DevWael / update_plugin_programatically.php
Created November 17, 2019 17:01
Update WordPress Plugin Programatically.
<?php
function replace_plugin() {
// modify these variables with your new/old plugin values
$plugin_slug = 'wp-reset/wp-reset.php';
$plugin_zip = 'https://downloads.wordpress.org/plugin/wp-reset.latest-stable.zip';
$old_plugin_slug = 'reset-wp/reset-wp.php';
echo 'If things are not done in a minute <a href="plugins.php">click here to return to Plugins page</a><br><br>';
echo 'Starting ...<br><br>';