5
5
* Plugin URI: https://pixelalbatross.pt/?utm_source=wp-plugins&utm_medium=accordion-block&utm_campaign=plugin-uri
6
6
* Requires at least: 6.1
7
7
* Requires PHP: 7.4
8
- * Version: 0.6 .0
8
+ * Version: 0.7 .0
9
9
* Author: Pixel Albatross
10
10
* Author URI: https://pixelalbatross.pt/?utm_source=wp-plugins&utm_medium=accordion-block&utm_campaign=author-uri
11
11
* License: GPL-2.0-or-later
17
17
* @package pixelalbatross/accordion-block
18
18
*/
19
19
20
+ namespace PixelAlbatross \WP \AccordionBlock ;
21
+
22
+ use YahnisElsts \PluginUpdateChecker \v5 \PucFactory ;
23
+
20
24
// If this file is called directly, abort.
21
25
if ( ! defined ( 'WPINC ' ) ) {
22
26
die;
23
27
}
24
28
25
- define ( 'PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH ' , plugin_dir_path ( __FILE__ ) );
29
+ define ( 'PIXALB_ACCORDION_BLOCK_PATH ' , plugin_dir_path ( __FILE__ ) );
30
+
31
+ if ( file_exists ( PIXALB_ACCORDION_BLOCK_PATH . 'vendor/autoload.php ' ) ) {
32
+ require_once PIXALB_ACCORDION_BLOCK_PATH . 'vendor/autoload.php ' ;
33
+ }
34
+
35
+ $ updater = PucFactory::buildUpdateChecker (
36
+ 'https://github.com/pixelalbatross/accordion-block/ ' ,
37
+ __FILE__ ,
38
+ 'accordion-block '
39
+ );
40
+
41
+ $ updater ->setBranch ( 'main ' );
26
42
27
43
/**
28
44
* Registers the block using the metadata loaded from the `block.json` file.
31
47
*
32
48
* @see https://developer.wordpress.org/reference/functions/register_block_type/
33
49
*/
34
- function pixelalbatross_accordion_block_init () {
50
+ function accordion_block_init () {
35
51
36
- $ block_json_files = glob ( PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH . 'build/*/block.json ' );
52
+ $ block_json_files = glob ( PIXALB_ACCORDION_BLOCK_PATH . 'build/*/block.json ' );
37
53
38
54
foreach ( $ block_json_files as $ filename ) {
39
55
@@ -45,30 +61,30 @@ function pixelalbatross_accordion_block_init() {
45
61
wp_set_script_translations (
46
62
$ handle ,
47
63
'accordion-block ' ,
48
- PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH . 'languages '
64
+ PIXALB_ACCORDION_BLOCK_PATH . 'languages '
49
65
);
50
66
}
51
67
}
52
68
}
53
69
}
54
- add_action ( 'init ' , ' pixelalbatross_accordion_block_init ' );
70
+ add_action ( 'init ' , __NAMESPACE__ . ' \accordion_block_init ' );
55
71
56
72
/**
57
73
* Registers the block textdomain.
58
74
*
59
75
* @return void
60
76
*/
61
- function pixelalbatross_accordion_block_i18n () {
62
- load_plugin_textdomain ( 'accordion-block ' , false , plugin_basename ( PIXELALBATROSS_ACCORDION_BLOCK_PLUGIN_PATH ) . '/languages ' );
77
+ function accordion_block_i18n () {
78
+ load_plugin_textdomain ( 'accordion-block ' , false , plugin_basename ( PIXALB_ACCORDION_BLOCK_PATH ) . '/languages ' );
63
79
}
64
- add_action ( 'plugins_loaded ' , ' pixelalbatross_accordion_block_i18n ' );
80
+ add_action ( 'plugins_loaded ' , __NAMESPACE__ . ' \accordion_block_i18n ' );
65
81
66
82
/**
67
83
* Handles JavaScript detection.
68
84
*
69
85
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
70
86
*/
71
- function pixelalbatross_accordion_block_js_detection () {
87
+ function accordion_block_js_detection () {
72
88
echo "<script>!function(s){s.classList.contains('js')?s.classList:s.classList.add('js')}(document.documentElement);</script> \n" ;
73
89
}
74
- add_action ( 'wp_head ' , ' pixelalbatross_accordion_block_js_detection ' , 0 );
90
+ add_action ( 'wp_head ' , __NAMESPACE__ . ' \accordion_block_js_detection ' , 0 );
0 commit comments