Created
June 14, 2017 23:31
-
-
Save BriceShatzer/0ff3913ded1424dd7af76ab96e7c8892 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define( 'SVG_instapaper', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 23.9356 24.0002"><title>Add to Instapaper</title><path d="M495.2844,421H481.78a5.2379,5.2379,0,0,0-5.2158,5.23v13.54a5.2384,5.2384,0,0,0,5.2158,5.23h13.504a5.2384,5.2384,0,0,0,5.2158-5.23V426.23A5.2379,5.2379,0,0,0,495.2844,421Zm-3.5324,5.9654c-1.2172,0-1.5871.4194-1.5871,0.9633v9.8825c0,0.5445.37,0.9645,1.5871,0.9645v0.8025H485.39V438.776c1.2169,0,1.5871-.42,1.5871-0.9645V427.929c0-.5439-0.37-0.9633-1.5871-0.9633v-0.8019h6.3617v0.8019Z" transform="translate(-476.5646 -421.0003)" fill="#36f"/><path d="M495.2844,421H481.78a5.2379,5.2379,0,0,0-5.2158,5.23v13.54a5.2384,5.2384,0,0,0,5.2158,5.23h13.504a5.2384,5.2384,0,0,0,5.2158-5.23V426.23A5.2379,5.2379,0,0,0,495.2844,421Zm-3.5324,5.9654c-1.2172,0-1.5871.4194-1.5871,0.9633v9.8825c0,0.5445.37,0.9645,1.5871,0.9645v0.8025H485.39V438.776c1.2169,0,1.5871-.42,1.5871-0.9645V427.929c0-.5439-0.37-0.9633-1.5871-0.9633v-0.8019h6.3617v0.8019Z" transform="translate(-476.5646 -421.0003)" fill="#36f"/>'); | |
define( 'SVG_pocket', '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 27.1322 24.0043"><title>Save To Pocket</title><path d="M24.687 0a2.427 2.427 0 0 1 2.445 2.44v8.11a13.186 13.186 0 0 1-1.072 5.25 13.562 13.562 0 0 1-24.987 0A13.18 13.18 0 0 1 0 10.55V2.44A2.33 2.33 0 0 1 .726.72 2.376 2.376 0 0 1 2.46 0h22.227zM13.582 16.628a1.832 1.832 0 0 0 1.293-.517l6.373-6.06a1.82 1.82 0 0 0 .04-2.634 1.804 1.804 0 0 0-1.318-.54 1.83 1.83 0 0 0-1.293.517l-5.095 4.843-5.095-4.843a1.857 1.857 0 0 0-2.595.023 1.767 1.767 0 0 0-.544 1.305 1.744 1.744 0 0 0 .567 1.329l6.39 6.06a1.743 1.743 0 0 0 1.277.518z" fill="#36f"/></svg>'); | |
define( 'SVG_facebook', '<svg xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Follow Us on Facebook" viewBox="0 0 257 258"><title>Facebook</title><path fill="#36f" d="M243.16 0H13.89A13.942 13.942 0 0 0 0 14.224v229.27C0 251.35 6.033 258 13.89 258H137V158h-33v-39h33V90.338c0-33.287 20.311-51.413 50.007-51.413A265.155 265.155 0 0 1 217 40.458v34.785l-20.66.01c-16.15 0-19.34 7.675-19.34 18.935V119h39.003l-5.016 39H177v100h66.16c7.855 0 13.84-6.65 13.84-14.506V14.224A13.9 13.9 0 0 0 243.16 0z"></path></svg>' ); | |
define( 'SVG_twitter', '<svg xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Follow on Twitter" viewBox="0 0 298.0041 242.1906"><title>Twitter</title><path fill="#36f" d="M93.72 242.19c112.46 0 173.96-93.167 173.96-173.96q0-3.97-.174-7.902a124.338 124.338 0 0 0 30.498-31.66 121.918 121.918 0 0 1-35.11 9.625 61.36 61.36 0 0 0 26.885-33.817 122.62 122.62 0 0 1-38.825 14.84 61.192 61.192 0 0 0-104.188 55.757 173.608 173.608 0 0 1-126.03-63.88 61.193 61.193 0 0 0 18.93 81.623 60.685 60.685 0 0 1-27.69-7.647c-.01.256-.01.506-.01.78a61.157 61.157 0 0 0 49.052 59.934 61.04 61.04 0 0 1-27.614 1.05 61.202 61.202 0 0 0 57.115 42.464 122.655 122.655 0 0 1-75.936 26.17A124.18 124.18 0 0 1 0 214.724a173.068 173.068 0 0 0 93.722 27.464"></path></svg>' ); | |
function trib43_print_save_for_later( string $url, string $title ) { | |
$services = [ | |
'pocket' => [ 'base' => 'https://getpocket.com/save' ], | |
'instapaper' => [ 'base' => 'http://www.instapaper.com/hello2' ], | |
]; | |
$socials = [ | |
'facebook' => [ 'base' => 'https://www.facebook.com/sharer/sharer.php?u=' ], | |
'twitter' => [ 'base' => 'https://twitter.com/home?status=' ], | |
]; | |
$out = '<div class="save-article"> | |
'; | |
if ( is_singular() ) { | |
foreach ( $services as $slug => $service ) { | |
$share_url = add_query_arg( [ 'url' => rawurlencode( $url ), 'title' => rawurlencode( $title ) ], $service['base'] ); | |
$out .= sprintf( ' <a class="save-to-%s" href="%s" target="_blank" rel="noopener noreferrer">' . constant( 'SVG_' . $slug ) . '</a>', | |
esc_attr( $slug ), | |
esc_url( $share_url ) | |
); | |
} | |
} | |
if ( is_singular() || get_query_var( 'daily-news-date' ) ) { | |
foreach( $socials as $slug => $social ) { | |
$share_url = $social['base'] . $url; | |
$out .= sprintf( ' <a class="save-to-%s" href="%s" target="_blank" rel="noopener noreferrer">' . constant( 'SVG_' . $slug ) . '</a>', | |
esc_attr( $slug ), | |
esc_url( $share_url ) | |
); | |
} | |
} | |
$out .= '</div>'; | |
// ESCAPED SEE ABOVE | |
echo $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment