Skip to content

Instantly share code, notes, and snippets.

View OksanaRomaniv's full-sized avatar

Oksana Romaniv OksanaRomaniv

  • Kalush, Ukraine
View GitHub Profile
@anhang
anhang / localStorage.js
Created July 20, 2011 23:07
HTML5 Local Storage with Expiration
AZHU.storage = {
save : function(key, jsonData, expirationMin){
if (!Modernizr.localstorage){return false;}
var expirationMS = expirationMin * 60 * 1000;
var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime() + expirationMS}
localStorage.setItem(key, JSON.stringify(record));
return jsonData;
},
load : function(key){
if (!Modernizr.localstorage){return false;}
@GaryJones
GaryJones / functions.php
Last active June 24, 2017 19:40
Style the Genesis comment count number
<?php
// Don't include above <?php
add_filter( 'genesis_post_comments_shortcode', 'prefix_post_comments_shortcode' );
/**
* Amend the post comments shortcode to add extra markup for styling.
*
* @author Gary Jones
* @link http://gamajo.com/style-comment-number/
@carlthewebmaster
carlthewebmaster / smallerversion.php
Created February 17, 2012 01:25
Show only author's articles
// hide articles from contribs who don't own them
function show_author_posts_only($query) {
global $user_level;
if($query->is_admin && $user_level < 5) {
global $user_ID;
$query->set('author', $user_ID);
unset($user_ID);
}
@cballou
cballou / youtube-vimeo-embed-urls.php
Created March 27, 2012 15:52
PHP Function to Convert Youtube and Vimeo URLs to Lightbox-Ready Equivalents
<?php
/**
* Given a string containing any combination of YouTube and Vimeo video URLs in
* a variety of formats (iframe, shortened, etc), each separated by a line break,
* parse the video string and determine it's valid embeddable URL for usage in
* popular JavaScript lightbox plugins.
*
* In addition, this handler grabs both the maximize size and thumbnail versions
* of video images for your general consumption. In the case of Vimeo, you must
* have the ability to make remote calls using file_get_contents(), which may be
@markoheijnen
markoheijnen / gist:2407319
Created April 17, 2012 16:29
Get WordPress menu title by theme location
<?
function get_menu_title( $theme_location, $default_name = 'menu' ) {
if ( $theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $theme_location ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $theme_location ] );
if( $menu && $menu->name ) {
return $menu->name;
}
}
@benbalter
benbalter / parse-csv.php
Created July 24, 2012 22:28
Parse CSV into Associative Array
<?php
$lines = explode( "\n", file_get_contents( 'input.csv' ) );
$headers = str_getcsv( array_shift( $lines ) );
$data = array();
foreach ( $lines as $line ) {
$row = array();
foreach ( str_getcsv( $line ) as $key => $field )
@grtaylor2
grtaylor2 / Change Read More Text Genesis WordPress
Last active August 11, 2021 19:53
Change the [Read More] Text in Genesis WordPress Child Theme
/** Customize Read More Text */
add_filter( 'excerpt_more', 'child_read_more_link' );
add_filter( 'get_the_content_more_link', 'child_read_more_link' );
add_filter( 'the_content_more_link', 'child_read_more_link' );
function child_read_more_link() {
return '<a href="' . get_permalink() . '" rel="nofollow">CUSTOMIZE YOUR TEXT HERE</a>';
}
@joshuafredrickson
joshuafredrickson / gist:5439897
Last active February 22, 2019 09:11
WordPress - Genesis: Custom "read more" link in excerpts
// Custom read more link
add_filter( 'excerpt_more', 'op_read_more_link' );
add_filter( 'get_the_content_more_link', 'op_read_more_link' );
add_filter( 'the_content_more_link', 'op_read_more_link' );
function op_read_more_link() {
return '... <a class="more-link" href="' . get_permalink() . '" rel="nofollow">Continue Reading &raquo;</a>';
}
@dylanhthomas
dylanhthomas / excel-remove-trailing-slash.txt
Created June 18, 2013 16:36
Remove the Trailing slash from a cell in Excel. This is especially handy when dealing with lots of urls. Replace "A1" with your cell.
=IF(RIGHT(A1,(LEN(A1)-(LEN(A1)-1)))="/",LEFT(A1,(LEN(A1)-1)),A1)
@irazasyed
irazasyed / strpos_arr.php
Created July 12, 2013 17:21
PHP: Strpos Array, Find in array!
<?php
/* strpos that takes an array of values to match against a string note the stupid argument order (to match strpos) */
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}