From f48304d9f9ea5e9cf677172f20ea6d6191c206ac Mon Sep 17 00:00:00 2001 From: James Nylen Date: Fri, 13 Mar 2020 03:02:19 +0000 Subject: [PATCH] First draft of new logo widget --- wp-content/mu-plugins/logo-list.php | 57 +++++++++++++++++++ .../classicpress-susty-child/functions.php | 2 +- .../themes/classicpress-susty-child/style.css | 24 ++++---- 3 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 wp-content/mu-plugins/logo-list.php diff --git a/wp-content/mu-plugins/logo-list.php b/wp-content/mu-plugins/logo-list.php new file mode 100644 index 00000000..0cacffde --- /dev/null +++ b/wp-content/mu-plugins/logo-list.php @@ -0,0 +1,57 @@ +' + . esc_html( $link_text ) + . '' + ); +} + +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 = "\n"; + foreach ( $index as $svg => $entry ) { + $html .= "
\n"; + $url = esc_url( $dir_url . $svg ); + $html .= "
"; + $html .= "
\n"; + $html .= "
\n"; + $html .= esc_html( $entry['description'] ) . "
\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 .= "
\n"; + + return $html; +} +add_shortcode( 'cp-logo-list', 'cp_logo_list_shortcode' ); diff --git a/wp-content/themes/classicpress-susty-child/functions.php b/wp-content/themes/classicpress-susty-child/functions.php index b081808d..3cd9c084 100644 --- a/wp-content/themes/classicpress-susty-child/functions.php +++ b/wp-content/themes/classicpress-susty-child/functions.php @@ -4,7 +4,7 @@ * Stylesheet version (cache buster) */ function cp_susty_get_asset_version() { - return '20200301.3'; + return '20200312.03'; } diff --git a/wp-content/themes/classicpress-susty-child/style.css b/wp-content/themes/classicpress-susty-child/style.css index 22041cc3..38ea4b82 100644 --- a/wp-content/themes/classicpress-susty-child/style.css +++ b/wp-content/themes/classicpress-susty-child/style.css @@ -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*****************************/