Skip to content

Instantly share code, notes, and snippets.

View Kudratullah's full-sized avatar

Kudratullah Kudratullah

View GitHub Profile
<?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 / 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 = {};
@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 / 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 / make-pot.bat.php
Last active August 29, 2015 14:27
execute WordPress l18n tools from windows command prompt.
/**
* Usage: php makepot.php PROJECT DIRECTORY [OUTPUT]
* Generate POT file from the files in DIRECTORY [OUTPUT]
* Available projects: generic, wp-frontend, wp-admin, wp-network-admin, wp-core, wp-ms, wp-tz, wp-plugin, wp-theme, bb, mu, bp, glotpress, rosetta, wporg-bb-forums
* This is windows cmd command
*/
C:\xampp\php>php c:\xampp\htdocs\wpdev\tools\makepot.php wp-plugin c:\xampp\htdocs\wpdev\wp-content\plugins\sp_google_maps c:\lang.pot
<?php
/**
* Dimox Breadcrumbs
* http://dimox.net/wordpress-breadcrumbs-without-a-plugin/
* Since ver 1.0
* Add this to any template file by calling dimox_breadcrumbs()
* Changes: MC added taxonomy support
*/
function dimox_breadcrumbs(){
/* === OPTIONS === */
@Kudratullah
Kudratullah / html5_form_attribute.html
Last active August 29, 2015 14:14
HTML5 Form With Validation
<!DOCTYPE html>
<html>
<head>
<title>HTML5 Form Attribute</title>
</head>
<body>
<form name="contact-form" method="POST" action="sentmail.php">
<p>
<label for="name">Name:</label>
<input type="text" id="name" name="name"
<?php
// in functions.php
add_theme_support( 'post-thumbnails');
/*
Wordpress crop an image = 5 size. Sizes are given below
thumbnail // Thumbnail (default 150px x 150px max)
@Kudratullah
Kudratullah / integrating_plugin_in_wordpress_theme_directly.php
Last active August 29, 2015 14:06
Integrating / Embedding WordPress Plugins Directly Into WordPress Theme.
<?php
/**
* Integratin WordPress Plugins into WordPress Theme for automatic download/instgall and activation.
* Required TGM Plugin Activation library [http://tgmpluginactivation.com/]
* Help Urls--
* http://code.tutsplus.com/tutorials/integrating-the-envato-wordpress-toolkit-to-your-theme-the-plugin--wp-33264
* http://tgmpluginactivation.com/
* https://wordpress.org/support/topic/embed-a-plugin-in-template
* http://thomasgriffinmedia.com/blog/2011/09/automatically-install-plugins-with-themes-for-wordpress/
* http://codex.wordpress.org/Function_Reference/is_plugin_active
@Kudratullah
Kudratullah / curl_file_type.php
Created September 4, 2014 20:27
Get Remote File Type Via PHP CURL
<?php
# the request
$file = file_get_contents('http://www.videojs.com/js/video-js.swf');
$file_url = 'http://www.videojs.com/js/video-js.swf';
echo "<br>";
$ch = curl_init($file_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
# get the content type