Completed
Push — develop ( f5cfcc...e2baaf )
by Naveen
01:17
created
src/admin/wordlift_admin_menu.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,24 +15,24 @@  discard block
 block discarded – undo
15 15
  */
16 16
 function wl_admin_menu() {
17 17
 
18
-	$menu_slug  = 'wl_admin_menu';
19
-	$capability = 'manage_options';
18
+    $menu_slug  = 'wl_admin_menu';
19
+    $capability = 'manage_options';
20 20
 
21
-	// see http://codex.wordpress.org/Function_Reference/add_menu_page
22
-	add_menu_page(
23
-		__( 'WordLift', 'wordlift' ), // page title
24
-		__( 'WordLift', 'wordlift' ), // menu title
25
-		$capability,                 // capabilities
26
-		$menu_slug,                  // menu slug
27
-		//'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28
-		'wl_configuration_admin_menu_callback',
29
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px
21
+    // see http://codex.wordpress.org/Function_Reference/add_menu_page
22
+    add_menu_page(
23
+        __( 'WordLift', 'wordlift' ), // page title
24
+        __( 'WordLift', 'wordlift' ), // menu title
25
+        $capability,                 // capabilities
26
+        $menu_slug,                  // menu slug
27
+        //'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28
+        'wl_configuration_admin_menu_callback',
29
+        WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px
30 30
 
31
-	// Call hooked functions.
32
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
31
+    // Call hooked functions.
32
+    do_action( 'wl_admin_menu', $menu_slug, $capability );
33 33
 
34
-	// Remove duplicate 'WordLift' subpage created by WordPress.
35
-	remove_submenu_page( $menu_slug, $menu_slug );
34
+    // Remove duplicate 'WordLift' subpage created by WordPress.
35
+    remove_submenu_page( $menu_slug, $menu_slug );
36 36
 
37 37
 }
38 38
 
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
  * @since 3.15.0
47 47
  */
48 48
 function wl_remove_entity_type_menu() {
49
-	/*
49
+    /*
50 50
 	 * Remove from the menu links to the entity type admin page when
51 51
 	 * under non entity hierarchy.
52 52
 	 */
53
-	foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
54
-		// In the context of admin menues post has no explicit indication of post type in the urls.
55
-		if ( 'post' !== $post_type ) {
56
-			remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
57
-		}
53
+    foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
54
+        // In the context of admin menues post has no explicit indication of post type in the urls.
55
+        if ( 'post' !== $post_type ) {
56
+            remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
57
+        }
58 58
 
59
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
60
-			remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&post_type=' . $post_type );
61
-		}
62
-	}
59
+        if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
60
+            remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&post_type=' . $post_type );
61
+        }
62
+    }
63 63
 }
64 64
 
65 65
 add_action( 'admin_menu', 'wl_remove_entity_type_menu', 100 );
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function wl_admin_menu_callback() {
73 73
 
74
-	if ( ! current_user_can( 'manage_options' ) ) {
75
-		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
76
-	}
74
+    if ( ! current_user_can( 'manage_options' ) ) {
75
+        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
76
+    }
77 77
 
78
-	echo '<div class="wrap">';
79
-	echo '<p>Here is where the form would go if I actually had options.</p>';
80
-	echo '</div>';
78
+    echo '<div class="wrap">';
79
+    echo '<p>Here is where the form would go if I actually had options.</p>';
80
+    echo '</div>';
81 81
 
82 82
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,23 +20,23 @@  discard block
 block discarded – undo
20 20
 
21 21
 	// see http://codex.wordpress.org/Function_Reference/add_menu_page
22 22
 	add_menu_page(
23
-		__( 'WordLift', 'wordlift' ), // page title
24
-		__( 'WordLift', 'wordlift' ), // menu title
25
-		$capability,                 // capabilities
26
-		$menu_slug,                  // menu slug
23
+		__('WordLift', 'wordlift'), // page title
24
+		__('WordLift', 'wordlift'), // menu title
25
+		$capability, // capabilities
26
+		$menu_slug, // menu slug
27 27
 		//'wl_admin_menu_callback',  // TODO: function callback to draw the coming dashboard
28 28
 		'wl_configuration_admin_menu_callback',
29
-		WP_CONTENT_URL . '/plugins/wordlift/images/svg/wl-logo-icon.svg' );  // icon URL 20x20 px
29
+		WP_CONTENT_URL.'/plugins/wordlift/images/svg/wl-logo-icon.svg' ); // icon URL 20x20 px
30 30
 
31 31
 	// Call hooked functions.
32
-	do_action( 'wl_admin_menu', $menu_slug, $capability );
32
+	do_action('wl_admin_menu', $menu_slug, $capability);
33 33
 
34 34
 	// Remove duplicate 'WordLift' subpage created by WordPress.
35
-	remove_submenu_page( $menu_slug, $menu_slug );
35
+	remove_submenu_page($menu_slug, $menu_slug);
36 36
 
37 37
 }
38 38
 
39
-add_action( 'admin_menu', 'wl_admin_menu' );
39
+add_action('admin_menu', 'wl_admin_menu');
40 40
 
41 41
 /**
42 42
  * This function is called by the *admin_menu* hook to remove for the admin menu
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
 	 * Remove from the menu links to the entity type admin page when
51 51
 	 * under non entity hierarchy.
52 52
 	 */
53
-	foreach ( Wordlift_Entity_Service::valid_entity_post_types() as $post_type ) {
53
+	foreach (Wordlift_Entity_Service::valid_entity_post_types() as $post_type) {
54 54
 		// In the context of admin menues post has no explicit indication of post type in the urls.
55
-		if ( 'post' !== $post_type ) {
56
-			remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME );
55
+		if ('post' !== $post_type) {
56
+			remove_submenu_page('edit.php', 'edit-tags.php?taxonomy='.Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME);
57 57
 		}
58 58
 
59
-		if ( Wordlift_Entity_Service::TYPE_NAME !== $post_type ) {
60
-			remove_submenu_page( 'edit.php?post_type=' . $post_type, 'edit-tags.php?taxonomy=' . Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . '&amp;post_type=' . $post_type );
59
+		if (Wordlift_Entity_Service::TYPE_NAME !== $post_type) {
60
+			remove_submenu_page('edit.php?post_type='.$post_type, 'edit-tags.php?taxonomy='.Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'&amp;post_type='.$post_type);
61 61
 		}
62 62
 	}
63 63
 }
64 64
 
65
-add_action( 'admin_menu', 'wl_remove_entity_type_menu', 100 );
65
+add_action('admin_menu', 'wl_remove_entity_type_menu', 100);
66 66
 
67 67
 /**
68 68
  * This function is called as a callback by the *wl_admin_menu* to display the actual page.
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function wl_admin_menu_callback() {
73 73
 
74
-	if ( ! current_user_can( 'manage_options' ) ) {
75
-		wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
74
+	if ( ! current_user_can('manage_options')) {
75
+		wp_die(__('You do not have sufficient permissions to access this page.'));
76 76
 	}
77 77
 
78 78
 	echo '<div class="wrap">';
Please login to merge, or discard this patch.
src/admin/class-wordlift-entity-type-admin-service.php 2 patches
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -20,76 +20,76 @@
 block discarded – undo
20 20
  */
21 21
 class Wordlift_Entity_Type_Admin_Service {
22 22
 
23
-	/**
24
-	 * Create a {@link Wordlift_Entity_List_Service} instance.
25
-	 *
26
-	 * Set up the relevant filters and actions.
27
-	 *
28
-	 * @since 3.15.0
29
-	 */
30
-	public function __construct() {
23
+    /**
24
+     * Create a {@link Wordlift_Entity_List_Service} instance.
25
+     *
26
+     * Set up the relevant filters and actions.
27
+     *
28
+     * @since 3.15.0
29
+     */
30
+    public function __construct() {
31 31
 
32
-		add_action( 'admin_init', array( $this, 'hide_entity_type_metabox', ) );
33
-		add_action( 'admin_init', array(
34
-			$this,
35
-			'set_filters_to_hide_entity_type_from_lists',
36
-		) );
37
-	}
32
+        add_action( 'admin_init', array( $this, 'hide_entity_type_metabox', ) );
33
+        add_action( 'admin_init', array(
34
+            $this,
35
+            'set_filters_to_hide_entity_type_from_lists',
36
+        ) );
37
+    }
38 38
 
39
-	/**
40
-	 * Hide the entity type metabox from non entity edit screens if user is not
41
-	 * allowed to configure entity types.
42
-	 *
43
-	 * @since 3.15.0
44
-	 */
45
-	public function hide_entity_type_metabox() {
39
+    /**
40
+     * Hide the entity type metabox from non entity edit screens if user is not
41
+     * allowed to configure entity types.
42
+     *
43
+     * @since 3.15.0
44
+     */
45
+    public function hide_entity_type_metabox() {
46 46
 
47
-		// Bail out if the user can edit entities.
48
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
49
-			return;
50
-		}
47
+        // Bail out if the user can edit entities.
48
+        if ( current_user_can( 'edit_wordlift_entity' ) ) {
49
+            return;
50
+        }
51 51
 
52
-		// Loop over all the non entity post types which support entities and turn off the metabox.
53
-		foreach ( $this->get_types_no_entity() as $type ) {
54
-			remove_meta_box( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . 'div', $type, 'side' );
55
-		}
52
+        // Loop over all the non entity post types which support entities and turn off the metabox.
53
+        foreach ( $this->get_types_no_entity() as $type ) {
54
+            remove_meta_box( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . 'div', $type, 'side' );
55
+        }
56 56
 
57
-	}
57
+    }
58 58
 
59
-	/**
60
-	 * Hide the entity type metabox from non entity list screens if user is not
61
-	 * allowed to configure entity types.
62
-	 *
63
-	 * @since 3.15.0
64
-	 */
65
-	function set_filters_to_hide_entity_type_from_lists() {
59
+    /**
60
+     * Hide the entity type metabox from non entity list screens if user is not
61
+     * allowed to configure entity types.
62
+     *
63
+     * @since 3.15.0
64
+     */
65
+    function set_filters_to_hide_entity_type_from_lists() {
66 66
 
67
-		// Bail out if the user can edit entities.
68
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
69
-			return;
70
-		}
67
+        // Bail out if the user can edit entities.
68
+        if ( current_user_can( 'edit_wordlift_entity' ) ) {
69
+            return;
70
+        }
71 71
 
72
-		// Loop over all the non entity post types which support entities and turn off the taxonomy column.
73
-		foreach ( $this->get_types_no_entity() as $type ) {
74
-			add_filter( 'manage_taxonomies_for_' . $type . '_columns', function ( $taxonomies ) {
75
-				unset( $taxonomies[ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] );
72
+        // Loop over all the non entity post types which support entities and turn off the taxonomy column.
73
+        foreach ( $this->get_types_no_entity() as $type ) {
74
+            add_filter( 'manage_taxonomies_for_' . $type . '_columns', function ( $taxonomies ) {
75
+                unset( $taxonomies[ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] );
76 76
 
77
-				return $taxonomies;
78
-			} );
79
-		}
77
+                return $taxonomies;
78
+            } );
79
+        }
80 80
 
81
-	}
81
+    }
82 82
 
83
-	/**
84
-	 * Get the types which are not the entity post type.
85
-	 *
86
-	 * @since 3.15.0
87
-	 *
88
-	 * @return array An array of types' names.
89
-	 */
90
-	private function get_types_no_entity() {
83
+    /**
84
+     * Get the types which are not the entity post type.
85
+     *
86
+     * @since 3.15.0
87
+     *
88
+     * @return array An array of types' names.
89
+     */
90
+    private function get_types_no_entity() {
91 91
 
92
-		return array_diff( Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME );
93
-	}
92
+        return array_diff( Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME );
93
+    }
94 94
 
95 95
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,11 +29,11 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct() {
31 31
 
32
-		add_action( 'admin_init', array( $this, 'hide_entity_type_metabox', ) );
33
-		add_action( 'admin_init', array(
32
+		add_action('admin_init', array($this, 'hide_entity_type_metabox',));
33
+		add_action('admin_init', array(
34 34
 			$this,
35 35
 			'set_filters_to_hide_entity_type_from_lists',
36
-		) );
36
+		));
37 37
 	}
38 38
 
39 39
 	/**
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	public function hide_entity_type_metabox() {
46 46
 
47 47
 		// Bail out if the user can edit entities.
48
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
48
+		if (current_user_can('edit_wordlift_entity')) {
49 49
 			return;
50 50
 		}
51 51
 
52 52
 		// Loop over all the non entity post types which support entities and turn off the metabox.
53
-		foreach ( $this->get_types_no_entity() as $type ) {
54
-			remove_meta_box( Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME . 'div', $type, 'side' );
53
+		foreach ($this->get_types_no_entity() as $type) {
54
+			remove_meta_box(Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME.'div', $type, 'side');
55 55
 		}
56 56
 
57 57
 	}
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	function set_filters_to_hide_entity_type_from_lists() {
66 66
 
67 67
 		// Bail out if the user can edit entities.
68
-		if ( current_user_can( 'edit_wordlift_entity' ) ) {
68
+		if (current_user_can('edit_wordlift_entity')) {
69 69
 			return;
70 70
 		}
71 71
 
72 72
 		// Loop over all the non entity post types which support entities and turn off the taxonomy column.
73
-		foreach ( $this->get_types_no_entity() as $type ) {
74
-			add_filter( 'manage_taxonomies_for_' . $type . '_columns', function ( $taxonomies ) {
75
-				unset( $taxonomies[ Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ] );
73
+		foreach ($this->get_types_no_entity() as $type) {
74
+			add_filter('manage_taxonomies_for_'.$type.'_columns', function($taxonomies) {
75
+				unset($taxonomies[Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME]);
76 76
 
77 77
 				return $taxonomies;
78 78
 			} );
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 */
90 90
 	private function get_types_no_entity() {
91 91
 
92
-		return array_diff( Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME );
92
+		return array_diff(Wordlift_Entity_Service::valid_entity_post_types(), (array) Wordlift_Entity_Service::TYPE_NAME);
93 93
 	}
94 94
 
95 95
 }
Please login to merge, or discard this patch.
src/includes/rebuild/class-wordlift-relation-rebuild-service.php 2 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -2,133 +2,133 @@
 block discarded – undo
2 2
 
