Version Description
- Fixed a problem when multiple Regular Expressions were used.
Download this release
Release Info
Developer | mspyratos |
Plugin | Show Hide Author |
Version | 2.0 |
Comparing to | |
See all releases |
Code changes from version 1.3 to 2.0
- readme.txt +67 -32
- show_hide_author.php +22 -24
readme.txt
CHANGED
@@ -4,18 +4,17 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EP9SL
|
|
4 |
Tags: show author, hide author, remove author, author name
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 3.5
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
Choose whether to show or hide author name
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
With this plugin you can choose to show or hide the author name
|
16 |
-
You also can choose where to show the name.
|
17 |
|
18 |
-
= Choose to show or hide author name =
|
19 |
|
20 |
* In Different Post Types
|
21 |
* In Individual Pages
|
@@ -28,64 +27,100 @@ You also can choose where to show the name.
|
|
28 |
* Twenty Twelve by Wordpress
|
29 |
* Theme Revenge on themerevenge.com
|
30 |
* Magnificent by ElegantThemes
|
31 |
-
* Portfolio Press by Devin
|
32 |
|
33 |
-
=
|
34 |
|
35 |
-
|
|
|
36 |
|
37 |
= In Future Versions =
|
38 |
-
|
|
|
39 |
|
40 |
* In Individual Categories
|
41 |
* By Author Role and Name
|
42 |
|
43 |
-
|
|
|
44 |
|
45 |
== Installation ==
|
46 |
|
47 |
-
= Method 1 =
|
48 |
|
49 |
-
|
50 |
|
51 |
-
= Method 2 =
|
52 |
|
53 |
-
|
54 |
|
55 |
= After Installation =
|
56 |
|
57 |
The plugin settings will be available under the "Plugins" main menu.
|
58 |
Click on "Plugins" main menu and then click on "Show Hide Author".
|
|
|
59 |
|
60 |
-
==
|
61 |
|
62 |
-
=
|
63 |
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
|
68 |
|
69 |
-
1.
|
70 |
-
2.
|
|
|
71 |
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
|
|
|
|
|
75 |
|
76 |
-
|
|
|
77 |
|
78 |
-
|
79 |
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
-
=
|
|
|
83 |
|
84 |
-
|
|
|
85 |
|
86 |
-
|
|
|
87 |
|
88 |
-
|
|
|
89 |
|
90 |
-
|
91 |
-
|
4 |
Tags: show author, hide author, remove author, author name
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 3.5
|
7 |
+
Stable tag: 2.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Choose whether to show or hide the author's name.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
+
With this plugin you can choose whether to show or hide the author's name from specific pages and post categories.
|
|
|
16 |
|
17 |
+
= Choose to show or hide the author name =
|
18 |
|
19 |
* In Different Post Types
|
20 |
* In Individual Pages
|
27 |
* Twenty Twelve by Wordpress
|
28 |
* Theme Revenge on themerevenge.com
|
29 |
* Magnificent by ElegantThemes
|
30 |
+
* Portfolio Press by Devin Price
|
31 |
|
32 |
+
= Problems with the plugin? =
|
33 |
|
34 |
+
Visit the FAQ or Support page. If you don't find the answer, just email me.
|
35 |
+
*m.spyratos@hotmail.com*
|
36 |
|
37 |
= In Future Versions =
|
38 |
+
|
39 |
+
Choose to show or hide the author name
|
40 |
|
41 |
* In Individual Categories
|
42 |
* By Author Role and Name
|
43 |
|
44 |
+
Expanding the plugin's functionality, will depend on user's correspondence and the free time I have.
|
45 |
+
So if you need more from this plugin, don't hesitate to ask for it.
|
46 |
|
47 |
== Installation ==
|
48 |
|
49 |
+
= Method 1: Online =
|
50 |
|
51 |
+
Go to your WP plugin installation page and search for "Show Hide Author". Then choose the plugin and install it.
|
52 |
|
53 |
+
= Method 2: Download the File =
|
54 |
|
55 |
+
Download the plugin to your computer, then go to your WP plugin installation page and choose to upload the plugin. Choose the file and install it.
|
56 |
|
57 |
= After Installation =
|
58 |
|
59 |
The plugin settings will be available under the "Plugins" main menu.
|
60 |
Click on "Plugins" main menu and then click on "Show Hide Author".
|
61 |
+
(Check the screenshots)
|
62 |
|
63 |
+
== Frequently Asked Questions ==
|
64 |
|
65 |
+
= How to remove the "by" word? =
|
66 |
|
67 |
+
If you are unfamiliar with using firebug (or similar debug tools), then send me an email ( m.spyratos@hotmail.com ).
|
68 |
+
Otherwise, follow these simple steps.
|
69 |
|
70 |
+
**STEPS**
|
71 |
|
72 |
+
1. Locate the `by` word you want to remove, by using firebug.
|
73 |
+
2. Find the `class` of the parent container that contains the `by` word and its tag.
|
74 |
+
3. Go to the plugin settings, near the bottom of the page and fill-in:
|
75 |
|
76 |
+
Advanced: Hide the "by" word
|
77 |
+
|
78 |
+
The parent classes: `class`
|
79 |
+
The regular expressions: `by`
|
80 |
+
|
81 |
+
**EXAMPLE**
|
82 |
+
Let's say that when you locate the `by` word with firebug, you find this html code:
|
83 |
+
|
84 |
+
`<div class="meta-text">
|
85 |
+
<span class="meta-author">by </span>
|
86 |
+
</div>`
|
87 |
+
|
88 |
+
Then you should enter:
|
89 |
+
|
90 |
+
The parent classes: `meta-text`
|
91 |
+
The regular expressions: `by`
|
92 |
|
93 |
+
*BE CAREFULL*
|
94 |
+
This will replace all `by` words inside the `meta-text` class (if more than one exists) and it won't remove the `<span>` tags surrounding `by`.
|
95 |
+
So even better use something like this:
|
96 |
|
97 |
+
The parent classes: `meta-text`
|
98 |
+
The regular expressions: `<span class="meta-author">by </span>`
|
99 |
|
100 |
+
*OR* by using regular expressions.
|
101 |
|
102 |
+
The parent classes: `meta-text`
|
103 |
+
The regular expressions: `<span class="meta-author(.*?)/span>`
|
104 |
+
|
105 |
+
|
106 |
+
== Screenshots ==
|
107 |
+
|
108 |
+
1. One page settings, under the main menu "Plugins".
|
109 |
+
2. A post without the Author name in Twenty Eleven.
|
110 |
+
|
111 |
+
== Changelog ==
|
112 |
|
113 |
+
= 2.0 =
|
114 |
+
* Fixed a problem when multiple Regular Expressions were used.
|
115 |
|
116 |
+
= 1.3 =
|
117 |
+
* More themes support
|
118 |
|
119 |
+
= 1.2 =
|
120 |
+
* More themes support
|
121 |
|
122 |
+
= 1.1 =
|
123 |
+
* Fixed wrong quotes somewhere in code.
|
124 |
|
125 |
+
= 1.0 =
|
126 |
+
* Beta - First Version
|
show_hide_author.php
CHANGED
@@ -2,13 +2,13 @@
|
|
2 |
/*
|
3 |
Plugin Name: Show Hide Author
|
4 |
Description: Choose whether to show or hide the author name.
|
5 |
-
Version:
|
6 |
Author: Michael Spyratos
|
7 |
Author URI: http://mspyratos.com/
|
8 |
License: GPL2
|
9 |
*/
|
10 |
|
11 |
-
/* Copyright 2013 Michael Spyratos (email : m.spyratos@
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License, version 2, as
|
@@ -313,16 +313,7 @@ function remove_the_by() {
|
|
313 |
$custom_classes = substr($custom_classes, 0, -2);
|
314 |
// Get the regex submitted
|
315 |
if(isset($options_by['option_by_regex']) && $options_by['option_by_regex'] != '') {
|
316 |
-
$
|
317 |
-
} else {
|
318 |
-
$custom_regexs_array = array('');
|
319 |
-
}
|
320 |
-
if($custom_regexs_array[0] != '') {
|
321 |
-
foreach($custom_regexs_array as $custom_regex) {
|
322 |
-
$custom_regexs .= $custom_regex . '|';
|
323 |
-
}
|
324 |
-
$custom_regexs = substr($custom_regexs, 0, -1);
|
325 |
-
$custom_regex_string = '/' . preg_replace('/\//', '\/', $custom_regexs) . '/';
|
326 |
} else {
|
327 |
$custom_regex_string = '';
|
328 |
}
|
@@ -334,9 +325,9 @@ function remove_the_by() {
|
|
334 |
// Custom Classes and Regexs
|
335 |
var classes = [<?php echo $custom_classes; ?>];
|
336 |
<?php if(isset($custom_regex_string) && $custom_regex_string != '') : ?>
|
337 |
-
var regex = <?php echo $custom_regex_string;
|
338 |
<?php else : ?>
|
339 |
-
var regex =
|
340 |
<?php endif; ?>
|
341 |
<?php else : ?>
|
342 |
// List of Themes, Classes and Regular expressions
|
@@ -344,37 +335,44 @@ function remove_the_by() {
|
|
344 |
switch(template_name) {
|
345 |
case 'twentyeleven' :
|
346 |
var classes = ['entry-meta'];
|
347 |
-
var regex =
|
348 |
break;
|
349 |
case 'twentyten' :
|
350 |
var classes = ['entry-meta'];
|
351 |
-
var regex =
|
352 |
break;
|
353 |
case 'object' :
|
354 |
var classes = ['post-details', 'post'];
|
355 |
-
var regex =
|
356 |
break;
|
357 |
case 'theme-revenge' :
|
358 |
var classes = ['post-entry-meta'];
|
359 |
-
var regex =
|
360 |
break;
|
361 |
case 'Magnificent' :
|
362 |
var classes = ['meta-info'];
|
363 |
-
var regex =
|
|
|
|
|
|
|
|
|
364 |
break;
|
365 |
default:
|
366 |
var classes = ['entry-meta'];
|
367 |
-
var regex =
|
368 |
}
|
369 |
<?php endif; ?>
|
370 |
if (typeof classes[0] !== 'undefined' && classes[0] !== null) {
|
371 |
for(var i = 0; i < classes.length; i++) {
|
372 |
var elements = document.getElementsByClassName(classes[i]);
|
373 |
for (var j = 0; j < elements.length; j++) {
|
374 |
-
|
375 |
-
|
376 |
-
elements[j].innerHTML
|
377 |
-
|
|
|
|
|
|
|
378 |
}
|
379 |
}
|
380 |
}
|
2 |
/*
|
3 |
Plugin Name: Show Hide Author
|
4 |
Description: Choose whether to show or hide the author name.
|
5 |
+
Version: 2.0
|
6 |
Author: Michael Spyratos
|
7 |
Author URI: http://mspyratos.com/
|
8 |
License: GPL2
|
9 |
*/
|
10 |
|
11 |
+
/* Copyright 2013 Michael Spyratos (email : m.spyratos@gmail.com)
|
12 |
|
13 |
This program is free software; you can redistribute it and/or modify
|
14 |
it under the terms of the GNU General Public License, version 2, as
|
313 |
$custom_classes = substr($custom_classes, 0, -2);
|
314 |
// Get the regex submitted
|
315 |
if(isset($options_by['option_by_regex']) && $options_by['option_by_regex'] != '') {
|
316 |
+
$custom_regex_string = preg_replace('/\//', '\/', $options_by['option_by_regex']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
} else {
|
318 |
$custom_regex_string = '';
|
319 |
}
|
325 |
// Custom Classes and Regexs
|
326 |
var classes = [<?php echo $custom_classes; ?>];
|
327 |
<?php if(isset($custom_regex_string) && $custom_regex_string != '') : ?>
|
328 |
+
var regex = '<?php echo $custom_regex_string; ?>';
|
329 |
<?php else : ?>
|
330 |
+
var regex = ' by <a(.*?)\/a>;<span class="sep"> by <\/span>';
|
331 |
<?php endif; ?>
|
332 |
<?php else : ?>
|
333 |
// List of Themes, Classes and Regular expressions
|
335 |
switch(template_name) {
|
336 |
case 'twentyeleven' :
|
337 |
var classes = ['entry-meta'];
|
338 |
+
var regex = ' by <a(.*?)\/a>;<span class="sep"> by <\/span>';
|
339 |
break;
|
340 |
case 'twentyten' :
|
341 |
var classes = ['entry-meta'];
|
342 |
+
var regex = ' by <a(.*?)\/a>;<span class="meta-sep">by<\/span>';
|
343 |
break;
|
344 |
case 'object' :
|
345 |
var classes = ['post-details', 'post'];
|
346 |
+
var regex = ' by <span(.*?)\/span>;<p class="post-details">by';
|
347 |
break;
|
348 |
case 'theme-revenge' :
|
349 |
var classes = ['post-entry-meta'];
|
350 |
+
var regex = 'By <a(.*?)\/a> on';
|
351 |
break;
|
352 |
case 'Magnificent' :
|
353 |
var classes = ['meta-info'];
|
354 |
+
var regex = '<span>by<\/span> <a(.*?)\/a>;Posted by <a(.*?)\/a> on ';
|
355 |
+
break;
|
356 |
+
case 'wp-clearphoto' :
|
357 |
+
var classes = ['meta'];
|
358 |
+
var regex = ' \|\s+<\/span>\s+<span class="meta-author">(.*?)\/span>';
|
359 |
break;
|
360 |
default:
|
361 |
var classes = ['entry-meta'];
|
362 |
+
var regex = ' by <a(.*?)\/a>;<span class="sep"> by <\/span>; <span class="meta-sep">by<\/span>;<span class="meta-sep"> by <\/span>';
|
363 |
}
|
364 |
<?php endif; ?>
|
365 |
if (typeof classes[0] !== 'undefined' && classes[0] !== null) {
|
366 |
for(var i = 0; i < classes.length; i++) {
|
367 |
var elements = document.getElementsByClassName(classes[i]);
|
368 |
for (var j = 0; j < elements.length; j++) {
|
369 |
+
var regex_array = regex.split(";");
|
370 |
+
for(var k = 0; k < regex_array.length; k++) {
|
371 |
+
if (elements[j].innerHTML.match(new RegExp(regex_array[k]))) {
|
372 |
+
var replaced_txt = elements[j].innerHTML.replace(new RegExp(regex_array[k]), '');
|
373 |
+
elements[j].innerHTML = replaced_txt;
|
374 |
+
}
|
375 |
+
}
|
376 |
}
|
377 |
}
|
378 |
}
|