Skip to content

Instantly share code, notes, and snippets.

View adrianthedev's full-sized avatar
🚀
Building Avo https://avohq.io

Adrian Marin adrianthedev

🚀
Building Avo https://avohq.io
View GitHub Profile
@adrianthedev
adrianthedev / gist:2842300
Created May 31, 2012 09:49
Search multidimensional arrays PHP
function search($array, $key, $value)
{
$results = array();
if (is_array($array))
{
if (isset($array[$key]) && $array[$key] == $value)
$results[] = $array;
foreach ($array as $subarray)
@adrianthedev
adrianthedev / gist:2842305
Created May 31, 2012 09:49
Remove extra paragraph in wordpress
remove_filter('the_content', 'wpautop');
@adrianthedev
adrianthedev / gist:2842306
Created May 31, 2012 09:50
Wordpress custom post type nivo slider management
$i=1;
echo '<div id="slider" class="nivoSlider">';
$args = array( 'post_type' => 'slide', 'posts_per_page' => 10 , 'orderby' => 'title' , 'order' => 'ASC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<a href="'.get_post_meta($post->ID, 'slide_info_slide_url', true).'"><img src="'.get_post_meta($post->ID, 'slide_info_slide_image', true).'" alt="'.get_post_meta($post->ID, 'slide_info_slide_title', true).'" title="#caption'.$i.'" /></a>';
$i++;
endwhile;
@adrianthedev
adrianthedev / gist:2842312
Created May 31, 2012 09:50
Wordpress menu
register_nav_menu( 'primary', __( 'Primary Menu', 'daily' ) );
<?php wp_nav_menu( array( 'theme_location' => 'primary','menu_class' => 'dropdown dropdown-horizontal', 'container' => '' ) ); ?>
/*============= Dropdown ============*/
ul.dropdown ul li,
ul.dropdown-vertical {
}
ul.dropdown ul,
ul.dropdown li:hover ul ul,
ul.dropdown li:hover ul ul ul,
ul.dropdown li:hover ul ul ul ul,
@adrianthedev
adrianthedev / gist:4309990
Created December 16, 2012 17:35
Apache restart
sudo /etc/init.d/apache2 restart
/sbin/service httpd restart
@adrianthedev
adrianthedev / gist:4310039
Created December 16, 2012 17:38
Facebook resize frame
<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript" charset="utf-8">
FB.Canvas.setSize({ width: 810 ,height: 780 });
</script>
@adrianthedev
adrianthedev / gist:4310048
Created December 16, 2012 17:39
Evenly spaced items
.hMenu
{
text-align:justify;
width:800px;
margin:0 auto;
}
.filler
{
width:100%;
@adrianthedev
adrianthedev / gist:4310049
Created December 16, 2012 17:39
Custom post type
function my_custom_post_product() {
$labels = array(
'name' => _x( 'Products', 'post type general name' ),
'singular_name' => _x( 'Product', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New Product' ),
'edit_item' => __( 'Edit Product' ),
'new_item' => __( 'New Product' ),
'all_items' => __( 'All Products' ),
'view_item' => __( 'View Product' ),
@adrianthedev
adrianthedev / gist:4310059
Created December 16, 2012 17:40
Laravel snippets
//timing and profiling helpers
Profiler::tick('ce sa logheze', callback);
Log::write($type,$output);
$type = 'info';
//get url
URI::segment(2)
//define contants