Skip to content

Instantly share code, notes, and snippets.

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

Rotsen Mark Acob webdevsuperfast

🏠
Working from home
View GitHub Profile
@webdevsuperfast
webdevsuperfast / truncate_html_string.php
Created February 24, 2016 05:15 — forked from mrwweb/truncate_html_string.php
Improved version of text-truncating html string function to improve character count accuracy. Code found on oikos.org.uk/2013/02/tech-notes-a-wordpress-excerpt-with-html-tags/.
<?
/**
* Truncates text.
*
* Cuts a string to the length of $length and replaces the last characters
* with the ending if the text is longer than length.
*
* See: oikos.org.uk/2013/02/tech-notes-a-wordpress-excerpt-with-html-tags/
* See also: wpengineer.com/2410/dont-use-strlen/
* See also also: oikos.org.uk/2013/02/tech-notes-a-wordpress-excerpt-with-html-tags/#comment-1467093876
@webdevsuperfast
webdevsuperfast / gist:4f730ceca1b014847883c22b52e124e6
Created July 19, 2016 03:43 — forked from mattie02/gist:8308341
only pull meta for specific page-template superCpt
if(class_exists( 'Super_Custom_Post_Type' )){
add_action( 'after_setup_theme','trusted_page_sup' );
function trusted_page_sup() {
if ( isset( $_GET['post'] ) )
$post_id = $_GET['post'];
elseif ( isset( $_POST['post_ID'] ) )
$post_id = $_POST['post_ID'];
else
$post_id = get_the_ID();
@webdevsuperfast
webdevsuperfast / wp-get-widget-instance.php
Created September 15, 2016 07:16 — forked from cyberhobo/wp-get-widget-instance.php
Get a WordPress registered widget instance settings.
<?php
function get_widget_instance( $widget_id ) {
global $wp_registered_widgets;
if ( empty( $wp_registered_widgets[$widget_id]['callback'] ) )
return array();
/** @var WP_Widget $widget */
$widget = $wp_registered_widgets[$widget_id]['callback'][0];
@webdevsuperfast
webdevsuperfast / perfectelementary.bash
Created December 19, 2016 02:42
HowTo Install the perfect Elementary-OS
#Download Elementary OS from here:
#http://sourceforge.net/projects/elementaryos/files/stable/
#First you update your system
sudo apt-get update && sudo apt-get dist-upgrade
#Install Google Chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
@webdevsuperfast
webdevsuperfast / functions.php
Created July 3, 2017 06:27
Eliminate thumbnails
<?php
@link https://bavotasan.com/2015/eliminate-thumbnails-custom-post-types/
add_filter( 'intermediate_image_sizes', rma_custom_intermediate_image_sizes, 999 );
function rma_custom_intermediate_image_sizes( $image_sizes ){
return array();
}
@webdevsuperfast
webdevsuperfast / filter-posts-mt.js
Created August 10, 2017 07:30 — forked from Bobz-zg/filter-posts-mt.js
Filter WordPress posts by multiple custom taxonomy terms with AJAX
(function($) {
$doc = $(document);
$doc.ready( function() {
/**
* Retrieve posts
*/
function get_posts($params) {
@webdevsuperfast
webdevsuperfast / filter-posts-mt.php
Created August 10, 2017 07:31 — forked from Bobz-zg/filter-posts-mt.php
Filter WordPress posts by multiple custom taxonomy terms with AJAX Raw
<?php
/**
* AJAC filter posts by taxonomy term
*/
function vb_filter_posts_mt() {
if( !isset( $_POST['nonce'] ) || !wp_verify_nonce( $_POST['nonce'], 'bobz' ) )
die('Permission denied');
/**
@webdevsuperfast
webdevsuperfast / gist:1f6f748cf1088855bfb1243abae13216
Created October 28, 2017 04:05 — forked from de-raaf-media/gist:4135538
wordpress function hook - wp_get_archives by category
// join term_relationships and term_taxonomy
add_filter( 'getarchives_join', 'customarchives_join' );
// add where condition for category
add_filter( 'getarchives_where', 'customarchives_where' );
// add where condition for date
add_filter('getarchives_where','filter_until_year_archives');
function customarchives_join($join_clause) {
global $wpdb;
return $join_clause." INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@webdevsuperfast
webdevsuperfast / gist:62a6b4e5e22d6c8377ac79da8b609fb8
Created November 2, 2017 21:45 — forked from darthwade/gist:9310975
JS String.format, String.prototype.format
// "{0} is dead, but {1} is alive! {0} {2}".format("ASP", "ASP.NET")
if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
@webdevsuperfast
webdevsuperfast / genesis-searchwp-image-search.php
Created November 9, 2017 07:28 — forked from robneu/genesis-searchwp-image-search.php
Create a custom search template to display custom search results using SearchWP and the Genesis Framework.
<?php
/**
* This file adds the SearchWP Images template to your theme.
*
* Template Name: SearchWP Images
*
* @author Robert Neu
* @package Genesis
* @subpackage SearchWP
*/