Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Last active July 28, 2021 18:33
Show Gist options
  • Save hellofromtonya/a6e41fa54ad5d47e191a75da158d278c to your computer and use it in GitHub Desktop.
Save hellofromtonya/a6e41fa54ad5d47e191a75da158d278c to your computer and use it in GitHub Desktop.
Test script for rendering a table for the 'site_logo' & theme mod 'custom_logo' options
<?php
// Add this test script to wp-content/mu-plugins/test-trac53770.php
// Add the function into the theme where the site logo is rendered.
function test_trac53770_logo() {
$theme = get_option( 'stylesheet' );
$mods = get_theme_mods();
$options = array(
'get theme mods' => array(
'logo_id' => isset( $mods['custom_logo'] ) ? $mods['custom_logo'] : false,
'heading' => "get_option( 'theme_mods_{$theme}' )['custom_logo']",
),
'get_theme_mod' => array(
'logo_id' => get_theme_mod( 'custom_logo' ),
'heading' => 'get_theme_mod( \'custom_logo\' )',
),
'site_logo' => array(
'logo_id' => get_option( 'site_logo' ),
'heading' => 'get_option( \'site_logo\' )',
),
);
?>
<div class="trac53770-test" style="text-align: left; background-color: #000; padding: 15px; color: #fff;">
<p>WordPress <?php echo get_bloginfo( 'version' ); ?> with <? echo $theme; ?></p>
<table>
<thead>
<th>Option</th>
<th>Logo ID</th>
<th>Data Type</th>
</thead>
<tbody>
<?php
foreach ( $options as $option => $config ) :
$heading = $config['heading'];
$logo_id = $config['logo_id'];
?>
<tr>
<td><?php echo $heading; ?></td>
<?php if ( false !== $logo_id ) : ?>
<td style="text-align: center"><?php echo $logo_id; ?></td>
<td style="text-align: center"><?php echo gettype( $logo_id ); ?></td>
<?php else : ?>
<td style="text-align: center">-</td>
<td style="text-align: center">-</td>
<?php endif; ?>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment