@@ -6,48 +6,48 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Sync_Hooks_Wordpress_Ontology { |
| 8 | 8 | |
| 9 | - const HTTP_PURL_ORG_WORDPRESS_1_0 = 'http://purl.org/wordpress/1.0/'; |
|
| 9 | + const HTTP_PURL_ORG_WORDPRESS_1_0 = 'http://purl.org/wordpress/1.0/'; |
|
| 10 | 10 | |
| 11 | - public function __construct() { |
|
| 12 | - add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 ); |
|
| 13 | - } |
|
| 11 | + public function __construct() { |
|
| 12 | + add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 ); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - public function jsonld( $jsonld, $type, $object_id ) { |
|
| 15 | + public function jsonld( $jsonld, $type, $object_id ) { |
|
| 16 | 16 | |
| 17 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'id' ] = $object_id; |
|
| 17 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'id' ] = $object_id; |
|
| 18 | 18 | |
| 19 | - switch ( $type ) { |
|
| 19 | + switch ( $type ) { |
|
| 20 | 20 | |
| 21 | - case Object_Type_Enum::TERM: |
|
| 22 | - $term = get_term( $object_id ); |
|
| 21 | + case Object_Type_Enum::TERM: |
|
| 22 | + $term = get_term( $object_id ); |
|
| 23 | 23 | |
| 24 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'term'; |
|
| 25 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'name' ] = $term->name; |
|
| 26 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'description' ] = $term->description; |
|
| 27 | - break; |
|
| 24 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'term'; |
|
| 25 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'name' ] = $term->name; |
|
| 26 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'description' ] = $term->description; |
|
| 27 | + break; |
|
| 28 | 28 | |
| 29 | - case Object_Type_Enum::USER: |
|
| 30 | - $user = get_userdata( $object_id ); |
|
| 29 | + case Object_Type_Enum::USER: |
|
| 30 | + $user = get_userdata( $object_id ); |
|
| 31 | 31 | |
| 32 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'user'; |
|
| 33 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'displayName' ] = $user->display_name; |
|
| 34 | - break; |
|
| 32 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'user'; |
|
| 33 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'displayName' ] = $user->display_name; |
|
| 34 | + break; |
|
| 35 | 35 | |
| 36 | - case Object_Type_Enum::POST: |
|
| 37 | - $post = get_post( $object_id ); |
|
| 36 | + case Object_Type_Enum::POST: |
|
| 37 | + $post = get_post( $object_id ); |
|
| 38 | 38 | |
| 39 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'post'; |
|
| 40 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'customType' ] = $post->post_type; |
|
| 41 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'title' ] = $post->post_title; |
|
| 42 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'status' ] = $post->post_status; |
|
| 43 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'content' ] = do_shortcode( $post->post_content ); |
|
| 44 | - break; |
|
| 39 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'post'; |
|
| 40 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'customType' ] = $post->post_type; |
|
| 41 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'title' ] = $post->post_title; |
|
| 42 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'status' ] = $post->post_status; |
|
| 43 | + $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'content' ] = do_shortcode( $post->post_content ); |
|
| 44 | + break; |
|
| 45 | 45 | |
| 46 | - default: |
|
| 46 | + default: |
|
| 47 | 47 | |
| 48 | - } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $jsonld; |
|
| 51 | - } |
|
| 50 | + return $jsonld; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | } |
@@ -9,38 +9,38 @@ |
||
| 9 | 9 | const HTTP_PURL_ORG_WORDPRESS_1_0 = 'http://purl.org/wordpress/1.0/'; |
| 10 | 10 | |
| 11 | 11 | public function __construct() { |
| 12 | - add_filter( 'wl_dataset__sync_service__sync_item__jsonld', array( $this, 'jsonld' ), 10, 3 ); |
|
| 12 | + add_filter('wl_dataset__sync_service__sync_item__jsonld', array($this, 'jsonld'), 10, 3); |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function jsonld( $jsonld, $type, $object_id ) { |
|
| 15 | + public function jsonld($jsonld, $type, $object_id) { |
|
| 16 | 16 | |
| 17 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'id' ] = $object_id; |
|
| 17 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'id'] = $object_id; |
|
| 18 | 18 | |
| 19 | - switch ( $type ) { |
|
| 19 | + switch ($type) { |
|
| 20 | 20 | |
| 21 | 21 | case Object_Type_Enum::TERM: |
| 22 | - $term = get_term( $object_id ); |
|
| 22 | + $term = get_term($object_id); |
|
| 23 | 23 | |
| 24 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'term'; |
|
| 25 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'name' ] = $term->name; |
|
| 26 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'description' ] = $term->description; |
|
| 24 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'type'] = 'term'; |
|
| 25 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'name'] = $term->name; |
|
| 26 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'description'] = $term->description; |
|
| 27 | 27 | break; |
| 28 | 28 | |
| 29 | 29 | case Object_Type_Enum::USER: |
| 30 | - $user = get_userdata( $object_id ); |
|
| 30 | + $user = get_userdata($object_id); |
|
| 31 | 31 | |
| 32 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'user'; |
|
| 33 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'displayName' ] = $user->display_name; |
|
| 32 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'type'] = 'user'; |
|
| 33 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'displayName'] = $user->display_name; |
|
| 34 | 34 | break; |
| 35 | 35 | |
| 36 | 36 | case Object_Type_Enum::POST: |
| 37 | - $post = get_post( $object_id ); |
|
| 37 | + $post = get_post($object_id); |
|
| 38 | 38 | |
| 39 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'type' ] = 'post'; |
|
| 40 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'customType' ] = $post->post_type; |
|
| 41 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'title' ] = $post->post_title; |
|
| 42 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'status' ] = $post->post_status; |
|
| 43 | - $jsonld[0][ self::HTTP_PURL_ORG_WORDPRESS_1_0 . 'content' ] = do_shortcode( $post->post_content ); |
|
| 39 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'type'] = 'post'; |
|
| 40 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'customType'] = $post->post_type; |
|
| 41 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'title'] = $post->post_title; |
|
| 42 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'status'] = $post->post_status; |
|
| 43 | + $jsonld[0][self::HTTP_PURL_ORG_WORDPRESS_1_0.'content'] = do_shortcode($post->post_content); |
|
| 44 | 44 | break; |
| 45 | 45 | |
| 46 | 46 | default: |
@@ -6,56 +6,56 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Sync_Background_Process_Wpjson_Endpoint { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * @var Sync_Background_Process |
|
| 11 | - */ |
|
| 12 | - private $sync_background_process; |
|
| 9 | + /** |
|
| 10 | + * @var Sync_Background_Process |
|
| 11 | + */ |
|
| 12 | + private $sync_background_process; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Sync_Background_Process_Wpjson_Endpoint constructor. |
|
| 16 | - * |
|
| 17 | - * @param Sync_Background_Process $sync_background_process |
|
| 18 | - */ |
|
| 19 | - function __construct( $sync_background_process ) { |
|
| 14 | + /** |
|
| 15 | + * Sync_Background_Process_Wpjson_Endpoint constructor. |
|
| 16 | + * |
|
| 17 | + * @param Sync_Background_Process $sync_background_process |
|
| 18 | + */ |
|
| 19 | + function __construct( $sync_background_process ) { |
|
| 20 | 20 | |
| 21 | - add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
|
| 21 | + add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
|
| 22 | 22 | |
| 23 | - $this->sync_background_process = $sync_background_process; |
|
| 23 | + $this->sync_background_process = $sync_background_process; |
|
| 24 | 24 | |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - function rest_api_init() { |
|
| 27 | + function rest_api_init() { |
|
| 28 | 28 | |
| 29 | - register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 30 | - 'methods' => WP_REST_Server::CREATABLE, |
|
| 31 | - 'callback' => array( $this->sync_background_process, 'start' ), |
|
| 32 | - 'permission_callback' => function () { |
|
| 33 | - $user = wp_get_current_user(); |
|
| 29 | + register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 30 | + 'methods' => WP_REST_Server::CREATABLE, |
|
| 31 | + 'callback' => array( $this->sync_background_process, 'start' ), |
|
| 32 | + 'permission_callback' => function () { |
|
| 33 | + $user = wp_get_current_user(); |
|
| 34 | 34 | |
| 35 | - return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 36 | - } |
|
| 37 | - ) ); |
|
| 35 | + return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 36 | + } |
|
| 37 | + ) ); |
|
| 38 | 38 | |
| 39 | - register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 40 | - 'methods' => WP_REST_Server::READABLE, |
|
| 41 | - 'callback' => array( $this->sync_background_process, 'get_info' ), |
|
| 42 | - 'permission_callback' => function () { |
|
| 43 | - $user = wp_get_current_user(); |
|
| 39 | + register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 40 | + 'methods' => WP_REST_Server::READABLE, |
|
| 41 | + 'callback' => array( $this->sync_background_process, 'get_info' ), |
|
| 42 | + 'permission_callback' => function () { |
|
| 43 | + $user = wp_get_current_user(); |
|
| 44 | 44 | |
| 45 | - return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 46 | - } |
|
| 47 | - ) ); |
|
| 45 | + return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 46 | + } |
|
| 47 | + ) ); |
|
| 48 | 48 | |
| 49 | - register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 50 | - 'methods' => WP_REST_Server::DELETABLE, |
|
| 51 | - 'callback' => array( $this->sync_background_process, 'stop' ), |
|
| 52 | - 'permission_callback' => function () { |
|
| 53 | - $user = wp_get_current_user(); |
|
| 49 | + register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 50 | + 'methods' => WP_REST_Server::DELETABLE, |
|
| 51 | + 'callback' => array( $this->sync_background_process, 'stop' ), |
|
| 52 | + 'permission_callback' => function () { |
|
| 53 | + $user = wp_get_current_user(); |
|
| 54 | 54 | |
| 55 | - return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 56 | - } |
|
| 57 | - ) ); |
|
| 55 | + return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 56 | + } |
|
| 57 | + ) ); |
|
| 58 | 58 | |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | } |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @param Sync_Background_Process $sync_background_process |
| 18 | 18 | */ |
| 19 | - function __construct( $sync_background_process ) { |
|
| 19 | + function __construct($sync_background_process) { |
|
| 20 | 20 | |
| 21 | - add_action( 'rest_api_init', array( $this, 'rest_api_init' ) ); |
|
| 21 | + add_action('rest_api_init', array($this, 'rest_api_init')); |
|
| 22 | 22 | |
| 23 | 23 | $this->sync_background_process = $sync_background_process; |
| 24 | 24 | |
@@ -26,35 +26,35 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | function rest_api_init() { |
| 28 | 28 | |
| 29 | - register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 29 | + register_rest_route('wordlift/v1', '/dataset/background/sync', array( |
|
| 30 | 30 | 'methods' => WP_REST_Server::CREATABLE, |
| 31 | - 'callback' => array( $this->sync_background_process, 'start' ), |
|
| 32 | - 'permission_callback' => function () { |
|
| 31 | + 'callback' => array($this->sync_background_process, 'start'), |
|
| 32 | + 'permission_callback' => function() { |
|
| 33 | 33 | $user = wp_get_current_user(); |
| 34 | 34 | |
| 35 | - return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 35 | + return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles); |
|
| 36 | 36 | } |
| 37 | - ) ); |
|
| 37 | + )); |
|
| 38 | 38 | |
| 39 | - register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 39 | + register_rest_route('wordlift/v1', '/dataset/background/sync', array( |
|
| 40 | 40 | 'methods' => WP_REST_Server::READABLE, |
| 41 | - 'callback' => array( $this->sync_background_process, 'get_info' ), |
|
| 42 | - 'permission_callback' => function () { |
|
| 41 | + 'callback' => array($this->sync_background_process, 'get_info'), |
|
| 42 | + 'permission_callback' => function() { |
|
| 43 | 43 | $user = wp_get_current_user(); |
| 44 | 44 | |
| 45 | - return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 45 | + return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles); |
|
| 46 | 46 | } |
| 47 | - ) ); |
|
| 47 | + )); |
|
| 48 | 48 | |
| 49 | - register_rest_route( 'wordlift/v1', '/dataset/background/sync', array( |
|
| 49 | + register_rest_route('wordlift/v1', '/dataset/background/sync', array( |
|
| 50 | 50 | 'methods' => WP_REST_Server::DELETABLE, |
| 51 | - 'callback' => array( $this->sync_background_process, 'stop' ), |
|
| 52 | - 'permission_callback' => function () { |
|
| 51 | + 'callback' => array($this->sync_background_process, 'stop'), |
|
| 52 | + 'permission_callback' => function() { |
|
| 53 | 53 | $user = wp_get_current_user(); |
| 54 | 54 | |
| 55 | - return is_super_admin( $user->ID ) || in_array( 'administrator', (array) $user->roles ); |
|
| 55 | + return is_super_admin($user->ID) || in_array('administrator', (array) $user->roles); |
|
| 56 | 56 | } |
| 57 | - ) ); |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | |