12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- if ( ! class_exists( 'ACF_Location_Post_Format' ) ) :
- class ACF_Location_Post_Format extends ACF_Location {
-
- public function initialize() {
- $this->name = 'post_format';
- $this->label = __( 'Post Format', 'acf' );
- $this->category = 'post';
- $this->object_type = 'post';
- }
-
- public function match( $rule, $screen, $field_group ) {
-
- if ( isset( $screen['post_format'] ) ) {
- $post_format = $screen['post_format'];
- } elseif ( isset( $screen['post_id'] ) ) {
- $post_type = get_post_type( $screen['post_id'] );
- $post_format = get_post_format( $screen['post_id'] );
-
- if ( ! $post_format && post_type_supports( $post_type, 'post-formats' ) ) {
- $post_format = 'standard';
- }
- } else {
- return false;
- }
-
- return $this->compare_to_rule( $post_format, $rule );
- }
-
- public function get_values( $rule ) {
- return get_post_format_strings();
- }
- }
-
- acf_register_location_type( 'ACF_Location_Post_Format' );
- endif;
|