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
@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/**\*
<?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()) );
*/
@stalukder03
stalukder03 / wp-get-image-alt-text.php
Created July 4, 2018 18:24 — forked from patrickgilmour/wp-get-image-alt-text.php
WordPress Images - echo the Alt text of the Featured image (and other image attributes)
<?php
/**
* Get the Alt text of a Featured Image
*
* And other image attributes
*/
add_action('genesis_before_sidebar_widget_area', 'pgwp_genesis_before_sidebar_widget_area' );
function pgwp_genesis_before_sidebar_widget_area () {
@stalukder03
stalukder03 / custom_excerpt_wp.php
Created June 11, 2018 16:03 — forked from sammdec/custom_excerpt_wp.php
Wordpress Custom Excerpt function
<?php
function get_excerpt($count, $post_id){
$permalink = get_permalink($post_id);
$excerpt = get_post($post_id);
$excerpt = $excerpt->post_content;
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, $count);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = $excerpt;
// Want a read more link and ellipsis, remove the line above this and replace it with the one below.