Skip to content

Instantly share code, notes, and snippets.

View ooooak's full-sized avatar
🏠
Working from home

Akshay ooooak

🏠
Working from home
View GitHub Profile
@ooooak
ooooak / gist:39ea74a455491e5e7b3e
Last active August 29, 2015 14:06
add all users to custom buddypress group
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 October 1, 2014 07:05
wordpress after save post.
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 October 3, 2014 09:52
save print_r in text file
$dump = print_r( $_POST, true );
file_put_contents('test.txt', $dump );
@ooooak
ooooak / gist:ec39f14e28bc9e0eb818
Last active August 29, 2015 14:07
[html] center img eliment
<div class='image'>
<img src='src/image.png'>
</div>
.image{
display: table-cell;
vertical-align: middle;
height: 320px;
}
@ooooak
ooooak / gist:dcc83cb4111f444c2b1d
Created October 16, 2014 14:51
revert last commit
git log
git reset --soft HEAD^
git status
@ooooak
ooooak / gist:3e94021254f08e680092
Created November 4, 2014 05:15
list all wordpress active plugins
$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 November 4, 2014 07:38
wordpress change post status to draft
$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 August 29, 2015 14:08
[javaScript] scrolltop animation
_element.stop().animate({scrollTop: _offset}, 600)
@ooooak
ooooak / gist:53646b3913f887522ba9
Last active August 29, 2015 14:08
[php] convert miles to kilometers && kilometers to miles php.
# 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) {
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