Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![Build Status](https://travis-ci.org/barzik/wp-notice.svg)](https://travis-ci.org/barzik/wp-notice)
[![Build Status](https://travis-ci.org/barzik/wp-notice.svg?branch=master)](https://travis-ci.org/barzik/wp-notice)

# WP Notice

WP Notice plugin enable every admin to post animated announcement or messages on top of posts based on tags, categories or date.
WP Notice plugin enable every admin to post animated announcement or messages in posts based on tags, categories or date.
You can assign several messages for the several posts. There are several custom designs based on BootStrap styles.
Along with the styles, you can also add to every message one of hundreds icons based on Font Awesome repository and
also choose animation type, duration and number of repetition.
also choose animation type, duration and number of repetition. You can choose the position of the notices.

# Installation and other information

Expand Down
20 changes: 15 additions & 5 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
=== WordPress Notice ===
Contributors: barzik
Tags: notification, posts, obsolete, notice, messages, notice based on category, animation, font awesome
Requires at least: 3.7
Tested up to: 4.3.1
Requires at least: 3.8
Tested up to: 4.4
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand All @@ -11,10 +11,10 @@ WP Notice Plugin enables site admin to display custom animated announcements in

== Description ==

WP Notice plugin enable every website manager to display animated announcement or messages on top of posts based on tags, categories or date.
You can assign several messages for the several posts. There are several custom designs based on Twitter BootStrap styles.
WP Notice plugin enable every admin to post animated announcement or messages in posts based on tags, categories or date.
You can assign several messages for the several posts. There are several custom designs based on BootStrap styles.
Along with the styles, you can also add to every message one of hundreds icons based on Font Awesome repository and
also choose animation type, duration and number of repetition. You can preview the message with the animation before saving it.
also choose animation type, duration and number of repetition. You can choose the position of the notices.

Ideal for technical sites that need to post deprecated notice on old posts and any other sites that need to show
messages to users based on categories, tags or date and get attention to the message by using icons and animation if needed.
Expand Down Expand Up @@ -59,6 +59,11 @@ GitHub: https://github.com/barzik/wp-notice

== Changelog ==

= 1.3.4 =
* Adding Position choice: before content, after content or both.
* Added PHPUnit test case.
* Removed tests from production to testing.

= 1.3.2 =
* Fix for link posting in messages.
* Added PHPUnit test case for the link issues.
Expand Down Expand Up @@ -103,6 +108,11 @@ GitHub: https://github.com/barzik/wp-notice

== Upgrade Notice ==

= 1.3.4 =
* Adding Position choice: before content, after content or both.
* Added PHPUnit test case.
* Removed tests from production to testing.

= 1.3.2 =
Fix for issue with link being inserted to message and got malformed.

Expand Down
4 changes: 4 additions & 0 deletions admin/assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ fieldset.wp_notice > div.wp_notice_style > label {
display: inline;
}

fieldset.wp_notice > div.wp_notice_position > label {
display: inline;
}

.wp_notice_animation.form-group > span {
display: inline-block;
}
Expand Down
64 changes: 48 additions & 16 deletions admin/class-wp-notice-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ private function prepare_wp_notice_post() {
$wp_notice_options_raw['animation'][ $i ]['duration'] = '';
$wp_notice_options_raw['animation'][ $i ]['repeat'] = '';
}
if ( isset( $wp_notice_options_raw['position'][ $i ] ) ) {
$wp_notice_options[ $i ]['position'] = sanitize_text_field( $wp_notice_options_raw['position'][ $i ] );
} else {
$wp_notice_options[ $i ]['position'] = 'before';
}
}
return $wp_notice_options;
}
Expand Down Expand Up @@ -390,7 +395,7 @@ private function get_all_fieldsets( $wp_notice_options ) {
$html .= $this->build_fieldset(
$key, $wp_notice_option['tag'], $wp_notice_option['cat'],
$wp_notice_option['wp_notice_time'], $wp_notice_option['wp_notice_text'], $wp_notice_option['style'],
$wp_notice_option['font'], $wp_notice_option['animation']
$wp_notice_option['font'], $wp_notice_option['animation'], $wp_notice_option['position']
);
}
return $html;
Expand All @@ -416,7 +421,7 @@ private function generate_category_list( $number = 0, $selected_category = array
$category_list .= "<select id='cat_$number' name='cat[$number][]' multiple='multiple' class='wp_notice_tag'>";
$category_list .= "<option $all value='0'>".__( 'Do not use categories', $this->plugin_slug ).'</option>';
foreach ( $categories as $cat ) {
if ( is_array( $selected_category ) && ! empty( $selected_category ) && in_array( $cat->term_id, $selected_category ) ) {
if ( is_array( $selected_category ) && ! empty( $selected_category ) && in_array( $cat->term_id, $selected_category, true ) ) {
$selected = $cat->term_id;
} else {
$selected = '';
Expand Down Expand Up @@ -448,7 +453,7 @@ private function generate_tag_list( $number = 0, $selected_tag = array() ) {
$tag_list .= "<option {$all_selected} value='0'>" . __( 'Do not use tags', $this->plugin_slug ) . '</option>';
foreach ( $tags as $tag ) {
$selected = '';
if ( is_array( $selected_tag ) && ! empty( $selected_tag ) && in_array( $tag->term_id, $selected_tag ) ) {
if ( is_array( $selected_tag ) && ! empty( $selected_tag ) && in_array( $tag->term_id, $selected_tag, true ) ) {
$selected = $tag->term_id;
}
$tag_list .= '<option ' . selected( $selected, $tag->term_id, false ) . ' value="' . $tag->term_id . '">' . $tag->name . '</option>';
Expand Down Expand Up @@ -500,6 +505,27 @@ private function generate_fonts_list( $number = 0, $selected_font = 'none' ) {
return $font_list;
}

/**
*
* Generating the position list for the fieldset in the admin options menu
*
* @param int $number The serial ID of the fieldset.
* @param string $selected_position The position for the notice.
* @return string
*/
private function generate_position( $number = 0, $selected_position = 'befote' ) {

$position_list = '';
$position_list .= "<label for='position_{$number}'>" . __( 'Select position for the notice : ', $this->plugin_slug ) . '</label>';
$position_list .= "<select id='position_{$number}' name='position[{$number}]' class='wp_notice_position'>";
$position_list .= '<option ' . selected( $selected_position, 'before', false ) . ' value="before">'. __( 'Before', $this->plugin_slug ) . '</option>';
$position_list .= '<option ' . selected( $selected_position, 'after', false ) . ' value="after">'. __( 'After', $this->plugin_slug ) . '</option>';
$position_list .= '<option ' . selected( $selected_position, 'both', false ) . ' value="both">'. __( 'Both', $this->plugin_slug ) . '</option>';
$position_list .= '</select> ';

return $position_list;
}

/**
*
* Generating the animation for the fieldset in the admin options menu
Expand Down Expand Up @@ -552,21 +578,24 @@ private function generate_animation( $number = 0, $selected_animation = array()
* @param string $selected_style The style string.
* @param string $selected_font The font string for fontAwsome.
* @param array $selected_animation Array for fonts.
* @param string $selected_position - The position of the notice.
* @return string
*/
private function build_fieldset( $number = 0, $selected_tag = array(), $selected_category = array(), $time = null,
$text = '', $selected_style = 'wp-notice-regular', $selected_font = 'none', $selected_animation = array() ) {

$category_list = $this->generate_category_list( $number, $selected_category );
$tag_list = $this->generate_tag_list( $number, $selected_tag );
$style_list = $this->generate_style_list( $number, $selected_style );
$fonts_list = $this->generate_fonts_list( $number, $selected_font );
$animation = $this->generate_animation( $number, $selected_animation );
$text_label = __( 'The Notice', $this->plugin_slug );
$time_label = __( 'Show in all posts that were created before:', $this->plugin_slug );
$text_place_holder = __( 'Insert the text of the notice here. It can be HTML or text string', $this->plugin_slug );
$time_place_holder = __( 'DD/MM/YYYY', $this->plugin_slug );
$fieldset = <<<EOD
$text = '', $selected_style = 'wp-notice-regular', $selected_font = 'none', $selected_animation = array(),
$selected_position = 'before' ) {

$category_list = $this->generate_category_list( $number, $selected_category );
$tag_list = $this->generate_tag_list( $number, $selected_tag );
$style_list = $this->generate_style_list( $number, $selected_style );
$fonts_list = $this->generate_fonts_list( $number, $selected_font );
$animation = $this->generate_animation( $number, $selected_animation );
$position = $this->generate_position( $number, $selected_position );
$text_label = __( 'The Notice', $this->plugin_slug );
$time_label = __( 'Show in all posts that were created before:', $this->plugin_slug );
$text_place_holder = __( 'Insert the text of the notice here. It can be HTML or text string', $this->plugin_slug );
$time_place_holder = __( 'DD/MM/YYYY', $this->plugin_slug );
$fieldset = <<<EOD
<fieldset class="wp_notice" rel="$number">
<div class="form-group">
<label for="wp_notice_text_$number">$text_label</label>
Expand All @@ -585,14 +614,17 @@ private function build_fieldset( $number = 0, $selected_tag = array(), $selected
<div class="wp_notice_animation form-group">
$animation
</div>
<div class="wp_notice_position form-group">
$position
</div>
<div class="wp_notice_mock_example">
<div class="wp_notice_message" id="wp_notice_message-$number"></div>
</div>
</fieldset>

EOD;

return $fieldset;
return $fieldset;
}

/**
Expand Down
Binary file modified languages/wp-notice-he_IL.mo
Binary file not shown.
114 changes: 70 additions & 44 deletions languages/wp-notice-he_IL.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ msgid ""
msgstr ""
"Project-Id-Version: wp-notice 1\n"
"Report-Msgid-Bugs-To: http://wordpress.org/plugins/plugin-name\n"
"POT-Creation-Date: 2015-09-19 13:32+0200\n"
"PO-Revision-Date: 2015-09-24 18:50+0200\n"
"POT-Creation-Date: 2015-12-12 14:49+0200\n"
"PO-Revision-Date: 2015-12-12 14:52+0200\n"
"Last-Translator: Ran Bar-Zik <ran@bar-zik.com>\n"
"Language-Team: <ran@bar-zik.com>\n"
"Language: he_IL\n"
Expand All @@ -20,113 +20,139 @@ msgstr ""
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: .\n"

#: admin/class-wp-notice-admin.php:79 admin/class-wp-notice-admin.php:90
#: public/class-wp-notice.php:82 public/class-wp-notice.php:93
#: admin/class-wp-notice-admin.php:115 admin/class-wp-notice-admin.php:126
#: public/class-wp-notice.php:98 public/class-wp-notice.php:109
msgid "Cheatin&#8217; huh?"
msgstr ""
msgstr "לרמות זה לא יפה."

#: admin/class-wp-notice-admin.php:152
#: admin/class-wp-notice-admin.php:175
msgid "Done"
msgstr "בוצע"

#: admin/class-wp-notice-admin.php:153
#: admin/class-wp-notice-admin.php:176
msgid "Today"
msgstr "היום"

#: admin/class-wp-notice-admin.php:156
#: admin/class-wp-notice-admin.php:179
msgid "Show a different month"
msgstr "הראה חודש אחר"

#: admin/class-wp-notice-admin.php:184
#: admin/class-wp-notice-admin.php:204
msgid "WP Notice Setting page"
msgstr "מסך ההגדרות של WP Notice"

#: admin/class-wp-notice-admin.php:200
#: admin/class-wp-notice-admin.php:205
msgid "WP Notice"
msgstr "הודעות וורדפרס"

#: admin/class-wp-notice-admin.php:224
msgid "Insert the notice and the conditions"
msgstr "הכניסו את ההודעה ואת התנאים"

#: admin/class-wp-notice-admin.php:331
#: admin/class-wp-notice-admin.php:374
msgid "WP Notice Settings Updated"
msgstr "ההגדרות של WP Notice עודכנו"

#: admin/class-wp-notice-admin.php:333
#: admin/class-wp-notice-admin.php:376
#, fuzzy
msgid "WP Notice Error! You did change the form, right? please try again."
msgstr "שגיאה ב Wp Notice אנא נסו שוב."

#: admin/class-wp-notice-admin.php:371 admin/class-wp-notice-admin.php:400
#: admin/class-wp-notice-admin.php:420 admin/class-wp-notice-admin.php:451
msgid "Show in all posts that belongs to : "
msgstr "הראה בכל הפוסטים ששייכים אל:"

#: admin/class-wp-notice-admin.php:373
#: admin/class-wp-notice-admin.php:422
msgid "Do not use categories"
msgstr "אל תשתמש בקטגוריות"

#: admin/class-wp-notice-admin.php:402
#: admin/class-wp-notice-admin.php:453
msgid "Do not use tags"
msgstr "אל תשתמש בתגיות"

#: admin/class-wp-notice-admin.php:427
#: admin/class-wp-notice-admin.php:477
msgid "Select the style of the notice : "
msgstr "בחרו את עיצוב ההודעה : "

#: admin/class-wp-notice-admin.php:455
#: admin/class-wp-notice-admin.php:497
msgid "Select icon for the notice : "
msgstr "בחרו אייקון שיופיע בהודעה"

#: admin/class-wp-notice-admin.php:499
#, fuzzy
msgid "Do not use font"
msgstr "אל תשתמש בתגיות"

#: admin/class-wp-notice-admin.php:519
#, fuzzy
msgid "Select position for the notice : "
msgstr "בחרו אייקון שיופיע בהודעה"

#: admin/class-wp-notice-admin.php:521
msgid "Before"
msgstr "לפני"

#: admin/class-wp-notice-admin.php:522
msgid "After"
msgstr "אחרי"

#: admin/class-wp-notice-admin.php:523
msgid "Both"
msgstr "גם וגם"

#: admin/class-wp-notice-admin.php:550
msgid "Select animation type : "
msgstr "בחרו את סוג האנימציה"

#: admin/class-wp-notice-admin.php:552
msgid "None"
msgstr "ללא"

#: admin/class-wp-notice-admin.php:559
msgid "Select animation duration (seconds) : "
msgstr "משך האנימציה בשניות"

#: admin/class-wp-notice-admin.php:563
msgid "Select animation repetition, -1 for infinite : "
msgstr "מספר החזרות. -1 עבור אינסוף"

#: admin/class-wp-notice-admin.php:594
msgid "The Notice"
msgstr "ההודעה"

#: admin/class-wp-notice-admin.php:456
#: admin/class-wp-notice-admin.php:595
msgid "Show in all posts that were created before:"
msgstr "הצג בכל הפוסטים שנוצרו לפני:"

#: admin/class-wp-notice-admin.php:457
#: admin/class-wp-notice-admin.php:596
msgid "Insert the text of the notice here. It can be HTML or text string"
msgstr "הכנס את הטקסט של ההודעה כאן. הטקסט יכול להיות HTML"

#: admin/class-wp-notice-admin.php:458
#: admin/class-wp-notice-admin.php:597
#, fuzzy
msgid "DD/MM/YYYY"
msgstr "DD/MM/YY"

#: admin/class-wp-notice-admin.php:489
#: admin/class-wp-notice-admin.php:639
msgid "Settings"
msgstr "הגדרות"

#: admin/views/admin.php:26
#: admin/views/admin.php:30
msgid ""
"Please fill in the notice text and the proper conditions that need to be "
"fulfilled in order to make the notice to appear"
msgstr "אנא מלאו את ההודעה ואת התנאים שצריכים להתקיים על מנת שהיא תופיע"

#: admin/views/admin.php:27
#: admin/views/admin.php:31
msgid "You can combine several conditions and create several notices"
msgstr "אפשר לשלב מספר תנאים וליצור מספר הודעות"

#: admin/views/admin.php:32
#: admin/views/admin.php:41
msgid "Submit"
msgstr "שלח"

msgid "Plugin to display notice and messages on posts"
msgstr "תוסף להצגת הודעות ומסרים בפוסטים שונים"

msgid "Select icon for the notice : "
msgstr "בחרו אייקון שיופיע בהודעה"

msgid "Select animation type : "
msgstr "בחרו את סוג האנימציה"

msgid "None"
msgstr "ללא"

msgid "Select animation duration (seconds) : "
msgstr "משך האנימציה בשניות"

msgid "Select animation repetition, -1 for infinite : "
msgstr "מספר החזרות. -1 עבור אינסוף"

#. Author of the plugin/theme
msgid "Ran Bar-Zik <ran@bar-zik.com>"
msgstr "רן בר-זיק <ran@bar-zik.com>"

#. Plugin name
msgid "WP Notice"
msgstr "הודעות וורדפרס"
Loading