Skip to content

Instantly share code, notes, and snippets.

View stalukder03's full-sized avatar

Sajib Talukder stalukder03

View GitHub Profile
/db
/plugins
/uploads
/logs
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="WordPress Coding Standards" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>A custom set of rules to check for a WPized WordPress project</description>
<!-- What to scan -->
<file>.</file>
<!-- Exclude the Composer Vendor directory. -->
<!-- <exclude-pattern>/vendor/*</exclude-pattern> -->
@stalukder03
stalukder03 / upload.js
Created June 28, 2022 05:48 — forked from Cheslab/upload.js
WordPress Media Library with pre-selected items
/**
* Utilize WordPress' media library. Easy select/upload files for your plugin/theme admin page.
* It uses build-in jQuery 1.4.1
* Tested with WordPress 5.2.4
*/
$('.my-upload-button').click(function(e) {
e.preventDefault();
// setup our media library frame
@stalukder03
stalukder03 / WordPress Conditional Custom Meta Box
Created January 9, 2021 04:04 — forked from WagnerMatos/WordPress Conditional Custom Meta Box
WordPress Custom Meta Box that can used only on certain post types, pages, etc.
<?php
/*/////////////////////////////////////////////////////////////////////////////////////
//// Load scripts and styles for Meta box */
// enqueue scripts and styles, but only if is_admin
if(is_admin()) {
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_script('jquery-ui-slider');
wp_enqueue_script('custom-js', get_template_directory_uri().'/library/metaboxes/js/custom-js.js');
wp_enqueue_style('jquery-ui-custom', get_template_directory_uri().'/library/metaboxes/css/jquery-ui-custom.css');
@stalukder03
stalukder03 / gulpfile.js
Created October 4, 2020 12:29 — forked from braginteractive/gulpfile.js
Gulp 4 and WordPress Development
// Load all the modules from package.json
var gulp = require( 'gulp' ),
plumber = require( 'gulp-plumber' ),
autoprefixer = require('gulp-autoprefixer'),
watch = require( 'gulp-watch' ),
jshint = require( 'gulp-jshint' ),
stylish = require( 'jshint-stylish' ),
uglify = require( 'gulp-uglify' ),
rename = require( 'gulp-rename' ),
notify = require( 'gulp-notify' ),

Zip excluding specific directories

Exclude .git file and node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/\*

Exclude .git file and files in node_modules directory, but keep node_modules directory

$ zip -r9 [target_file] [source_file] -x *.git* node_modules/**\*
var arr = [4,2,5,3];
function myRd(arr,callback){
var val=arr[0];
for(i=1;i<arr.length;i++){
val = callback(val,arr[i]);
}
return val;
<?php
/**
* Escape all translations with
*/
__( ‘Some String’, ‘text-domain’ ); _e( ‘Some string’, ‘text-domain’ );.
/**
* When there is no HTML use:
*/
@stalukder03
stalukder03 / WP Customizer - Select
Created February 2, 2019 21:38 — forked from ajskelton/WP Customizer - Select
Add a Select field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_select_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_select',
'default' => 'value1',
) );
$wp_customize->add_control( 'themeslug_select_setting_id', array(
'type' => 'select',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Select Option' ),
@stalukder03
stalukder03 / wp-updates-theme.php
Created August 9, 2018 22:25 — forked from gilbitron/wp-updates-theme.php
WPUpdates Theme Updater Class (with Envato API verification)
<?php
/*
WPUpdates Theme Updater Class (with Envato API verification)
http://wp-updates.com
v1.1
Example Usage:
require_once('wp-updates-theme.php');
new WPUpdatesThemeUpdater( 'http://wp-updates.com/api/1/theme', 1, basename(get_template_directory()) );
*/