Skip to content

Instantly share code, notes, and snippets.

View Irfan-Ansari's full-sized avatar

Irfan Ansari Irfan-Ansari

View GitHub Profile
@Irfan-Ansari
Irfan-Ansari / How to add wysiwyg editor in Wordpress meta box
Created February 13, 2015 07:20
How to add wysiwyg editor in Wordpress meta box
<?php
add_action( 'add_meta_boxes', 'adding_new_metaabox' );
function adding_new_metaabox()
{
add_meta_box('adsexcerptid', 'Ads Content', 'my_output_function');
}
function my_output_function( $post )
{
$settings = array(
@Irfan-Ansari
Irfan-Ansari / Replace the Post Excerpt Meta Box with a Field in My Custom Meta Box
Created February 13, 2015 06:17
Replace the Post Excerpt Meta Box with a Field in My Custom Meta Box
<?php
function my_custom_save_function($post_id){
update_post(array('ID' => $post_id, 'post_excerpt' => $_POST['my_custom_field']));
}
add_action('save_post', 'my_custom_save_function');
var myConfObj = {
iframeMouseOver : false
}
window.addEventListener('blur',function(){
if(myConfObj.iframeMouseOver){
console.log('Wow! Iframe Click!');
}
});
document.getElementById('YOUR_CONTAINER_ID').addEventListener('mouseover',function(){
@Irfan-Ansari
Irfan-Ansari / gist:bb16f1acf3dcff7ff926
Created January 21, 2015 05:58
swap your old to new URLs for Wordpress while moving website
# SQL to Use the code as below and swap in your old and new URLs, no trailing slashes. Also if necessary change the table prefix values where applicable (ie wp_ )
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
<?php
define('MY_POST_TYPE', 'my');
define('MY_POST_SLUG', 'gallery');
function my_register_post_type () {
$args = array (
'label' => 'Gallery',
'supports' => array( 'title', 'excerpt' ),
'register_meta_box_cb' => 'my_meta_box_cb',
@Irfan-Ansari
Irfan-Ansari / dailymotion-autoplay.php
Created November 12, 2014 07:17
Dailymotion videos - autoplay
<?php
/**
* Implements hook_video_filter_codec_info_alter().
* Add video filter html5 support for dailymotion.
*/
function MY_MODULE_video_filter_codec_info_alter(&$codecs) {
if (!isset($codecs['dailymotion']['html5_callback'])) {
$codecs['dailymotion']['html5_callback'] = 'MY_MODULE_video_filter_dailymotion_html5';
}
}
@Irfan-Ansari
Irfan-Ansari / Grab URL Parameters
Created October 17, 2014 12:40
Grab URL Parameters - PHP code snippt
<?php
$url = 'http://www.IrfanAnsari.com/embedviz?q=select+col9+from+1c16ZytvOGsazT5r4borWzDSKmRy1dyeCqzOHdnWb&viz=MAP&h=false&lat=28.098107336734692&lng=68.93999515039059&t=1&z=6&l=col9&y=2&tmplt=2&hml=GEOCODABLE';
function grab_url($url) {
if(!empty($url)) {
$urllist=parse_url($url);
if(is_array($urllist) && isset($urllist["query"])) {
$keyvalue_list=explode("&",($urllist["query"]));
@Irfan-Ansari
Irfan-Ansari / Squarifying Bootstrap Spans
Created July 4, 2014 06:41
Squarifying Bootstrap Spans
Squarifying Bootstrap Spans
I just wrote a quick little js plugin to make any element's height equal to it's width. It's not really bootstrap specific, but it's helpful for spans if you need a span to be square at all times, even when the responsive resizing is done.
Introducing Squarify...
function squarifyMe(element) {
squareItUp()
window.onresize = function(element) {
squareItUp();
}
/**
* Convert From/To Binary/Decimal/Hexadecimal in JavaScript
* https://gist.github.com/faisalman
*
* Copyright 2012, Faisalman <fyzlman@gmail.com>
* Licensed under The MIT License
* http://www.opensource.org/licenses/mit-license
*/
(function(){
@Irfan-Ansari
Irfan-Ansari / Media Manager sidebox
Created June 11, 2014 09:50
wordpress Media Manager sidebox
/**
* Removes "image edit" option from Media Manager.
*/
add_action( 'admin_footer-post-new.php', 'wpse_76214_script' );
add_action( 'admin_footer-post.php', 'wpse_76214_script' );
function wpse_76214_script() {
?>
<script type="text/javascript">
jQuery(document).ready( function($) {
$( 'li.attachment' ).live( 'click', function( event ) {