Skip to content

Instantly share code, notes, and snippets.

View Kudratullah's full-sized avatar

Kudratullah Kudratullah

View GitHub Profile
@Kudratullah
Kudratullah / show_all_posts.php
Created September 10, 2015 12:20
get all post in csv
<textarea style="width: 100%; height: 299px;" onclick="select();">
<?php
$args = array(
'post_type' => array( 'post', 'page', 'media', 'news' ),
'posts_per_page' => -1,
);
echo 'Title of page, URL of Page'. PHP_EOL;
$dump = new WP_Query($args);
if($dump->have_posts()){
while($dump->have_posts()){
@Kudratullah
Kudratullah / freedownloadbd.com.userscript.js
Created October 30, 2015 02:59
Fun with Greasemonkey/Tampermonkey Scripting
// ==UserScript==
// @name Easy Browse freedownloadbd.com
// @namespace http://facebook.com/kudratullah/
// @version 9.80
// @description Script for Easy Category Browsing in freedownloadbd.com
// @match *.freedownloadbd.com/*
// @include *.freedownloadbd.com/*
// @exclude *.freedownloadbd.com/index.php/component/search/*
// @require http://code.jquery.com/jquery-2.1.4.min.js
// @require http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
@Kudratullah
Kudratullah / parseUri.js
Created December 14, 2015 14:23
JS URI Parser
/**
* See: https://gist.github.com/1847816
* See: http://stackoverflow.com/questions/736513/how-do-i-parse-a-url-into-hostname-and-path-in-javascript
* Parse a URI, returning an object similar to Location
* Usage: var uri = parseUri("hello?search#hash")
*/
function parseUri(url) {
var result = {};
<?php
/**
* This will copy all terms from country taxonomy to area taxonomy
* this will also include the child terms, but will not place them in right hierarchy
* for this please check the wp_insert_term() [ https://codex.wordpress.org/Function_Reference/wp_insert_term ] argument in codex and modify the loop
* @uses wp_insert_term()
* @return boolean
*/
function CopyTermsToOtherTaxonomy(){
static $done;
@Kudratullah
Kudratullah / post_query.php
Last active February 15, 2016 11:44
WordPress Post Date Query for this month's posts and previous month's posts
<?php
global $current_user;
$ThisMonthArgs = array(
'post_type' => 'post',
'author'=> $current_user->ID,
'posts_per_page' => -1,
'date_query' => array(
array(
'column' => 'post_modified_gmt',
'after' => array(
@Kudratullah
Kudratullah / restrict_admin_panel_for_non_admin_user.php
Last active March 5, 2016 07:00
Restrict Non Admin User To Home Page of WordPress Site
<?php
if(!function_exists("redirect_non_admin_users")):
/**
* Redirect non-admin users to home page
*/
function redirect_non_admin_users() {
global $currentUser;
if ( is_admin() && ! current_user_can( 'manage_options' )
&& '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF']
&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
@Kudratullah
Kudratullah / wp_custom_login_url.php
Last active February 18, 2021 22:36
Customize WordPress Default Login URL Returned by wp_login_url() For adding custom login template via WordPress page template feature.
<?php
if(!function_exists('sekaiju_login_page')):
/**
* Change Default Login Url Regurned by wp_login_url()
* @param string $login_url
* @param string $redirect
* @return string
*/
add_filter( 'login_url', 'custom_login_url', 10, 2 );
function custom_login_url( $login_url, $redirect ) {
@Kudratullah
Kudratullah / cmb2-functions.php
Last active May 12, 2016 12:22
cmb2 user meta object_id issue
<?php
//issue: cmb2 metabox form getting wrong object_id for user edit form, so it's can't display the meta values stored in database.
//cmb2 veriosn 2.2.1
add_action( 'cmb2_init', 'UserMetabox' );
function UserMetabox(){
$cmb_user_fields = new_cmb2_box( array(
'id' => '_user_info',
'title' => 'User Extras',
'object_types' => array( 'user' ), // Tells CMB2 to use user_meta vs post_meta
'show_names' => true,
@Kudratullah
Kudratullah / LolipopWebmail.user.js
Last active August 10, 2018 18:16
Some Tweaks and English Translation for Lolipop Webmail UI
// ==UserScript==
// @name LolipopWebmail
// @namespace github.com/Kudratullah
// @version 1.1.9
// @description Some Tweaks and English Translation for Lolipop Webmail UI
// @author Kudratullah <[email protected]>
// @updateURL https://gist.githubusercontent.com/Kudratullah/83c57ea87c1c0aaf81968c7db83bba1a/raw/LolipopWebmail.user.js
// @downloadURL https://gist.githubusercontent.com/Kudratullah/83c57ea87c1c0aaf81968c7db83bba1a/raw/LolipopWebmail.user.js
// @match https://tools.lolipop.jp/mail/mail*
// @icon https://tools.lolipop.jp/mail/mail/img/title.png
@Kudratullah
Kudratullah / input.scss
Created October 16, 2019 10:22
Extending WordPress admin core UI button and input fields
/**
* Extend Core UI Button Style And Size for custom dashboard
* @version 1.0.0
* @copyright KD <[email protected]>
* @license MIT
* @see https://github.com/markjaquith/WordPress/blob/master/wp-admin/css/colors/_admin.scss
* @see https://github.com/markjaquith/WordPress/blob/master/wp-admin/css/colors/_mixins.scss
* @todo input styles
*/
@mixin button( $button-color, $text-color: #fff ) {