Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Akshaydeep Giri ooooak

🏠
Working from home
View GitHub Profile
@ooooak
ooooak / gist:39ea74a455491e5e7b3e
Last active Aug 29, 2015
add all users to custom buddypress group
View gist:39ea74a455491e5e7b3e
function add_users_to_bpgroup() {
$group_id = 1;
$users = get_users(); // all users
foreach ( $users as $user ) {
var_dump(groups_join_group($group_id, $user->ID ));
}
}
add_action ( 'wp_enqueue_scripts', 'add_users_to_bpgroup' );
@ooooak
ooooak / gist:a817eecc8f200a9bcfd7
Created Oct 1, 2014
wordpress after save post.
View gist:a817eecc8f200a9bcfd7
function on_save( $post_id ) {
$post_type = get_post_type($post_id);
// order page
if ($post_type == 'shop_order'){}
}
add_action( 'save_post', 'ag_on_booking_save' ); // called after post saved
@ooooak
ooooak / gist:83dc95a7d2918747c383
Created Oct 3, 2014
save print_r in text file
View gist:83dc95a7d2918747c383
$dump = print_r( $_POST, true );
file_put_contents('test.txt', $dump );
@ooooak
ooooak / gist:ec39f14e28bc9e0eb818
Last active Aug 29, 2015
[html] center img eliment
View gist:ec39f14e28bc9e0eb818
<div class='image'>
<img src='src/image.png'>
</div>
.image{
display: table-cell;
vertical-align: middle;
height: 320px;
}
View gist:dcc83cb4111f444c2b1d
git log
git reset --soft HEAD^
git status
@ooooak
ooooak / gist:3e94021254f08e680092
Created Nov 4, 2014
list all wordpress active plugins
View gist:3e94021254f08e680092
$all_plugins = get_option();
$active_plugins = get_option('active_plugins');
foreach ($active_plugins as $plugin){
if (is_plugin_active_for_network($plugin)){
// plugin is network activated
}
}
@ooooak
ooooak / gist:1f471542ee3571284281
Created Nov 4, 2014
wordpress change post status to draft
View gist:1f471542ee3571284281
$posts = get_posts(array(
'post_type' => $post_type,
'posts_per_page' => -1,
'post_status' => 'publish'
));
foreach ($posts as $post){
$post->post_status = 'draft';
@ooooak
ooooak / gist:77a8a628468fd1320836
Last active Aug 29, 2015
[javaScript] scrolltop animation
View gist:77a8a628468fd1320836
_element.stop().animate({scrollTop: _offset}, 600)
@ooooak
ooooak / gist:53646b3913f887522ba9
Last active Aug 29, 2015
[php] convert miles to kilometers && kilometers to miles php.
View gist:53646b3913f887522ba9
# conversion factor
private $conv_fac = 0.621371;
// convert miles to kilometers
private function miles_to_kl($miles) {
return $miles / $this->conv_fac;
}
// convert kilometers to miles
private function kl_to_miles($kilometers) {
View gist:c0ef1ecce8d5eb67ab00
4GiB SODIMM DDR3 Synchronous 1600 MHz
Memory Device
Array Handle: 0x0023
Error Information Handle: 0x0026
Total Width: 64 bits
Data Width: 64 bits
Size: 4096 MB
Form Factor: SODIMM
Set: None