Completed
Push — develop ( 608016...d786f7 )
by David
03:43
created
src/install/class-wordlift-install-3-18-0.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -15,114 +15,114 @@
 block discarded – undo
15 15
  * @subpackage Wordlift/install
16 16
  */
17 17
 class Wordlift_Install_3_18_0 extends Wordlift_Install {
18
-	/**
19
-	 * @inheritdoc
20
-	 */
21
-	protected static $version = '3.18.0';
22
-
23
-	/**
24
-	 * @inheritdoc
25
-	 */
26
-	public function __construct() {
27
-		parent::__construct();
28
-
29
-		add_action( 'wl_async_wl_push_references', array(
30
-			$this,
31
-			'push_references',
32
-		) );
33
-	}
34
-
35
-	/**
36
-	 * @inheritdoc
37
-	 */
38
-	public function install() {
39
-		$this->add_offer_entity_type();
40
-		$this->add_editors_read_wordlift_entity_capability();
41
-		do_action( 'wl_push_references' );
42
-	}
43
-
44
-	/**
45
-	 * Creates references for articles *referencing* entities
46
-	 *
47
-	 * @since 3.18.0
48
-	 *
49
-	 * @return void
50
-	 */
51
-	public function push_references() {
52
-		// Get relations.
53
-		$relations = Wordlift_Relation_Service::get_instance()->find_all_grouped_by_subject_id();
54
-
55
-		$entity_service = Wordlift_Entity_Service::get_instance();
56
-
57
-		// Loop through all relations and push the references.
58
-		foreach ( $relations as $relation ) {
59
-
60
-			$post = get_post( $relation->subject_id );
61
-
62
-			// Bail out if it's an entity: we're only interested in articles
63
-			// *referencing* entities.
64
-			if ( $entity_service->is_entity( $post->ID ) ) {
65
-				continue;
66
-			}
67
-
68
-			// Push the references.
69
-			Wordlift_Linked_Data_Service::get_instance()->push( $post->ID );
70
-		}
71
-
72
-	}
73
-
74
-	/**
75
-	 * Adds the new `Offer` entity type.
76
-	 *
77
-	 * @since 3.18.0
78
-	 *
79
-	 * @return void
80
-	 */
81
-	public function add_offer_entity_type() {
82
-		// Check whether the `offer` term exists.
83
-		$offer = get_term_by(
84
-			'slug',
85
-			'offer',
86
-			Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME
87
-		);
88
-
89
-		// The `offer` term doesn't exists, so create it.
90
-		if ( empty( $offer ) ) {
91
-			wp_insert_term(
92
-				'Offer',
93
-				Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
94
-				array(
95
-					'slug'        => 'offer',
96
-					'description' => 'An Offer.',
97
-				)
98
-			);
99
-		}
100
-	}
101
-
102
-	/**
103
-	 * Add additional `read_wordlift_entity` capability to editors.
104
-	 *
105
-	 * @since 3.18.0
106
-	 *
107
-	 * @return void
108
-	 */
109
-	public function add_editors_read_wordlift_entity_capability() {
110
-		// Get the editor roles.
111
-		$admins = get_role( 'administrator' );
112
-		$admins->add_cap( 'read_wordlift_entity' );
113
-
114
-		/*
18
+    /**
19
+     * @inheritdoc
20
+     */
21
+    protected static $version = '3.18.0';
22
+
23
+    /**
24
+     * @inheritdoc
25
+     */
26
+    public function __construct() {
27
+        parent::__construct();
28
+
29
+        add_action( 'wl_async_wl_push_references', array(
30
+            $this,
31
+            'push_references',
32
+        ) );
33
+    }
34
+
35
+    /**
36
+     * @inheritdoc
37
+     */
38
+    public function install() {
39
+        $this->add_offer_entity_type();
40
+        $this->add_editors_read_wordlift_entity_capability();
41
+        do_action( 'wl_push_references' );
42
+    }
43
+
44
+    /**
45
+     * Creates references for articles *referencing* entities
46
+     *
47
+     * @since 3.18.0
48
+     *
49
+     * @return void
50
+     */
51
+    public function push_references() {
52
+        // Get relations.
53
+        $relations = Wordlift_Relation_Service::get_instance()->find_all_grouped_by_subject_id();
54
+
55
+        $entity_service = Wordlift_Entity_Service::get_instance();
56
+
57
+        // Loop through all relations and push the references.
58
+        foreach ( $relations as $relation ) {
59
+
60
+            $post = get_post( $relation->subject_id );
61
+
62
+            // Bail out if it's an entity: we're only interested in articles
63
+            // *referencing* entities.
64
+            if ( $entity_service->is_entity( $post->ID ) ) {
65
+                continue;
66
+            }
67
+
68
+            // Push the references.
69
+            Wordlift_Linked_Data_Service::get_instance()->push( $post->ID );
70
+        }
71
+
72
+    }
73
+
74
+    /**
75
+     * Adds the new `Offer` entity type.
76
+     *
77
+     * @since 3.18.0
78
+     *
79
+     * @return void
80
+     */
81
+    public function add_offer_entity_type() {
82
+        // Check whether the `offer` term exists.
83
+        $offer = get_term_by(
84
+            'slug',
85
+            'offer',
86
+            Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME
87
+        );
88
+
89
+        // The `offer` term doesn't exists, so create it.
90
+        if ( empty( $offer ) ) {
91
+            wp_insert_term(
92
+                'Offer',
93
+                Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
94
+                array(
95
+                    'slug'        => 'offer',
96
+                    'description' => 'An Offer.',
97
+                )
98
+            );
99
+        }
100
+    }
101
+
102
+    /**
103
+     * Add additional `read_wordlift_entity` capability to editors.
104
+     *
105
+     * @since 3.18.0
106
+     *
107
+     * @return void
108
+     */
109
+    public function add_editors_read_wordlift_entity_capability() {
110
+        // Get the editor roles.
111
+        $admins = get_role( 'administrator' );
112
+        $admins->add_cap( 'read_wordlift_entity' );
113
+
114
+        /*
115 115
 		 * Check that the `editor` role exists before using it.
116 116
 		 *
117 117
 		 * @since 3.19.6
118 118
 		 *
119 119
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/886
120 120
 		 */
121
-		$editors = get_role( 'editor' );
122
-		if ( isset( $editors ) ) {
123
-			$editors->add_cap( 'read_wordlift_entity' );
124
-		}
121
+        $editors = get_role( 'editor' );
122
+        if ( isset( $editors ) ) {
123
+            $editors->add_cap( 'read_wordlift_entity' );
124
+        }
125 125
 
126
-	}
126
+    }
127 127
 
128 128
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		parent::__construct();
28 28
 
29
-		add_action( 'wl_async_wl_push_references', array(
29
+		add_action('wl_async_wl_push_references', array(
30 30
 			$this,
31 31
 			'push_references',
32
-		) );
32
+		));
33 33
 	}
