Skip to content

Instantly share code, notes, and snippets.

Baki Goxhaj banago

Block or report user

Report or block banago

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@banago
banago / mysqlcheck.md
Created Feb 13, 2016 — forked from francois-blanchard/mysqlcheck.md
Check and Repair MySQL Tables Using Mysqlcheck
View mysqlcheck.md

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 / convo-feed-api.php
Last active Aug 29, 2015
PHP script for working with Convo's custom feed API.
View convo-feed-api.php
<?php
/* Convo Custom Feed API
*
* This is the PHP version of the python example script Convo offers on their website:
* https://www.convo.com/developer_center/api/imported_feed_api.py
*/
function add_link_in_feed($resource_id, $url, $title, $description, $image, $site_name) {
global $access_key_id, $secret_access_key;
$params = http_build_query(['resource_id' => $resource_id, 'url' => $url, 'title' => $title, 'description' => $description, 'image' => $image, 'site_name' => $site_name ]);
View create-project.sh
#!/bin/bash
# This script creates a new project (or site) under /var/sites and creates
# new virtual host for that site. With the options a site can also
# install the latest version of Laravel directly.
# This script was originally based on the following script by @Nek from
# Coderwall: https://coderwall.com/p/cqoplg
# Display the usage information of the command.
create-project-usage() {
@banago
banago / random-testimonial.php
Last active Aug 29, 2015
WordPress Random Testimonial Shortcode
View random-testimonial.php
<?php
//[random_testimonial]
function random_testimonial_func( $atts ){
$query = new WP_Query( array ( 'category__in' => array( 4 ), 'posts_per_page' => -1, 'ignore_sticky_posts' => 1, ) );
$testimonials = array();
while( $query->have_posts() ) : $query->the_post();
$testimonials[] = get_the_content();
endwhile;
@banago
banago / infinite-previous-next-looping.php
Last active Oct 14, 2019
Infinite next and previous post looping in WordPress
View infinite-previous-next-looping.php
<?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();
View gist:5597006
<?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 Apr 16, 2013
Legacy Paginate Functions for WordPress
View paginate.php
<?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 / get-fisrt-paragraph.php
Created Nov 6, 2012
Get first paragraph from a WordPress post.
View get-fisrt-paragraph.php
<?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 Oct 10, 2012
Facebook Page Feed Parser through cURL or SimpleXML in PHP
View fb-parse-feed-curl.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 / old-style-recent-comments.php
Last active Sep 15, 2017
WordPress - Recent Comments without a Plugin or Widget
View old-style-recent-comments.php
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);
You can’t perform that action at this time.