Skip to content

Instantly share code, notes, and snippets.

@ahmad24
ahmad24 / form-style2
Last active December 30, 2015 03:59
wordpress : setting form style 2
<table class="widefat">
<thead>
<tr>
<th>Name </th>
<th>Favorite Holiday </th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name </th>
@ahmad24
ahmad24 / simple-debug
Last active December 30, 2015 05:38
wordpress : print queries[PLUGIN SECURITY]
<?php
/*
Plugin Name: Simple Debug
Plugin URI: http://example.com/
Description: Append ?debug=1 to display debug info if you are an admin
Author: WROX
Author URI: http://wrox.com
*/
add_action( 'init', 'boj_debug_check' );
@ahmad24
ahmad24 / unused-tag
Last active December 30, 2015 05:39
wordpress : unused-tag [Security]
<?php
/*
Plugin Name: Unused Tags
Plugin URI: http://example.com/
Description: Find unused tags and rename or delete them
Author: WROX
Author URI: http://wrox.com
*/
@ahmad24
ahmad24 / settings-api
Last active December 30, 2015 11:09
wordpress : Settings API
<?php
/*
Plugin Name: Settings API example
Plugin URI: http://example.com/
Description: A complete and practical example of use of the Settings API
Author: WROX
Author URI: http://wrox.com
*/
// Add a menu for our option page
add_action('admin_menu', 'boj_myplugin_add_page');
@ahmad24
ahmad24 / add-section
Last active December 30, 2015 11:09
wordpress : Add section to existing page
<?php
// Register and define the settings
add_action('admin_init', 'boj_myplugin_admin_init');
function boj_myplugin_admin_init(){
//You still need to whitelist this setting, with register_setting() .
//Omitting this step would make WordPress ignore the setting when submitting the form.
register_setting(
'privacy',
'boj_myplugin_options',
@ahmad24
ahmad24 / transiant-example
Created December 6, 2013 10:57
wordpress : transient Skeleton
<?php
// Fetches from an online radio a song title currently on air
function boj_myplugin_fetch_song_title_from_radio() {
// ... code to fetch data from the remote website
return $title;
}
// Get song title from database, using a 3 minute transient, and return it
function boj_myplugin_get_song_title() {
// Get transient value
@ahmad24
ahmad24 / user-select-lang
Created December 6, 2013 11:29
wordpress : select lang for each user
<?php
/*
Plugin Name: Per User Setting example
Plugin URI: http://example.com/
Description: Allow choosing either English or Spanish in the admin area
Author: WROX
Author URI: http://wrox.com
*/
// Return user's locale
function boj_adminlang_set_user_locale() {
@ahmad24
ahmad24 / insert user
Created December 7, 2013 08:51
wordpress : insert user
<?php
/*
Plugin Name: Insert User
Plugin URI: http://example.com
Description: Plugin that inserts a user.
Version: 0.1
Author: WROX
Author URI: http://goo.com
*/
/* Insert the new user on the 'init' hook. */
@ahmad24
ahmad24 / additional-contact
Created December 7, 2013 09:15
wordpress : additional contact for user
<?php
/*
Plugin Name: User Contact Methods
Plugin URI: http://example.com
Description: Additional user contact methods.
Author: WROX
Author URI: http://goo.com
*/
/* Add a filter to the hook. */
add_filter( 'user_contactmethods', 'boj_user_contactmethods' );
@ahmad24
ahmad24 / user-favorite-post
Created December 7, 2013 09:22
wordpress : User Favorite Post
User Favorite Post