Skip to content

Instantly share code, notes, and snippets.

View banago's full-sized avatar

Baki Goxhaj banago

View GitHub Profile
@banago
banago / infinite-previous-next-looping.php
Last active March 28, 2024 11:31
Infinite next and previous post looping in WordPress
<?php
/**
* Infinite next and previous post looping in WordPress
*/
if( get_adjacent_post(false, '', true) ) {
previous_post_link('%link', '&larr; Previous Post');
} else {
$first = new WP_Query('posts_per_page=1&order=DESC'); $first->the_post();
echo '<a href="' . get_permalink() . '">&larr; Previous Post</a>';
wp_reset_query();
@banago
banago / get-fisrt-paragraph.php
Created November 6, 2012 09:18
Get first paragraph from a WordPress post.
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );
@banago
banago / fb-parse-feed-curl.php
Created October 10, 2012 10:05
Facebook Page Feed Parser through cURL or SimpleXML in PHP
</php
/**
* Facebook Page Feed Parser
*
* @using cURL
*/
function fb_parse_feed( $page_id, $no = 5 ) {
// URL to the Facebook page's RSS feed.
@banago
banago / mysqlcheck.md
Created February 13, 2016 10:48 — forked from francois-blanchard/mysqlcheck.md
Check and Repair MySQL Tables Using Mysqlcheck

Check and Repair MySQL Tables Using Mysqlcheck

Check a Specific Table in a Database

$ mysqlcheck -c database_name table_name -u root -p

Check All Tables in a Database

@banago
banago / old-style-recent-comments.php
Last active September 15, 2017 08:55
WordPress - Recent Comments without a Plugin or Widget
function bg_recent_comments($no_comments = 10, $comment_len = 35) {
global $wpdb;
$request = "SELECT * FROM $wpdb->comments";
$request .= " JOIN $wpdb->posts ON ID = comment_post_ID";
$request .= " WHERE comment_approved = '1' AND post_status = 'publish' AND post_password =''";
$request .= " ORDER BY comment_date DESC LIMIT $no_comments";
$comments = $wpdb->get_results($request);
@banago
banago / inView.js
Created August 24, 2012 14:13
Keep Elements in View When Scrolling
//keep element in view
(function($)
{
$(document).ready( function()
{
var elementPosTop = $('#sidebar-ads').position().top;
$(window).scroll(function()
{
var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
//if top of element is in view
<?php
/*
Usage:
$frag = new CWS_Fragment_Cache( 'unique-key', 3600 ); // Second param is TTL
if ( !$frag->output() ) { // NOTE, testing for a return of false
functions_that_do_stuff_live();
these_should_echo();
// IMPORTANT
$frag->store();
// YOU CANNOT FORGET THIS. If you do, the site will break.
@banago
banago / paginate.php
Created April 16, 2013 10:17
Legacy Paginate Functions for WordPress
<?php
/**
* A pagination function
* @param integer $range: The range of the slider, works best with even numbers
* Used WP functions:
* get_pagenum_link($i) - creates the link, e.g. http://site.com/page/4
* previous_posts_link(' « '); - returns the Previous page link
* next_posts_link(' » '); - returns the Next page link
*/
function da_pagination( $range = 4, $wrap = true ){
@banago
banago / gist:3260741
Created August 5, 2012 00:10 — forked from JeffreyWay/gist:3185773
PHP Installation Options
./configure \
--prefix=/usr \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--with-apxs2=/usr/sbin/apxs \
--enable-cli \
--with-config-file-path=/etc \
--with-libxml-dir=/usr \
--with-openssl=/usr \
@banago
banago / the_includes.html
Created June 9, 2012 17:38 — forked from linssen/the_includes.html
Extending the jQuery Sortable With Ajax & MYSQL
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link rel='stylesheet' href='styles.css' type='text/css' media='all' />