Skip to content

Instantly share code, notes, and snippets.

View ScarletPonytail's full-sized avatar

ScarletPonytail ScarletPonytail

View GitHub Profile
@ScarletPonytail
ScarletPonytail / code.js
Last active October 1, 2018 13:15
jQuery - Remove the first character
var thing = 'Thing';
var itemId = thing.substring(1, thing.length);
// Output would be "hing".
@ScarletPonytail
ScarletPonytail / variable.php
Last active September 12, 2018 16:18
Wordpress - Adding a variable for an esc_html
<?php echo esc_html( sprintf( 'Text here %s', $variable ), 'standardchartered' ) ?>
@ScarletPonytail
ScarletPonytail / file.php
Created August 31, 2018 14:32
PHP - Make image a link for SC.com
<?php // Make the image a link
if ( 'yes' === $settings->cb_blk_one_show_btns ) :
// Run a foreach loop over every button from global options
if ( count( $settings->cb_blk_one_btns ) === 1 ) :
foreach ( $settings->cb_blk_one_btns as $key => $val ) :
printf( '<a href="%1$s" class="ctawrapa %2$s" target="%3$s" %4$s>',
( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) !== false ) ? esc_attr( '#country-popup' ) : esc_url( $settings->cb_blk_one_btns[ $key ]->sc_global_btnurl ), // %1$s : href
( ( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) !== false ) ? esc_attr( 'country-popup' ) : '' ), // %2$s : Add country-popup class for JS listener
( ( strpos( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype, 'open-country-popup' ) === false ) ? esc_url( $settings->cb_blk_one_btns[ $key ]->sc_global_urltype ) : '' ), // %3$s : If not country popup as target (_self, _blank)
@ScarletPonytail
ScarletPonytail / test.php
Last active June 4, 2019 12:53
PHP - Echo to console
// Echo a specific thing
<?php echo '<script>console.log("Your stuff here")</script>'; ?>
// Echo a dynamic element
<?php echo '<script>console.log( ' . get_page_template() . ' )</script>'; ?>
@ScarletPonytail
ScarletPonytail / sheets.txt
Last active August 10, 2018 09:26
Google Sheets - Round a number
// The 'Round' syntax
=MROUND( A1 ; 0.25 )
// ROUND a SUM
=MROUND( sum( ( hour( E141 )*60+MINUTE( E141 ) ) )/60 ; 0.25 )
// Another way
=CEILING( sum( ( hour( E175 )*60+MINUTE( E175 ) ) )/60 , 0.25 )
@ScarletPonytail
ScarletPonytail / sheets.txt
Created August 10, 2018 09:07
Google Sheets - Convert time to decimal
=sum((hour(C3)*60+MINUTE(C3)))/60
@ScarletPonytail
ScarletPonytail / sheet.txt
Last active August 9, 2018 15:37
Google Sheets - Last edited date
function onEdit(e) {
if (!e.value) return;
e.source.getActiveSheet()
.getRange('K1')
.setValue(new Date());
}
Date format: dd/MM/yyyy
@ScarletPonytail
ScarletPonytail / page.php
Created July 23, 2018 09:16
Wordpress - Add page / page title
<?php the_title_attribute(); ?>
@ScarletPonytail
ScarletPonytail / script.js
Last active June 20, 2018 13:04
jQuery - Aria-expanded
$( '.accordion-effect' ).click( function () {
$( this ).attr( 'aria-expanded', 'true' );
if ( $( '.accordion-effect' ).attr( 'true' ) ) {
$( this ).attr( 'aria-expanded', 'false' );
}
} );
@ScarletPonytail
ScarletPonytail / frontend.php
Last active June 11, 2018 11:07
Wordpress - Date range for wp_query loop
<?php
$mostloop = new WP_Query(
[
'post_type' => 'post',
'post__in' => explode( ',', $settings->ins_mv_suggest ),
'posts_per_page' => 12,
'date_query' => [
'column' => 'post_date_gmt',
'after' => '3 months ago',
'inclusive' => true,