class-activation.php
4 months ago
class-admin-menu-organizer.php
4 months ago
class-admin-menu-svg-icon-mask.php
4 months ago
class-auto-publish-posts-with-missed-schedule.php
4 months ago
class-avif-upload.php
4 months ago
class-captcha-protection.php
4 months ago
class-change-login-url.php
4 months ago
class-cleanup-admin-bar.php
4 months ago
class-common-methods.php
4 months ago
class-content-duplication.php
4 months ago
class-content-order.php
4 months ago
class-custom-admin-footer-text.php
4 months ago
class-custom-body-class.php
4 months ago
class-custom-css.php
4 months ago
class-custom-nav-menu-items-in-new-tab.php
4 months ago
class-deactivation.php
4 months ago
class-disable-author-archives.php
4 months ago
class-disable-comments.php
4 months ago
class-disable-dashboard-widgets.php
4 months ago
class-disable-embeds.php
4 months ago
class-disable-feeds.php
4 months ago
class-disable-gutenberg.php
4 months ago
class-disable-rest-api.php
4 months ago
class-disable-smaller-components.php
4 months ago
class-disable-updates.php
4 months ago
class-disable-xml-rpc.php
4 months ago
class-display-system-summary.php
4 months ago
class-email-address-obfuscator.php
4 months ago
class-email-delivery.php
4 months ago
class-enhance-list-tables.php
4 months ago
class-external-permalinks.php
4 months ago
class-heartbeat-control.php
4 months ago
class-hide-admin-bar.php
4 months ago
class-hide-admin-notices.php
4 months ago
class-image-sizes-panel.php
4 months ago
class-image-upload-control.php
4 months ago
class-insert-head-body-footer-code.php
4 months ago
class-last-login-column.php
4 months ago
class-limit-login-attempts.php
4 months ago
class-login-id-type.php
4 months ago
class-login-logout-menu.php
4 months ago
class-maintenance-mode.php
4 months ago
class-manage-ads-appads-txt.php
4 months ago
class-manage-robots-txt.php
4 months ago
class-media-files-visibility-control.php
4 months ago
class-media-replacement.php
4 months ago
class-multiple-user-roles.php
4 months ago
class-obfuscate-author-slugs.php
4 months ago
class-open-external-links-in-new-tab.php
4 months ago
class-password-protection.php
4 months ago
class-redirect-after-login.php
4 months ago
class-redirect-after-logout.php
4 months ago
class-redirect-fourofour.php
4 months ago
class-registration-date-column.php
4 months ago
class-revisions-control.php
4 months ago
class-search-engines-visibility.php
4 months ago
class-settings-fields-render.php
4 months ago
class-settings-sanitization.php
4 months ago
class-settings-sections-fields.php
4 months ago
class-show-custom-taxonomy-filters.php
4 months ago
class-site-identity-on-login-page.php
4 months ago
class-svg-upload.php
4 months ago
class-various-admin-ui-enhancements.php
4 months ago
class-view-admin-as-role.php
4 months ago
class-wider-admin-menu.php
4 months ago
class-wp-config-transformer.php
4 months ago
class-revisions-control.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ASENHA\Classes; |
| 4 | |
| 5 | /** |
| 6 | * Class for Revisions Control module |
| 7 | * |
| 8 | * @since 6.9.5 |
| 9 | */ |
| 10 | class Revisions_Control { |
| 11 | /** |
| 12 | * Limit the number of revisions for post types |
| 13 | * |
| 14 | * @since 3.7.0 |
| 15 | */ |
| 16 | public function limit_revisions_to_max_number( $num, $post ) { |
| 17 | $options = get_option( ASENHA_SLUG_U, array() ); |
| 18 | $revisions_max_number = ( isset( $options['revisions_max_number'] ) ? $options['revisions_max_number'] : 10 ); |
| 19 | $for_post_types = ( isset( $options['enable_revisions_control_for'] ) && is_array( $options['enable_revisions_control_for'] ) ? $options['enable_revisions_control_for'] : array() ); |
| 20 | $revisions_control_type = 'only-on'; |
| 21 | // Assemble single-dimensional array of post type slugs for which revisions is being limited. |
| 22 | $limited_post_types = array(); |
| 23 | foreach ( $for_post_types as $post_type_slug => $post_type_is_limited ) { |
| 24 | if ( $post_type_is_limited ) { |
| 25 | $limited_post_types[] = $post_type_slug; |
| 26 | } |
| 27 | } |
| 28 | // Change revisions number to keep if set for the post type as such. |
| 29 | $post_type = ( is_object( $post ) && property_exists( $post, 'post_type' ) ? $post->post_type : '' ); |
| 30 | if ( 'only-on' === $revisions_control_type && in_array( $post_type, $limited_post_types, true ) ) { |
| 31 | $num = $revisions_max_number; |
| 32 | } |
| 33 | return $num; |
| 34 | } |
| 35 | |
| 36 | } |
| 37 |