Completed
Push — master ( 32c778...a56e44 )
by
unknown
13:55
created
includes/modules/wps-eav-revisions/wps-eav-revisions.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@  discard block
 block discarded – undo
2 2
 class WPS_EAV_Revisions {
3 3
 	public static $created_revisions = array();
4 4
 	public function __construct() {
5
-		add_action( 'save_post', array( $this, 'save_post' ), 100, 2 );
6
-		add_action( 'wp_restore_post_revision', array( $this, 'wp_restore_post_revision' ), 10, 2 );
7
-		add_filter( '_wp_post_revision_fields', array( $this, 'wp_post_revision_fields' ), 10, 2 );
5
+		add_action('save_post', array($this, 'save_post'), 100, 2);
6
+		add_action('wp_restore_post_revision', array($this, 'wp_restore_post_revision'), 10, 2);
7
+		add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields'), 10, 2);
8 8
 	}
9
-	public function save_post( $post_id, $post ) {
10
-		if ( false === wp_is_post_revision( $post_id ) ) {
11
-			if ( ( ! isset( self::$created_revisions[ $post_id ] ) || true !== self::$created_revisions[ $post_id ] ) && post_type_supports( $post->post_type, 'revisions' ) ) {
12
-				self::$created_revisions[ wp_is_post_revision( $post_id ) ] = true;
13
-				add_filter( 'wp_save_post_revision_post_has_changed', array( $this, 'wp_save_post_revision_post_has_changed' ), 10, 3 );
14
-				wp_save_post_revision( $post_id );
9
+	public function save_post($post_id, $post) {
10
+		if (false === wp_is_post_revision($post_id)) {
11
+			if ((!isset(self::$created_revisions[$post_id]) || true !== self::$created_revisions[$post_id]) && post_type_supports($post->post_type, 'revisions')) {
12
+				self::$created_revisions[wp_is_post_revision($post_id)] = true;
13
+				add_filter('wp_save_post_revision_post_has_changed', array($this, 'wp_save_post_revision_post_has_changed'), 10, 3);
14
+				wp_save_post_revision($post_id);
15 15
 			}
16 16
 		} else {
17
-			self::$created_revisions[ wp_is_post_revision( $post_id ) ] = true;
17
+			self::$created_revisions[wp_is_post_revision($post_id)] = true;
18 18
 		}
19 19
 	}
20
-	public function wp_save_post_revision_post_has_changed( $post_has_changed, $last_revision, $post ) {
20
+	public function wp_save_post_revision_post_has_changed($post_has_changed, $last_revision, $post) {
21 21
 		return true;
22 22
 	}
23
-	public function wp_restore_post_revision( $post_id, $revision_id ) {
23
+	public function wp_restore_post_revision($post_id, $revision_id) {
24 24
 		/*
25 25
 		$post     = get_post( $post_id );
26 26
 		$revision = get_post( $revision_id );
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 			update_post_meta( $post_id, 'foo', $meta );
32 32
 		}*/
33 33
 	}
34
-	public function wp_post_revision_fields( $fields, $post ) {
34
+	public function wp_post_revision_fields($fields, $post) {
35 35
 		global $wpdb;
36 36
 		$wpsdb_attribute = WPSHOP_DBT_ATTRIBUTE;
37 37
 		$wpsdb_attribute_set = WPSHOP_DBT_ATTRIBUTE_DETAILS;
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		$wpsdb_values_varchar = WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR;
43 43
 		$wpsdb_values_text = WPSHOP_DBT_ATTRIBUTE_VALUES_TEXT;
44 44
 		$wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;
45
-		$datas = $wpdb->get_results( $wpdb->prepare(
45
+		$datas = $wpdb->get_results($wpdb->prepare(
46 46
 			"SELECT attr.id,
47 47
 			attr.code,
48 48
 			attr.frontend_label,
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 			WHERE p.ID = %d
72 72
 			GROUP BY attr.code",
73 73
 			$post['ID']
74
-		), ARRAY_A );
75
-		foreach ( $datas as $data ) {
76
-			$fields[ $data['id'] ] = $data['frontend_label'];
77
-			add_filter( "_wp_post_revision_field_{$data['id']}", array( $this, 'wp_post_revision_field' ), 10, 4 );
74
+		), ARRAY_A);
75
+		foreach ($datas as $data) {
76
+			$fields[$data['id']] = $data['frontend_label'];
77
+			add_filter("_wp_post_revision_field_{$data['id']}", array($this, 'wp_post_revision_field'), 10, 4);
78 78
 		}
79 79
 		return $fields;
80 80
 	}
81
-	public function wp_post_revision_field( $value, $field, $revision, $fromto ) {
81
+	public function wp_post_revision_field($value, $field, $revision, $fromto) {
82 82
 		global $wpdb;
83 83
 		$wpsdb_histo = WPSHOP_DBT_ATTRIBUTE_VALUES_HISTO;
84 84
 		$wpsdb_values_options = WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS;
85 85
 		$result = '0';
86 86
 		$fromto_compare = '';
87
-		if ( ! empty( $fromto ) ) {
88
-			$result = $wpdb->get_var( $wpdb->prepare(
87
+		if (!empty($fromto)) {
88
+			$result = $wpdb->get_var($wpdb->prepare(
89 89
 				"SELECT IFNULL( val_opt.label,
90 90
 					histo.value
91 91
 				),
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 				$revision->post_date,
111 111
 				$field,
112 112
 				$revision->post_parent
113
-			) );
113
+			));
114 114
 		}
115
-		$result = ( '0' === $result ) ? null : $result;
115
+		$result = ('0' === $result) ? null : $result;
116 116
 		return $result;
117 117
 	}
118 118
 }
Please login to merge, or discard this patch.