Skip to content

Instantly share code, notes, and snippets.

View OksanaRomaniv's full-sized avatar

Oksana Romaniv OksanaRomaniv

  • Kalush, Ukraine
View GitHub Profile
@muya
muya / minify_on_save.py
Last active March 4, 2017 16:57
Sublime Text 3 Plugin to Minify JS & CSS files on save (requires bistory's Sublime Minifier here: https://github.com/bistory/Sublime-Minifier)
import sublime, sublime_plugin
class MinifyOnSave(sublime_plugin.EventListener):
def on_post_save(self, view):
file_types_to_minify = ['js', 'css']
filenameParts = view.file_name().split('.')
if filenameParts[len(filenameParts) - 1] in file_types_to_minify:
view.run_command('minify')
@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/
@nickpelton
nickpelton / localize-script-002.php
Last active July 15, 2017 13:15
WP: wp_localize_script admin-ajax url
<?php
// Setup our data
$myDataArray = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
);
// Pass data to myscript.js on page load
wp_localize_script( "myScript", "myLocalizedData", $myDataArray );
@kellenmace
kellenmace / get-file-type-url-remote-file-wordpress.php
Created September 9, 2016 18:07
Get File Type by URL for a Remote File in WordPress
<?php
/**
* Get the file mime type for a file by its URL.
*
* @param $url The URL to the file.
* @return The file mime type or empty string on failure.
*/
function km_get_file_type_by_url( $url ) {
@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;
}
}
@spivurno
spivurno / gw-gravity-forms-checkbox-to-acf.php
Last active October 29, 2018 15:26
Gravity Wiz // Gravity Forms // Map GF Checkbox Field to ACF Checkbox Field
/**
* Gravity Wiz // Gravity Forms // Map GF Checkbox Field to ACF Checkbox Field
* http://graivtywiz.com/
*/
add_filter( 'gform_post_data', function( $data ) {
// Update "checkboxes" to your cusotm field name.
$data['post_custom_fields']['checkboxes'] = serialize( explode( ',', $data['post_custom_fields']['checkboxes'] ) );
return $data;
} );
@vishalkakadiya
vishalkakadiya / commands.txt
Created August 3, 2017 19:54
Commands to Upgrade PHPcs and WordPress_Coding_Standards
// Update PHPcs
sudo pear upgrade-all and sudo pear install PHP_CodeSniffer
// Check version of PHPcs
phpcs --version
// Go to Where coding standards available
/usr/local/pear/share/pear/PHP/CodeSniffer/Standards/WordPress-Coding-Standards
@oriolrivera
oriolrivera / today.js
Created October 15, 2014 20:43
jQuery Get Todays Date dd/mm/yyyy
var fullDate = new Date()
console.log(fullDate);
//Thu Otc 15 2014 17:25:38 GMT+1000 {}
//convert month to 2 digits
var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) :(fullDate.getMonth()+1);
var currentDate = fullDate.getDate() + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
console.log(currentDate);
//15/10/2014
@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>';
}
@ohryan
ohryan / responsive-align.less
Last active April 30, 2019 17:27
Bootstrap 3 Responsive Text Align
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: @screen-sm-min) {
.text-sm-left { text-align: left; }
.text-sm-right { text-align: right; }
.text-sm-center { text-align: center; }
.text-sm-justify { text-align: justify; }