Skip to content

Instantly share code, notes, and snippets.

View hasinhayder's full-sized avatar
🚀
Back on track, yayyyy!

Hasin Hayder hasinhayder

🚀
Back on track, yayyyy!
View GitHub Profile
@hasinhayder
hasinhayder / .htaccess
Created June 6, 2020 19:28
Apache Browser Cache
### marker BROWSER CACHE start ###
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/pdf A31557600
ExpiresByType image/x-icon A31557600
ExpiresByType image/vnd.microsoft.icon A31557600
ExpiresByType image/svg+xml A31557600
ExpiresByType image/jpg A31557600
ExpiresByType image/jpeg A31557600
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar --info
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
@hasinhayder
hasinhayder / admin-ssl-vesta.sh
Last active March 21, 2022 19:51
Install Admin Panel SSL Cert for VestaCP using LetsEncrypt
v-change-sys-hostname somedomain.com
v-add-letsencrypt-domain 'admin' $HOSTNAME '' 'yes'
# v-add-letsencrypt-domain 'admin' $HOSTNAME '' 'no'#mail domain = no
v-update-host-certificate admin $HOSTNAME
echo "UPDATE_HOSTNAME_SSL='yes'" >> /usr/local/vesta/conf/vesta.conf
@hasinhayder
hasinhayder / php-7.0-template-deb-9.sh
Last active July 15, 2021 00:55
PHP Templates in Debian 9 + VestaCP
apt-get update
apt install apt-transport-https ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb https://packages.sury.org/php/ stretch main" > /etc/apt/sources.list.d/php.list'
apt-get update
a2enmod proxy_fcgi setenvif
apt-get install php7.0-apcu php7.0-mbstring php7.0-bcmath php7.0-cli php7.0-curl php7.0-fpm php7.0-gd php7.0-intl php7.0-mcrypt php7.0-mysql php7.0-soap php7.0-xml php7.0-zip php7.0-memcache php7.0-memcached php7.0-zip
update-rc.d php7.0-fpm defaults
@hasinhayder
hasinhayder / kirkibuilderfix.php
Created May 21, 2020 14:03
Kirki Builder Fix
static function initialize( $theme_config, $capability = 'edit_theme_options', $option_type = 'theme_mod' ) {
if ( class_exists( 'Kirki' ) ) {
\Kirki::add_config( $theme_config, array(
'capability' => $capability,
'option_type' => $option_type,
) );
self::set_theme_config( $theme_config );
}
}
@hasinhayder
hasinhayder / id-name-pair.php
Created April 30, 2020 13:13
Get single category for a post in different way
//Get a single category name with id, name pair
function get_single_category( $post_id = null ) {
global $post;
$post_id = is_null( $post_id ) ? $post->ID : $post_id;
$categories = wp_get_post_categories( $post_id, array( 'fields' => 'all' ) );
shuffle( $categories );
$single_category = array_shift( $categories );
return array($single_category->term_id => $single_category->name);
@hasinhayder
hasinhayder / example.php
Last active April 15, 2020 15:18
posts using wpdb
<?php
global $wpdb;
$_posts = $wpdb->get_results("SELECT ID, post_title from {$wpdb->prefix}posts WHERE post_status='publish' and post_type='post'",ARRAY_A);
$p = [];
foreach($_posts as $_post){
$p[$_post['ID']] = $_post['post_title'];
}
//now pass this $p array to carbon field's set_option() function
<?php
add_filter( 'the_content', function ( $content ) {
global $post;
if ( is_singular() && strpos( $post->post_content, '<!--more-->' ) ) {
$_content = $post->post_content;
$_content = str_replace("<!-- wp:more -->",'',$_content);
$_content = str_replace("<!-- /wp:more -->",'',$_content);
return str_replace("<!--more-->","<p>##HELLO-HELLO##</p>",$_content);
}
return $content;
@hasinhayder
hasinhayder / vscode.md
Last active March 10, 2020 06:39
Visual Studio Code Tips

Open files on different tabs

Add the following line to the settings "workbench.editor.enablePreview": false

Enable blade formatting

"blade.format.enable": true

Enable K&R style brace completion (brace on the same line of the function definition)

"phpfmt.psr2":false,
 "phpfmt.exclude": [
@hasinhayder
hasinhayder / settings.json
Created February 19, 2020 07:39
K&R Style brace processing in VSCode
{
"phpfmt.psr2":false,
"phpfmt.exclude": [
"AllmanStyleBraces"
]
}