Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

Commit 10828e2

Browse files
committed
PHP fixes.
Changed a couple + to . for strings (doh!) And updated translate calls to not use variables because it's not kosher. https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#text-domains
1 parent 8e07ab9 commit 10828e2

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

wp-rest-api-plugin-jquery-example.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,17 @@ public function load_plugin_textdomain() {
5454
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
5555
$mo_file = $domain . '-' . get_locale() . '.mo';
5656

57-
load_textdomain( $domain, WP_LANG_DIR . '/' + $domain + '/' . $mo_file );
57+
load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $mo_file );
5858
load_plugin_textdomain( $domain, false, plugin_basename( dirname( __FILE__ ) ) . '/languages/' );
5959
}
6060

6161
/**
6262
* Attaches the admin menu we'll use for our plugin.
6363
*/
6464
public function attach_menu() {
65-
$domain = REST_API_Plugin_JQuery_Example::TEXT_DOMAIN;
66-
6765
add_menu_page(
68-
__( 'REST API Plugin Example Using jQuery', $domain ),
69-
__( 'REST API Example', $domain ),
66+
__( 'REST API Plugin Example Using jQuery', 'rest-api-plugin-jquery-example' ),
67+
__( 'REST API Example', 'rest-api-plugin-jquery-example' ),
7068
'read',
7169
'rest-api-plugin-jquery-example',
7270
array( $this, 'output_page' ),
@@ -79,8 +77,6 @@ public function attach_menu() {
7977
* Outputs the scripts and html for our page.
8078
*/
8179
public function output_page() {
82-
$domain = REST_API_Plugin_JQuery_Example::TEXT_DOMAIN;
83-
8480
wp_enqueue_script( 'jquery' );
8581

8682
wp_enqueue_script(
@@ -95,26 +91,26 @@ public function output_page() {
9591
'api_root' => esc_url_raw( rest_url() ),
9692
'api_nonce' => wp_create_nonce( 'wp_rest' ),
9793
'i18n' => array(
98-
'post' => __( 'Post', $domain ),
99-
'author' => __( 'Author', $domain ),
100-
'status' => __( 'Status', $domain ),
101-
'publish' => __( 'Published', $domain ),
102-
'future' => __( 'Scheduled', $domain ),
103-
'draft' => __( 'Draft', $domain ),
104-
'pending' => __( 'Pending Review', $domain ),
105-
'private' => __( 'Private', $domain ),
106-
'loading' => __( '(loading)', $domain ),
94+
'post' => __( 'Post', 'rest-api-plugin-jquery-example' ),
95+
'author' => __( 'Author', 'rest-api-plugin-jquery-example' ),
96+
'status' => __( 'Status', 'rest-api-plugin-jquery-example' ),
97+
'publish' => __( 'Published', 'rest-api-plugin-jquery-example' ),
98+
'future' => __( 'Scheduled', 'rest-api-plugin-jquery-example' ),
99+
'draft' => __( 'Draft', 'rest-api-plugin-jquery-example' ),
100+
'pending' => __( 'Pending Review', 'rest-api-plugin-jquery-example' ),
101+
'private' => __( 'Private', 'rest-api-plugin-jquery-example' ),
102+
'loading' => __( '(loading)', 'rest-api-plugin-jquery-example' ),
107103
)
108104
) );
109105

110106
?>
111107
<div class="rest-api-example">
112-
<h1><?php _e( 'REST API Plugin Example Using jQuery', $domain ) ?></h1>
113-
<p><?php _e( 'This is the example page for using the REST API from a plugin using jQuery!', $domain ) ?></p>
108+
<h1><?php _e( 'REST API Plugin Example Using jQuery', 'rest-api-plugin-jquery-example' ) ?></h1>
109+
<p><?php _e( 'This is the example page for using the REST API from a plugin using jQuery!', 'rest-api-plugin-jquery-example' ) ?></p>
114110
<div id="post-search">
115111
<form id="search-form" class="search">
116112
<label>
117-
<?php _e( 'Search Posts:', $domain ) ?>
113+
<?php _e( 'Search Posts:', 'rest-api-plugin-jquery-example' ) ?>
118114
<input id="search-box" type="search"></input>
119115
</label>
120116
<span id="search-message"></span>

0 commit comments

Comments
 (0)