Skip to content

Commit

Permalink
First draft of new logo widget
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed Mar 13, 2020
1 parent c5d8926 commit f48304d
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 15 deletions.
57 changes: 57 additions & 0 deletions wp-content/mu-plugins/logo-list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

function cp_logo_link_html( $dir, $entry, $format_key, $link_text ) {
$dir_url = site_url( "/$dir" );
return (
'<a href="' . esc_attr(
$dir_url . '/' . $entry['formats'][ $format_key ]
) . '">'
. esc_html( $link_text )
. '</a>'
);
}

function cp_logo_list_shortcode( $atts ) {
$dir = trim( $atts['dir'] ?? '', '/' );
if ( empty( $dir ) || ! is_dir( ABSPATH . $dir ) ) {
return '';
}
$dir = trailingslashit( $dir );
$dir_full = ABSPATH . $dir;
$dir_url = site_url( "/$dir" );

if ( ! file_exists( "$dir_full/index.json" ) ) {
return '';
}

$index = json_decode( file_get_contents( "$dir_full/index.json" ), true );

$html = "<table class=\"cp-logo-list\">\n";
foreach ( $index as $svg => $entry ) {
$html .= "<tr><td class=\"cp-logo-preview\">\n";
$url = esc_url( $dir_url . $svg );
$html .= "<a href=\"$url\"><div class=\"cp-logo-wrapper\">";
$html .= "<div class=\"cp-logo-thumbnail\" style=\"
width: 120px;
height: 120px;
background-image: url( '$url' );
background-repeat: no-repeat;
background-size: contain;
background-position: center;
\"></div></div></a>\n";
$html .= "</td><td class=\"cp-logo-info\">\n";
$html .= esc_html( $entry['description'] ) . "<br>\n";
$html .= "Formats: ";
$html .= cp_logo_link_html( $dir, $entry, 'svg', 'SVG' );
$html .= " | PNG: ";
$html .= cp_logo_link_html( $dir, $entry, 'png:1200', '1200px' );
$html .= ", ";
$html .= cp_logo_link_html( $dir, $entry, 'png:600', '600px' );
$html .= " | ";
$html .= cp_logo_link_html( $dir, $entry, 'pdf', 'PDF' );
}
$html .= "</table>\n";

return $html;
}
add_shortcode( 'cp-logo-list', 'cp_logo_list_shortcode' );
2 changes: 1 addition & 1 deletion wp-content/themes/classicpress-susty-child/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Stylesheet version (cache buster)
*/
function cp_susty_get_asset_version() {
return '20200301.3';
return '20200312.03';
}


Expand Down
24 changes: 10 additions & 14 deletions wp-content/themes/classicpress-susty-child/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1392,45 +1392,41 @@ label select {
}


/* TABLE */
/* LOGO TABLE (https://www.classicpress.net/brand-guidelines/) */

table.cp-file-list {
table.cp-logo-list {
max-width: 600px;
border-spacing: 0 6px;
}

table.cp-file-list td {
table.cp-logo-list td {
padding: 0;
margin-bottom: 4px;
}

table.cp-file-list tr:hover td {
table.cp-logo-list tr:hover td {
background: #ddd;
}

table.cp-file-list .cp-file-preview .cp-file-wrapper {
table.cp-logo-list .cp-logo-preview .cp-logo-wrapper {
border: 6px solid #eee;
background: #ddd;
width: 132px;
height: 132px;
}

table.cp-file-list tr:hover .cp-file-preview .cp-file-wrapper {
border-color: #ddd
table.cp-logo-list tr:hover .cp-logo-preview .cp-logo-wrapper {
border-color: #ddd;
}

table.cp-file-list .cp-file-preview .cp-file-thumbnail {
border: 6px solid #ddd
table.cp-logo-list .cp-logo-preview .cp-logo-thumbnail {
border: 6px solid #ddd;
}

table.cp-file-list .cp-file-name {
table.cp-logo-list .cp-logo-info {
padding-left: 1em;
}

table.cp-file-list .cp-file-size {
padding-right: 1em;
}


/*****SIDEBAR*****************************/

Expand Down

0 comments on commit f48304d

Please sign in to comment.