-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbp-profile-field-duplicator.php
97 lines (82 loc) · 2.38 KB
/
bp-profile-field-duplicator.php
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
90
91
92
93
94
95
96
97
<?php
/**
* Plugin Name: BuddyPress Profile Field Duplicator
* Plugin URI: https://bhargavb.com/buddypress-profile-field-duplicator-wordpress-plugin/
* Description: Make a duplicate of BuddyPress profile fields.
* Author: Bunty
* Author URI: https://bhargavb.com/
* Text Domain: bp-profile-field-duplicator
* Domain Path: /languages
* Version: 1.1.0
*
* @package Bp_Profile_Field_Duplicator
*/
/**
* Main file, contains the plugin metadata and activation processes
*
* @package Bp_Profile_Field_Duplicator
*/
if ( ! defined( 'BPPFC_VERSION' ) ) {
/**
* The version of the plugin.
*/
define( 'BPPFC_VERSION', '1.1.0' );
}
if ( ! defined( 'BPPFC_PATH' ) ) {
/**
* The server file system path to the plugin directory.
*/
define( 'BPPFC_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'BPPFC_URL' ) ) {
/**
* The url to the plugin directory.
*/
define( 'BPPFC_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'BPPFC_BASE_NAME' ) ) {
/**
* The url to the plugin directory.
*/
define( 'BPPFC_BASE_NAME', plugin_basename( __FILE__ ) );
}
/**
* Apply transaltion file as per WP language.
*/
function bppfc_text_domain_loader() {
// Get mo file as per current locale.
$mofile = BPPFC_PATH . 'languages/' . get_locale() .'.mo';
// If file does not exists, then applu default mo.
if ( ! file_exists( $mofile ) ) {
$mofile = BPPFC_PATH . 'languages/default.mo';
}
load_textdomain( 'bp-profile-field-duplicator', $mofile );
}
add_action( 'plugins_loaded', 'bppfc_text_domain_loader' );
/**
* Display admin notice if BuddyPress is not activated.
*/
function bppfc_admin_notice__error() {
if ( function_exists( 'bp_is_active' ) ) {
return;
}
// Notice class.
$class = 'notice notice-error';
// Get plugin name.
$plugin_data = get_plugin_data( __FILE__ );
$plugin_name = $plugin_data['Name'];
// Display error if BuddyPress is not active.
$message = sprintf(
__( '%s works with BuddyPress only. Please activate BuddyPress or de-activate %s.', 'bp-profile-field-duplicator' ),
esc_html( $plugin_name ),
esc_html( $plugin_name )
);
printf(
'<div class="%1$s"><p>%2$s</p></div>',
esc_attr( $class ),
esc_html( $message )
);
}
add_action( 'admin_notices', 'bppfc_admin_notice__error' );
// Include admin functions file.
require BPPFC_PATH . 'app/admin/class-bp-profile-field-duplicator-admin.php';