diff --git a/includes/class-displayfeaturedimagegenesis-output.php b/includes/class-displayfeaturedimagegenesis-output.php index 0f2697e..5c3eea0 100644 --- a/includes/class-displayfeaturedimagegenesis-output.php +++ b/includes/class-displayfeaturedimagegenesis-output.php @@ -362,13 +362,14 @@ class Display_Featured_Image_Genesis_Output { * @since 2.2.0 */ protected function move_title() { - $keep_titles = $this->setting['keep_titles']; + $keep_titles = $this->setting['keep_titles']; + $post_meta = (bool) get_post_meta( get_the_ID(), '_displayfeaturedimagegenesis_move', true ); /** * Creates display_featured_image_genesis_do_not_move_titles filter to check * whether get_post_type array should not move titles to overlay the featured image. * @uses is_in_array() */ - if ( ! $keep_titles && ! Display_Featured_Image_Genesis_Common::is_in_array( 'do_not_move_titles' ) ) { + if ( ! $keep_titles && ! Display_Featured_Image_Genesis_Common::is_in_array( 'do_not_move_titles' ) && ! $post_meta ) { return true; } return false; diff --git a/includes/class-displayfeaturedimagegenesis-postmeta.php b/includes/class-displayfeaturedimagegenesis-postmeta.php index 7e9ee5d..8fe3f04 100644 --- a/includes/class-displayfeaturedimagegenesis-postmeta.php +++ b/includes/class-displayfeaturedimagegenesis-postmeta.php @@ -10,34 +10,58 @@ */ class Display_Featured_Image_Genesis_Post_Meta { - /** - * The plugin setting - * @var $setting - */ - protected $setting; - /** * Post meta key to disable buttons * @var string */ protected $disable = '_displayfeaturedimagegenesis_disable'; + /** + * Post meta key to not move titles + * @var string + */ + protected $move = '_displayfeaturedimagegenesis_move'; + /** * Build the metabox with the checkbox setting. */ public function meta_box( $content ) { - $check = get_post_meta( get_the_ID(), $this->disable, true ) ? 1 : ''; - - wp_nonce_field( 'displayfeaturedimagegenesis_post_save', 'displayfeaturedimagegenesis_post_nonce' ); - $output = '

'; - $output .= sprintf( '', $this->disable, checked( $check, 1, false ) ); - $output .= sprintf( '', $this->disable, __( 'Don\'t show the featured image on this post', 'display-featured-image-genesis' ) ); - $output .= '

'; + $checkboxes = array( + array( + 'setting' => $this->disable, + 'label' => __( 'Don\'t show the featured image on this post', 'display-featured-image-genesis' ), + ), + array( + 'setting' => $this->move, + 'label' => __( 'Don\'t move the title to overlay the featured image on this post', 'display-featured-image-genesis' ), + ), + ); + foreach ( $checkboxes as $checkbox ) { + $output .= $this->do_checkbox( $checkbox ); + } return $output . $content; } + wp_nonce_field( 'displayfeaturedimagegenesis_post_save', 'displayfeaturedimagegenesis_post_nonce' ); + /** + * Generic function to add a post_meta checkbox + * @param $args array includes setting and label + * + * @return string checkbox label/input + */ + protected function do_checkbox( $args ) { + $check = get_post_meta( get_the_ID(), $args['setting'], true ) ? 1 : ''; + $output = '

'; + $output .= sprintf( ''; + $output .= '

'; + + return $output; + } + /** * Update the post meta. * @param $post_id @@ -59,10 +83,14 @@ class Display_Featured_Image_Genesis_Post_Meta { return; } - if ( isset( $_POST[ $this->disable ] ) ) { - update_post_meta( $post_id, $this->disable, 1 ); - } else { - delete_post_meta( $post_id, $this->disable ); + $settings = array( $this->disable, $this->move ); + + foreach ( $settings as $setting ) { + if ( isset( $_POST[ $setting ] ) ) { + update_post_meta( $post_id, $setting, 1 ); + } else { + delete_post_meta( $post_id, $setting ); + } } }