Skip to content

Instantly share code, notes, and snippets.

View sumonst21's full-sized avatar
💭
I may be slow to respond.

Md. Sumon Islam sumonst21

💭
I may be slow to respond.
View GitHub Profile
@sumonst21
sumonst21 / wc-auth-net-cim-adjust-auth-only-order-status.php
Created March 15, 2022 21:59 — forked from maxrice/wc-auth-net-cim-adjust-auth-only-order-status.php
WooCommerce Authorize.net CIM: Adjust authorize-only transaction order status
<?php
function sv_wc_auth_net_cim_tweak_held_order_status( $order_status, $order, $response ) {
if ( 'on-hold' === $order_status && $response instanceof SV_WC_Payment_Gateway_API_Response && $response->transaction_approved() ) {
$order_status = 'processing';
}
return $order_status;
}
@sumonst21
sumonst21 / sources.list
Created March 14, 2022 20:08 — forked from ishad0w/sources.list
Ubuntu 20.04 LTS (Focal Fossa) -- Full sources.list
deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
@sumonst21
sumonst21 / csv_to_array.php
Created March 13, 2022 00:13 — forked from jaywilliams/csv_to_array.php
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array
@sumonst21
sumonst21 / remove-woo-noindex-public-pages.php
Created March 9, 2022 12:57 — forked from robwent/remove-woo-noindex-public-pages.php
Removes WooCommerce noindex robots tag on public pages
function YOURPREFIX_remove_wc_account_page_noindex(){
if (!is_user_logged_in()) {
remove_action( 'wp_head', 'wc_page_noindex' );
}
}
add_action( 'init', 'YOURPREFIX_remove_wc_account_page_noindex' );
@sumonst21
sumonst21 / wc-noindex-nofollow.php
Created March 9, 2022 12:17 — forked from deeman/wc-noindex-nofollow.php
(SEO) WooCommerce "No Index, No Follow" on cart, order, checkout- pages then using YOAST!
function woo_seo_noindex_special_pages () {
global $post;
$woocommerce_pages = array('cart', 'checkout', 'order-received', 'order-tracking',
'my-account', 'logout', 'lost-password', 'mijireh-secure-checkout');
$slug = get_post($post)->post_name;
if (in_array($slug, $woocommerce_pages)) {
echo '<meta name="robots" content="noindex,follow"/>' . "\n";
}
@sumonst21
sumonst21 / sources.list
Created March 4, 2022 18:57 — forked from rohitrawat/sources.list
Ubuntu 16.04 Xenial default /etc/apt/sources.list
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
@sumonst21
sumonst21 / apache2_vhost_config_vuejs_dist
Created March 2, 2022 21:08 — forked from 7rin0/apache2_vhost_config_vuejs_dist
VueJS: Apache / Nginx vhost config examples
<VirtualHost *:80>
DocumentRoot "/home/dev/server/project/dist/"
ServerName vuejs.project.local
<Directory /home/dev/server/project/dist/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
Order allow,deny
allow from all
@sumonst21
sumonst21 / example.md
Created March 1, 2022 20:23 — forked from devdrops/example.md
Mysqldump from Docker container

Mysqldump from Docker container

docker exec -i mysql_container mysqldump -uroot -proot --databases database_name --skip-comments > /path/to/my/dump.sql

OBS

  • This will generate a dump.sql file in your host machine. Awesome, eh?
  • Avoid using --compact on your dump. This will make MySQL check your constraints which will cause troubles when reading your file (damm you MySQL). And don't use --force to fix this scenario: recreate your dump without --compact ¯_(ツ)_/¯
@sumonst21
sumonst21 / load-styles-conditionally.php
Created February 23, 2022 18:55 — forked from keiraarts/load-styles-conditionally.php
How to solve the PHP Notice: is_page was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. By using the Template Redirect hook the action can be called before any templates are loaded.
// Currently there is an issue in our PHP server error logs.
// PHP Notice: is_page was called incorrectly.
// Conditional query tags do not work before the query is run. Before then, they always return false.
// This is the wrong way to call is_page.
// is_page() only work within template files.
// To use it within plugin files, you need to use it with the combination of template_redirect action hook.
// function wordpress_theme_enqueue_styles() {
// if (is_page(2072)) {
@sumonst21
sumonst21 / gist:dd8bc25c1ee64bb6a6186196f62c4d70
Created February 23, 2022 14:46 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,