34 34
 
35 35
 	/**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	public function install() {
39 39
 		$this->add_offer_entity_type();
40 40
 		$this->add_editors_read_wordlift_entity_capability();
41
-		do_action( 'wl_push_references' );
41
+		do_action('wl_push_references');
42 42
 	}
43 43
 
44 44
 	/**
@@ -55,18 +55,18 @@  discard block
 block discarded – undo
55 55
 		$entity_service = Wordlift_Entity_Service::get_instance();
56 56
 
57 57
 		// Loop through all relations and push the references.
58
-		foreach ( $relations as $relation ) {
58
+		foreach ($relations as $relation) {
59 59
 
60
-			$post = get_post( $relation->subject_id );
60
+			$post = get_post($relation->subject_id);
61 61
 
62 62
 			// Bail out if it's an entity: we're only interested in articles
63 63
 			// *referencing* entities.
64
-			if ( $entity_service->is_entity( $post->ID ) ) {
64
+			if ($entity_service->is_entity($post->ID)) {
65 65
 				continue;
66 66
 			}
67 67
 
68 68
 			// Push the references.
69
-			Wordlift_Linked_Data_Service::get_instance()->push( $post->ID );
69
+			Wordlift_Linked_Data_Service::get_instance()->push($post->ID);
70 70
 		}
71 71
 
72 72
 	}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		);
88 88
 
89 89
 		// The `offer` term doesn't exists, so create it.
90
-		if ( empty( $offer ) ) {
90
+		if (empty($offer)) {
91 91
 			wp_insert_term(
92 92
 				'Offer',
93 93
 				Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 */
