Completed
Push — develop ( b6ba36...46f6d5 )
by Naveen
31s queued 12s
created
wordlift/external-plugin-hooks/recipe-maker/class-recipe-maker-warning.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -16,12 +16,12 @@  discard block
 block discarded – undo
16 16
 	 */
17 17
 	private $recipe_maker_validation_service;
18 18
 
19
-	public function __construct( $recipe_maker_validation_service ) {
19
+	public function __construct($recipe_maker_validation_service) {
20 20
 		$this->recipe_maker_validation_service = $recipe_maker_validation_service;
21 21
 		add_action(
22 22
 			'load-post.php',
23
-			function () {
24
-				add_action( 'wordlift_admin_notices', array( $this, 'display_image_size_warning' ) );
23
+			function() {
24
+				add_action('wordlift_admin_notices', array($this, 'display_image_size_warning'));
25 25
 			}
26 26
 		);
27 27
 
@@ -33,33 +33,33 @@  discard block
 block discarded – undo
33 33
 	public function display_image_size_warning() {
34 34
 
35 35
 		// Check if we are on the post.
36
-		if ( ! get_post() instanceof \WP_Post ) {
36
+		if ( ! get_post() instanceof \WP_Post) {
37 37
 			return false;
38 38
 		}
39
-		if ( ! $this->recipe_maker_validation_service->is_wp_recipe_maker_available() ) {
39
+		if ( ! $this->recipe_maker_validation_service->is_wp_recipe_maker_available()) {
40 40
 			return false;
41 41
 		}
42 42
 		$post_id = get_the_ID();
43 43
 
44 44
 		// Dont show notification if there is no recipes referred by the post.
45
-		if ( ! $this->recipe_maker_validation_service->is_atleast_once_recipe_present_in_the_post( $post_id ) ) {
45
+		if ( ! $this->recipe_maker_validation_service->is_atleast_once_recipe_present_in_the_post($post_id)) {
46 46
 			return false;
47 47
 		}
48 48
 
49
-		$warnings = $this->get_warnings( $post_id );
49
+		$warnings = $this->get_warnings($post_id);
50 50
 
51
-		if ( count( $warnings ) > 0 ) {
51
+		if (count($warnings) > 0) {
52 52
 			// Show notification.
53 53
 			?>
54 54
 			<div class="notice notice-warning is-dismissible">
55
-				<h3><?php esc_html_e( 'WordLift', 'wordlift' ); ?></h3>
56
-				<p><?php esc_html_e( 'The following recipes didn\'t have minimum image size of 1200 x 1200 px', 'wordlift' ); ?></p>
55
+				<h3><?php esc_html_e('WordLift', 'wordlift'); ?></h3>
56
+				<p><?php esc_html_e('The following recipes didn\'t have minimum image size of 1200 x 1200 px', 'wordlift'); ?></p>
57 57
 				<ol>
58 58
 					<?php
59
-					foreach ( $warnings as $warning ) {
60
-						$image_link = get_edit_post_link( $warning['image_id'] );
59
+					foreach ($warnings as $warning) {
60
+						$image_link = get_edit_post_link($warning['image_id']);
61 61
 						?>
62
-						<li><?php echo esc_html( get_the_title( $warning['recipe_id'] ) ); ?> <a href="<?php echo esc_attr( $image_link ); ?>"><?php esc_html_e( '[edit image]', 'wordlift' ); ?></a></li>
62
+						<li><?php echo esc_html(get_the_title($warning['recipe_id'])); ?> <a href="<?php echo esc_attr($image_link); ?>"><?php esc_html_e('[edit image]', 'wordlift'); ?></a></li>
63 63
 						<?php
64 64
 					}
65 65
 					?>
@@ -75,32 +75,32 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return array
77 77
 	 */
78
-	private function get_warnings( $post_id ) {
78
+	private function get_warnings($post_id) {
79 79
 
80
-		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post( $post_id );
80
+		$recipe_ids = \WPRM_Recipe_Manager::get_recipe_ids_from_post($post_id);
81 81
 
82 82
 		// Dont show duplicate warnings.
83
-		$recipe_ids = array_unique( $recipe_ids );
83
+		$recipe_ids = array_unique($recipe_ids);
84 84
 
85 85
 		$recipe_with_image_warnings = array();
86 86
 
87
-		foreach ( $recipe_ids as $recipe_id ) {
88
-			$recipe = \WPRM_Recipe_Manager::get_recipe( $recipe_id );
89
-			if ( ! $recipe ) {
87
+		foreach ($recipe_ids as $recipe_id) {
88
+			$recipe = \WPRM_Recipe_Manager::get_recipe($recipe_id);
89
+			if ( ! $recipe) {
90 90
 				continue;
91 91
 			}
92 92
 			$image_id   = $recipe->image_id();
93
-			$image_data = wp_get_attachment_image_src( $image_id, array( 1200, 1200 ) );
94
-			if ( ! is_array( $image_data ) ) {
93
+			$image_data = wp_get_attachment_image_src($image_id, array(1200, 1200));
94
+			if ( ! is_array($image_data)) {
95 95
 				continue;
96 96
 			}
97
-			$image_width  = array_key_exists( 1, $image_data ) ? $image_data [1] : false;
98
-			$image_height = array_key_exists( 2, $image_data ) ? $image_data [2] : false;
99
-			if ( ! ( $image_height && $image_width ) ) {
97
+			$image_width  = array_key_exists(1, $image_data) ? $image_data [1] : false;
98
+			$image_height = array_key_exists(2, $image_data) ? $image_data [2] : false;
99
+			if ( ! ($image_height && $image_width)) {
100 100
 				continue;
101 101
 			}
102 102
 
103
-			if ( $image_height < 1200 || $image_width < 1200 ) {
103
+			if ($image_height < 1200 || $image_width < 1200) {
104 104
 				// Image size not present in 1200 * 1200, show a warning.
105 105
 				$recipe_with_image_warnings[] = array(
106 106
 					'recipe_id' => $recipe_id,
Please login to merge, or discard this patch.