Skip to content

Instantly share code, notes, and snippets.

View Kudratullah's full-sized avatar

Kudratullah Kudratullah

View GitHub Profile
#!/usr/bin/php
<?php
/*
* Convert JSON file to CSV and output it.
*
* JSON should be an array of objects, dictionaries with simple data structure
* and the same keys in each object.
* The order of keys it took from the first element.
*
* Example:
// jQuery Headers support for $.ajax
$.ajax({
beforeSend: function(xhrObj){
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Accept","application/json");
}
type: "POST",
url: "/article",
processData: false,
@Kudratullah
Kudratullah / setup_video_player.php
Last active August 29, 2015 14:05
SetUp Video Player For Browser
<?php
/*
* This Function Is InComplete.
* @param video url string;
* @return mixed;
**/
//$url="https://www.youtube.com/embed/Tgb0jK143MI";
//$url = 'https://www.youtube.com/embed/FblnhqYEae0';
$url ="https://www.youtube.com/watch?v=Hg8Fa_EUQqY&index=23&list=PLDu39zhqv26ILpsfB1INvhqqsBvSdI6wG";
//$url = 'http://vimeo.com/channels/staffpicks/97916782';
@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
@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
<?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 / 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
/**
* 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 / 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
@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()){