list_theme_updates() WordPress Function

The list_theme_updates() function allows you to view a list of all the themes that have updates available. This is useful if you want to keep your themes up to date, or if you want to see if there are any new features available in the latest version of a theme.

list_theme_updates() #

Display the upgrade themes form.


Source

File: wp-admin/update-core.php

624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
function list_theme_updates() {
    $themes = get_theme_updates();
    if ( empty( $themes ) ) {
        echo '<h2>' . __( 'Themes' ) . '</h2>';
        echo '<p>' . __( 'Your themes are all up to date.' ) . '</p>';
        return;
    }
 
    $form_action = 'update-core.php?action=do-theme-upgrade';
 
    $themes_count = count( $themes );
    ?>
<h2>
    <?php
    printf(
        '%s <span class="count">(%d)</span>',
        __( 'Themes' ),
        number_format_i18n( $themes_count )
    );
    ?>
</h2>
<p><?php _e( 'The following themes have new versions available. Check the ones you want to update and then click &#8220;Update Themes&#8221;.' ); ?></p>
<p>
    <?php
    printf(
        /* translators: %s: Link to documentation on child themes. */
        __( '<strong>Please Note:</strong> Any customizations you have made to theme files will be lost. Please consider using <a href="%s">child themes</a> for modifications.' ),
    );
    ?>
</p>
<form method="post" action="<?php echo esc_url( $form_action ); ?>" name="upgrade-themes" class="upgrade">
    <?php wp_nonce_field( 'upgrade-core' ); ?>
<p><input id="upgrade-themes" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
<table class="widefat updates-table" id="update-themes-table">
    <thead>
    <tr>
        <td class="manage-column check-column"><input type="checkbox" id="themes-select-all" /></td>
        <td class="manage-column"><label for="themes-select-all"><?php _e( 'Select All' ); ?></label></td>
    </tr>
    </thead>
 
    <tbody class="plugins">
    <?php
    $auto_updates = array();
    if ( wp_is_auto_update_enabled_for_type( 'theme' ) ) {
        $auto_updates       = (array) get_site_option( 'auto_update_themes', array() );
        $auto_update_notice = ' | ' . wp_get_auto_update_message();
    }
 
    foreach ( $themes as $stylesheet => $theme ) {
        $requires_wp  = isset( $theme->update['requires'] ) ? $theme->update['requires'] : null;
        $requires_php = isset( $theme->update['requires_php'] ) ? $theme->update['requires_php'] : null;
 
        $compatible_wp  = is_wp_version_compatible( $requires_wp );
        $compatible_php = is_php_version_compatible( $requires_php );
 
        $compat = '';
 
        if ( ! $compatible_wp && ! $compatible_php ) {
            $compat .= '<br>' . __( 'This update does not work with your versions of WordPress and PHP.' ) . '&nbsp;';
            if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
                $compat .= sprintf(
                    /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
                    __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
                    self_admin_url( 'update-core.php' ),
                    esc_url( wp_get_update_php_url() )
                );
 
                $annotation = wp_get_update_php_annotation();
 
                if ( $annotation ) {
                    $compat .= '</p><p><em>' . $annotation . '</em>';
                }
            } elseif ( current_user_can( 'update_core' ) ) {
                $compat .= sprintf(
                    /* translators: %s: URL to WordPress Updates screen. */
                    __( '<a href="%s">Please update WordPress</a>.' ),
                    self_admin_url( 'update-core.php' )
                );
            } elseif ( current_user_can( 'update_php' ) ) {
                $compat .= sprintf(
                    /* translators: %s: URL to Update PHP page. */
                    __( '<a href="%s">Learn more about updating PHP</a>.' ),
                    esc_url( wp_get_update_php_url() )
                );
 
                $annotation = wp_get_update_php_annotation();
 
                if ( $annotation ) {
                    $compat .= '</p><p><em>' . $annotation . '</em>';
                }
            }
        } elseif ( ! $compatible_wp ) {
            $compat .= '<br>' . __( 'This update does not work with your version of WordPress.' ) . '&nbsp;';
            if ( current_user_can( 'update_core' ) ) {
                $compat .= sprintf(
                    /* translators: %s: URL to WordPress Updates screen. */
                    __( '<a href="%s">Please update WordPress</a>.' ),
                    self_admin_url( 'update-core.php' )
                );
            }
        } elseif ( ! $compatible_php ) {
            $compat .= '<br>' . __( 'This update does not work with your version of PHP.' ) . '&nbsp;';
            if ( current_user_can( 'update_php' ) ) {
                $compat .= sprintf(
                    /* translators: %s: URL to Update PHP page. */
                    __( '<a href="%s">Learn more about updating PHP</a>.' ),
                    esc_url( wp_get_update_php_url() )
                );
 
                $annotation = wp_get_update_php_annotation();
 
                if ( $annotation ) {
                    $compat .= '</p><p><em>' . $annotation . '</em>';
                }
            }
        }
 
        $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
        ?>
    <tr>
        <td class="check-column">
            <?php if ( $compatible_wp && $compatible_php ) : ?>
                <input type="checkbox" name="checked[]" id="<?php echo $checkbox_id; ?>" value="<?php echo esc_attr( $stylesheet ); ?>" />
                <label for="<?php echo $checkbox_id; ?>" class="screen-reader-text">
                    <?php
                    /* translators: %s: Theme name. */
                    printf( __( 'Select %s' ), $theme->display( 'Name' ) );
                    ?>
                </label>
            <?php endif; ?>
        </td>
        <td class="plugin-title"><p>
            <img src="<?php echo esc_url( $theme->get_screenshot() . '?ver=' . $theme->version ); ?>" width="85" height="64" class="updates-table-screenshot" alt="" />
            <strong><?php echo $theme->display( 'Name' ); ?></strong>
            <?php
            printf(
                /* translators: 1: Theme version, 2: New version. */
                __( 'You have version %1$s installed. Update to %2$s.' ),
                $theme->display( 'Version' ),
                $theme->update['new_version']
            );
 
            echo ' ' . $compat;
 
            if ( in_array( $stylesheet, $auto_updates, true ) ) {
                echo $auto_update_notice;
            }
            ?>
        </p></td>
    </tr>
            <?php
    }
    ?>
    </tbody>
 
    <tfoot>
    <tr>
        <td class="manage-column check-column"><input type="checkbox" id="themes-select-all-2" /></td>
        <td class="manage-column"><label for="themes-select-all-2"><?php _e( 'Select All' ); ?></label></td>
    </tr>
    </tfoot>
</table>
<p><input id="upgrade-themes-2" class="button" type="submit" value="<?php esc_attr_e( 'Update Themes' ); ?>" name="upgrade" /></p>
</form>
    <?php
}


Top ↑

Changelog

Changelog
VersionDescription
2.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.