Version Description
Avoid wpdb->prepare warning Minor admin fixes, don't double translate strings
Download this release
Release Info
Developer | leewillis77 |
Plugin | Say what? |
Version | 0.9.2 |
Comparing to | |
See all releases |
Code changes from version 0.9.1 to 0.9.2
- html/say_what_admin_addedit.php +9 -9
- readme.txt +7 -3
- say-what-admin.php +12 -3
- say-what-frontend.php +7 -1
- say-what-list-table.class.php +25 -4
- say-what-settings.php +7 -1
- say-what.php +6 -3
html/say_what_admin_addedit.php
CHANGED
@@ -1,24 +1,24 @@
|
|
1 |
|
2 |
<div class="wrap">
|
3 |
<div id="icon-tools" class="icon32"></div>
|
4 |
-
<h2><?php _e
|
5 |
|
6 |
<form action="tools.php?page=say_what_admin&say_what_action=addedit" method="post">
|
7 |
<input type="hidden" name="say_what_save" value="1">
|
8 |
<?php wp_nonce_field( 'swaddedit', 'nonce' ); ?>
|
9 |
<?php if ( ! empty ( $replacement->string_id ) ) : ?>
|
10 |
-
<input type="hidden" name="say_what_string_id" value="<?php
|
11 |
<?php endif; ?>
|
12 |
<p>
|
13 |
-
<label for="say_what_orig_string"><?php _e
|
14 |
-
<input type="text" name="say_what_orig_string" size="120" value="<?php
|
15 |
-
<label for="say_what_domain"><?php _e
|
16 |
-
<input type="text" name="say_what_domain" value="<?php
|
17 |
-
<label for="say_what_replacement_string"><?php _e
|
18 |
-
<input type="text" name="say_what_replacement_string" size="120" value="<?php
|
19 |
</p>
|
20 |
<p>
|
21 |
-
<input type="submit" class="button-primary" value="<?php ! empty
|
22 |
</p>
|
23 |
</form>
|
24 |
|
1 |
|
2 |
<div class="wrap">
|
3 |
<div id="icon-tools" class="icon32"></div>
|
4 |
+
<h2><?php _e( 'Text changes', 'say_what' ); ?></h2>
|
5 |
|
6 |
<form action="tools.php?page=say_what_admin&say_what_action=addedit" method="post">
|
7 |
<input type="hidden" name="say_what_save" value="1">
|
8 |
<?php wp_nonce_field( 'swaddedit', 'nonce' ); ?>
|
9 |
<?php if ( ! empty ( $replacement->string_id ) ) : ?>
|
10 |
+
<input type="hidden" name="say_what_string_id" value="<?php echo esc_attr( $replacement->string_id ); ?>">
|
11 |
<?php endif; ?>
|
12 |
<p>
|
13 |
+
<label for="say_what_orig_string"><?php _e( 'Original string', 'say_what' ); ?></label><br/>
|
14 |
+
<input type="text" name="say_what_orig_string" size="120" value="<?php echo esc_attr( $replacement->orig_string ) ?>"><br/>
|
15 |
+
<label for="say_what_domain"><?php _e( 'Domain', 'say_what' ); ?></label><br/>
|
16 |
+
<input type="text" name="say_what_domain" value="<?php echo esc_attr( $replacement->domain ); ?>"><br/>
|
17 |
+
<label for="say_what_replacement_string"><?php _e( 'Replacement string', 'say_what' ); ?></label><br/>
|
18 |
+
<input type="text" name="say_what_replacement_string" size="120" value="<?php echo esc_attr( $replacement->replacement_string ); ?>"><br/>
|
19 |
</p>
|
20 |
<p>
|
21 |
+
<input type="submit" class="button-primary" value="<?php ! empty( $replacement->string_id ) ? _e( 'Update', 'say_what' ) : _e( 'Add', 'say_what' ); ?>">
|
22 |
</p>
|
23 |
</form>
|
24 |
|
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
=== Say what? ===
|
2 |
Contributors: leewillis77
|
3 |
Donate link: http://www.leewillis.co.uk/wordpress-plugins/?utm_source=wordpress&utm_medium=www&utm_campaign=say-what
|
4 |
-
Tags: string, change, translation
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.5.1
|
7 |
-
Stable tag: 0.9.
|
8 |
|
9 |
== Description ==
|
10 |
An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code. Simply enter the current string, and what you want to replace it with and the plugin will automatically do the rest!
|
@@ -38,6 +38,10 @@ You can either have a guess, or checkout the plugin in question's source code, t
|
|
38 |
|
39 |
== Changelog ==
|
40 |
|
|
|
|
|
|
|
|
|
41 |
= 0.9.1 =
|
42 |
Fix issue with fields being swapped when first entered
|
43 |
|
1 |
+
=== Say what? - Easy string replacements ===
|
2 |
Contributors: leewillis77
|
3 |
Donate link: http://www.leewillis.co.uk/wordpress-plugins/?utm_source=wordpress&utm_medium=www&utm_campaign=say-what
|
4 |
+
Tags: string, change, translation, replace, swap, override
|
5 |
Requires at least: 3.5
|
6 |
Tested up to: 3.5.1
|
7 |
+
Stable tag: 0.9.2
|
8 |
|
9 |
== Description ==
|
10 |
An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code. Simply enter the current string, and what you want to replace it with and the plugin will automatically do the rest!
|
38 |
|
39 |
== Changelog ==
|
40 |
|
41 |
+
= 0.9.2 =
|
42 |
+
Avoid wpdb->prepare warning
|
43 |
+
Minor admin fixes, don't double translate strings
|
44 |
+
|
45 |
= 0.9.1 =
|
46 |
Fix issue with fields being swapped when first entered
|
47 |
|
say-what-admin.php
CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) )
|
|
7 |
|
8 |
|
9 |
/**
|
10 |
-
*
|
11 |
*/
|
12 |
class say_what_admin {
|
13 |
|
@@ -15,6 +15,8 @@ class say_what_admin {
|
|
15 |
|
16 |
private $settings;
|
17 |
|
|
|
|
|
18 |
/**
|
19 |
* Constructor
|
20 |
*/
|
@@ -28,6 +30,9 @@ class say_what_admin {
|
|
28 |
|
29 |
|
30 |
|
|
|
|
|
|
|
31 |
public function admin_init() {
|
32 |
|
33 |
if ( isset ( $_POST['say_what_save'] ) ) {
|
@@ -82,7 +87,8 @@ class say_what_admin {
|
|
82 |
*/
|
83 |
public function admin() {
|
84 |
|
85 |
-
|
|
|
86 |
|
87 |
case 'addedit':
|
88 |
$this->admin_addedit();
|
@@ -195,7 +201,7 @@ class say_what_admin {
|
|
195 |
|
196 |
|
197 |
/**
|
198 |
-
* Something on the admin pages needs saved.
|
199 |
* Output error/warning messages as required
|
200 |
*/
|
201 |
private function save() {
|
@@ -248,6 +254,9 @@ class say_what_admin {
|
|
248 |
|
249 |
|
250 |
|
|
|
|
|
|
|
251 |
private function show_current() {
|
252 |
|
253 |
require_once ( 'say-what-list-table.class.php' );
|
7 |
|
8 |
|
9 |
/**
|
10 |
+
* Say What admin class - controller for all of the admin pages
|
11 |
*/
|
12 |
class say_what_admin {
|
13 |
|
15 |
|
16 |
private $settings;
|
17 |
|
18 |
+
|
19 |
+
|
20 |
/**
|
21 |
* Constructor
|
22 |
*/
|
30 |
|
31 |
|
32 |
|
33 |
+
/**
|
34 |
+
* Admin init actions. Takes care of saving stuff before redirects
|
35 |
+
*/
|
36 |
public function admin_init() {
|
37 |
|
38 |
if ( isset ( $_POST['say_what_save'] ) ) {
|
87 |
*/
|
88 |
public function admin() {
|
89 |
|
90 |
+
$action = isset( $_GET['say_what_action'] ) ? $_GET['say_what_action'] : 'list';
|
91 |
+
switch ( $action ) {
|
92 |
|
93 |
case 'addedit':
|
94 |
$this->admin_addedit();
|
201 |
|
202 |
|
203 |
/**
|
204 |
+
* Something on the admin pages needs saved. Handle it here
|
205 |
* Output error/warning messages as required
|
206 |
*/
|
207 |
private function save() {
|
254 |
|
255 |
|
256 |
|
257 |
+
/**
|
258 |
+
* Show the current list of configured replacements.
|
259 |
+
*/
|
260 |
private function show_current() {
|
261 |
|
262 |
require_once ( 'say-what-list-table.class.php' );
|
say-what-frontend.php
CHANGED
@@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) )
|
|
7 |
|
8 |
|
9 |
/**
|
10 |
-
*
|
11 |
*/
|
12 |
class say_what_frontend {
|
13 |
|
@@ -17,6 +17,9 @@ class say_what_frontend {
|
|
17 |
|
18 |
|
19 |
|
|
|
|
|
|
|
20 |
function __construct($settings) {
|
21 |
|
22 |
foreach ( $settings->replacements as $key => $value ) {
|
@@ -33,6 +36,9 @@ class say_what_frontend {
|
|
33 |
|
34 |
|
35 |
|
|
|
|
|
|
|
36 |
function gettext( $translated, $original, $domain ) {
|
37 |
|
38 |
if ( isset ( $this->replacements[$domain][$original] ) ) {
|
7 |
|
8 |
|
9 |
/**
|
10 |
+
* The frontend class, responsible for performing the actual replacements
|
11 |
*/
|
12 |
class say_what_frontend {
|
13 |
|
17 |
|
18 |
|
19 |
|
20 |
+
/**
|
21 |
+
* Read the settings in and put them into a format optimised for the final filter
|
22 |
+
*/
|
23 |
function __construct($settings) {
|
24 |
|
25 |
foreach ( $settings->replacements as $key => $value ) {
|
36 |
|
37 |
|
38 |
|
39 |
+
/**
|
40 |
+
* The main function - optionally perform a string replacement
|
41 |
+
*/
|
42 |
function gettext( $translated, $original, $domain ) {
|
43 |
|
44 |
if ( isset ( $this->replacements[$domain][$original] ) ) {
|
say-what-list-table.class.php
CHANGED
@@ -18,6 +18,9 @@ class say_what_list_table extends WP_List_Table {
|
|
18 |
|
19 |
|
20 |
|
|
|
|
|
|
|
21 |
function __construct ( $settings ) {
|
22 |
|
23 |
$this->settings = $settings;
|
@@ -43,7 +46,7 @@ class say_what_list_table extends WP_List_Table {
|
|
43 |
function get_columns(){
|
44 |
|
45 |
$columns = array(
|
46 |
-
'cb' => 'Checkboxes'
|
47 |
'string_id' => 'String replacement ID (Internal)',
|
48 |
'orig_string' => __( 'Original string', 'say_what' ),
|
49 |
'domain' => __( 'Domain', 'say_what' ),
|
@@ -79,7 +82,7 @@ class say_what_list_table extends WP_List_Table {
|
|
79 |
$sql .= " ORDER BY ".$wpdb->escape ( $_GET['orderby'] );
|
80 |
|
81 |
if ( isset ( $_GET['order'] ) ) {
|
82 |
-
$sql .= " ".$wpdb->
|
83 |
}
|
84 |
|
85 |
} else {
|
@@ -93,6 +96,10 @@ class say_what_list_table extends WP_List_Table {
|
|
93 |
|
94 |
|
95 |
|
|
|
|
|
|
|
|
|
96 |
function get_sortable_columns() {
|
97 |
|
98 |
return array (
|
@@ -104,6 +111,9 @@ class say_what_list_table extends WP_List_Table {
|
|
104 |
|
105 |
|
106 |
|
|
|
|
|
|
|
107 |
function get_bulk_actions() {
|
108 |
|
109 |
// FIXME - implement bulk actions
|
@@ -115,14 +125,19 @@ class say_what_list_table extends WP_List_Table {
|
|
115 |
|
116 |
|
117 |
|
|
|
|
|
|
|
118 |
function column_cb ( $item ) {
|
119 |
|
120 |
-
return sprintf ( '<input type="checkbox" name="string_id[]" value="%d" />', $item['
|
121 |
|
122 |
}
|
123 |
|
124 |
|
125 |
-
|
|
|
|
|
126 |
function column_default ( $item, $column_name ) {
|
127 |
|
128 |
return $item[$column_name];
|
@@ -131,6 +146,9 @@ class say_what_list_table extends WP_List_Table {
|
|
131 |
|
132 |
|
133 |
|
|
|
|
|
|
|
134 |
function column_edit_links ( $item ) {
|
135 |
|
136 |
return '<a href="tools.php?page=say_what_admin&say_what_action=addedit&id='.urlencode($item['string_id']).'&nonce='.urlencode(wp_create_nonce('swaddedit')).'">'.__( 'Edit', 'say_what').'</a>';
|
@@ -139,6 +157,9 @@ class say_what_list_table extends WP_List_Table {
|
|
139 |
|
140 |
|
141 |
|
|
|
|
|
|
|
142 |
function column_delete_links ( $item ) {
|
143 |
|
144 |
return '<a href="tools.php?page=say_what_admin&say_what_action=delete&id='.urlencode($item['string_id']).'&nonce='.urlencode(wp_create_nonce('swdelete')).'">'.__( 'Delete', 'say_what').'</a>';
|
18 |
|
19 |
|
20 |
|
21 |
+
/**
|
22 |
+
* Constructor
|
23 |
+
*/
|
24 |
function __construct ( $settings ) {
|
25 |
|
26 |
$this->settings = $settings;
|
46 |
function get_columns(){
|
47 |
|
48 |
$columns = array(
|
49 |
+
/*'cb' => 'Checkboxes',*/
|
50 |
'string_id' => 'String replacement ID (Internal)',
|
51 |
'orig_string' => __( 'Original string', 'say_what' ),
|
52 |
'domain' => __( 'Domain', 'say_what' ),
|
82 |
$sql .= " ORDER BY ".$wpdb->escape ( $_GET['orderby'] );
|
83 |
|
84 |
if ( isset ( $_GET['order'] ) ) {
|
85 |
+
$sql .= " ".$wpdb->escape ( $_GET['order'] );
|
86 |
}
|
87 |
|
88 |
} else {
|
96 |
|
97 |
|
98 |
|
99 |
+
/**
|
100 |
+
* Indicate which columns are sortable
|
101 |
+
* @return array A list of the columns that are sortable.
|
102 |
+
*/
|
103 |
function get_sortable_columns() {
|
104 |
|
105 |
return array (
|
111 |
|
112 |
|
113 |
|
114 |
+
/**
|
115 |
+
* Specify the bulk actions available. Not used currently
|
116 |
+
*/
|
117 |
function get_bulk_actions() {
|
118 |
|
119 |
// FIXME - implement bulk actions
|
125 |
|
126 |
|
127 |
|
128 |
+
/**
|
129 |
+
* Checkboxes for the rows. Not used while we don't have bulk actions
|
130 |
+
*/
|
131 |
function column_cb ( $item ) {
|
132 |
|
133 |
+
return sprintf ( '<input type="checkbox" name="string_id[]" value="%d" />', $item['string_id'] );
|
134 |
|
135 |
}
|
136 |
|
137 |
|
138 |
+
/**
|
139 |
+
* Output column data
|
140 |
+
*/
|
141 |
function column_default ( $item, $column_name ) {
|
142 |
|
143 |
return $item[$column_name];
|
146 |
|
147 |
|
148 |
|
149 |
+
/**
|
150 |
+
* Output an edit link for the row
|
151 |
+
*/
|
152 |
function column_edit_links ( $item ) {
|
153 |
|
154 |
return '<a href="tools.php?page=say_what_admin&say_what_action=addedit&id='.urlencode($item['string_id']).'&nonce='.urlencode(wp_create_nonce('swaddedit')).'">'.__( 'Edit', 'say_what').'</a>';
|
157 |
|
158 |
|
159 |
|
160 |
+
/**
|
161 |
+
* Output a delete link for the row
|
162 |
+
*/
|
163 |
function column_delete_links ( $item ) {
|
164 |
|
165 |
return '<a href="tools.php?page=say_what_admin&say_what_action=delete&id='.urlencode($item['string_id']).'&nonce='.urlencode(wp_create_nonce('swdelete')).'">'.__( 'Delete', 'say_what').'</a>';
|
say-what-settings.php
CHANGED
@@ -1,8 +1,14 @@
|
|
1 |
<?php
|
2 |
|
|
|
3 |
if ( ! defined( 'ABSPATH' ) )
|
4 |
exit; // Exit if accessed directly
|
5 |
|
|
|
|
|
|
|
|
|
|
|
6 |
class say_what_settings {
|
7 |
|
8 |
public $replacements;
|
@@ -11,7 +17,7 @@ class say_what_settings {
|
|
11 |
|
12 |
global $wpdb, $table_prefix;
|
13 |
|
14 |
-
// @TODO - Read other settings in
|
15 |
$sql = "SELECT * FROM {$table_prefix}say_what_strings";
|
16 |
|
17 |
$this->replacements = $wpdb->get_results ( $sql, ARRAY_A );
|
1 |
<?php
|
2 |
|
3 |
+
|
4 |
if ( ! defined( 'ABSPATH' ) )
|
5 |
exit; // Exit if accessed directly
|
6 |
|
7 |
+
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Settings class. Possibly overkill at the moment
|
11 |
+
*/
|
12 |
class say_what_settings {
|
13 |
|
14 |
public $replacements;
|
17 |
|
18 |
global $wpdb, $table_prefix;
|
19 |
|
20 |
+
// @TODO - Read other settings in when we have them
|
21 |
$sql = "SELECT * FROM {$table_prefix}say_what_strings";
|
22 |
|
23 |
$this->replacements = $wpdb->get_results ( $sql, ARRAY_A );
|
say-what.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
-
Plugin Name: Say What?
|
5 |
Plugin URI: https://github.com/leewillis77/say-what
|
6 |
Description: An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code
|
7 |
-
Version: 0.9.
|
8 |
Author: Lee Willis
|
9 |
Author URI: http://www.leewillis.co.uk/
|
10 |
*/
|
@@ -53,7 +53,7 @@ class say_what {
|
|
53 |
*/
|
54 |
public function __construct(){
|
55 |
|
56 |
-
add_action ( 'init', array ( $this, init ) );
|
57 |
|
58 |
require_once ( 'say-what-settings.php' );
|
59 |
$this->settings_instance = new say_what_settings();
|
@@ -88,6 +88,9 @@ class say_what {
|
|
88 |
|
89 |
|
90 |
|
|
|
|
|
|
|
91 |
function say_what_install() {
|
92 |
|
93 |
global $wpdb;
|
1 |
<?php
|
2 |
|
3 |
/*
|
4 |
+
Plugin Name: Say What? - Easy string replacements
|
5 |
Plugin URI: https://github.com/leewillis77/say-what
|
6 |
Description: An easy-to-use plugin that allows you to alter strings on your site without editing WordPress core, or plugin code
|
7 |
+
Version: 0.9.2
|
8 |
Author: Lee Willis
|
9 |
Author URI: http://www.leewillis.co.uk/
|
10 |
*/
|
53 |
*/
|
54 |
public function __construct(){
|
55 |
|
56 |
+
add_action ( 'init', array ( $this, 'init' ) );
|
57 |
|
58 |
require_once ( 'say-what-settings.php' );
|
59 |
$this->settings_instance = new say_what_settings();
|
88 |
|
89 |
|
90 |
|
91 |
+
/**
|
92 |
+
* Install function. Create the table to store the replacements
|
93 |
+
*/
|
94 |
function say_what_install() {
|
95 |
|
96 |
global $wpdb;
|