Skip to content

Instantly share code, notes, and snippets.

View sabbir1991's full-sized avatar
🏠
Working from home

Sabbir Ahmed sabbir1991

🏠
Working from home
View GitHub Profile
@sabbir1991
sabbir1991 / regext.php
Created January 5, 2023 07:05
Replace anchor tag content depending on specific attributes.
$input_lines = '<a href="index.php" target="_blank" class="link testing" >Test Link</a><a href="index.php" class="link testing" target="_blank" >Test Link</a><a href="index.php" target="_blank" class="link testing" >Test Link</a>';
$replace_text = preg_replace('/(\<a.*?target=\"_blank\".*?>)(.*?)(\<\/a\>)/', '$1$2<span>screen reader</span>$3', $input_lines);
echo $replace_text;
// Output...
<a href="index.php" target="_blank" class="link testing" >Test Link<span>screen reader</span></a>
<a href="index.php" class="link testing" target="_blank" >Test Link<span>screen reader</span></a>
➜ vvv-local git:(stable) vagrant reload --provision
__ __ __ __
\ V\ V\ V / v3.8.1 Path:"/Users/sabbir/vvv-local"
\_/\_/\_/ git::stable(8252690)
Platform: darwin19 shell:/bin/zsh vagrant-goodhosts shared_db_folder_disabled
Vagrant: v2.2.19, virtualbox: v6.1.32
Docs: https://varyingvagrantvagrants.org/
Contribute: https://github.com/varying-vagrant-vagrants/vvv
@sabbir1991
sabbir1991 / Modal.vue
Created August 6, 2019 19:05
Modal Component for Vuejs 2.x
<template>
<div class="wpvue-modal-dialog">
<div class="wpvue-modal">
<div class="wpvue-modal-content" :style="{ width: width }">
<section :class="['wpvue-modal-main', { 'has-footer': footer }]">
<header class="modal-header" v-if="header">
<slot name="header">
<h1>{{ title }}</h1>
</slot>
</header>
/* Woocommerce Styles */
/*
A couple things to note...
1. This code was written very specifically for my base child theme so it might not work out of the box with every theme.
I have it here mostly to share with anyone who might be looking to do the same thing I was.
2. I generally add my WooCommerce CSS overrides to a custom-woo.css file then use wp_enqueue_style() to call it
so that it enqueues after the default WooCommerce Stylesheets
@sabbir1991
sabbir1991 / vueMenuloaded.php
Created September 26, 2018 16:36
Menu under sub menu
<?php
add_action( 'admin_menu', 'prefix_admin_menu' );
function prefix_admin_menu() {
global $submenu;
add_menu_page( __( 'Project Manager', 'text-domain' ), __( 'Project Manager', 'text-domain' ), 'manage_options', 'awesome-pm', 'pm_dashboard_cb' );
$submenu[ 'awesome-pm' ][] = array( __( 'Project', 'text-domain' ), 'manage_options', 'admin.php?page=awesome-pm#/' );
@sabbir1991
sabbir1991 / select2-vuejs-component.md
Created March 6, 2018 11:07 — forked from craigh411/select2-vuejs-component.md
Vue.js component for Select2

#Vue.js component for Select2

A select2 component for vue.js. Quickly create select2 components, load data via ajax and retrieve selected values and newly created tags.

#Usage

Download and register the component:

Vue.component(
// JS File -- index.js
Vue.component( 'test-com', {
template: 'tmpl-test-com',
data: function() {
return {
localizeData: []
}
@sabbir1991
sabbir1991 / wpinstaller.sh
Created October 16, 2017 08:44
Autometic WP installation Process using bash
#!/bin/bash
clear
# Remove/Uninstall process
echo "Start WordPress installation"
if [[ $1 == "remove" ]]; then
# Grab the project name
if [[ -z $2 ]]; then
echo "WP Project to remove: "
@sabbir1991
sabbir1991 / functions.php
Last active November 23, 2017 18:50
File Upload in WordPress in custom directory
<?php
function wp1982_handle_file_upload( $filename, $file_url ) {
add_filter( 'upload_dir', 'wp1982_customize_upload_dir', 10 );
$upload_file = wp_upload_bits( $filename, null, file_get_contents( $file_url ) );
remove_filter( 'upload_dir', 'wp1982_customize_upload_dir' , 10 );
if ( !$upload_file['error'] ) {
$wp_filetype = wp_check_filetype( $filename, null );
$attachment = array(
@sabbir1991
sabbir1991 / pr.md
Created May 18, 2017 07:13 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: