1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace lloc\Msls\ContentImport; |
4
|
|
|
|
5
|
|
|
use lloc\Msls\ContentImport\LogWriters\AdminNoticeLogger; |
6
|
|
|
use lloc\Msls\MslsOptions; |
7
|
|
|
use lloc\Msls\MslsRegistryInstance; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class Service |
11
|
|
|
* |
12
|
|
|
* A service provider for the content import functionality. |
13
|
|
|
* |
14
|
|
|
* @package lloc\Msls\ContentImport |
15
|
|
|
*/ |
16
|
|
|
class Service extends MslsRegistryInstance { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Hooks the classes that provide the content import functionality if the content import option is active. |
20
|
|
|
* |
21
|
|
|
* @return bool Whether the content import functionality support classes where hooked or not. |
22
|
|
|
*/ |
23
|
|
|
public function register() { |
24
|
|
|
if ( ! MslsOptions::instance()->activate_content_import ) { |
|
|
|
|
25
|
|
|
return false; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
$this->hook(); |
29
|
|
|
|
30
|
|
|
return true; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Hooks the filters and actions for this service provider. |
35
|
|
|
* |
36
|
|
|
* Differently from the `register` method this method will not check for options to hook. |
37
|
|
|
*/ |
38
|
|
|
public function hook() { |
39
|
|
|
add_action( 'load-post.php', function () { |
40
|
|
|
return ContentImporter::instance()->handle_import(); |
41
|
|
|
} ); |
42
|
|
|
add_action( 'load-post.php', function () { |
43
|
|
|
add_action( 'admin_notices', function () { |
44
|
|
|
AdminNoticeLogger::instance()->show_last_log(); |
45
|
|
|
} ); |
46
|
|
|
} ); |
47
|
|
|
add_action( 'load-post-new.php', function () { |
48
|
|
|
return ContentImporter::instance()->handle_import(); |
49
|
|
|
} ); |
50
|
|
|
add_filter( 'wp_insert_post_empty_content', function ( $empty ) { |
51
|
|
|
return ContentImporter::instance()->filter_empty( $empty ); |
52
|
|
|
} ); |
53
|
|
|
add_filter( 'wp_get_attachment_url', function ( $url, $post_id ) { |
54
|
|
|
return AttachmentPathFinder::instance()->filter_attachment_url( $url, $post_id ); |
55
|
|
|
}, 99, 2 ); |
56
|
|
|
add_filter( 'wp_calculate_image_srcset', function ( $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ) { |
57
|
|
|
return AttachmentPathFinder::instance()->filter_srcset( $sources, $sizeArray, $imageSrc, $imageMeta, $attachmentId ); |
58
|
|
|
}, 99, 5 ); |
59
|
|
|
|
60
|
|
|
if ( is_admin() ) { |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
} |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.