1 | <?php |
||
8 | class Jetpack_Gallery_Settings { |
||
9 | function __construct() { |
||
12 | |||
13 | function admin_init() { |
||
34 | |||
35 | /** |
||
36 | * Updates the schema of the core gallery widget so we can save the |
||
37 | * fields that we add to Gallery Widgets, like `type` and `conditions` |
||
38 | * |
||
39 | * @param $schema The current schema for the core gallery widget |
||
40 | * |
||
41 | * @return array the updated schema |
||
42 | */ |
||
43 | public function core_media_widget_compat( $schema ) { |
||
52 | |||
53 | /** |
||
54 | * Registers/enqueues the gallery settings admin js. |
||
55 | */ |
||
56 | function wp_enqueue_media() { |
||
57 | if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) ) { |
||
58 | /** |
||
59 | * This only happens if we're not in Jetpack, but on WPCOM instead. |
||
60 | * This is the correct path for WPCOM. |
||
61 | */ |
||
62 | wp_register_script( |
||
63 | 'jetpack-gallery-settings', |
||
64 | Assets::get_file_url_for_environment( '_inc/build/gallery-settings.min.js', '_inc/gallery-settings.js' ), |
||
65 | array( 'media-views' ), |
||
66 | '20121225' |
||
67 | ); |
||
68 | } |
||
69 | |||
70 | wp_enqueue_script( 'jetpack-gallery-settings' ); |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Outputs a view template which can be used with wp.media.template |
||
75 | */ |
||
76 | function print_media_templates() { |
||
102 | } |
||
103 | new Jetpack_Gallery_Settings; |
||
104 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: