Skip to content

Instantly share code, notes, and snippets.

View jahid32's full-sized avatar

Md Mostafizur Rahman jahid32

  • Sourcetop Inc.
  • Bangladesh
View GitHub Profile
@jahid32
jahid32 / dokan.sql
Created December 4, 2023 18:24 — forked from ajaxray/dokan.sql
[Database Course] Sample schema
CREATE DATABASE `dokan`;
USE `dokan`;
CREATE TABLE customers (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100),
phone CHAR(15),
PASSWORD CHAR(32),
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
@jahid32
jahid32 / wp-local-media-nginx.txt
Created October 6, 2023 09:01 — forked from chuckreynolds/wp-local-media-nginx.txt
Local NGINX WordPress Media Uploads Fallback. Substitute {PROD} for the domain to use images from.
location ~* ^.+\.(svg|svgz|jpg|jpeg|gif|png|ico|bmp)$ {
try_files $uri @image_fallback;
}
location @image_fallback {
proxy_pass http://{PROD};
}
@jahid32
jahid32 / replacevar-script.js
Created July 26, 2023 12:00 — forked from erikyo/replacevar-script.js
Adds to Yoast an additional replacement variable both in frontend and snippet preview (backend)
/* inspired from https://github.com/Yoast/wpseo-woocommerce/blob/trunk/js/src/yoastseo-woo-replacevars.js */
/* global jQuery, YoastSEO, app, globals YoastACFAnalysisConfig */
var pluginName = "additionalVariablePlugin";
var ReplaceVar = window.YoastReplaceVarPlugin && window.YoastReplaceVarPlugin.ReplaceVar;
var placeholders = {};
var modifiableFields = [
"content",
"title",
@jahid32
jahid32 / export-from-custom-db-tables.md
Created June 14, 2023 09:12 — forked from trey8611/export-from-custom-db-tables.md
WP All Export - export data from custom database tables

Sometimes you might need to export extra data from a custom database table. This is possible by using a custom PHP function in the export along with the WPDB class.

For example, let’s say that we are exporting Users from a BuddyPress installation and we need to get the value of the “Name” field from the BuddyPress “Extended Profile” section: https://d.pr/6kZfA8. This information is stored inside the ‘bp_xprofile_data’ table: https://d.pr/CTdjb2. So, to export this, we’ll want to:

  • Click “Add Field” in our export, keep “ID” in the top drop-down
  • Name the field, for example “BuddyPress Name”
  • Click “Export the value returned by a PHP function"
  • Type in our function name, add the code to the function editor, and click “Done”.

Example video: https://drive.google.com/file/d/0BxSOi52PDCsAZ1JXazB0RzFFTnc/view?usp=sharing&resourcekey=0-OOnGF0Zes40Qqn6iEvFtIQ

@jahid32
jahid32 / wp-query-ref.php
Created August 24, 2022 13:33 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
@jahid32
jahid32 / custom-post-type-ajax-pagination.php
Created July 9, 2022 13:49 — forked from raazon/custom-post-type-ajax-pagination.php
Wordpress custom post type ajax pagination
<?php
/*
* Custom Post Pagination
* @since 1.0.0
* return
*/
if (!function_exists('ic_custom_posts_pagination')) :
function ic_custom_posts_pagination($the_query=NULL, $paged=1){
global $wp_query;
@jahid32
jahid32 / example.php
Created September 14, 2020 07:33 — forked from Webcreations907/example.php
Example VC Nesting
<?php
/************************************************************************
* Example Nested For VC
* vc_map() stuff should only be included when VC is enabled.
*
* This is just for a copy/paste test purpose.
*************************************************************************/
@jahid32
jahid32 / php
Last active January 21, 2020 16:41
Sent Mail Via WP Mail:
<?php
if(!empty($_POST)){
$form = $_POST['form'];
$to = $_POST['to'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
@jahid32
jahid32 / php
Created October 28, 2019 12:37
Laravel 5.3 Count problem
//Illuminate/Database/Eloguent/Builder.php
// Line 1231
- $originalWhereCount = count($query->wheres);
+ $originalWhereCount = is_null($query->wheres) ? 0 : count($query->wheres);
// Line 1277
- return count($query->wheres) > $originalWhereCount;
+ return (is_null($query->wheres) ? 0 : count($query->wheres)) > $originalWhereCount;
@jahid32
jahid32 / example-skills-block
Created July 10, 2019 14:49
This example is just really simple, the main shortcode is simple enough to not need any options or globals applied, it simply wraps the innner shortcodes.
<?php
/**
* The Shortcode
*/
function ebor_skills_shortcode( $atts, $content = null ) {
$output = '<div class="skills-wrapper">'. do_shortcode($content) .'</div>';
return $output;
}
add_shortcode( 'machine_skills', 'ebor_skills_shortcode' );