3 3
 class Wordlift_Relation_Rebuild_Service extends Wordlift_Listable {
4 4
 
5
-	/**
6
-	 * @var Wordlift_Content_Filter_Service
7
-	 */
8
-	private $content_filter_service;
5
+    /**
6
+     * @var Wordlift_Content_Filter_Service
7
+     */
8
+    private $content_filter_service;
9 9
 
10
-	/**
11
-	 * @var Wordlift_Entity_Service
12
-	 */
13
-	private $entity_service;
10
+    /**
11
+     * @var Wordlift_Entity_Service
12
+     */
13
+    private $entity_service;
14 14
 
15
-	/**
16
-	 * A {@link Wordlift_Log_Service} instance.
17
-	 *
18
-	 * @since  3.14.3
19
-	 * @access private
20
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
21
-	 */
22
-	private $log;
15
+    /**
16
+     * A {@link Wordlift_Log_Service} instance.
17
+     *
18
+     * @since  3.14.3
19
+     * @access private
20
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
21
+     */
22
+    private $log;
23 23
 
24 24
 
25
-	/**
26
-	 * Wordlift_Relation_Rebuild_Service constructor.
27
-	 *
28
-	 * @param \Wordlift_Content_Filter_Service $content_filter_service
29
-	 * @param \Wordlift_Entity_Service         $entity_service
30
-	 */
31
-	public function __construct( $content_filter_service, $entity_service ) {
25
+    /**
26
+     * Wordlift_Relation_Rebuild_Service constructor.
27
+     *
28
+     * @param \Wordlift_Content_Filter_Service $content_filter_service
29
+     * @param \Wordlift_Entity_Service         $entity_service
30
+     */
31
+    public function __construct( $content_filter_service, $entity_service ) {
32 32
 
33
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Relation_Rebuild_Service' );
33
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Relation_Rebuild_Service' );
34 34
 
35
-		$this->content_filter_service = $content_filter_service;
36
-		$this->entity_service         = $entity_service;
35
+        $this->content_filter_service = $content_filter_service;
36
+        $this->entity_service         = $entity_service;
37 37
 
38
-	}
38
+    }
39 39
 
40
-	public function process_all() {
41
-		global $wpdb;
40
+    public function process_all() {
41
+        global $wpdb;
42 42
 
43
-		set_time_limit( 21600 ); // 6 hours
43
+        set_time_limit( 21600 ); // 6 hours
44 44
 
45
-		$this->log->debug( 'Deleting all existing relations...' );
45
+        $this->log->debug( 'Deleting all existing relations...' );
46 46
 
47
-		// Delete existing data.
48
-		$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wl_relation_instances" );
47
+        // Delete existing data.
48
+        $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wl_relation_instances" );
49 49
 
50
-		$this->log->debug( 'Processing contents...' );
50
+        $this->log->debug( 'Processing contents...' );
51 51
 
52
-		$this->process( array( $this, 'process_single' ) );
52
+        $this->process( array( $this, 'process_single' ) );
53 53
 
54
-	}
54
+    }
55 55
 
56
-	public function process_single( $post_id ) {
56
+    public function process_single( $post_id ) {
57 57
 
58
-		$this->log->debug( "Processing post $post_id..." );
58
+        $this->log->debug( "Processing post $post_id..." );
59 59
 
60
-		// Bail out if the post is not found.
61
-		$post = get_post( $post_id );
60
+        // Bail out if the post is not found.
61
+        $post = get_post( $post_id );
62 62
 
63
-		if ( null === $post ) {
64
-			$this->log->error( "Post $post_id not found." );
63
+        if ( null === $post ) {
64
+            $this->log->error( "Post $post_id not found." );
65 65
 
66
-			return;
67
-		}
66
+            return;
67
+        }
68 68
 
69
-		// Get the URIs from the post content.
70
-		$uris = $this->content_filter_service->get_entity_uris( $post->post_content );
69
+        // Get the URIs from the post content.
70
+        $uris = $this->content_filter_service->get_entity_uris( $post->post_content );
71 71
 
72
-		// Map the URIs to post IDs.
73
-		$ids = $this->uri_to_post_id( $uris );
72
+        // Map the URIs to post IDs.
73
+        $ids = $this->uri_to_post_id( $uris );
74 74
 
75
-		$this->log->info( 'Found ' . count( $uris ) . ' annotation(s) and ' . count( $ids ) . ' unique relation(s).' );
75
+        $this->log->info( 'Found ' . count( $uris ) . ' annotation(s) and ' . count( $ids ) . ' unique relation(s).' );
76 76
 
77
-		// Create the relations.
78
-		$this->create_relations( $post_id, $ids );
77
+        // Create the relations.
78
+        $this->create_relations( $post_id, $ids );
79 79
 
80
-	}
80
+    }
81 81
 
82
-	private function create_relations( $subject_id, $object_ids ) {
82
+    private function create_relations( $subject_id, $object_ids ) {
83 83
 
84
-		$this->log->info( "Creating relations for post $subject_id..." );
84
+        $this->log->info( "Creating relations for post $subject_id..." );
85 85
 
86
-		$entity_service = $this->entity_service;
86
+        $entity_service = $this->entity_service;
87 87
 
88
-		array_walk( $object_ids, function ( $item ) use ( $subject_id, $entity_service ) {
89
-			wl_core_add_relation_instance(
90
-				$subject_id,
91
-				$entity_service->get_classification_scope_for( $item ),
92
-				$item
93
-			);
94
-		} );
88
+        array_walk( $object_ids, function ( $item ) use ( $subject_id, $entity_service ) {
89
+            wl_core_add_relation_instance(
90
+                $subject_id,
91
+                $entity_service->get_classification_scope_for( $item ),
92
+                $item
93
+            );
94
+        } );
95 95
 
96
-	}
96
+    }
97 97
 
98
-	private function uri_to_post_id( $uris ) {
98
+    private function uri_to_post_id( $uris ) {
99 99
 
100
-		$entity_service = $this->entity_service;
100
+        $entity_service = $this->entity_service;
101 101
 
102
-		$ids = array_unique( array_map( function ( $item ) use ( $entity_service ) {
103
-			$post = $entity_service->get_entity_post_by_uri( $item );
102
+        $ids = array_unique( array_map( function ( $item ) use ( $entity_service ) {
103
+            $post = $entity_service->get_entity_post_by_uri( $item );
104 104
 
105
-			return null === $post ? null : $post->ID;
106
-		}, (array) $uris ) );
105
+            return null === $post ? null : $post->ID;
106
+        }, (array) $uris ) );
107 107
 
108
-		return array_filter( $ids, function ( $item ) {
109
-			return null !== $item;
110
-		} );
111
-	}
108
+        return array_filter( $ids, function ( $item ) {
109
+            return null !== $item;
110
+        } );
111
+    }
112 112
 
113
-	/**
114
-	 * @inheritdoc
115
-	 */
116
-	function find( $offset = 0, $limit = 10, $args = array() ) {
117
-		global $wpdb;
113
+    /**
114
+     * @inheritdoc
115
+     */
116
+    function find( $offset = 0, $limit = 10, $args = array() ) {
117
+        global $wpdb;
118 118
 
119
-		return $wpdb->get_col( $wpdb->prepare(
120
-			"
119
+        return $wpdb->get_col( $wpdb->prepare(
120
+            "
121 121
 			SELECT id
122 122
 			FROM $wpdb->posts
123 123
 			WHERE post_type NOT IN ( 'attachment', 'revision' )
124 124
 				AND post_content REGEXP %s
125 125
 			LIMIT %d OFFSET %d
126 126
 			",
127
-			'<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">',
128
-			$limit,
129
-			$offset
130
-		) );
127
+            '<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">',
128
+            $limit,
129
+            $offset
130
+        ) );
131 131
 
132
-	}
132
+    }
133 133
 
134 134
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 	 * @param \Wordlift_Content_Filter_Service $content_filter_service
28 28
 	 * @param \Wordlift_Entity_Service         $entity_service
29 29
 	 */
30
-	public function __construct( $content_filter_service, $entity_service ) {
30
+	public function __construct($content_filter_service, $entity_service) {
31 31
 
32
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Relation_Rebuild_Service' );
32
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Relation_Rebuild_Service');
33 33
 
34 34
 		$this->content_filter_service = $content_filter_service;
35 35
 		$this->entity_service         = $entity_service;
@@ -39,72 +39,72 @@  discard block
 block discarded – undo
39 39
 	public function process_all() {
40 40
 		global $wpdb;
41 41
 
42
-		set_time_limit( 21600 ); // 6 hours
42
+		set_time_limit(21600); // 6 hours
43 43
 
44
-		$this->log->debug( 'Deleting all existing relations...' );
44
+		$this->log->debug('Deleting all existing relations...');
45 45
 
46 46
 		// Delete existing data.
47
-		$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wl_relation_instances" );
47
+		$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}wl_relation_instances");
48 48
 
49
-		$this->log->debug( 'Processing contents...' );
49
+		$this->log->debug('Processing contents...');
50 50
 
51
-		$this->process( array( $this, 'process_single' ) );
51
+		$this->process(array($this, 'process_single'));
52 52
 
53 53
 	}
54 54
 
55
-	public function process_single( $post_id ) {
55
+	public function process_single($post_id) {
56 56
 
57
-		$this->log->debug( "Processing post $post_id..." );
57
+		$this->log->debug("Processing post $post_id...");
58 58
 
59 59
 		// Bail out if the post is not found.
60
-		$post = get_post( $post_id );
60
+		$post = get_post($post_id);
61 61
 
62
-		if ( null === $post ) {
63
-			$this->log->error( "Post $post_id not found." );
62
+		if (null === $post) {
63
+			$this->log->error("Post $post_id not found.");
64 64
 
65 65
 			return;
66 66
 		}
67 67
 
68 68
 		// Get the URIs from the post content.
69
-		$uris = $this->content_filter_service->get_entity_uris( $post->post_content );
69
+		$uris = $this->content_filter_service->get_entity_uris($post->post_content);
70 70
 
71 71
 		// Map the URIs to post IDs.
72
-		$ids = $this->uri_to_post_id( $uris );
72
+		$ids = $this->uri_to_post_id($uris);
73 73
 
74
-		$this->log->info( 'Found ' . count( $uris ) . ' annotation(s) and ' . count( $ids ) . ' unique relation(s).' );
74
+		$this->log->info('Found '.count($uris).' annotation(s) and '.count($ids).' unique relation(s).');
75 75
 
76 76
 		// Create the relations.
77
-		$this->create_relations( $post_id, $ids );
77
+		$this->create_relations($post_id, $ids);
78 78
 
79 79
 	}
80 80
 
81
-	private function create_relations( $subject_id, $object_ids ) {
81
+	private function create_relations($subject_id, $object_ids) {
82 82
 
83
-		$this->log->info( "Creating relations for post $subject_id..." );
83
+		$this->log->info("Creating relations for post $subject_id...");
84 84
 
85 85
 		$entity_service = $this->entity_service;
86 86
 
87
-		array_walk( $object_ids, function ( $item ) use ( $subject_id, $entity_service ) {
87
+		array_walk($object_ids, function($item) use ($subject_id, $entity_service) {
88 88
 			wl_core_add_relation_instance(
89 89
 				$subject_id,
90
-				$entity_service->get_classification_scope_for( $item ),
90
+				$entity_service->get_classification_scope_for($item),
91 91
 				$item
92 92
 			);
93 93
 		} );
94 94
 
95 95
 	}
96 96
 
97
-	private function uri_to_post_id( $uris ) {
97
+	private function uri_to_post_id($uris) {
98 98
 
99 99
 		$entity_service = $this->entity_service;
100 100
 
101
-		$ids = array_unique( array_map( function ( $item ) use ( $entity_service ) {
102
-			$post = $entity_service->get_entity_post_by_uri( $item );
101
+		$ids = array_unique(array_map(function($item) use ($entity_service) {
102
+			$post = $entity_service->get_entity_post_by_uri($item);
103 103
 
104 104
 			return null === $post ? null : $post->ID;
105
-		}, (array) $uris ) );
105
+		}, (array) $uris));
106 106
 
107
-		return array_filter( $ids, function ( $item ) {
107
+		return array_filter($ids, function($item) {
108 108
 			return null !== $item;
109 109
 		} );
110 110
 	}
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	/**
113 113
 	 * @inheritdoc
114 114
 	 */
115
-	function find( $offset = 0, $limit = 10, $args = array() ) {
115
+	function find($offset = 0, $limit = 10, $args = array()) {
116 116
 		global $wpdb;
117 117
 
118
-		return $wpdb->get_col( $wpdb->prepare(
118
+		return $wpdb->get_col($wpdb->prepare(
119 119
 			"
120 120
 			SELECT id
121 121
 			FROM $wpdb->posts
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			'<[a-z]+ id="urn:[^"]+" class="[^"]+" itemid="[^"]+">',
127 127
 			$limit,
128 128
 			$offset
129
-		) );
129
+		));
130 130
 
131 131
 	}
132 132
 
Please login to merge, or discard this patch.
src/includes/rebuild/class-wordlift-listable.php 2 patches
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -4,54 +4,54 @@
 block discarded – undo
4 4
  */
5 5
 abstract class Wordlift_Listable {
6 6
 
7
-	private $count = 0;
8
-
9
-	/**
10
-	 * List the items starting at the specified offset and up to the specified limit.
11
-	 *
12
-	 * @param int   $offset The start offset.
13
-	 * @param int   $limit  The maximum number of items to return.
14
-	 * @param array $args   Additional arguments.
15
-	 *
16
-	 * @return array A array of items (or an empty array if no items are found).
17
-	 */
18
-	abstract function find( $offset = 0, $limit = 10, $args = array() );
19
-
20
-	/**
21
-	 * @param callable $callback
22
-	 * @param array    $args
23
-	 * @param int      $offset
24
-	 * @param int      $max
25
-	 */
26
-	public function process( $callback, $args = array(), $offset = 0, $max = PHP_INT_MAX ) {
27
-
28
-		// We process chunks in order to avoid using too much memory,
29
-		// starting at offset 0.
30
-		while ( 0 < sizeof( $items = $this->find( $offset, 1, $args ) ) && $offset < $max ) {
31
-
32
-			// Cycle through items and call the callback function.
33
-			foreach ( $items as $item ) {
34
-				call_user_func_array( $callback, array( $item ) );
35
-			}
36
-
37
-			// Remove the flush of the cache.
38
-			//
39
-			// See https://github.com/insideout10/wordlift-plugin/issues/686.
40
-			// Clean the cache to avoid memory errors.
41
-			// wp_cache_flush();
42
-
43
-			// Move to the next offset.
44
-			$offset += 1;
45
-
46
-			$this->count ++;
47
-
48
-		}
49
-
50
-	}
51
-
52
-	public function get_count() {
53
-
54
-		return $this->count;
55
-	}
7
+    private $count = 0;
8
+
9
+    /**
10
+     * List the items starting at the specified offset and up to the specified limit.
11
+     *
12
+     * @param int   $offset The start offset.
13
+     * @param int   $limit  The maximum number of items to return.
14
+     * @param array $args   Additional arguments.
15
+     *
16
+     * @return array A array of items (or an empty array if no items are found).
17
+     */
18
+    abstract function find( $offset = 0, $limit = 10, $args = array() );
19
+
20
+    /**
21
+     * @param callable $callback
22
+     * @param array    $args
23
+     * @param int      $offset
24
+     * @param int      $max
25
+     */
26
+    public function process( $callback, $args = array(), $offset = 0, $max = PHP_INT_MAX ) {
27
+
28
+        // We process chunks in order to avoid using too much memory,
29
+        // starting at offset 0.
30
+        while ( 0 < sizeof( $items = $this->find( $offset, 1, $args ) ) && $offset < $max ) {
31
+
32
+            // Cycle through items and call the callback function.
33
+            foreach ( $items as $item ) {
34
+                call_user_func_array( $callback, array( $item ) );
35
+            }
36
+
37
+            // Remove the flush of the cache.
38
+            //
39
+            // See https://github.com/insideout10/wordlift-plugin/issues/686.
40
+            // Clean the cache to avoid memory errors.
41
+            // wp_cache_flush();
42
+
43
+            // Move to the next offset.
44
+            $offset += 1;
45
+
46
+            $this->count ++;
47
+
48
+        }
49
+
50
+    }
51
+
52
+    public function get_count() {
53
+
54
+        return $this->count;
55
+    }
56 56
 
57 57
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
 	 * @return array A array of items (or an empty array if no items are found).
17 17
 	 */
18
-	abstract function find( $offset = 0, $limit = 10, $args = array() );
18
+	abstract function find($offset = 0, $limit = 10, $args = array());
19 19
 
20 20
 	/**
21 21
 	 * @param callable $callback
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 	 * @param int      $offset
24 24
 	 * @param int      $max
25 25
 	 */
26
-	public function process( $callback, $args = array(), $offset = 0, $max = PHP_INT_MAX ) {
26
+	public function process($callback, $args = array(), $offset = 0, $max = PHP_INT_MAX) {
27 27
 
28 28
 		// We process chunks in order to avoid using too much memory,
29 29
 		// starting at offset 0.
30
-		while ( 0 < sizeof( $items = $this->find( $offset, 1, $args ) ) && $offset < $max ) {
30
+		while (0 < sizeof($items = $this->find($offset, 1, $args)) && $offset < $max) {
31 31
 
32 32
 			// Cycle through items and call the callback function.
33
-			foreach ( $items as $item ) {
34
-				call_user_func_array( $callback, array( $item ) );
33
+			foreach ($items as $item) {
34
+				call_user_func_array($callback, array($item));
35 35
 			}
36 36
 
37 37
 			// Remove the flush of the cache.
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			// Move to the next offset.
44 44
 			$offset += 1;
45 45
 
46
-			$this->count ++;
46
+			$this->count++;
47 47
 
48 48
 		}
49 49
 
Please login to merge, or discard this patch.
src/includes/rebuild/class-wordlift-relation-rebuild-adapter.php 2 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class Wordlift_Relation_Rebuild_Adapter {
4
-	/**
5
-	 * @var Wordlift_Relation_Rebuild_Service
6
-	 */
7
-	private $relation_rebuild_service;
4
+    /**
5
+     * @var Wordlift_Relation_Rebuild_Service
6
+     */
7
+    private $relation_rebuild_service;
8 8
 
9 9
 
10
-	/**
11
-	 * Wordlift_Relation_Rebuild_Adapter constructor.
12
-	 *
13
-	 * @param \Wordlift_Relation_Rebuild_Service $relation_rebuild_service
14
-	 */
15
-	public function __construct( $relation_rebuild_service ) {
16
-		$this->relation_rebuild_service = $relation_rebuild_service;
17
-	}
10
+    /**
11
+     * Wordlift_Relation_Rebuild_Adapter constructor.
12
+     *
13
+     * @param \Wordlift_Relation_Rebuild_Service $relation_rebuild_service
14
+     */
15
+    public function __construct( $relation_rebuild_service ) {
16
+        $this->relation_rebuild_service = $relation_rebuild_service;
17
+    }
18 18
 
19
-	public function process_all() {
19
+    public function process_all() {
20 20
 
21
-		$this->relation_rebuild_service->process_all();
21
+        $this->relation_rebuild_service->process_all();
22 22
 
23
-		ob_clean();
23
+        ob_clean();
24 24
 
25
-		wp_send_json_success( array(
26
-			'count' => $this->relation_rebuild_service->get_count(),
27
-		) );
25
+        wp_send_json_success( array(
26
+            'count' => $this->relation_rebuild_service->get_count(),
27
+        ) );
28 28
 
29
-	}
29
+    }
30 30
 
31 31
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 *
13 13
 	 * @param \Wordlift_Relation_Rebuild_Service $relation_rebuild_service
14 14
 	 */
15
-	public function __construct( $relation_rebuild_service ) {
15
+	public function __construct($relation_rebuild_service) {
16 16
 		$this->relation_rebuild_service = $relation_rebuild_service;
17 17
 	}
18 18
 
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 
23 23
 		ob_clean();
24 24
 
25
-		wp_send_json_success( array(
25
+		wp_send_json_success(array(
26 26
 			'count' => $this->relation_rebuild_service->get_count(),
27
-		) );
27
+		));
28 28
 
29 29
 	}
30 30
 
Please login to merge, or discard this patch.
src/includes/linked-data/storage/class-wordlift-storage-factory.php 2 patches
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -18,210 +18,210 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Storage_Factory {
20 20
 
21
-	/**
22
-	 * The {@link Wordlift_Entity_Service} instance.
23
-	 *
24
-	 * @since  3.15.0
25
-	 * @access private
26
-	 * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
27
-	 */
28
-	private $entity_service;
29
-
30
-	/**
31
-	 * The {@link Wordlift_User_Service} instance.
32
-	 *
33
-	 * @since  3.15.0
34
-	 * @access private
35
-	 * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance.
36
-	 */
37
-	private $user_service;
38
-
39
-	/**
40
-	 * The {@link Wordlift_Property_Getter} instance.
41
-	 *
42
-	 * @since  3.15.0
43
-	 * @access private
44
-	 * @var \Wordlift_Property_Getter The {@link Wordlift_Property_Getter} instance.
45
-	 */
46
-	private $property_getter;
47
-
48
-	/**
49
-	 * The singleton instance.
50
-	 *
51
-	 * @since  3.15.0
52
-	 * @access private
53
-	 * @var \Wordlift_Storage_Factory $instance The singleton instance.
54
-	 */
55
-	private static $instance;
56
-
57
-	/**
58
-	 * Create a {@link Wordlift_Storage_Factory} instance.
59
-	 *
60
-	 * @since 3.15.0
61
-	 *
62
-	 * @param \Wordlift_Entity_Service  $entity_service  The {@link Wordlift_Entity_Service} instance.
63
-	 * @param \Wordlift_User_Service    $user_service    The {@link Wordlift_User_Service} instance.
64
-	 * @param \Wordlift_Property_Getter $property_getter The {@link Wordlift_Property_Getter} instance.
65
-	 */
66
-	public function __construct( $entity_service, $user_service, $property_getter ) {
67
-
68
-		$this->entity_service  = $entity_service;
69
-		$this->user_service    = $user_service;
70
-		$this->property_getter = $property_getter;
71
-
72
-		self::$instance = $this;
73
-	}
74
-
75
-	/**
76
-	 * Get the singleton instance.
77
-	 *
78
-	 * @since 3.15.0
79
-	 *
80
-	 * @return \Wordlift_Storage_Factory The singleton instance.
81
-	 */
82
-	public static function get_instance() {
83
-
84
-		return self::$instance;
85
-	}
86
-
87
-	/**
88
-	 * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
89
-	 * titles.
90
-	 *
91
-	 * @since 3.15.0
92
-	 *
93
-	 * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage}
94
-	 *                                         instance.
95
-	 */
96
-	public function post_title() {
97
-
98
-		return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::TITLE );
99
-	}
100
-
101
-	/**
102
-	 * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
103
-	 * descriptions stripped of tags and shortcodes.
104
-	 *
105
-	 * @since 3.15.0
106
-	 *
107
-	 * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage}
108
-	 *                                         instance.
109
-	 */
110
-	public function post_description_no_tags_no_shortcodes() {
111
-
112
-		return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::DESCRIPTION_NO_TAGS_NO_SHORTCODES );
113
-	}
114
-
115
-	/**
116
-	 * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
117
-	 * authors.
118
-	 *
119
-	 * @since 3.15.0
120
-	 *
121
-	 * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage}
122
-	 *                                         instance.
123
-	 */
124
-	public function post_author() {
125
-
126
-		return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::AUTHOR );
127
-	}
128
-
129
-	/**
130
-	 * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
131
-	 * metas.
132
-	 *
133
-	 * @since 3.15.0
134
-	 *
135
-	 * @param string $meta_key The meta key to read.
136
-	 *
137
-	 * @return Wordlift_Post_Meta_Storage A {@link Wordlift_Post_Meta_Storage}
138
-	 *                                    instance.
139
-	 */
140
-	public function post_meta( $meta_key ) {
141
-
142
-		return new Wordlift_Post_Meta_Storage( $meta_key );
143
-	}
144
-
145
-	/**
146
-	 * Get a {@link Wordlift_Post_Schema_Class_Storage} to read {@link WP_Post}s'
147
-	 * entity type class.
148
-	 *
149
-	 * @since 3.15.0
150
-	 *
151
-	 * @return Wordlift_Post_Schema_Class_Storage A {@link Wordlift_Post_Schema_Class_Storage}
152
-	 *                                    instance.
153
-	 */
154
-	public function schema_class() {
155
-
156
-		return new Wordlift_Post_Schema_Class_Storage();
157
-	}
158
-
159
-	/**
160
-	 * Get a {@link Wordlift_Post_Author_Storage} instance able to turn an author
161
-	 * id into a URI.
162
-	 *
163
-	 * @since 3.15.0
164
-	 *
165
-	 * @return \Wordlift_Post_Author_Storage A {@link Wordlift_Post_Author_Storage}
166
-	 *                                       instance.
167
-	 */
168
-	public function author_uri() {
169
-
170
-		return new Wordlift_Post_Author_Storage( $this->entity_service, $this->user_service );
171
-	}
172
-
173
-	/**
174
-	 * Get a {@link Wordlift_Post_Meta_Uri_Storage} instance which reads {@link WP_Post}
175
-	 * ids and maps them to URI.
176
-	 *
177
-	 * @param string $meta_key The {@link WP_Post}'s meta key.
178
-	 *
179
-	 * @return \Wordlift_Post_Meta_Uri_Storage A {@link Wordlift_Post_Meta_Uri_Storage}
180
-	 *                                         instance.
181
-	 */
182
-	public function post_meta_to_uri( $meta_key ) {
183
-
184
-		return new Wordlift_Post_Meta_Uri_Storage( $meta_key, $this->entity_service );
185
-	}
186
-
187
-	/**
188
-	 * Get a list of {@link WP_Post}'s images URI.
189
-	 *
190
-	 * @since 3.15.0
191
-	 *
192
-	 * @return \Wordlift_Post_Image_Storage A {@link Wordlift_Post_Image_Storage}
193
-	 *                                      instance.
194
-	 */
195
-	public function post_images() {
196
-
197
-		return new Wordlift_Post_Image_Storage();
198
-	}
199
-
200
-	/**
201
-	 * Get a {@link Wordlift_Post_Related_Storage} instance to get related
202
-	 * {@link WP_Post}s.
203
-	 *
204
-	 * @since 3.15.0
205
-	 *
206
-	 * @return \Wordlift_Post_Related_Storage A {@link Wordlift_Post_Related_Storage}
207
-	 *                                        instance.
208
-	 */
209
-	public function relations() {
210
-
211
-		return new Wordlift_Post_Related_Storage( $this->entity_service );
212
-	}
213
-
214
-	/**
215
-	 * Get the {@link Wordlift_Url_Property_Storage} instance.
216
-	 *
217
-	 * @since 3.15.0
218
-	 *
219
-	 * @return \Wordlift_Url_Property_Storage The {@link Wordlift_Url_Property_Storage}
220
-	 *                                        instance.
221
-	 */
222
-	public function url_property() {
223
-
224
-		return new Wordlift_Url_Property_Storage( $this->property_getter );
225
-	}
21
+    /**
22
+     * The {@link Wordlift_Entity_Service} instance.
23
+     *
24
+     * @since  3.15.0
25
+     * @access private
26
+     * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance.
27
+     */
28
+    private $entity_service;
29
+
30
+    /**
31
+     * The {@link Wordlift_User_Service} instance.
32
+     *
33
+     * @since  3.15.0
34
+     * @access private
35
+     * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance.
36
+     */
37
+    private $user_service;
38
+
39
+    /**
40
+     * The {@link Wordlift_Property_Getter} instance.
41
+     *
42
+     * @since  3.15.0
43
+     * @access private
44
+     * @var \Wordlift_Property_Getter The {@link Wordlift_Property_Getter} instance.
45
+     */
46
+    private $property_getter;
47
+
48
+    /**
49
+     * The singleton instance.
50
+     *
51
+     * @since  3.15.0
52
+     * @access private
53
+     * @var \Wordlift_Storage_Factory $instance The singleton instance.
54
+     */
55
+    private static $instance;
56
+
57
+    /**
58
+     * Create a {@link Wordlift_Storage_Factory} instance.
59
+     *
60
+     * @since 3.15.0
61
+     *
62
+     * @param \Wordlift_Entity_Service  $entity_service  The {@link Wordlift_Entity_Service} instance.
63
+     * @param \Wordlift_User_Service    $user_service    The {@link Wordlift_User_Service} instance.
64
+     * @param \Wordlift_Property_Getter $property_getter The {@link Wordlift_Property_Getter} instance.
65
+     */
66
+    public function __construct( $entity_service, $user_service, $property_getter ) {
67
+
68
+        $this->entity_service  = $entity_service;
69
+        $this->user_service    = $user_service;
70
+        $this->property_getter = $property_getter;
71
+
72
+        self::$instance = $this;
73
+    }
74
+
75
+    /**
76
+     * Get the singleton instance.
77
+     *
78
+     * @since 3.15.0
79
+     *
80
+     * @return \Wordlift_Storage_Factory The singleton instance.
81
+     */
82
+    public static function get_instance() {
83
+
84
+        return self::$instance;
85
+    }
86
+
87
+    /**
88
+     * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
89
+     * titles.
90
+     *
91
+     * @since 3.15.0
92
+     *
93
+     * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage}
94
+     *                                         instance.
95
+     */
96
+    public function post_title() {
97
+
98
+        return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::TITLE );
99
+    }
100
+
101
+    /**
102
+     * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
103
+     * descriptions stripped of tags and shortcodes.
104
+     *
105
+     * @since 3.15.0
106
+     *
107
+     * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage}
108
+     *                                         instance.
109
+     */
110
+    public function post_description_no_tags_no_shortcodes() {
111
+
112
+        return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::DESCRIPTION_NO_TAGS_NO_SHORTCODES );
113
+    }
114
+
115
+    /**
116
+     * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
117
+     * authors.
118
+     *
119
+     * @since 3.15.0
120
+     *
121
+     * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage}
122
+     *                                         instance.
123
+     */
124
+    public function post_author() {
125
+
126
+        return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::AUTHOR );
127
+    }
128
+
129
+    /**
130
+     * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s'
131
+     * metas.
132
+     *
133
+     * @since 3.15.0
134
+     *
135
+     * @param string $meta_key The meta key to read.
136
+     *
137
+     * @return Wordlift_Post_Meta_Storage A {@link Wordlift_Post_Meta_Storage}
138
+     *                                    instance.
139
+     */
140
+    public function post_meta( $meta_key ) {
141
+
142
+        return new Wordlift_Post_Meta_Storage( $meta_key );
143
+    }
144
+
145
+    /**
146
+     * Get a {@link Wordlift_Post_Schema_Class_Storage} to read {@link WP_Post}s'
147
+     * entity type class.
148
+     *
149
+     * @since 3.15.0
150
+     *
151
+     * @return Wordlift_Post_Schema_Class_Storage A {@link Wordlift_Post_Schema_Class_Storage}
152
+     *                                    instance.
153
+     */
154
+    public function schema_class() {
155
+
156
+        return new Wordlift_Post_Schema_Class_Storage();
157
+    }
158
+
159
+    /**
160
+     * Get a {@link Wordlift_Post_Author_Storage} instance able to turn an author
161
+     * id into a URI.
162
+     *
163
+     * @since 3.15.0
164
+     *
165
+     * @return \Wordlift_Post_Author_Storage A {@link Wordlift_Post_Author_Storage}
166
+     *                                       instance.
167
+     */
168
+    public function author_uri() {
169
+
170
+        return new Wordlift_Post_Author_Storage( $this->entity_service, $this->user_service );
171
+    }
172
+
173
+    /**
174
+     * Get a {@link Wordlift_Post_Meta_Uri_Storage} instance which reads {@link WP_Post}
175
+     * ids and maps them to URI.
176
+     *
177
+     * @param string $meta_key The {@link WP_Post}'s meta key.
178
+     *
179
+     * @return \Wordlift_Post_Meta_Uri_Storage A {@link Wordlift_Post_Meta_Uri_Storage}
180
+     *                                         instance.
181
+     */
182
+    public function post_meta_to_uri( $meta_key ) {
183
+
184
+        return new Wordlift_Post_Meta_Uri_Storage( $meta_key, $this->entity_service );
185
+    }
186
+
187
+    /**
188
+     * Get a list of {@link WP_Post}'s images URI.
189
+     *
190
+     * @since 3.15.0
191
+     *
192
+     * @return \Wordlift_Post_Image_Storage A {@link Wordlift_Post_Image_Storage}
193
+     *                                      instance.
194
+     */
195
+    public function post_images() {
196
+
197
+        return new Wordlift_Post_Image_Storage();
198
+    }
199
+
200
+    /**
201
+     * Get a {@link Wordlift_Post_Related_Storage} instance to get related
202
+     * {@link WP_Post}s.
203
+     *
204
+     * @since 3.15.0
205
+     *
206
+     * @return \Wordlift_Post_Related_Storage A {@link Wordlift_Post_Related_Storage}
207
+     *                                        instance.
208
+     */
209
+    public function relations() {
210
+
211
+        return new Wordlift_Post_Related_Storage( $this->entity_service );
212
+    }
213
+
214
+    /**
215
+     * Get the {@link Wordlift_Url_Property_Storage} instance.
216
+     *
217
+     * @since 3.15.0
218
+     *
219
+     * @return \Wordlift_Url_Property_Storage The {@link Wordlift_Url_Property_Storage}
220
+     *                                        instance.
221
+     */
222
+    public function url_property() {
223
+
224
+        return new Wordlift_Url_Property_Storage( $this->property_getter );
225
+    }
226 226
 
227 227
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param \Wordlift_User_Service    $user_service    The {@link Wordlift_User_Service} instance.
64 64
 	 * @param \Wordlift_Property_Getter $property_getter The {@link Wordlift_Property_Getter} instance.
65 65
 	 */
66
-	public function __construct( $entity_service, $user_service, $property_getter ) {
66
+	public function __construct($entity_service, $user_service, $property_getter) {
67 67
 
68 68
 		$this->entity_service  = $entity_service;
69 69
 		$this->user_service    = $user_service;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	public function post_title() {
97 97
 
98
-		return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::TITLE );
98
+		return new Wordlift_Post_Property_Storage(Wordlift_Post_Property_Storage::TITLE);
99 99
 	}
100 100
 
101 101
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function post_description_no_tags_no_shortcodes() {
111 111
 
112
-		return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::DESCRIPTION_NO_TAGS_NO_SHORTCODES );
112
+		return new Wordlift_Post_Property_Storage(Wordlift_Post_Property_Storage::DESCRIPTION_NO_TAGS_NO_SHORTCODES);
113 113
 	}
114 114
 
115 115
 	/**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 */
124 124
 	public function post_author() {
125 125
 
126
-		return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::AUTHOR );
126
+		return new Wordlift_Post_Property_Storage(Wordlift_Post_Property_Storage::AUTHOR);
127 127
 	}
128 128
 
129 129
 	/**
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 * @return Wordlift_Post_Meta_Storage A {@link Wordlift_Post_Meta_Storage}
138 138
 	 *                                    instance.
139 139
 	 */
140
-	public function post_meta( $meta_key ) {
140
+	public function post_meta($meta_key) {
141 141
 
142
-		return new Wordlift_Post_Meta_Storage( $meta_key );
142
+		return new Wordlift_Post_Meta_Storage($meta_key);
143 143
 	}
144 144
 
145 145
 	/**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function author_uri() {
169 169
 
170
-		return new Wordlift_Post_Author_Storage( $this->entity_service, $this->user_service );
170
+		return new Wordlift_Post_Author_Storage($this->entity_service, $this->user_service);
171 171
 	}
172 172
 
173 173
 	/**
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 	 * @return \Wordlift_Post_Meta_Uri_Storage A {@link Wordlift_Post_Meta_Uri_Storage}
180 180
 	 *                                         instance.
181 181
 	 */
182
-	public function post_meta_to_uri( $meta_key ) {
182
+	public function post_meta_to_uri($meta_key) {
183 183
 
184
-		return new Wordlift_Post_Meta_Uri_Storage( $meta_key, $this->entity_service );
184
+		return new Wordlift_Post_Meta_Uri_Storage($meta_key, $this->entity_service);
185 185
 	}
186 186
 
187 187
 	/**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function relations() {
210 210
 
211
-		return new Wordlift_Post_Related_Storage( $this->entity_service );
211
+		return new Wordlift_Post_Related_Storage($this->entity_service);
212 212
 	}
213 213
 
214 214
 	/**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 	public function url_property() {
223 223
 
224
-		return new Wordlift_Url_Property_Storage( $this->property_getter );
224
+		return new Wordlift_Url_Property_Storage($this->property_getter);
225 225
 	}
226 226
 
227 227
 }
Please login to merge, or discard this patch.
src/includes/wp-async-task/class-wordlift-push-references-async-task.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -18,59 +18,59 @@
 block discarded – undo
18 18
  */
19 19
 class Wordlift_Push_References_Async_Task extends Wordlift_Async_Task {
20 20
 
21
-	/**
22
-	 * The protected $action property should be set to the action to which you
23
-	 * wish to attach the asynchronous task. For example, if you want to spin
24
-	 * off an asynchronous task whenever a post gets saved, you would set this
25
-	 * to save_post.
26
-	 *
27
-	 * @since  3.18.0
28
-	 * @access protected
29
-	 * @var string $action The action to which you wish to attach the
30
-	 *                     asynchronous task.
31
-	 */
32
-	protected $action = 'wl_push_references';
21
+    /**
22
+     * The protected $action property should be set to the action to which you
23
+     * wish to attach the asynchronous task. For example, if you want to spin
24
+     * off an asynchronous task whenever a post gets saved, you would set this
25
+     * to save_post.
26
+     *
27
+     * @since  3.18.0
28
+     * @access protected
29
+     * @var string $action The action to which you wish to attach the
30
+     *                     asynchronous task.
31
+     */
32
+    protected $action = 'wl_push_references';
33 33
 
34
-	/**
35
-	 * A {@link Wordlift_Log_Service} instance.
36
-	 *
37
-	 * @since  3.18.0
38
-	 * @access private
39
-	 * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
40
-	 */
41
-	private $log;
34
+    /**
35
+     * A {@link Wordlift_Log_Service} instance.
36
+     *
37
+     * @since  3.18.0
38
+     * @access private
39
+     * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance.
40
+     */
41
+    private $log;
42 42
 
43
-	/**
44
-	 * Create a {@link Wordlift_Push_References_Async_Task} instance.
45
-	 *
46
-	 * @since 3.18.0
47
-	 *
48
-	 * @param int $auth_level The authentication level to use (see above)
49
-	 */
50
-	public function __construct( $auth_level = self::BOTH ) {
51
-		parent::__construct( $auth_level );
43
+    /**
44
+     * Create a {@link Wordlift_Push_References_Async_Task} instance.
45
+     *
46
+     * @since 3.18.0
47
+     *
48
+     * @param int $auth_level The authentication level to use (see above)
49
+     */
50
+    public function __construct( $auth_level = self::BOTH ) {
51
+        parent::__construct( $auth_level );
52 52
 
53
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Push_References_Async_Task' );
53
+        $this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Push_References_Async_Task' );
54 54
 
55
-	}
55
+    }
56 56
 
57
-	/**
58
-	 * @inheritdoc
59
-	 */
60
-	protected function prepare_data( $data ) {
57
+    /**
58
+     * @inheritdoc
59
+     */
60
+    protected function prepare_data( $data ) {
61 61
 
62
-		// Return the link setting.
63
-		return array();
64
-	}
62
+        // Return the link setting.
63
+        return array();
64
+    }
65 65
 
66
-	/**
67
-	 * @inheritdoc
68
-	 */
69
-	protected function run_action() {
66
+    /**
67
+     * @inheritdoc
68
+     */
69
+    protected function run_action() {
70 70
 
71
-		// Run the asynchronous action.
72
-		do_action( "wl_async_$this->action" );
71
+        // Run the asynchronous action.
72
+        do_action( "wl_async_$this->action" );
73 73
 
74
-	}
74
+    }
75 75
 
76 76
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -47,17 +47,17 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param int $auth_level The authentication level to use (see above)
49 49
 	 */
50
-	public function __construct( $auth_level = self::BOTH ) {
51
-		parent::__construct( $auth_level );
50
+	public function __construct($auth_level = self::BOTH) {
51
+		parent::__construct($auth_level);
52 52
 
53
-		$this->log = Wordlift_Log_Service::get_logger( 'Wordlift_Push_References_Async_Task' );
53
+		$this->log = Wordlift_Log_Service::get_logger('Wordlift_Push_References_Async_Task');
54 54
 
55 55
 	}
56 56
 
57 57
 	/**
58 58
 	 * @inheritdoc
59 59
 	 */
60
-	protected function prepare_data( $data ) {
60
+	protected function prepare_data($data) {
61 61
 
62 62
 		// Return the link setting.
63 63
 		return array();
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	protected function run_action() {
70 70
 
71 71
 		// Run the asynchronous action.
72
-		do_action( "wl_async_$this->action" );
72
+		do_action("wl_async_$this->action");
73 73
 
74 74
 	}
75 75
 
Please login to merge, or discard this patch.
src/includes/class-wordlift-query-builder.php 2 patches
Spacing   +20 added lines, -22 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return $this \Wordlift_Query_Builder The Query builder.
201 201
 	 */
202
-	public function select( $props = '*' ) {
202
+	public function select($props = '*') {
203 203
 
204 204
 		$this->template = "SELECT $props WHERE { %s }";
205 205
 
@@ -220,38 +220,36 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return $this \Wordlift_Query_Builder The Query builder.
222 222
 	 */
223
-	public function statement( $subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null ) {
223
+	public function statement($subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null) {
224 224
 
225 225
 		// If no value has been provided, we don't set any statement.
226
-		if ( empty( $object ) ) {
226
+		if (empty($object)) {
227 227
 			return $this;
228 228
 		}
229 229
 
230 230
 		// Guess the subject type.
231
-		$subject_value_type = $this->guess_subject_type( $subject );
231
+		$subject_value_type = $this->guess_subject_type($subject);
232 232
 
233 233
 		// Get the object type if set, otherwise try to guess it.
234
-		$object_value_type = ( self::OBJECT_AUTO === $object_type ? $this->guess_object_type( $predicate, $object ) : $object_type );
234
+		$object_value_type = (self::OBJECT_AUTO === $object_type ? $this->guess_object_type($predicate, $object) : $object_type);
235 235
 
236 236
 		// Prepare the statement template.
237 237
 		$template =
238 238
 			// Subject as a parameter, no `<`, `>`.
239
-			( self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>' ) .
239
+			(self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>').
240 240
 			// Predicate.
241
-			' <%2$s> ' .
241
+			' <%2$s> '.
242 242
 			// Object.
243
-			( self::OBJECT_URI === $object_value_type ? '<%3$s>' :
244
-				( self::OBJECT_PARAMETER === $object_value_type ? '%3$s' :
245
-					// self::OBJECT_VALUE === $object_value_type
246
-					'"%3$s"' . ( isset( $data_type ) ? '^^%4$s' : '' ) . ( isset( $language ) ? '@%5$s' : '' ) ) );
243
+			(self::OBJECT_URI === $object_value_type ? '<%3$s>' : (self::OBJECT_PARAMETER === $object_value_type ? '%3$s' : // self::OBJECT_VALUE === $object_value_type
244
+					'"%3$s"'.(isset($data_type) ? '^^%4$s' : '').(isset($language) ? '@%5$s' : '')));
247 245
 
248 246
 		// Escape the subject, predicate and object.
249
-		$escaped_subject   = Wordlift_Sparql_Service::escape_uri( $subject );
250
-		$escaped_predicate = Wordlift_Sparql_Service::escape_uri( $predicate );
251
-		$escaped_object    = ( self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri( $object ) : Wordlift_Sparql_Service::escape( $object ) );
247
+		$escaped_subject   = Wordlift_Sparql_Service::escape_uri($subject);
248
+		$escaped_predicate = Wordlift_Sparql_Service::escape_uri($predicate);
249
+		$escaped_object    = (self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri($object) : Wordlift_Sparql_Service::escape($object));
252 250
 
253 251
 		// Prepare the statement and add it to the list of statements.
254
-		$this->statements[] = sprintf( $template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language );
252
+		$this->statements[] = sprintf($template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language);
255 253
 
256 254
 		return $this;
257 255
 	}
@@ -265,11 +263,11 @@  discard block
 block discarded – undo
265 263
 	public function build() {
266 264
 
267 265
 		// If there are no statements return an empty string.
268
-		if ( empty( $this->statements ) ) {
266
+		if (empty($this->statements)) {
269 267
 			return '';
270 268
 		}
271 269
 
272
-		return sprintf( $this->template, implode( ' . ', $this->statements ) ) . "\n";
270
+		return sprintf($this->template, implode(' . ', $this->statements))."\n";
273 271
 	}
274 272
 
275 273
 	/**
@@ -282,15 +280,15 @@  discard block
 block discarded – undo
282 280
 	 *
283 281
 	 * @return int {@link Wordlift_Query_Builder::OBJECT_URI} if the Query builder thinks the object must be an URI, {@link Wordlift_Query_Builder::OBJECT_VALUE} otherwise.
284 282
 	 */
285
-	private function guess_object_type( $predicate, $object ) {
283
+	private function guess_object_type($predicate, $object) {
286 284
 
287 285
 		// If the object starts with a question mark, it's a parameter.
288
-		if ( 0 === strpos( $object, '?' ) ) {
286
+		if (0 === strpos($object, '?')) {
289 287
 			return self::OBJECT_PARAMETER;
290 288
 		}
291 289
 
292 290
 		// Guess based on the predicate.
293
-		switch ( $predicate ) {
291
+		switch ($predicate) {
294 292
 
295 293
 			case self::DCTERMS_REFERENCES_URI:
296 294
 			case self::DCTERMS_SUBJECT_URI:
@@ -315,10 +313,10 @@  discard block
 block discarded – undo
315 313
 	 *
316 314
 	 * @return int {@link Wordlift_Query_Builder::OBJECT_PARAMETER} if the Query builder thinks the subject is a parameter (starts with ?), otherwise {@link Wordlift_Query_Builder::OBJECT_URI}.
317 315
 	 */
318
-	private function guess_subject_type( $subject ) {
316
+	private function guess_subject_type($subject) {
319 317
 
320 318
 		// If the object starts with a question mark, it's a parameter.
321
-		if ( 0 === strpos( $subject, '?' ) ) {
319
+		if (0 === strpos($subject, '?')) {
322 320
 			return self::OBJECT_PARAMETER;
323 321
 		}
324 322
 
Please login to merge, or discard this patch.
Indentation   +324 added lines, -324 removed lines patch added patch discarded remove patch
@@ -7,329 +7,329 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Query_Builder {
9 9
 
10
-	/**
11
-	 * The INSERT statement template.
12
-	 *
13
-	 * @since 3.1.7
14
-	 */
15
-	const INSERT = 'INSERT DATA { %s };';
16
-
17
-	/**
18
-	 * The DELETE statement template (it repeats the statements in the WHERE clause.
19
-	 *
20
-	 * @since 3.1.7
21
-	 */
22
-	const DELETE = 'DELETE { %s } WHERE { %1$s };';
23
-
24
-	/**
25
-	 * Tell the statement function to guess the object type (URI, value or parameter).
26
-	 *
27
-	 * @since 3.1.7
28
-	 */
29
-	const OBJECT_AUTO = - 1;
30
-
31
-	/**
32
-	 * Tell the statement function that the object is a URI.
33
-	 *
34
-	 * @since 3.1.7
35
-	 */
36
-	const OBJECT_URI = 0;
37
-
38
-	/**
39
-	 * Tell the statement function that the object is a value.
40
-	 *
41
-	 * @since 3.1.7
42
-	 */
43
-	const OBJECT_VALUE = 1;
44
-
45
-	/**
46
-	 * Tell the statement function that the object is a parameter.
47
-	 *
48
-	 * @since 3.1.7
49
-	 */
50
-	const OBJECT_PARAMETER = 2;
51
-
52
-	/**
53
-	 * The RDFS type.
54
-	 *
55
-	 * @since 3.1.7
56
-	 */
57
-	const RDFS_TYPE_URI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
58
-
59
-	/**
60
-	 * The schema.org/Person type.
61
-	 *
62
-	 * @since 3.1.7
63
-	 */
64
-	const SCHEMA_PERSON_URI = 'http://schema.org/Person';
65
-
66
-	/**
67
-	 * The schema.org given name predicate.
68
-	 *
69
-	 * @since 3.1.7
70
-	 */
71
-	const SCHEMA_GIVEN_NAME_URI = 'http://schema.org/givenName';
72
-
73
-	/**
74
-	 * The schema.org family name predicate.
75
-	 *
76
-	 * @since 3.1.7
77
-	 */
78
-	const SCHEMA_FAMILY_NAME_URI = 'http://schema.org/familyName';
79
-
80
-	/**
81
-	 * The schema.org url predicate.
82
-	 *
83
-	 * @since 3.1.7
84
-	 */
85
-	const SCHEMA_URL_URI = 'http://schema.org/url';
86
-
87
-	/**
88
-	 * @since 3.14.0
89
-	 */
90
-	const SCHEMA_IMAGE_URI = 'http://schema.org/image';
91
-
92
-	/**
93
-	 * The location created predicate.
94
-	 *
95
-	 * @since 3.14.0
96
-	 */
97
-	const SCHEMA_LOCATION_CREATED_URI = 'http://schema.org/locationCreated';
98
-
99
-	/**
100
-	 * @since 3.14.0
101
-	 */
102
-	const SCHEMA_AUTHOR_URI = 'http://schema.org/author';
103
-
104
-	/**
105
-	 * @since 3.14.0
106
-	 */
107
-	const SCHEMA_INTERACTION_COUNT_URI = 'http://schema.org/interactionCount';
108
-
109
-	/**
110
-	 * @since 3.14.0
111
-	 */
112
-	const DCTERMS_SUBJECT_URI = 'http://purl.org/dc/terms/subject';
113
-
114
-	/**
115
-	 * @since 3.14.0
116
-	 */
117
-	const DCTERMS_REFERENCES_URI = 'http://purl.org/dc/terms/references';
118
-
119
-	/**
120
-	 * @since 3.15.0
121
-	 */
122
-	const DCTERMS_RELATION_URI = 'http://purl.org/dc/terms/relation';
123
-
124
-	/**
125
-	 * The RDF label.
126
-	 *
127
-	 * @since 3.1.7
128
-	 */
129
-	const RDFS_LABEL_URI = 'http://www.w3.org/2000/01/rdf-schema#label';
130
-
131
-	/**
132
-	 * The schema.org `streetAddress` property.
133
-	 *
134
-	 * @since 3.18.0
135
-	 */
136
-	const SCHEMA_STREET_ADDRESS = 'http://schema.org/streetAddress';
137
-
138
-	/**
139
-	 * The schema.org headline.
140
-	 *
141
-	 * @since 3.18.0
142
-	 */
143
-	const SCHEMA_HEADLINE_URI = 'http://schema.org/headline';
144
-
145
-	/**
146
-	 * Hold the template (INSERT or DELETE).
147
-	 *
148
-	 * @since  3.1.7
149
-	 * @access private
150
-	 * @var string $template The query template.
151
-	 */
152
-	private $template;
153
-
154
-	/**
155
-	 * An array of statements (in the form of subject, predicate, object).
156
-	 *
157
-	 * @since  3.1.7
158
-	 * @access private
159
-	 * @var array $statements An array of statements.
160
-	 */
161
-	private $statements = array();
162
-
163
-	/**
164
-	 * Create a new instance of the Query builder (compatible with PHP 5.3).
165
-	 *
166
-	 * @since 3.1.7
167
-	 * @return Wordlift_Query_Builder A new instance of the Query builder.
168
-	 */
169
-	public static function new_instance() {
170
-
171
-		return new Wordlift_Query_Builder();
172
-	}
173
-
174
-	/**
175
-	 * Set the query to INSERT.
176
-	 *
177
-	 * @since 3.1.7
178
-	 * @return Wordlift_Query_Builder The Query builder.
179
-	 */
180
-	public function insert() {
181
-
182
-		$this->template = self::INSERT;
183
-
184
-		return $this;
185
-	}
186
-
187
-	/**
188
-	 * Set the query to DELETE.
189
-	 *
190
-	 * @since 3.1.7
191
-	 * @return $this \Wordlift_Query_Builder The Query builder.
192
-	 */
193
-	public function delete() {
194
-
195
-		$this->template = self::DELETE;
196
-
197
-		return $this;
198
-	}
199
-
200
-	/**
201
-	 * Set the query to SELECT.
202
-	 *
203
-	 * @since 3.12.2
204
-	 *
205
-	 * @param string $props The list of properties to read.
206
-	 *
207
-	 * @return $this \Wordlift_Query_Builder The Query builder.
208
-	 */
209
-	public function select( $props = '*' ) {
210
-
211
-		$this->template = "SELECT $props WHERE { %s }";
212
-
213
-		return $this;
214
-	}
215
-
216
-	/**
217
-	 * Add a statement.
218
-	 *
219
-	 * @since 3.1.7
220
-	 *
221
-	 * @param string      $subject     The subject of the statement (must be a URI).
222
-	 * @param string      $predicate   The predicate (must be a URI).
223
-	 * @param string      $object      The object, can be a URI or a value.
224
-	 * @param int         $object_type The object type, either a {@link OBJECT_URI} or a value {@link OBJECT_VALUE}. If set to {@link OBJECT_AUTO}, the Query builder will try to guess.
225
-	 * @param string|null $data_type   The data type (or null).
226
-	 * @param string|null $language    The language code (or null).
227
-	 *
228
-	 * @return $this \Wordlift_Query_Builder The Query builder.
229
-	 */
230
-	public function statement( $subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null ) {
231
-
232
-		// If no value has been provided, we don't set any statement.
233
-		if ( empty( $object ) ) {
234
-			return $this;
235
-		}
236
-
237
-		// Guess the subject type.
238
-		$subject_value_type = $this->guess_subject_type( $subject );
239
-
240
-		// Get the object type if set, otherwise try to guess it.
241
-		$object_value_type = ( self::OBJECT_AUTO === $object_type ? $this->guess_object_type( $predicate, $object ) : $object_type );
242
-
243
-		// Prepare the statement template.
244
-		$template =
245
-			// Subject as a parameter, no `<`, `>`.
246
-			( self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>' ) .
247
-			// Predicate.
248
-			' <%2$s> ' .
249
-			// Object.
250
-			( self::OBJECT_URI === $object_value_type ? '<%3$s>' :
251
-				( self::OBJECT_PARAMETER === $object_value_type ? '%3$s' :
252
-					// self::OBJECT_VALUE === $object_value_type
253
-					'"%3$s"' . ( isset( $data_type ) ? '^^%4$s' : '' ) . ( isset( $language ) ? '@%5$s' : '' ) ) );
254
-
255
-		// Escape the subject, predicate and object.
256
-		$escaped_subject   = Wordlift_Sparql_Service::escape_uri( $subject );
257
-		$escaped_predicate = Wordlift_Sparql_Service::escape_uri( $predicate );
258
-		$escaped_object    = ( self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri( $object ) : Wordlift_Sparql_Service::escape( $object ) );
259
-
260
-		// Prepare the statement and add it to the list of statements.
261
-		$this->statements[] = sprintf( $template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language );
262
-
263
-		return $this;
264
-	}
265
-
266
-	/**
267
-	 * Build the query.
268
-	 *
269
-	 * @since 3.1.7
270
-	 * @return string The query string.
271
-	 */
272
-	public function build() {
273
-
274
-		// If there are no statements return an empty string.
275
-		if ( empty( $this->statements ) ) {
276
-			return '';
277
-		}
278
-
279
-		return sprintf( $this->template, implode( ' . ', $this->statements ) ) . "\n";
280
-	}
281
-
282
-	/**
283
-	 * Guess the statement object type.
284
-	 *
285
-	 * @since 3.1.7
286
-	 *
287
-	 * @param string $predicate The predicate.
288
-	 * @param string $object    The object.
289
-	 *
290
-	 * @return int {@link Wordlift_Query_Builder::OBJECT_URI} if the Query builder thinks the object must be an URI, {@link Wordlift_Query_Builder::OBJECT_VALUE} otherwise.
291
-	 */
292
-	private function guess_object_type( $predicate, $object ) {
293
-
294
-		// If the object starts with a question mark, it's a parameter.
295
-		if ( 0 === strpos( $object, '?' ) ) {
296
-			return self::OBJECT_PARAMETER;
297
-		}
298
-
299
-		// Guess based on the predicate.
300
-		switch ( $predicate ) {
301
-
302
-			case self::DCTERMS_REFERENCES_URI:
303
-			case self::DCTERMS_SUBJECT_URI:
304
-			case self::RDFS_TYPE_URI:
305
-			case self::SCHEMA_AUTHOR_URI:
306
-			case self::SCHEMA_LOCATION_CREATED_URI:
307
-			case self::SCHEMA_URL_URI:
308
-			case self::SCHEMA_IMAGE_URI:
309
-				return self::OBJECT_URI;
310
-
311
-		}
312
-
313
-		return self::OBJECT_VALUE;
314
-	}
315
-
316
-	/**
317
-	 * Guess the subject type.
318
-	 *
319
-	 * @since 3.12.3
320
-	 *
321
-	 * @param string $subject The subject string.
322
-	 *
323
-	 * @return int {@link Wordlift_Query_Builder::OBJECT_PARAMETER} if the Query builder thinks the subject is a parameter (starts with ?), otherwise {@link Wordlift_Query_Builder::OBJECT_URI}.
324
-	 */
325
-	private function guess_subject_type( $subject ) {
326
-
327
-		// If the object starts with a question mark, it's a parameter.
328
-		if ( 0 === strpos( $subject, '?' ) ) {
329
-			return self::OBJECT_PARAMETER;
330
-		}
331
-
332
-		return self::OBJECT_URI;
333
-	}
10
+    /**
11
+     * The INSERT statement template.
12
+     *
13
+     * @since 3.1.7
14
+     */
15
+    const INSERT = 'INSERT DATA { %s };';
16
+
17
+    /**
18
+     * The DELETE statement template (it repeats the statements in the WHERE clause.
19
+     *
20
+     * @since 3.1.7
21
+     */
22
+    const DELETE = 'DELETE { %s } WHERE { %1$s };';
23
+
24
+    /**
25
+     * Tell the statement function to guess the object type (URI, value or parameter).
26
+     *
27
+     * @since 3.1.7
28
+     */
29
+    const OBJECT_AUTO = - 1;
30
+
31
+    /**
32
+     * Tell the statement function that the object is a URI.
33
+     *
34
+     * @since 3.1.7
35
+     */
36
+    const OBJECT_URI = 0;
37
+
38
+    /**
39
+     * Tell the statement function that the object is a value.
40
+     *
41
+     * @since 3.1.7
42
+     */
43
+    const OBJECT_VALUE = 1;
44
+
45
+    /**
46
+     * Tell the statement function that the object is a parameter.
47
+     *
48
+     * @since 3.1.7
49
+     */
50
+    const OBJECT_PARAMETER = 2;
51
+
52
+    /**
53
+     * The RDFS type.
54
+     *
55
+     * @since 3.1.7
56
+     */
57
+    const RDFS_TYPE_URI = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
58
+
59
+    /**
60
+     * The schema.org/Person type.
61
+     *
62
+     * @since 3.1.7
63
+     */
64
+    const SCHEMA_PERSON_URI = 'http://schema.org/Person';
65
+
66
+    /**
67
+     * The schema.org given name predicate.
68
+     *
69
+     * @since 3.1.7
70
+     */
71
+    const SCHEMA_GIVEN_NAME_URI = 'http://schema.org/givenName';
72
+
73
+    /**
74
+     * The schema.org family name predicate.
75
+     *
76
+     * @since 3.1.7
77
+     */
78
+    const SCHEMA_FAMILY_NAME_URI = 'http://schema.org/familyName';
79
+
80
+    /**
81
+     * The schema.org url predicate.
82
+     *
83
+     * @since 3.1.7
84
+     */
85
+    const SCHEMA_URL_URI = 'http://schema.org/url';
86
+
87
+    /**
88
+     * @since 3.14.0
89
+     */
90
+    const SCHEMA_IMAGE_URI = 'http://schema.org/image';
91
+
92
+    /**
93
+     * The location created predicate.
94
+     *
95
+     * @since 3.14.0
96
+     */
97
+    const SCHEMA_LOCATION_CREATED_URI = 'http://schema.org/locationCreated';
98
+
99
+    /**
100
+     * @since 3.14.0
101
+     */
102
+    const SCHEMA_AUTHOR_URI = 'http://schema.org/author';
103
+
104
+    /**
105
+     * @since 3.14.0
106
+     */
107
+    const SCHEMA_INTERACTION_COUNT_URI = 'http://schema.org/interactionCount';
108
+
109
+    /**
110
+     * @since 3.14.0
111
+     */
112
+    const DCTERMS_SUBJECT_URI = 'http://purl.org/dc/terms/subject';
113
+
114
+    /**
115
+     * @since 3.14.0
116
+     */
117
+    const DCTERMS_REFERENCES_URI = 'http://purl.org/dc/terms/references';
118
+
119
+    /**
120
+     * @since 3.15.0
121
+     */
122
+    const DCTERMS_RELATION_URI = 'http://purl.org/dc/terms/relation';
123
+
124
+    /**
125
+     * The RDF label.
126
+     *
127
+     * @since 3.1.7
128
+     */
129
+    const RDFS_LABEL_URI = 'http://www.w3.org/2000/01/rdf-schema#label';
130
+
131
+    /**
132
+     * The schema.org `streetAddress` property.
133
+     *
134
+     * @since 3.18.0
135
+     */
136
+    const SCHEMA_STREET_ADDRESS = 'http://schema.org/streetAddress';
137
+
138
+    /**
139
+     * The schema.org headline.
140
+     *
141
+     * @since 3.18.0
142
+     */
143
+    const SCHEMA_HEADLINE_URI = 'http://schema.org/headline';
144
+
145
+    /**
146
+     * Hold the template (INSERT or DELETE).
147
+     *
148
+     * @since  3.1.7
149
+     * @access private
150
+     * @var string $template The query template.
151
+     */
152
+    private $template;
153
+
154
+    /**
155
+     * An array of statements (in the form of subject, predicate, object).
156
+     *
157
+     * @since  3.1.7
158
+     * @access private
159
+     * @var array $statements An array of statements.
160
+     */
161
+    private $statements = array();
162
+
163
+    /**
164
+     * Create a new instance of the Query builder (compatible with PHP 5.3).
165
+     *
166
+     * @since 3.1.7
167
+     * @return Wordlift_Query_Builder A new instance of the Query builder.
168
+     */
169
+    public static function new_instance() {
170
+
171
+        return new Wordlift_Query_Builder();
172
+    }
173
+
174
+    /**
175
+     * Set the query to INSERT.
176
+     *
177
+     * @since 3.1.7
178
+     * @return Wordlift_Query_Builder The Query builder.
179
+     */
180
+    public function insert() {
181
+
182
+        $this->template = self::INSERT;
183
+
184
+        return $this;
185
+    }
186
+
187
+    /**
188
+     * Set the query to DELETE.
189
+     *
190
+     * @since 3.1.7
191
+     * @return $this \Wordlift_Query_Builder The Query builder.
192
+     */
193
+    public function delete() {
194
+
195
+        $this->template = self::DELETE;
196
+
197
+        return $this;
198
+    }
199
+
200
+    /**
201
+     * Set the query to SELECT.
202
+     *
203
+     * @since 3.12.2
204
+     *
205
+     * @param string $props The list of properties to read.
206
+     *
207
+     * @return $this \Wordlift_Query_Builder The Query builder.
208
+     */
209
+    public function select( $props = '*' ) {
210
+
211
+        $this->template = "SELECT $props WHERE { %s }";
212
+
213
+        return $this;
214
+    }
215
+
216
+    /**
217
+     * Add a statement.
218
+     *
219
+     * @since 3.1.7
220
+     *
221
+     * @param string      $subject     The subject of the statement (must be a URI).
222
+     * @param string      $predicate   The predicate (must be a URI).
223
+     * @param string      $object      The object, can be a URI or a value.
224
+     * @param int         $object_type The object type, either a {@link OBJECT_URI} or a value {@link OBJECT_VALUE}. If set to {@link OBJECT_AUTO}, the Query builder will try to guess.
225
+     * @param string|null $data_type   The data type (or null).
226
+     * @param string|null $language    The language code (or null).
227
+     *
228
+     * @return $this \Wordlift_Query_Builder The Query builder.
229
+     */
230
+    public function statement( $subject, $predicate, $object, $object_type = self::OBJECT_AUTO, $data_type = null, $language = null ) {
231
+
232
+        // If no value has been provided, we don't set any statement.
233
+        if ( empty( $object ) ) {
234
+            return $this;
235
+        }
236
+
237
+        // Guess the subject type.
238
+        $subject_value_type = $this->guess_subject_type( $subject );
239
+
240
+        // Get the object type if set, otherwise try to guess it.
241
+        $object_value_type = ( self::OBJECT_AUTO === $object_type ? $this->guess_object_type( $predicate, $object ) : $object_type );
242
+
243
+        // Prepare the statement template.
244
+        $template =
245
+            // Subject as a parameter, no `<`, `>`.
246
+            ( self::OBJECT_PARAMETER === $subject_value_type ? '%1$s' : '<%1$s>' ) .
247
+            // Predicate.
248
+            ' <%2$s> ' .
249
+            // Object.
250
+            ( self::OBJECT_URI === $object_value_type ? '<%3$s>' :
251
+                ( self::OBJECT_PARAMETER === $object_value_type ? '%3$s' :
252
+                    // self::OBJECT_VALUE === $object_value_type
253
+                    '"%3$s"' . ( isset( $data_type ) ? '^^%4$s' : '' ) . ( isset( $language ) ? '@%5$s' : '' ) ) );
254
+
255
+        // Escape the subject, predicate and object.
256
+        $escaped_subject   = Wordlift_Sparql_Service::escape_uri( $subject );
257
+        $escaped_predicate = Wordlift_Sparql_Service::escape_uri( $predicate );
258
+        $escaped_object    = ( self::OBJECT_URI === $object_value_type ? Wordlift_Sparql_Service::escape_uri( $object ) : Wordlift_Sparql_Service::escape( $object ) );
259
+
260
+        // Prepare the statement and add it to the list of statements.
261
+        $this->statements[] = sprintf( $template, $escaped_subject, $escaped_predicate, $escaped_object, $data_type, $language );
262
+
263
+        return $this;
264
+    }
265
+
266
+    /**
267
+     * Build the query.
268
+     *
269
+     * @since 3.1.7
270
+     * @return string The query string.
271
+     */
272
+    public function build() {
273
+
274
+        // If there are no statements return an empty string.
275
+        if ( empty( $this->statements ) ) {
276
+            return '';
277
+        }
278
+
279
+        return sprintf( $this->template, implode( ' . ', $this->statements ) ) . "\n";
280
+    }
281
+
282
+    /**
283
+     * Guess the statement object type.
284
+     *
285
+     * @since 3.1.7
286
+     *
287
+     * @param string $predicate The predicate.
288
+     * @param string $object    The object.
289
+     *
290
+     * @return int {@link Wordlift_Query_Builder::OBJECT_URI} if the Query builder thinks the object must be an URI, {@link Wordlift_Query_Builder::OBJECT_VALUE} otherwise.
291
+     */
292
+    private function guess_object_type( $predicate, $object ) {
293
+
294
+        // If the object starts with a question mark, it's a parameter.
295
+        if ( 0 === strpos( $object, '?' ) ) {
296
+            return self::OBJECT_PARAMETER;
297
+        }
298
+
299
+        // Guess based on the predicate.
300
+        switch ( $predicate ) {
301
+
302
+            case self::DCTERMS_REFERENCES_URI:
303
+            case self::DCTERMS_SUBJECT_URI:
304
+            case self::RDFS_TYPE_URI:
305
+            case self::SCHEMA_AUTHOR_URI:
306
+            case self::SCHEMA_LOCATION_CREATED_URI:
307
+            case self::SCHEMA_URL_URI:
308
+            case self::SCHEMA_IMAGE_URI:
309
+                return self::OBJECT_URI;
310
+
311
+        }
312
+
313
+        return self::OBJECT_VALUE;
314
+    }
315
+
316
+    /**
317
+     * Guess the subject type.
318
+     *
319
+     * @since 3.12.3
320
+     *
321
+     * @param string $subject The subject string.
322
+     *
323
+     * @return int {@link Wordlift_Query_Builder::OBJECT_PARAMETER} if the Query builder thinks the subject is a parameter (starts with ?), otherwise {@link Wordlift_Query_Builder::OBJECT_URI}.
324
+     */
325
+    private function guess_subject_type( $subject ) {
326
+
327
+        // If the object starts with a question mark, it's a parameter.
328
+        if ( 0 === strpos( $subject, '?' ) ) {
329
+            return self::OBJECT_PARAMETER;
330
+        }
331
+
332
+        return self::OBJECT_URI;
333
+    }
334 334
 
335 335
 }
Please login to merge, or discard this patch.
src/includes/linked-data/rendition/intf-wordlift-sparql-tuple-rendition.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@
 block discarded – undo
11 11
  * Define the {@link Wordlift_Sparql_Tuple_Rendition} interface.
12 12
  */
13 13
 interface Wordlift_Sparql_Tuple_Rendition {
14
-	/**
15
-	 * Get tuple representations for the specified {@link WP_Post}.
16
-	 *
17
-	 * @since 3.18.0
18
-	 *
19
-	 * @param int $post_id The {@link WP_Post}'s id.
20
-	 *
21
-	 * @return array An array of triples.
22
-	 */
23
-	public function get_insert_triples( $post_id );
14
+    /**
15
+     * Get tuple representations for the specified {@link WP_Post}.
16
+     *
17
+     * @since 3.18.0
18
+     *
19
+     * @param int $post_id The {@link WP_Post}'s id.
20
+     *
21
+     * @return array An array of triples.
22
+     */
23
+    public function get_insert_triples( $post_id );
24 24
 
25
-	/**
26
-	 * Get delete statement for current post uri.
27
-	 *
28
-	 * @since 3.18.0
29
-	 *
30
-	 * @param int $post_id The post id.
31
-	 *
32
-	 * @return array An array of delete triples (`<...> <...> ?o` and `?s <...> <...>`).
33
-	 */
34
-	public function get_delete_triples( $post_id );
25
+    /**
26
+     * Get delete statement for current post uri.
27
+     *
28
+     * @since 3.18.0
29
+     *
30
+     * @param int $post_id The post id.
31
+     *
32
+     * @return array An array of delete triples (`<...> <...> ?o` and `?s <...> <...>`).
33
+     */
34
+    public function get_delete_triples( $post_id );
35 35
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return array An array of triples.
22 22
 	 */
23
-	public function get_insert_triples( $post_id );
23
+	public function get_insert_triples($post_id);
24 24
 
25 25
 	/**
26 26
 	 * Get delete statement for current post uri.
@@ -31,5 +31,5 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return array An array of delete triples (`<...> <...> ?o` and `?s <...> <...>`).
33 33
 	 */
34
-	public function get_delete_triples( $post_id );
34
+	public function get_delete_triples($post_id);
35 35
 }
Please login to merge, or discard this patch.