-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimed-visibility-block.php
More file actions
89 lines (77 loc) · 2.37 KB
/
Copy pathtimed-visibility-block.php
File metadata and controls
89 lines (77 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Plugin Name: Timed Visibility Block
* Description: Control when your content shines. Perfect for announcements, promotions, and time-sensitive information!
* Version: 1.0.0
* Requires at least: 6.6
* Requires PHP: 7.4
* Author: Hackkzy
* Author URI: https://github.com/Hackkzy
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: timed-visibility-block
*
* @package Timed_Visibility_Block
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Defining Constants.
*
* @package Timed_Visibility_Block
*/
if ( ! defined( 'TIMED_VBLCK_VERSION' ) ) {
/**
* The version of the plugin.
*/
define( 'TIMED_VBLCK_VERSION', '1.0.0' );
}
if ( ! defined( 'TIMED_VBLCK_PATH' ) ) {
/**
* The server file system path to the plugin directory.
*/
define( 'TIMED_VBLCK_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'TIMED_VBLCK_URL' ) ) {
/**
* The url to the plugin directory.
*/
define( 'TIMED_VBLCK_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'TIMED_VBLCK_BASE_NAME' ) ) {
/**
* The url to the plugin directory.
*/
define( 'TIMED_VBLCK_BASE_NAME', plugin_basename( __FILE__ ) );
}
/**
* Sets translated strings for a script.
*
* @return void
*/
function timed_vblck_script_translations() {
wp_set_script_translations( 'timed-vblck-timed-visibility-block-editor-script', 'timed-visibility-block' );
}
add_action( 'init', 'timed_vblck_script_translations' );
/**
* Apply translation file as per WP language.
*/
function timed_vblck_text_domain_loader() {
// Get mo file as per current locale.
$mofile = trailingslashit( TIMED_VBLCK_PATH ) . 'languages/' . get_locale() . '.mo';
// If file does not exists, then apply default mo.
if ( ! file_exists( $mofile ) ) {
$mofile = trailingslashit( TIMED_VBLCK_PATH ) . 'languages/default.mo';
}
load_textdomain( 'timed-visibility-block', $mofile );
}
add_action( 'plugins_loaded', 'timed_vblck_text_domain_loader' );
/**
* Registers the Timed Visibility Block using the metadata loaded from the `block.json` file.
*/
function timed_vblck_block_init() {
register_block_type( __DIR__ . '/build/timed-visibility-block' );
}
add_action( 'init', 'timed_vblck_block_init' );
require_once trailingslashit( TIMED_VBLCK_PATH ) . 'app/includes/common-functions.php';