Skip to content

Instantly share code, notes, and snippets.

@zahedkamal87
zahedkamal87 / namecheap SSL.md
Created January 27, 2020 19:04 — forked from Shourai/namecheap SSL.md
Letsencrypt SSL certificate with namecheap hosting

source: https://savedlog.com/uncategorized/letsencrypt-ssl-certificate-namecheap-hosting/

The “Positive SSL” certificate I bought along with my domain is invalid with any of my subdomains and cannot be used with wildcards. One annoying thing is that namecheap doesn’t offer auto installation of free let’s encrypt certificates, even though, they are saying “Namecheap is dedicated to data security and privacy for all internet users. We believe the movement to encrypt nearly all web traffic is a positive direction. As more sites embrace HTTPS and use of security products, providers of free SSL are beginning to come online.”

Let me show you what it needs to be done in order to “encrypt nearly all web traffic”.

First, not required but it’s helpful to enable ssh access, it is not enabled by default on the base hosting plans, just go an start a live chat and request ssh access.

<?php
/**
* Created by PhpStorm.
* User: alpipego
* Date: 03.05.18
* Time: 18:01
*/
//return;
@zahedkamal87
zahedkamal87 / class.php
Created November 7, 2019 08:42 — forked from hlashbrooke/class.php
A complete, versatile options page class for any WordPress plugin
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
class WordPress_Plugin_Template_Settings {
private $dir;
private $file;
private $assets_dir;
private $assets_url;
private $settings_base;
@zahedkamal87
zahedkamal87 / calculate_reading_time.php
Created July 30, 2019 03:03 — forked from tomhazledine/calculate_reading_time.php
Calculate Reading Time (for WordPress content)
<?php
/**
* READING TIME
*
* Calculate an approximate reading-time for a post.
*
* @param string $content The content to be measured.
* @return integer Reading-time in seconds.
*/
function reading_time( $content ) {
@zahedkamal87
zahedkamal87 / Props
Created July 30, 2019 03:02 — forked from mynameispj/Props
Estimated reading time in PHP, by Brian Cray
Total props to Brian Cray: http://briancray.com/posts/estimated-reading-time-web-design/
@zahedkamal87
zahedkamal87 / simpleimage.php
Created February 27, 2019 11:43 — forked from miguelfrmn/simpleimage.php
SimpleImage PHP Class
<?php
/**
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@zahedkamal87
zahedkamal87 / scrape.php
Created January 5, 2019 16:04 — forked from ziadoz/scrape.php
Scraping Google using PHP and Goutte:
<?php
/**
* Todo: Send a random user agent string and sleep a random amount between requests.
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
// Extract and sanatize input:
$domain = filter_input(INPUT_POST, 'domain', FILTER_SANITIZE_URL);
$terms = filter_input(INPUT_POST, 'terms', FILTER_SANITIZE_STRING);
// Setup Goutte (which also includes Guzzle):
@zahedkamal87
zahedkamal87 / function.php
Created December 19, 2018 20:45 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
@zahedkamal87
zahedkamal87 / gist:4e354e926bc1ce80d35b8069e6b4b0cf
Created December 16, 2018 21:25 — forked from excalq/gist:2961415
Javacript: Set or Update a URL/QueryString Parameter, and update URL using HTML history.replaceState()
// Explicitly save/update a url parameter using HTML5's replaceState().
function updateQueryStringParam(param, value) {
baseUrl = [location.protocol, '//', location.host, location.pathname].join('');
urlQueryString = document.location.search;
var newParam = key + '=' + value,
params = '?' + newParam;
// If the "search" string exists, then build params from it
if (urlQueryString) {
keyRegex = new RegExp('([\?&])' + key + '[^&]*');
@zahedkamal87
zahedkamal87 / wc_change_sales_price.php
Created December 6, 2018 15:35 — forked from mrizwan47/wc_change_sales_price.php
Change woocommerce sales price programmatically
<?php
// Your Product ID
$product_id = 57;
$ecd_product = new WC_Product( $product_id );
/**
* Check if product exists
*/
if( $ecd_product->exists() ){