Plugin Directory

Changeset 2020412


Ignore:
Timestamp:
01/28/2019 12:53:14 PM (7 years ago)
Author:
nikolam
Message:

Add transient cleaner

Location:
sermon-manager-for-wordpress/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sermon-manager-for-wordpress/trunk/includes/admin/settings/class-sm-settings-debug.php

    r1981432 r2020412  
    176176                'default'  => 'no',
    177177            ),
     178            array(
     179                'title'    => __( 'Clear All Transients', 'sermon-manager-for-wordpress' ),
     180                'type'     => 'checkbox',
     181                'desc'     => __( 'Clear all transients on save.', 'sermon-manager-for-wordpress' ),
     182                'desc_tip' => __( 'Removes all transients from the database on save. Useful for debugging RSS feed. Your website will not break by executing this.', 'sermon-manager-for-wordpress' ),
     183                'id'       => 'clear_transients',
     184                'default'  => 'no',
     185            ),
    178186
    179187            array(
  • sermon-manager-for-wordpress/trunk/sermons.php

    r2020189 r2020412  
    660660        );
    661661
     662        // Clear all transients.
     663        add_action(
     664            'sm_admin_settings_sanitize_option_clear_transients',
     665            function ( $value ) {
     666                if ( '' !== $value ) {
     667                    global $wpdb;
     668
     669                    $sql = 'DELETE FROM ' . $wpdb->options . ' WHERE ( `option_name` LIKE "_transient_%" OR `option_name` LIKE "transient_%")';
     670                    $wpdb->query( $sql );
     671
     672                    ?>
     673                    <div class="notice notice-success">
     674                        <p>Removed <?php echo $wpdb->rows_affected; ?> transient fields.</p>
     675                    </div>
     676                    <?php
     677                }
     678
     679                return '';
     680            }
     681        );
     682
    662683        // Execute all non-executed update functions on request.
    663684        add_action(
Note: See TracChangeset for help on using the changeset viewer.