-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-locale-setup.php
More file actions
68 lines (61 loc) · 2.11 KB
/
wp-locale-setup.php
File metadata and controls
68 lines (61 loc) · 2.11 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
<?php
/**
* Plugin Name: setup local language.
* Plugin URI: https://www.example.com
* Description: To change wordpress local language, admin side and frontend.
* Version: 0.1
* Author: Muhammed Shafaf
* Author URI: https://muhammad-shafaf123.github.io/personal/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if(!class_exists("wp_locale_root_class")){
class wp_locale_root_class{
public function __construct(){
add_action( 'init', array($this,'load_textdomain' ));
add_filter('the_content', array($this, 'the_content_callback'));
add_action('admin_menu', array($this, 'wp_locale_menu_setup'));
add_action('admin_notices', array($this, 'show_motivation_text'));
}
public function wp_locale_menu_setup(){
add_menu_page('Locale Admin', 'locale title', 'manage_options', 'translator_settings', array($this, 'locale_text_disaplay'));
}
public function locale_text_disaplay(){
echo __('hello world','wp-locale-setup');
}
public function the_content_callback($content){
$locale_text = "Hello world";
return $locale_text.$content;
}
public function get_motivation_text(){
$motivation = array(
__( 'You are awesome', 'wp-locale-setup'),
__( 'This website is boss', 'wp-locale-setup'),
__( 'You look great today', 'wp-locale-setup'),
__( 'Your earlobes are well rounded, good job!, 'wp-locale-setup')
);
shuffle( $motivation );
return $motivation[0];
}
public function show_motivation_text(){
$text = $this->get_motivation_text();
$this->write_log($text);
echo "<p id='wp-admin-motivation'>$text</p>";
}
public function load_textdomain(){
load_plugin_textdomain( 'plugin_translator', false, basename( dirname( __FILE__ ) ) . '/language/' );
}
public function write_log ( $log ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
}
}
new wp_locale_root_class;
?>