Skip to content

Instantly share code, notes, and snippets.

Sudar Muthu sudar

Block or report user

Report or block sudar

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sudar
sudar / exclude-attachments.php
Created Nov 17, 2018
Exclude attachments from getting deleted using the Bulk Delete Attachments add-on for Bulk Delete plugin
View exclude-attachments.php
<?php
add_filter( 'bd_delete_attachment_excluded_attachment_ids', 'prefix_exclude_attachment_ids_from_deletion' );
function prefix_exclude_attachment_ids_from_deletion( $attachment_ids ) {
return array(
100,
111,
112,
);
}
@sudar
sudar / capability.php
Last active Aug 7, 2017
Change the capability that is required for viewing email logs
View capability.php
<?php
function wpel_change_email_log_user_role( $capability ) {
return 'manage_options' // change this to the capability that you want.
}
add_filter( 'el_view_email_log_capability', 'wpel_change_email_log_user_role' );
@sudar
sudar / dump-taxonomies.php
Last active Jan 30, 2017
Dump All Taxonomies for debugging
View dump-taxonomies.php
<?php
/**
* Plugin Name: Dump Taxonomy
* Plugin URI: http://bulkwp.com
* Description: Dump all Taxonomy for debugging
* Version: 0.1
* License: GPL
* Author: Sudar
* Author URI: http://sudarmuthu.com/
*/
@sudar
sudar / last-page.php
Last active Jun 18, 2016
How to find if you are on the last page of a multi-page post in WordPress. Explanation at http://sudarmuthu.com/blog/how-to-find-if-you-are-on-the-last-page-of-a-multi-page-post-in-wordpress/
View last-page.php
<?php
/**
* Is the current page the last page of the multi-page post.
*
* @return bool True if last page, False otherwise.
*/
function is_last_page() {
global $page, $numpages, $multipage;
if ( $multipage ) {
View error_msg.php
<?php
/**
* Display an error message at the top of the post edit screen explaining that ratings is required.
*
* Doing this prevents users from getting confused when their new posts aren't published, as we
* require a valid rating custom taxonomy.
*
* @param WP_Post The current post object.
*/
function show_required_field_error_msg( $post ) {
View Customfile-memory.rb
config.vm.provider "virtualbox" do |v|
v.memory = 2048
end
@sudar
sudar / gist:d362472ef9b1f6b6ffef
Created Feb 2, 2015
vip-quickstart error output
View gist:d362472ef9b1f6b6ffef
$ v up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Fixed port collision for 22 => 2222. Now on port 2201.
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2201 (adapter 1)
@sudar
sudar / apache-error-mailer.py
Last active Aug 29, 2015
Automatically send unique errors (with count) from Apache error log as email. Details at http://sudarmuthu.com/blog/automatically-send-unique-errors-with-count-from-apache-error-log-as-email/
View apache-error-mailer.py
#!/usr/bin/env python
import sys
import mandrill
MANDRILL_API_KEY = "api-key"
EMAIL_FROM = "your@email.com"
EMAIL_TO = "your@email.com"
EMAIL_SUBJECT = "Error Log"
@sudar
sudar / wordpress.vim
Created Sep 8, 2014
Syntastic Syntax Checker for WordPress
View wordpress.vim
if exists("g:loaded_syntastic_wordpress_phpcs_checker")
finish
endif
let g:loaded_syntastic_wordpress_phpcs_checker = 1
" Use PHP's phpcs checker
runtime! syntax_checkers/php/phpcs.vim
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'wordpress',
@sudar
sudar / gsheet.py
Created Aug 31, 2014
Read data from Google Sheet into a Python Pandas DataFrame. Details at http://sudarmuthu.com/blog/read-data-from-google-sheet-into-a-python-pandas-dataframe/
View gsheet.py
import gspread
import pandas
gc = gspread.login('my@email.com', 'supersecretepassword')
book = gc.open('Spreadsheet name')
sheet = book.sheet1 #choose the first sheet
dataframe = pandas.DataFrame(sheet.get_all_records())
You can’t perform that action at this time.