Skip to content

Instantly share code, notes, and snippets.

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

Umesh Kumar UmeshSingla

🏠
Working from home
View GitHub Profile
@UmeshSingla
UmeshSingla / hide_bulk_smush.php
Created August 23, 2016 08:10
WP Smush: Hide Bulk Smush page for different User Roles
<?php
function remove_bulk_smush_page() {
if( is_super_admin() ) {
return;
}
remove_submenu_page( 'upload.php', 'wp-smush-bulk' );
}
add_action( 'admin_menu', 'remove_bulk_smush_page', 99 );
?>
@UmeshSingla
UmeshSingla / modify_resize_dimesnions.php
Created July 13, 2016 04:57
WP Smush: Allows to filter the resize dimensions for a specific admin role
<?php
add_filter( 'wp_smush_resize_sizes', 'filter_resize_dimesnsion' );
function filter_resize_dimension( $dimensions ) {
$user = wp_get_current_user();
if ( ! empty( $user ) && in_array( 'custom role', (array) $user->roles ) ) {
//The user has the "specific admin" role, modify the dimensions
$dimensions = array(
'width' => 1440,
'height' => 1440
);
@UmeshSingla
UmeshSingla / skip_smush_meta.php
Last active August 23, 2016 08:02
WP Smush: Allows you to skip WP Smush Meta while exporting WordPress content
add_filter( 'wxr_export_skip_postmeta', 'skip_smush_meta', '', 2 );
/**
* Skip WP Smush meta while exporting
*
* @param $skip, Whether to skip meta key or not
* @param $meta_key, Current meta_key
*
* @return bool
*/
function skip_smush_meta( $skip, $meta_key ) {
@UmeshSingla
UmeshSingla / functions.php
Created November 2, 2014 09:05
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array (
'name' =&gt; 'value'
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' =&gt; 'multipart/form-data; boundary=' . $boundary
);
$payload = '';
@UmeshSingla
UmeshSingla / post.js
Last active April 3, 2023 15:53
http, https post request in node.js
//Install required modules, and include them
var https = require('https'), // https server
http = require('http'), // http server
querystring = require('querystring'),
url = require('url'); // url parser
//URL to which post request will be sent
var callback_url = 'http://example.com';
var callback = url.parse(callback_url);
@UmeshSingla
UmeshSingla / functions.php
Created December 27, 2013 07:45
Wordpress: Remove a shortocde or a specific list of shortcode
<?php
global $remove_shortcode;
/**
* Strips and Removes shortcode if exists
* @global int $remove_shortcode
* @param type $shortcodes comma seprated string, array of shortcodes
* @return content || excerpt
*/
function dot1_strip_shortcode( $shortcodes ){
global $remove_shortcode;
@UmeshSingla
UmeshSingla / function.php
Created August 15, 2013 06:53
Change Menu Labels, Reorder Menu Wordpress
<?php
function change_post_menu_label() {
global $menu;
global $submenu;
$menu[5][0] = 'Contacts';
$submenu['edit.php'][5][0] = 'Contacts';
$submenu['edit.php'][10][0] = 'Add Contacts';
$submenu['edit.php'][15][0] = 'Status'; // Change name for categories
$submenu['edit.php'][16][0] = 'Labels'; // Change name for tags
echo '';
@UmeshSingla
UmeshSingla / uploader.js
Created July 18, 2013 13:22
Media Uploader Wordpress
jQuery(document).ready(function(){
var _rtp_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
jQuery('.rtp-media-uploader').click(function () {
var button = jQuery(this),
textbox_id = jQuery(this).attr('data-id');
_rtp_media = true;
@UmeshSingla
UmeshSingla / function.php
Created June 29, 2013 08:45
Image Uploader for Custom Taxonomies
<?php
//Add a Image Uploader for each taxonomy
// Add term page
function rtp_news_image_add($tag) {
// this will add the custom meta field to the add new term page
$get_img = get_option( "custom_marketimg_id_$tag->term_id" ); ?>
<table class="form-table">
<tr class="form-field">
<th>
Check the link
https://github.com/lafeber