109 109
 	public function add_editors_read_wordlift_entity_capability() {
110 110
 		// Get the editor roles.
111
-		$admins = get_role( 'administrator' );
112
-		$admins->add_cap( 'read_wordlift_entity' );
111
+		$admins = get_role('administrator');
112
+		$admins->add_cap('read_wordlift_entity');
113 113
 
114 114
 		/*
115 115
 		 * Check that the `editor` role exists before using it.
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 		 *
119 119
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/886
120 120
 		 */
121
-		$editors = get_role( 'editor' );
122
-		if ( isset( $editors ) ) {
123
-			$editors->add_cap( 'read_wordlift_entity' );
121
+		$editors = get_role('editor');
122
+		if (isset($editors)) {
123
+			$editors->add_cap('read_wordlift_entity');
124 124
 		}
125 125
 
126 126
 	}
Please login to merge, or discard this patch.
src/install/class-wordlift-install-3-14-0.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -15,67 +15,67 @@
 block discarded – undo
15 15
  * @subpackage Wordlift/install
16 16
  */
17 17
 class Wordlift_Install_3_14_0 extends Wordlift_Install {
18
-	/**
19
-	 * @inheritdoc
20
-	 */
21
-	protected static $version = '3.14.0';
18
+    /**
19
+     * @inheritdoc
20
+     */
21
+    protected static $version = '3.14.0';
22 22
 
23
-	/**
24
-	 * @inheritdoc
25
-	 */
26
-	public function install() {
27
-		// Check whether the `recipe` term exists.
28
-		$recipe = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
23
+    /**
24
+     * @inheritdoc
25
+     */
26
+    public function install() {
27
+        // Check whether the `recipe` term exists.
28
+        $recipe = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
29 29
 
30
-		// The recipe term doesn't exists, so create it.
31
-		if ( empty( $recipe ) ) {
32
-			$result = wp_insert_term(
33
-				'Recipe',
34
-				Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
35
-				array(
36
-					'slug'        => 'recipe',
37
-					'description' => 'A Recipe.',
38
-				)
39
-			);
40
-		}
30
+        // The recipe term doesn't exists, so create it.
31
+        if ( empty( $recipe ) ) {
32
+            $result = wp_insert_term(
33
+                'Recipe',
34
+                Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
35
+                array(
36
+                    'slug'        => 'recipe',
37
+                    'description' => 'A Recipe.',
38
+                )
39
+            );
40
+        }
41 41
 
42
-		// Assign capabilities to manipulate entities to admins.
43
-		$admins = get_role( 'administrator' );
42
+        // Assign capabilities to manipulate entities to admins.
43
+        $admins = get_role( 'administrator' );
44 44
 
45
-		$admins->add_cap( 'edit_wordlift_entity' );
46
-		$admins->add_cap( 'edit_wordlift_entities' );
47
-		$admins->add_cap( 'edit_others_wordlift_entities' );
48
-		$admins->add_cap( 'publish_wordlift_entities' );
49
-		$admins->add_cap( 'read_private_wordlift_entities' );
50
-		$admins->add_cap( 'delete_wordlift_entity' );
51
-		$admins->add_cap( 'delete_wordlift_entities' );
52
-		$admins->add_cap( 'delete_others_wordlift_entities' );
53
-		$admins->add_cap( 'delete_published_wordlift_entities' );
54
-		$admins->add_cap( 'delete_private_wordlift_entities' );
45
+        $admins->add_cap( 'edit_wordlift_entity' );
46
+        $admins->add_cap( 'edit_wordlift_entities' );
47
+        $admins->add_cap( 'edit_others_wordlift_entities' );
48
+        $admins->add_cap( 'publish_wordlift_entities' );
49
+        $admins->add_cap( 'read_private_wordlift_entities' );
50
+        $admins->add_cap( 'delete_wordlift_entity' );
51
+        $admins->add_cap( 'delete_wordlift_entities' );
52
+        $admins->add_cap( 'delete_others_wordlift_entities' );
53
+        $admins->add_cap( 'delete_published_wordlift_entities' );
54
+        $admins->add_cap( 'delete_private_wordlift_entities' );
55 55
 
56
-		// Assign capabilities to manipulate entities to editors.
57
-		/*
56
+        // Assign capabilities to manipulate entities to editors.
57
+        /*
58 58
 		 * Check that the `editor` role exists before using it.
59 59
 		 *
60 60
 		 * @since 3.19.6
61 61
 		 *
62 62
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/886
63 63
 		 */
64
-		$editors = get_role( 'editor' );
64
+        $editors = get_role( 'editor' );
65 65
 
66
-		if ( isset( $editors ) ) {
67
-			$editors->add_cap( 'edit_wordlift_entity' );
68
-			$editors->add_cap( 'edit_wordlift_entities' );
69
-			$editors->add_cap( 'edit_others_wordlift_entities' );
70
-			$editors->add_cap( 'publish_wordlift_entities' );
71
-			$editors->add_cap( 'read_private_wordlift_entities' );
72
-			$editors->add_cap( 'delete_wordlift_entity' );
73
-			$editors->add_cap( 'delete_wordlift_entities' );
74
-			$editors->add_cap( 'delete_others_wordlift_entities' );
75
-			$editors->add_cap( 'delete_published_wordlift_entities' );
76
-			$editors->add_cap( 'delete_private_wordlift_entities' );
77
-		}
66
+        if ( isset( $editors ) ) {
67
+            $editors->add_cap( 'edit_wordlift_entity' );
68
+            $editors->add_cap( 'edit_wordlift_entities' );
69
+            $editors->add_cap( 'edit_others_wordlift_entities' );
70
+            $editors->add_cap( 'publish_wordlift_entities' );
71
+            $editors->add_cap( 'read_private_wordlift_entities' );
72
+            $editors->add_cap( 'delete_wordlift_entity' );
73
+            $editors->add_cap( 'delete_wordlift_entities' );
74
+            $editors->add_cap( 'delete_others_wordlift_entities' );
75
+            $editors->add_cap( 'delete_published_wordlift_entities' );
76
+            $editors->add_cap( 'delete_private_wordlift_entities' );
77
+        }
78 78
 
79
-	}
79
+    }
80 80
 
81 81
 }
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -25,10 +25,10 @@  discard block
 block discarded – undo
25 25
 	 */
26 26
 	public function install() {
27 27
 		// Check whether the `recipe` term exists.
28
-		$recipe = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
28
+		$recipe = get_term_by('slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
29 29
 
30 30
 		// The recipe term doesn't exists, so create it.
31
-		if ( empty( $recipe ) ) {
31
+		if (empty($recipe)) {
32 32
 			$result = wp_insert_term(
33 33
 				'Recipe',
34 34
 				Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME,
@@ -40,18 +40,18 @@  discard block
 block discarded – undo
40 40
 		}
41 41
 
42 42
 		// Assign capabilities to manipulate entities to admins.
43
-		$admins = get_role( 'administrator' );
43
+		$admins = get_role('administrator');
44 44
 
45
-		$admins->add_cap( 'edit_wordlift_entity' );
46
-		$admins->add_cap( 'edit_wordlift_entities' );
47
-		$admins->add_cap( 'edit_others_wordlift_entities' );
48
-		$admins->add_cap( 'publish_wordlift_entities' );
49
-		$admins->add_cap( 'read_private_wordlift_entities' );
50
-		$admins->add_cap( 'delete_wordlift_entity' );
51
-		$admins->add_cap( 'delete_wordlift_entities' );
52
-		$admins->add_cap( 'delete_others_wordlift_entities' );
53
-		$admins->add_cap( 'delete_published_wordlift_entities' );
54
-		$admins->add_cap( 'delete_private_wordlift_entities' );
45
+		$admins->add_cap('edit_wordlift_entity');
46
+		$admins->add_cap('edit_wordlift_entities');
47
+		$admins->add_cap('edit_others_wordlift_entities');
48
+		$admins->add_cap('publish_wordlift_entities');
49
+		$admins->add_cap('read_private_wordlift_entities');
50
+		$admins->add_cap('delete_wordlift_entity');
51
+		$admins->add_cap('delete_wordlift_entities');
52
+		$admins->add_cap('delete_others_wordlift_entities');
53
+		$admins->add_cap('delete_published_wordlift_entities');
54
+		$admins->add_cap('delete_private_wordlift_entities');
55 55
 
56 56
 		// Assign capabilities to manipulate entities to editors.
57 57
 		/*
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
 		 *
62 62
 		 * @see https://github.com/insideout10/wordlift-plugin/issues/886
63 63
 		 */
64
-		$editors = get_role( 'editor' );
64
+		$editors = get_role('editor');
65 65
 
66
-		if ( isset( $editors ) ) {
67
-			$editors->add_cap( 'edit_wordlift_entity' );
68
-			$editors->add_cap( 'edit_wordlift_entities' );
69
-			$editors->add_cap( 'edit_others_wordlift_entities' );
70
-			$editors->add_cap( 'publish_wordlift_entities' );
71
-			$editors->add_cap( 'read_private_wordlift_entities' );
72
-			$editors->add_cap( 'delete_wordlift_entity' );
73
-			$editors->add_cap( 'delete_wordlift_entities' );
74
-			$editors->add_cap( 'delete_others_wordlift_entities' );
75
-			$editors->add_cap( 'delete_published_wordlift_entities' );
76
-			$editors->add_cap( 'delete_private_wordlift_entities' );
66
+		if (isset($editors)) {
67
+			$editors->add_cap('edit_wordlift_entity');
68
+			$editors->add_cap('edit_wordlift_entities');
69
+			$editors->add_cap('edit_others_wordlift_entities');
70
+			$editors->add_cap('publish_wordlift_entities');
71
+			$editors->add_cap('read_private_wordlift_entities');
72
+			$editors->add_cap('delete_wordlift_entity');
73
+			$editors->add_cap('delete_wordlift_entities');
74
+			$editors->add_cap('delete_others_wordlift_entities');
75
+			$editors->add_cap('delete_published_wordlift_entities');
76
+			$editors->add_cap('delete_private_wordlift_entities');
77 77
 		}
78 78
 
79 79
 	}
Please login to merge, or discard this patch.