Say what? - Version 0.9

Version Description

Beta ready for testing and feedback

Download this release

Release Info

Developer leewillis77
Plugin Icon 128x128 Say what?
Version 0.9
Comparing to
See all releases

Version 0.9

banner-772x250.png ADDED
Binary file
css/admin.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ .wp-list-table .column-orig_string {
2
+ width: 40%;
3
+ }
4
+ .wp-list-table .column-replacement_string{
5
+ width: 40%;
6
+ }
7
+ .wp-list-table .column-domain {
8
+ width: 10%;
9
+ }
html/say_what_admin_addedit.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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&amp;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 esc_attr_e($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 esc_attr_e ( $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 esc_attr_e ( $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 esc_attr_e ( $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
+
25
+ </div>
html/say_what_admin_delete.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <div id="icon-tools" class="icon32"></div>
3
+ <h2><?php _e ( 'Text changes', 'say_what' ); ?></h2>
4
+
5
+ <p><?php printf ( __( 'Are you sure you want to delete the replacement string for &quot;%s&quot;?', 'say_what' ), esc_html($replacement->orig_string) ); ?></p>
6
+ <p>
7
+ <a href="tools.php?page=say_what_admin&amp;say_what_action=delete-confirmed&amp;id=<?php echo urlencode($_GET['id']); ?>&amp;nonce=<?php echo urlencode($_GET['nonce']); ?>" class="button"><?php _e('Yes', 'say_what'); ?></a> <a href="tools.php?page=say_what_admin" class="button button-primary"><?php _e('No', 'say_what'); ?></a>
8
+
9
+ </div>
html/say_what_admin_list.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <div id="icon-tools" class="icon32"></div>
3
+ <h2><?php _e ( 'Text changes', 'say_what' ); ?><a href="tools.php?page=say_what_admin&amp;say_what_action=addedit" class="add-new-h2"><?php _e('Add New', 'say_what'); ?></a></h2>
4
+
5
+ <?php $this->show_current(); ?>
6
+
7
+ </div>
languages/say-what.pot ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2013 Lee Willis
2
+ # This file is distributed under the same license as the Say What? package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Say What? 0.9\n"
6
+ "Report-Msgid-Bugs-To: http://plugins.leewillis.co.uk/\n"
7
+ "POT-Creation-Date: 2013-03-06 21:25:36+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: say-what-list-table.class.php:34
16
+ msgid "No string replacements configured yet."
17
+ msgstr ""
18
+
19
+ #: say-what-list-table.class.php:48 html/say_what_admin_addedit.php:13
20
+ msgid "Original string"
21
+ msgstr ""
22
+
23
+ #: say-what-list-table.class.php:49 html/say_what_admin_addedit.php:15
24
+ msgid "Domain"
25
+ msgstr ""
26
+
27
+ #: say-what-list-table.class.php:50 html/say_what_admin_addedit.php:17
28
+ msgid "Replacement string"
29
+ msgstr ""
30
+
31
+ #: say-what-list-table.class.php:136
32
+ msgid "Edit"
33
+ msgstr ""
34
+
35
+ #: say-what-list-table.class.php:144
36
+ msgid "Delete"
37
+ msgstr ""
38
+
39
+ #: html/say_what_admin_addedit.php:4 html/say_what_admin_list.php:3
40
+ #: html/say_what_admin_delete.php:3 say-what-admin.php:52
41
+ #: say-what-admin.php:53
42
+ msgid "Text changes"
43
+ msgstr ""
44
+
45
+ #: html/say_what_admin_addedit.php:21
46
+ msgid "Update"
47
+ msgstr ""
48
+
49
+ #: html/say_what_admin_addedit.php:21
50
+ msgid "Add"
51
+ msgstr ""
52
+
53
+ #: html/say_what_admin_list.php:3
54
+ msgid "Add New"
55
+ msgstr ""
56
+
57
+ #: html/say_what_admin_delete.php:5
58
+ msgid ""
59
+ "Are you sure you want to delete the replacement string for &quot;%s&quot;?"
60
+ msgstr ""
61
+
62
+ #: html/say_what_admin_delete.php:7
63
+ msgid "Yes"
64
+ msgstr ""
65
+
66
+ #: html/say_what_admin_delete.php:7
67
+ msgid "No"
68
+ msgstr ""
69
+
70
+ #: say-what-admin.php:125 say-what-admin.php:136 say-what-admin.php:154
71
+ #: say-what-admin.php:206
72
+ msgid "Did you really mean to do that? Please go back and try again."
73
+ msgstr ""
74
+
75
+ #. Plugin Name of the plugin/theme
76
+ msgid "Say What?"
77
+ msgstr ""
78
+
79
+ #. Plugin URI of the plugin/theme
80
+ msgid "https://github.com/leewillis77/say-what"
81
+ msgstr ""
82
+
83
+ #. Description of the plugin/theme
84
+ msgid ""
85
+ "An easy-to-use plugin that allows you to alter strings on your site without "
86
+ "editing WordPress core, or plugin code"
87
+ msgstr ""
88
+
89
+ #. Author of the plugin/theme
90
+ msgid "Lee Willis"
91
+ msgstr ""
92
+
93
+ #. Author URI of the plugin/theme
94
+ msgid "http://www.leewillis.co.uk/"
95
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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!
11
+
12
+ == Installation ==
13
+
14
+ * Install it as you would any other plugin
15
+ * Activate it
16
+ * Head over to Tools &raquo; Text changes and configure some string replacements
17
+
18
+ Note: This plugin may produce performance issues if you use it to configure a *large* number of string translations. I'd be interested in feedback if that's the case.
19
+
20
+ == Frequently Asked Questions ==
21
+
22
+ = Can I use it to change any string? =
23
+ You can only use the plugin to translate strings which are marked for translation.
24
+
25
+ = How do I find the string to translate? =
26
+ You can either have a guess, or checkout the plugin in question's source code, translatable strings are generally wrapped in __(), _e(), or _x(), for example:
27
+
28
+ `$foo = __('This is a translatable string', 'plugin-domain');`
29
+
30
+ == Screenshots ==
31
+
32
+ 1. Finding a string to replace
33
+ 2. The admin screen - setting up a replacement
34
+ 3. The result
35
+
36
+
37
+ == Changelog ==
38
+
39
+ = 0.9 =
40
+ Beta ready for testing and feedback
say-what-admin.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) )
6
+ exit; // Exit if accessed directly
7
+
8
+
9
+ /**
10
+ * @TODO docs
11
+ */
12
+ class say_what_admin {
13
+
14
+
15
+
16
+ private $settings;
17
+
18
+ /**
19
+ * Constructor
20
+ */
21
+ function __construct($settings) {
22
+
23
+ $this->settings = $settings;
24
+ add_action( 'admin_menu', array ( $this, 'admin_menu' ) );
25
+ add_action ( 'admin_init', array ( $this, 'admin_init' ) );
26
+
27
+ }
28
+
29
+
30
+
31
+ public function admin_init() {
32
+
33
+ if ( isset ( $_POST['say_what_save'] ) ) {
34
+ $this->save();
35
+ }
36
+
37
+ if ( isset ( $_GET['say_what_action'] ) && ( $_GET['say_what_action'] == 'delete-confirmed' ) ) {
38
+ $this->admin_delete_confirmed();
39
+ }
40
+
41
+ }
42
+
43
+
44
+
45
+ /**
46
+ * Register the menu item for the admin pages
47
+ */
48
+ public function admin_menu() {
49
+
50
+ if ( current_user_can ( 'manage_options' ) ) {
51
+
52
+ $page = add_management_page ( __('Text changes', 'say_what'),
53
+ __('Text changes', 'say_what'),
54
+ 'manage_options',
55
+ 'say_what_admin',
56
+ array ( $this, 'admin' ) );
57
+
58
+ if ( isset ( $_GET['page'] ) && $_GET['page'] == 'say_what_admin' ) {
59
+ add_action('admin_print_styles-' . $page, array ( &$this, 'enqueue_scripts' ) );
60
+ }
61
+
62
+ }
63
+
64
+ }
65
+
66
+
67
+
68
+ /**
69
+ * Add CSS / javascript to admin pages
70
+ */
71
+ public function enqueue_scripts() {
72
+
73
+ wp_register_style ( 'say_what_admin_css', plugins_url().'/say-what/css/admin.css', array() );
74
+ wp_enqueue_style ( 'say_what_admin_css' );
75
+
76
+ }
77
+
78
+
79
+
80
+ /**
81
+ * The main admin page controller
82
+ */
83
+ public function admin() {
84
+
85
+ switch ( $_GET['say_what_action'] ) {
86
+
87
+ case 'addedit':
88
+ $this->admin_addedit();
89
+ break;
90
+
91
+ case 'delete':
92
+ $this->admin_delete();
93
+ break;
94
+
95
+ case 'list':
96
+ default:
97
+ $this->admin_list();
98
+ break;
99
+
100
+ }
101
+
102
+ }
103
+
104
+
105
+
106
+ /**
107
+ * Render the list of currently configured replacement strings
108
+ */
109
+ public function admin_list() {
110
+
111
+ require_once('html/say_what_admin_list.php');
112
+
113
+ }
114
+
115
+
116
+
117
+ /**
118
+ * Show the page asking the user to confirm deletion
119
+ */
120
+ public function admin_delete() {
121
+
122
+ global $wpdb, $table_prefix;
123
+
124
+ if ( ! wp_verify_nonce ( $_GET['nonce'], 'swdelete' ) ) {
125
+ wp_die ( __("Did you really mean to do that? Please go back and try again.", 'say_what') );
126
+ }
127
+
128
+ if ( isset ( $_GET['id'] ) ) {
129
+
130
+ $sql = "SELECT * FROM {$table_prefix}say_what_strings WHERE string_id = %d";
131
+ $replacement = $wpdb->get_row ( $wpdb->prepare ( $sql, $_GET['id'] ) );
132
+
133
+ }
134
+
135
+ if ( ! $replacement ) {
136
+ wp_die ( __("Did you really mean to do that? Please go back and try again.", 'say_what') );
137
+ }
138
+
139
+ require_once('html/say_what_admin_delete.php');
140
+
141
+ }
142
+
143
+
144
+
145
+ /**
146
+ * Show the page asking the user to confirm deletion
147
+ */
148
+ public function admin_delete_confirmed() {
149
+
150
+ global $wpdb, $table_prefix;
151
+
152
+ if ( ! wp_verify_nonce ( $_GET['nonce'], 'swdelete' ) ||
153
+ empty ( $_GET['id'] ) ) {
154
+ wp_die ( __("Did you really mean to do that? Please go back and try again.", 'say_what') );
155
+ }
156
+
157
+ $sql = "DELETE FROM {$table_prefix}say_what_strings WHERE string_id = %d";
158
+ $wpdb->query ( $wpdb->prepare ( $sql, $_GET['id'] ) );
159
+
160
+ wp_redirect( 'tools.php?page=say_what_admin', '303' );
161
+ die();
162
+
163
+ }
164
+
165
+
166
+
167
+ /**
168
+ * Render the add/edit page for a replacement
169
+ */
170
+ public function admin_addedit() {
171
+
172
+ global $wpdb, $table_prefix;
173
+
174
+ $replacement = false;
175
+
176
+ if ( isset ( $_GET['id'] ) ) {
177
+
178
+ $sql = "SELECT * FROM {$table_prefix}say_what_strings WHERE string_id = %d";
179
+ $replacement = $wpdb->get_row ( $wpdb->prepare ( $sql, $_GET['id'] ) );
180
+
181
+ }
182
+
183
+ if ( ! $replacement ) {
184
+ $replacement = new stdClass();
185
+ $replacement->string_id = '';
186
+ $replacement->orig_string = '';
187
+ $replacement->replacement_string = '';
188
+ $replacement->domain = '';
189
+ }
190
+
191
+ require_once('html/say_what_admin_addedit.php');
192
+
193
+ }
194
+
195
+
196
+
197
+ /**
198
+ * Something on the admin pages needs saved. handle it all here
199
+ * Output error/warning messages as required
200
+ */
201
+ private function save() {
202
+
203
+ global $wpdb, $table_prefix;
204
+
205
+ if ( ! wp_verify_nonce ($_POST['nonce'], 'swaddedit' ) ) {
206
+ wp_die ( __("Did you really mean to do that? Please go back and try again.", 'say_what') );
207
+ }
208
+
209
+ $_POST = stripslashes_deep( $_POST );
210
+
211
+ if ( isset ( $_POST['say_what_string_id'] ) ) {
212
+
213
+ $sql = "UPDATE {$table_prefix}say_what_strings
214
+ SET orig_string = %s,
215
+ replacement_string = %s,
216
+ domain = %s
217
+ WHERE string_id = %d";
218
+
219
+ $wpdb->query ( $wpdb->prepare ( $sql,
220
+ $_POST['say_what_orig_string'],
221
+ $_POST['say_what_replacement_string'],
222
+ $_POST['say_what_domain'],
223
+ $_POST['say_what_string_id']
224
+ )
225
+ );
226
+
227
+ } else {
228
+
229
+ $sql = "INSERT INTO {$table_prefix}say_what_strings
230
+ VALUES ( NULL,
231
+ %s,
232
+ %s,
233
+ %s )";
234
+
235
+ $wpdb->query ( $wpdb->prepare ( $sql,
236
+ $_POST['say_what_orig_string'],
237
+ $_POST['say_what_replacement_string'],
238
+ $_POST['say_what_domain']
239
+ )
240
+ );
241
+
242
+ }
243
+
244
+ wp_redirect( 'tools.php?page=say_what_admin', '303' );
245
+ die();
246
+
247
+ }
248
+
249
+
250
+
251
+ private function show_current() {
252
+
253
+ require_once ( 'say-what-list-table.class.php' );
254
+ $list_table_instance = new say_what_list_table ( $this->settings );
255
+ $list_table_instance->prepare_items();
256
+ $list_table_instance->display();
257
+
258
+ }
259
+
260
+ }
say-what-frontend.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ if ( ! defined( 'ABSPATH' ) )
6
+ exit; // Exit if accessed directly
7
+
8
+
9
+ /**
10
+ * @TODO - docblocks
11
+ */
12
+ class say_what_frontend {
13
+
14
+
15
+
16
+ private $replacements;
17
+
18
+
19
+
20
+ function __construct($settings) {
21
+
22
+ foreach ( $settings->replacements as $key => $value ) {
23
+
24
+ if ( empty ( $value['domain'] ) )
25
+ $value['domain'] = 'default';
26
+
27
+ $this->replacements[$value['domain']][$value['orig_string']] = $value['replacement_string'];
28
+ }
29
+
30
+ add_filter ( 'gettext', array ( $this, 'gettext' ), 10, 3 );
31
+
32
+ }
33
+
34
+
35
+
36
+ function gettext( $translated, $original, $domain ) {
37
+
38
+ if ( isset ( $this->replacements[$domain][$original] ) ) {
39
+ return $this->replacements[$domain][$original];
40
+ } else {
41
+ return $translated;
42
+ }
43
+
44
+ }
45
+
46
+
47
+
48
+ }
say-what-list-table.class.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ if ( ! class_exists ( 'WP_List_Table' ) ) {
5
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
6
+ }
7
+
8
+
9
+
10
+ /**
11
+ * List table class for the admin pages
12
+ */
13
+ class say_what_list_table extends WP_List_Table {
14
+
15
+
16
+
17
+ private $settings;
18
+
19
+
20
+
21
+ function __construct ( $settings ) {
22
+
23
+ $this->settings = $settings;
24
+ parent::__construct();
25
+
26
+ }
27
+
28
+
29
+
30
+ /**
31
+ * Description shown when no replacements configured
32
+ */
33
+ function no_items() {
34
+ _e( 'No string replacements configured yet.', 'say_what' );
35
+ }
36
+
37
+
38
+
39
+ /**
40
+ * Specify the list of columns in the table
41
+ * @return array The list of columns
42
+ */
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' ),
50
+ 'replacement_string' => __( 'Replacement string', 'say_what' ),
51
+ 'edit_links' => _x( '', 'Header for edit links on admin list table', 'say_what' ),
52
+ 'delete_links' => _x( '', 'Header for delete links on admin list table', 'say_what' ),
53
+ );
54
+ return $columns;
55
+
56
+ }
57
+
58
+
59
+
60
+ /**
61
+ * Retrieve the items for display
62
+ * @return [type] [description]
63
+ */
64
+ function prepare_items() {
65
+
66
+ global $wpdb, $table_prefix;
67
+
68
+ $columns = $this->get_columns();
69
+ $hidden = array('string_id');
70
+ $sortable = $this->get_sortable_columns();
71
+ $this->_column_headers = array($columns, $hidden, $sortable);
72
+ //$this->search_box(__('Search', 'say_what'), 'search_id'); // FIXME - implement searching
73
+
74
+ // We don't use the replacements from the settings object, we query them separately to make
75
+ // ordering/searhing/pagination easier. This may turn out bad if people have "lots"
76
+ $sql = "SELECT * FROM {$table_prefix}say_what_strings";
77
+ if ( isset ( $_GET['orderby'] ) ) {
78
+
79
+ $sql .= " ORDER BY ".$wpdb->escape ( $_GET['orderby'] );
80
+
81
+ if ( isset ( $_GET['order'] ) ) {
82
+ $sql .= " ".$wpdb->prepare ( $_GET['order'] );
83
+ }
84
+
85
+ } else {
86
+
87
+ $sql .= ' ORDER BY orig_string ASC';
88
+ }
89
+
90
+ $this->items = $wpdb->get_results ( $sql, ARRAY_A );
91
+
92
+ }
93
+
94
+
95
+
96
+ function get_sortable_columns() {
97
+
98
+ return array (
99
+ 'orig_string' => array ( 'orig_string', true ),
100
+ 'domain' => array ( 'domain', false ),
101
+ 'replacement_string' => array ( 'replacement_string', false ) );
102
+
103
+ }
104
+
105
+
106
+
107
+ function get_bulk_actions() {
108
+
109
+ // FIXME - implement bulk actions
110
+ //$actions = array ( 'delete' => __( 'Delete', 'say_what' ) );
111
+
112
+ return array();
113
+
114
+ }
115
+
116
+
117
+
118
+ function column_cb ( $item ) {
119
+
120
+ return sprintf ( '<input type="checkbox" name="string_id[]" value="%d" />', $item['ID'] );
121
+
122
+ }
123
+
124
+
125
+
126
+ function column_default ( $item, $column_name ) {
127
+
128
+ return $item[$column_name];
129
+
130
+ }
131
+
132
+
133
+
134
+ function column_edit_links ( $item ) {
135
+
136
+ return '<a href="tools.php?page=say_what_admin&amp;say_what_action=addedit&amp;id='.urlencode($item['string_id']).'&amp;nonce='.urlencode(wp_create_nonce('swaddedit')).'">'.__( 'Edit', 'say_what').'</a>';
137
+
138
+ }
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>';
145
+
146
+ }
147
+
148
+ }
say-what-settings.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) )
4
+ exit; // Exit if accessed directly
5
+
6
+ class say_what_settings {
7
+
8
+ public $replacements;
9
+
10
+ function __construct() {
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 );
18
+
19
+ }
20
+
21
+ }
say-what.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ */
11
+
12
+ /**
13
+ * Copyright (c) 2013 Lee Willis. All rights reserved.
14
+ *
15
+ * Released under the GPL license
16
+ * http://www.opensource.org/licenses/gpl-license.php
17
+ *
18
+ * This is an add-on for WordPress
19
+ * http://wordpress.org/
20
+ *
21
+ * **********************************************************************
22
+ * This program is free software; you can redistribute it and/or modify
23
+ * it under the terms of the GNU General Public License as published by
24
+ * the Free Software Foundation; either version 2 of the License, or
25
+ * (at your option) any later version.
26
+ *
27
+ * This program is distributed in the hope that it will be useful,
28
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30
+ * GNU General Public License for more details.
31
+ * **********************************************************************
32
+ */
33
+
34
+ if ( ! defined( 'ABSPATH' ) )
35
+ exit; // Exit if accessed directly
36
+
37
+
38
+ /**
39
+ * Main plugin class, responsible for triggering everything
40
+ */
41
+ class say_what {
42
+
43
+
44
+
45
+ private $settings_instance;
46
+ private $frontend_instance;
47
+ private $admin_instance;
48
+
49
+
50
+
51
+ /**
52
+ * Constructor
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();
60
+
61
+ if ( is_admin() ) {
62
+
63
+ require_once ( 'say-what-admin.php' );
64
+ $this->admin_instance = new say_what_admin ( $this->settings_instance );
65
+
66
+ }
67
+
68
+ require_once ( 'say-what-frontend.php' );
69
+ $this->frontend_instance = new say_what_frontend ( $this->settings_instance );
70
+
71
+ }
72
+
73
+
74
+
75
+ /**
76
+ * Fires on init()
77
+ * Set up translation for the plugin itself
78
+ */
79
+ public function init() {
80
+
81
+ $locale = apply_filters ( 'plugin_locale', get_locale(), "say_what");
82
+ load_textdomain ( 'say_what', WP_LANG_DIR.'/say_what/say_what-'.$locale.'.mo');
83
+ load_plugin_textdomain ( 'say_what', false, basename( dirname( __FILE__ ) ) . '/languages/' );
84
+
85
+ }
86
+
87
+ }
88
+
89
+
90
+
91
+ function say_what_install() {
92
+
93
+ global $wpdb;
94
+
95
+ $table_name = $wpdb->prefix . "say_what_strings";
96
+
97
+ $sql = "CREATE TABLE $table_name (
98
+ `string_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
99
+ `orig_string` text NOT NULL,
100
+ `domain` varchar(255),
101
+ `replacement_string` text
102
+ )";
103
+
104
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
105
+ dbDelta($sql);
106
+
107
+ }
108
+
109
+ register_activation_hook ( __FILE__, 'say_what_install' );
110
+
111
+
112
+
113
+ $say_what = new say_what();