true, ], 'objects' ); /** * Filters the post type on submitbox. * * @since 3.12.1 * * @param array $cpts Post Types. */ $cpts = apply_filters( 'rocket_submitbox_options_post_types', $cpts ); if ( isset( $cpts[ $post->post_type ] ) ) { $url = wp_nonce_url( admin_url( 'admin-post.php?action=purge_cache&type=post-' . $post->ID ), 'purge_cache_post-' . $post->ID ); printf( '
', esc_url( $url ), esc_html__( 'Clear cache', 'rocket' ) ); } } } add_action( 'post_submitbox_start', 'rocket_post_submitbox_start' ); /** * Add "Cache options" metabox * * @since 2.5 */ function rocket_cache_options_meta_boxes() { if ( ! rocket_can_display_options() ) { return; } if ( current_user_can( 'rocket_manage_options' ) ) { $cpts = get_post_types( [ 'public' => true, ], 'objects' ); unset( $cpts['attachment'] ); $cpts = apply_filters( 'rocket_metabox_options_post_types', $cpts ); foreach ( $cpts as $cpt => $cpt_object ) { $label = $cpt_object->labels->singular_name; add_meta_box( 'rocket_post_exclude', sprintf( __( 'WP Rocket Options', 'rocket' ), $label ), 'rocket_display_cache_options_meta_boxes', $cpt, 'side', 'core' ); } } } add_action( 'add_meta_boxes', 'rocket_cache_options_meta_boxes' ); /** * Displays some checkbox to de/activate some cache options * * @since 2.5 */ function rocket_display_cache_options_meta_boxes() { if ( current_user_can( 'rocket_manage_options' ) ) { global $post, $pagenow; wp_nonce_field( 'rocket_box_option', '_rocketnonce', false, true ); ?>', '' ); ?>