Skip to content

Instantly share code, notes, and snippets.

View banago's full-sized avatar

Baki Goxhaj banago

View GitHub Profile
@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 / convo-feed-api.php
Last active August 29, 2015 14:19
PHP script for working with Convo's custom feed API.
<?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 ]);
#!/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 August 29, 2015 13:57
WordPress Random Testimonial Shortcode
<?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 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();
<?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 / 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 / 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);