Skip to content

Instantly share code, notes, and snippets.

View smartrashed's full-sized avatar
💭
Love Wordpress and Opensource Technology

MD.MAINUDDIN smartrashed

💭
Love Wordpress and Opensource Technology
  • Tech Bangladesh
  • Dhaka
View GitHub Profile
@smartrashed
smartrashed / class-backend-tables.php
Created March 10, 2020 10:41 — forked from wturnerharris/class-backend-tables.php
This is an example of extending the default class for tables in the admin section, WP_List_Table. It does take some setup arguments, but works and looks seamlessly within WordPress.
<?php
if(!class_exists('WP_List_Table')) require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
/**
* Extended class for displaying a list of items in an HTML table.
*
* @usage
* // be sure to modify the display_rows function to customize the output of the rows
* $args = array(
@smartrashed
smartrashed / example-wp-list-table.php
Created March 10, 2020 08:12 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@smartrashed
smartrashed / aux-functions.php
Created February 25, 2020 11:53 — forked from eduwass/duplicate-post.php
Programmatically duplicating a WordPress post
<?php
/**
* Duplicates a post & its meta and it returns the new duplicated Post ID
* @param [int] $post_id The Post you want to clone
* @return [int] The duplicated Post ID
*/
function duplicate($post_id) {
$title = get_the_title($post_id);
$oldpost = get_post($post_id);
@smartrashed
smartrashed / manage_columns_wp_admin.php
Created February 25, 2020 10:36 — forked from vishalkakadiya/manage_columns_wp_admin.php
Manage custom columns with sortable in WordPress Admin side
<?php
/*
* =================================================================================================
* Below both hooks works for custom post types.
* e.g. Suppose we have custom post-type name : Books
* @ref https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
* =================================================================================================
*/
@smartrashed
smartrashed / expanded_alowed_tags
Created November 25, 2019 10:52 — forked from adamsilverstein/expanded_alowed_tags
WordPress expanded allowed tags for wp_kses with iframe, forms, etc.
function expanded_alowed_tags() {
$my_allowed = wp_kses_allowed_html( 'post' );
// iframe
$my_allowed['iframe'] = array(
'src' => array(),
'height' => array(),
'width' => array(),
'frameborder' => array(),
'allowfullscreen' => array(),
);
@smartrashed
smartrashed / functions.php
Created November 9, 2019 04:58 — forked from vishalbasnet23/functions.php
User Registration Front End WordPress with Ajax
<?php
add_action('wp_ajax_register_user_front_end', 'register_user_front_end', 0);
add_action('wp_ajax_nopriv_register_user_front_end', 'register_user_front_end');
function register_user_front_end() {
$new_user_name = stripcslashes($_POST['new_user_name']);
$new_user_email = stripcslashes($_POST['new_user_email']);
$new_user_password = $_POST['new_user_password'];
$user_nice_name = strtolower($_POST['new_user_email']);
$user_data = array(
'user_login' => $new_user_name,
@smartrashed
smartrashed / Simple Ajax Login Form.php
Created November 7, 2019 07:49 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">