Page Links To - Version 2.9

Version Description

  • Respect "open in new tab" setting in more custom situations, like custom loops and widgets.
  • Add unit tests
  • Massive code refactoring
  • Added translations for: Spanish, Catalan, French.
Download this release

Release Info

Developer markjaquith
Plugin Icon wp plugin Page Links To
Version 2.9
Comparing to
See all releases

Code changes from version 2.8 to 2.9

js/new-tab.coffee ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ jQuery ($) ->
2
+ $( 'body' ).on 'click', 'a', (e) ->
3
+ i = $ this
4
+ i.attr( 'target', '_blank' ) if $.inArray( i.attr('href'), pltNewTabURLs ) > -1
js/new-tab.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ // Generated by CoffeeScript 1.6.1
2
+ (function(){jQuery(function(e){return e("body").on("click","a",function(t){var n;n=e(this);if(e.inArray(n.attr("href"),pltNewTabURLs)>-1)return n.attr("target","_blank")})})}).call(this);
js/page-links-to.coffee ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery ($) ->
2
+ section = $ '#cws-links-to-custom-section'
3
+ input = $ 'input[type=radio]', '#page-links-to'
4
+
5
+ if input.filter('input[value="wp"]').prop 'checked'
6
+ section.fadeTo(1, 0).hide()
7
+
8
+ input.change ->
9
+ if $(@).val() is 'wp'
10
+ section.fadeTo 'fast', 0, ->
11
+ $(@).slideUp()
12
+ else
13
+ section.slideDown 'fast', ->
14
+ $(@).fadeTo 'fast', 1, ->
15
+ i = $ '#cws-links-to'
16
+ i.focus().val i.val()
js/page-links-to.dev.js DELETED
@@ -1,12 +0,0 @@
1
- (function($){
2
- $('input[type=radio]', '#page-links-to').change(function(){
3
- if ( 'wp' == $(this).val() ) {
4
- $('#txfx-links-to-alternate-section').fadeOut();
5
- } else {
6
- $('#txfx-links-to-alternate-section').fadeIn(function(){
7
- i = $('#txfx-links-to');
8
- i.focus().val(i.val());
9
- });
10
- }
11
- });
12
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
js/page-links-to.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ // Generated by CoffeeScript 1.6.1
2
+ (function(){jQuery(function(e){var t,n;n=e("#cws-links-to-custom-section");t=e("input[type=radio]","#page-links-to");t.filter('input[value="wp"]').prop("checked")&&n.fadeTo(1,0).hide();return t.change(function(){return e(this).val()==="wp"?n.fadeTo("fast",0,function(){return e(this).slideUp()}):n.slideDown("fast",function(){return e(this).fadeTo("fast",1,function(){var t;t=e("#cws-links-to");return t.focus().val(t.val())})})})})}).call(this);
languages/import.rb ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/ruby
2
+ langs = {
3
+ 'af' => 'af',
4
+ 'ak' => 'ak',
5
+ 'ar' => 'ar',
6
+ 'as' => 'as',
7
+ 'az' => 'az',
8
+ 'azb' => 'azb',
9
+ 'az_TR' => 'az-tr',
10
+ 'ba' => 'ba',
11
+ 'bal' => 'bal',
12
+ 'bg_BG' => 'bg',
13
+ 'bn_BD' => 'bn',
14
+ 'bs_BA' => 'bs',
15
+ 'ca' => 'ca',
16
+ 'ckb' => 'ckb',
17
+ 'co' => 'co',
18
+ 'cs_CZ' => 'cs',
19
+ 'cy' => 'cy',
20
+ 'da_DK' => 'da',
21
+ 'de_DE' => 'de',
22
+ 'dv' => 'dv',
23
+ 'el' => 'el',
24
+ 'en_US' => 'en',
25
+ 'en_CA' => 'en-ca',
26
+ 'en_GB' => 'en-gb',
27
+ 'eo' => 'eo',
28
+ 'es_CL' => 'es-cl',
29
+ 'es_MX' => 'es-mx',
30
+ 'es_PE' => 'es-pe',
31
+ 'es_PR' => 'es-pr',
32
+ 'es_VE' => 'es-ve',
33
+ 'es_CO' => 'es-co',
34
+ 'es_ES' => 'es',
35
+ 'et' => 'et',
36
+ 'eu' => 'eu',
37
+ 'fa_IR' => 'fa',
38
+ 'fa_AF' => 'fa-af',
39
+ 'fi' => 'fi',
40
+ 'fo' => 'fo',
41
+ 'fr_FR' => 'fr',
42
+ 'fr_BE' => 'fr-be',
43
+ 'fy' => 'fy',
44
+ 'gd' => 'gd',
45
+ 'gl_ES' => 'gl',
46
+ 'gn' => 'gn',
47
+ 'gsw' => 'gsw',
48
+ 'gu_IN' => 'gu',
49
+ 'haw_US' => 'haw',
50
+ 'haz' => 'haz',
51
+ 'he_IL' => 'he',
52
+ 'hi_IN' => 'hi',
53
+ 'hr' => 'hr',
54
+ 'hu_HU' => 'hu',
55
+ 'hy' => 'hy',
56
+ 'id_ID' => 'id',
57
+ 'is_IS' => 'is',
58
+ 'it_IT' => 'it',
59
+ 'ja' => 'ja',
60
+ 'jv_ID' => 'jv',
61
+ 'ka_GE' => 'ka',
62
+ 'kk' => 'kk',
63
+ 'kn' => 'kn',
64
+ 'ko_KR' => 'ko',
65
+ 'ky_KY' => 'ky',
66
+ 'lb_LU' => 'lb',
67
+ 'li' => 'li',
68
+ 'lo' => 'lo',
69
+ 'lt_LT' => 'lt',
70
+ 'lv' => 'lv',
71
+ 'me_ME' => 'me',
72
+ 'mg_MG' => 'mg',
73
+ 'mk_MK' => 'mk',
74
+ 'ml_IN' => 'ml',
75
+ 'ms_MY' => 'ms',
76
+ 'my_MM' => 'mya',
77
+ 'ne_NP' => 'ne',
78
+ 'nb_NO' => 'nb',
79
+ 'nl_NL' => 'nl',
80
+ 'nl_BE' => 'nl-be',
81
+ 'nn_NO' => 'nn',
82
+ 'os' => 'os',
83
+ 'pa_IN' => 'pa',
84
+ 'pl_PL' => 'pl',
85
+ 'pt_BR' => 'pt-br',
86
+ 'pt_PT' => 'pt',
87
+ 'ps' => 'ps',
88
+ 'ro_RO' => 'ro',
89
+ 'ru_RU' => 'ru',
90
+ 'ru_UA' => 'ru-ua',
91
+ 'rue' => 'rue',
92
+ 'rup_MK' => 'rup',
93
+ 'sah' => 'sah',
94
+ 'sa_IN' => 'sa-in',
95
+ 'sd_PK' => 'sd',
96
+ 'si_LK' => 'si',
97
+ 'sk_SK' => 'sk',
98
+ 'sl_SI' => 'sl',
99
+ 'so_SO' => 'so',
100
+ 'sq' => 'sq',
101
+ 'sr_RS' => 'sr',
102
+ 'srd' => 'srd',
103
+ 'su_ID' => 'su',
104
+ 'sv_SE' => 'sv',
105
+ 'sw' => 'sw',
106
+ 'ta_IN' => 'ta',
107
+ 'ta_LK' => 'ta-lk',
108
+ 'te' => 'te',
109
+ 'tg' => 'tg',
110
+ 'th' => 'th',
111
+ 'tl' => 'tl',
112
+ 'tr_TR' => 'tr',
113
+ 'tt_RU' => 'tt',
114
+ 'tuk' => 'tuk',
115
+ 'tzm' => 'tzm',
116
+ 'ug_CN' => 'ug',
117
+ 'uk' => 'uk',
118
+ 'ur' => 'ur',
119
+ 'uz_UZ' => 'uz',
120
+ 'vi' => 'vi',
121
+ 'wa' => 'wa',
122
+ 'xmf' => 'xmf',
123
+ 'zh_CN' => 'zh-cn',
124
+ 'zh_HK' => 'zh-hk',
125
+ 'zh_TW' => 'zh-tw',
126
+ }
127
+ require 'pathname'
128
+ plugin = Pathname.new(File.expand_path '../').basename
129
+ url_root = 'http://translate.markjaquith.com/projects/wordpress-plugins/%s/%s/default/export-translations?format=%s'
130
+ files = Dir.glob("*.mo").map { |f| g = f[/#{plugin}-(.*)\.mo/, 1]; [g, langs[g]] }
131
+ files.each do |l|
132
+ ['po', 'mo'].each do |fmt|
133
+ `wget -O #{plugin}-#{l[0]}.#{fmt} #{format url_root, plugin, l[1], fmt} 2>/dev/null`
134
+ end
135
+ `git checkout #{plugin}-#{l[0]}.*` if `git diff #{plugin}-#{l[0]}.po | ack '^[+-][^+-]{2}' | ack -v 'PO-Revision-Date'`.chomp.length === 0
136
+ end
languages/page-links-to-ca.mo ADDED
Binary file
languages/page-links-to-ca.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in Catalan
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:58+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Page Links a"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "URL personalitzada"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Obrir l'enllaç en una nova pestanya"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Atenció</strong>: Aquest contingut apunta a una URL pròpia. Utilitza la caixa de &#8220;Page Links To&#8221; per canviar aquest comportament"
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Apuntar aquest contingut a: "
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "La url normal de WordPress"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Page Links a"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Et permet apuntar pàgines o entrades de WordPress a una URL que escullis. És bo per configurar enllaços de navegació a seccions que no siguin de WordPress o a recursos fora del teu web."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to-de_DE.mo ADDED
Binary file
languages/page-links-to-de_DE.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in German
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:58+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Seite enthält Links zu"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "Eine benutzerdefinierte URL"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Öffne diesen Link in einem neuen Tab"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Hinweis</strong>: Dieser Inhalt zeigt auf eine benutzerdefinierte URL. Verwende die \"Seite zu Links\" Box,um dieses Verhalten zu ändern."
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Zeig diesen Inhalt auf:"
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "Deine normale WordPress URL"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Page Links To"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Hier kannst du WordPress Seiten oder Beiträge zu einer URL deiner Wahl zeigen. Das ist gut für die Einrichtung bei Navigations-Links zu nicht WP Bereichen deiner Website oder Off-Site-Ressourcen."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to-es_ES.mo ADDED
Binary file
languages/page-links-to-es_ES.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in Spanish (Spain)
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:58+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Page Links a"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "Una url personalizada"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Abrir este enlace en una nueva pestaña"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Atención</strong>: Este contenido apunta a una url propia. Usa la caja de &#8220;Page Links To&#8221; para cambiar este comportamiento. "
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Apuntar este contenido a:"
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "La url normal de WordPress"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Page Links a"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Te permite apuntar entradas o páginas de WordPress a una url que escojas. Está bien para configurar enlaces de navegación a secciones que no sean de WordPress de tu sitio o a recursos de fuera de tu web."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to-fr_FR.mo ADDED
Binary file
languages/page-links-to-fr_FR.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in French (France)
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:58+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n > 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Lier la page vers"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "Une URL personnalisée"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Ouvrir ce lien dans un nouvel onglet"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Note</strong>: Ce contenu pointe vers une URL personnalisée. Utilisez le bloc &#8220;Lier la page vers&#8221; pour changer ce comportement."
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Faire pointer ce contenu vers:"
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "Son URL WordPress normale"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Page Links To"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Vous permet de faire pointer des pages ou des articles WordPress vers une URL de votre choix. Utile pour mettre en place des liens de navigation vers des sections non-WP de votre site ou vers des ressources d'un site tiers."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to-he_IL.mo CHANGED
Binary file
languages/page-links-to-he_IL.po CHANGED
@@ -1,56 +1,51 @@
1
- # Copyright (C) 2012 Page Links To
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Page Links To 2.7-beta\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
- "POT-Creation-Date: 2012-01-05 22:58:34+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: 2012-05-01 19:18-0500\n"
12
- "Last-Translator: Mark Jaquith <mark.gpl@txfx.net>\n"
13
- "Language-Team: ARYO Digital <relklik@gmail.com>\n"
14
- "X-Poedit-Language: Hebrew\n"
15
- "X-Poedit-Country: ISRAEL\n"
16
 
17
- #: page-links-to.php:153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  msgid "Point this content to:"
19
  msgstr "קישור עמוד זה אל:"
20
 
21
- #: page-links-to.php:154
22
  msgid "Its normal WordPress URL"
23
  msgstr "קישור וורדפרס רגיל"
24
 
25
- #: page-links-to.php:155
26
- msgid "An alternate URL"
27
- msgstr "להפנות קישור"
28
-
29
- #: page-links-to.php:158
30
- msgid "Open this link in a new window"
31
- msgstr "פתח קישור בחלון חדש"
32
-
33
- #: page-links-to.php:286
34
- msgid "<strong>Note</strong>: This content is pointing to an alternate URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
35
- msgstr "<strong>הערה</strong>: עמוד זה מפנה לכתובת אחרת, השתמש בחלונית &#8220;הפניית קישור עמוד&#8221; כדי לשנות בחזרה לקישור המקורי."
36
-
37
- #. Plugin Name of the plugin/theme
38
  msgid "Page Links To"
39
  msgstr "הפניית קישור עמוד"
40
 
41
- #. Plugin URI of the plugin/theme
42
  msgid "http://txfx.net/wordpress-plugins/page-links-to/"
43
  msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
44
 
45
- #. Description of the plugin/theme
46
  msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
47
  msgstr "מאפשר לקשר עמודים / פוסטים לכל קישור אחר שתרצו. תוכלו לקשר בין כתובות בתוך האתר שלך או לכתובות חיצוניות."
48
 
49
- #. Author of the plugin/theme
50
  msgid "Mark Jaquith"
51
  msgstr "Mark Jaquith"
52
 
53
- #. Author URI of the plugin/theme
54
  msgid "http://coveredwebservices.com/"
55
- msgstr "http://coveredwebservices.com/"
56
-
1
+ # Translation of Page Links To in Hebrew
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:59+0000\n"
 
 
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
 
 
12
 
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr ""
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr ""
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr ""
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr ""
29
+
30
+ #: page-links-to.php:228
31
  msgid "Point this content to:"
32
  msgstr "קישור עמוד זה אל:"
33
 
34
+ #: page-links-to.php:229
35
  msgid "Its normal WordPress URL"
36
  msgstr "קישור וורדפרס רגיל"
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  msgid "Page Links To"
39
  msgstr "הפניית קישור עמוד"
40
 
 
41
  msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
  msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
 
 
44
  msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
  msgstr "מאפשר לקשר עמודים / פוסטים לכל קישור אחר שתרצו. תוכלו לקשר בין כתובות בתוך האתר שלך או לכתובות חיצוניות."
46
 
 
47
  msgid "Mark Jaquith"
48
  msgstr "Mark Jaquith"
49
 
 
50
  msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
 
languages/page-links-to-ja.mo CHANGED
Binary file
languages/page-links-to-ja.po CHANGED
@@ -1,56 +1,51 @@
1
- # Copyright (C) 2012 Page Links To
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Page Links To 2.7-beta\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
- "POT-Creation-Date: 2012-01-05 22:58:34+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: 2012-01-06 10:07+0900\n"
12
- "Last-Translator: JOTAKI, Taisuke <jotaki@digitalcube.jp>\n"
13
- "Language-Team: ja <tekapo@gmail.com>\n"
14
- "X-Poedit-Language: ja\n"
15
- "X-Poedit-Country: JP\n"
16
 
17
- #: page-links-to.php:153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  msgid "Point this content to:"
19
  msgstr "このコンテンツを向ける先:"
20
 
21
- #: page-links-to.php:154
22
  msgid "Its normal WordPress URL"
23
  msgstr "通常の WordPress の URL"
24
 
25
- #: page-links-to.php:155
26
- msgid "An alternate URL"
27
- msgstr "代替の URL"
28
-
29
- #: page-links-to.php:158
30
- msgid "Open this link in a new window"
31
- msgstr "このリンクを新しいウインドウで開く"
32
-
33
- #: page-links-to.php:286
34
- msgid "<strong>Note</strong>: This content is pointing to an alternate URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
35
- msgstr "<strong>メモ</strong>: このコンテンツは別の URL に向けられています。この挙動を変更するには &#8220;Page Links To&#8221; ボックスを利用してください。"
36
-
37
- #. Plugin Name of the plugin/theme
38
  msgid "Page Links To"
39
  msgstr "Page Links To"
40
 
41
- #. Plugin URI of the plugin/theme
42
  msgid "http://txfx.net/wordpress-plugins/page-links-to/"
43
  msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
44
 
45
- #. Description of the plugin/theme
46
  msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
47
  msgstr "WordPress の固定ページや投稿を任意の URL に向けます。WP 以外のセクションやサイト外のリソースにナビゲーションリンクを設定するのに便利です。"
48
 
49
- #. Author of the plugin/theme
50
  msgid "Mark Jaquith"
51
  msgstr "Mark Jaquith"
52
 
53
- #. Author URI of the plugin/theme
54
  msgid "http://coveredwebservices.com/"
55
- msgstr "http://coveredwebservices.com/"
56
-
1
+ # Translation of Page Links To in Japanese
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:59+0000\n"
 
 
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=1; plural=0;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
 
 
12
 
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr ""
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr ""
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr ""
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr ""
29
+
30
+ #: page-links-to.php:228
31
  msgid "Point this content to:"
32
  msgstr "このコンテンツを向ける先:"
33
 
34
+ #: page-links-to.php:229
35
  msgid "Its normal WordPress URL"
36
  msgstr "通常の WordPress の URL"
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  msgid "Page Links To"
39
  msgstr "Page Links To"
40
 
 
41
  msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
  msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
 
 
44
  msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
  msgstr "WordPress の固定ページや投稿を任意の URL に向けます。WP 以外のセクションやサイト外のリソースにナビゲーションリンクを設定するのに便利です。"
46
 
 
47
  msgid "Mark Jaquith"
48
  msgstr "Mark Jaquith"
49
 
 
50
  msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
 
languages/page-links-to-nb_NO.mo CHANGED
Binary file
languages/page-links-to-nb_NO.po CHANGED
@@ -1,56 +1,51 @@
1
- # Copyright (C) 2012 Page Links To
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Page Links To 2.7-beta\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
- "POT-Creation-Date: 2012-01-05 22:58:34+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: 2012-01-06 00:39+0100\n"
12
- "Last-Translator: \n"
13
- "Language-Team: NorskWP <post@gulbrandsoy.com>\n"
14
- "X-Poedit-Language: Norwegian Bokmal\n"
15
- "X-Poedit-Country: NORWAY\n"
16
 
17
- #: page-links-to.php:153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  msgid "Point this content to:"
19
  msgstr "Pek dette innholdet til:"
20
 
21
- #: page-links-to.php:154
22
  msgid "Its normal WordPress URL"
23
  msgstr "Sin vanlige WordPress URL"
24
 
25
- #: page-links-to.php:155
26
- msgid "An alternate URL"
27
- msgstr "En alternativ URL"
28
-
29
- #: page-links-to.php:158
30
- msgid "Open this link in a new window"
31
- msgstr "Åpne denne lenken i nytt vindu"
32
-
33
- #: page-links-to.php:286
34
- msgid "<strong>Note</strong>: This content is pointing to an alternate URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
35
- msgstr "<strong>NB</strong>: Dette innholdet peker til en alternativ URL. Bruk &#8220;Side lenker til&#8221; boksen for å endre oppførsel."
36
-
37
- #. Plugin Name of the plugin/theme
38
  msgid "Page Links To"
39
- msgstr "Side lenker til"
40
 
41
- #. Plugin URI of the plugin/theme
42
  msgid "http://txfx.net/wordpress-plugins/page-links-to/"
43
  msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
44
 
45
- #. Description of the plugin/theme
46
  msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
47
  msgstr "Lar deg peke WordPress sider eller poster til en vilkårlig URL. Kjekt å bruke til å peke navigasjonslinker til annet innhold på siden din eller til ressurser som ikke er på ditt domene."
48
 
49
- #. Author of the plugin/theme
50
  msgid "Mark Jaquith"
51
  msgstr "Mark Jaquith"
52
 
53
- #. Author URI of the plugin/theme
54
  msgid "http://coveredwebservices.com/"
55
- msgstr "http://coveredwebservices.com/"
56
-
1
+ # Translation of Page Links To in Norwegian (Bokmål)
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
+ "PO-Revision-Date: 2013-06-23 00:49:54+0000\n"
 
 
6
  "MIME-Version: 1.0\n"
7
  "Content-Type: text/plain; charset=UTF-8\n"
8
  "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
 
 
12
 
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Side lenker til"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "En tilpasset URL"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Åpne denne lenken i en ny fane"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Merk</strong>: Dette innholdet peker til en tilpasset nettadresse. Bruk &#8220;Side lenker til&#8221; boksen for å endre denne atferden."
29
+
30
+ #: page-links-to.php:228
31
  msgid "Point this content to:"
32
  msgstr "Pek dette innholdet til:"
33
 
34
+ #: page-links-to.php:229
35
  msgid "Its normal WordPress URL"
36
  msgstr "Sin vanlige WordPress URL"
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  msgid "Page Links To"
39
+ msgstr "Page Links To"
40
 
 
41
  msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
  msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
 
 
44
  msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
  msgstr "Lar deg peke WordPress sider eller poster til en vilkårlig URL. Kjekt å bruke til å peke navigasjonslinker til annet innhold på siden din eller til ressurser som ikke er på ditt domene."
46
 
 
47
  msgid "Mark Jaquith"
48
  msgstr "Mark Jaquith"
49
 
 
50
  msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
 
languages/page-links-to-pt-BR.mo DELETED
Binary file
languages/page-links-to-pt-BR.po DELETED
@@ -1,54 +0,0 @@
1
- # Copyright (C) 2012 Page Links To
2
- # This file is distributed under the same license as the Page Links To package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Page Links To 2.7-beta\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
- "POT-Creation-Date: 2012-01-05 22:58:34+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: 2012-01-05 21:29-0300\n"
12
- "Last-Translator: Rafael Ehlers <rafaehlers@gmail.com>\n"
13
- "Language-Team: Rafael Ehlers <rafaehlers@gmail.com>\n"
14
-
15
- #: page-links-to.php:153
16
- msgid "Point this content to:"
17
- msgstr "Apontar este conteúdo para:"
18
-
19
- #: page-links-to.php:154
20
- msgid "Its normal WordPress URL"
21
- msgstr "Sua URL normal do WordPress"
22
-
23
- #: page-links-to.php:155
24
- msgid "An alternate URL"
25
- msgstr "Uma URL alternativa"
26
-
27
- #: page-links-to.php:158
28
- msgid "Open this link in a new window"
29
- msgstr "Abra este link em uma nova janela"
30
-
31
- #: page-links-to.php:286
32
- msgid "<strong>Note</strong>: This content is pointing to an alternate URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
33
- msgstr "<strong>Nota</strong>: Este conteúdo está apontando para uma URL alternativa. Use o campo &#8220;Página aponta para&#8221; para alterar este comportamento."
34
-
35
- #. Plugin Name of the plugin/theme
36
- msgid "Page Links To"
37
- msgstr "Página aponta para"
38
-
39
- #. Plugin URI of the plugin/theme
40
- msgid "http://txfx.net/wordpress-plugins/page-links-to/"
41
- msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
42
-
43
- #. Description of the plugin/theme
44
- msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
- msgstr "Permite a você apontar páginas e posts do WordPress para a URL de sua escolha. Bom para apontar links de navegação para seções não-WP do seu site ou para recursos fora do site."
46
-
47
- #. Author of the plugin/theme
48
- msgid "Mark Jaquith"
49
- msgstr "Mark Jaquith"
50
-
51
- #. Author URI of the plugin/theme
52
- msgid "http://coveredwebservices.com/"
53
- msgstr "http://coveredwebservices.com/"
54
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/page-links-to-pt_BR.mo ADDED
Binary file
languages/page-links-to-pt_BR.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in Portuguese (Brazil)
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:59+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "A página aponta para"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "URL customizada"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Abrir este link em uma nova aba do navegador"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Aviso</strong>: Este conteúdo aponta para um endereço customizado da Internet. Utilize a caixa &#8220;A página aponta para&#8221; para modificar este endereço."
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Apontar este conteúdo para:"
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "Sua URL normal do WordPress"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Page Links To"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Permite a você apontar páginas e posts do WordPress para a URL de sua escolha. Bom para apontar links de navegação para seções não-WP do seu site ou para recursos fora do site."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to-pt_PT.mo ADDED
Binary file
languages/page-links-to-pt_PT.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in Portuguese (Portugal)
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:59+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Link da página "
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "Uma URL personalizada"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Abrir este link numa nova janela"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Nota</strong>: Este conteúdo está a apontar para uma URL personalizada. Use a opção &#8220;Link da página&#8221; para alterar este comportamento."
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Apontar este conteúdo para:"
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "A sua URL normal de WordPress"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Ligações de páginas"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Permite apontar os links de páginas e artigos para as URLs que deseje. Excelente para apontar links de navegação para secções não-WordPress do seu site ou para recursos externos."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to-sv-SE.mo DELETED
Binary file
languages/page-links-to-sv-SE.po DELETED
@@ -1,56 +0,0 @@
1
- # Copyright (C) 2012 Page Links To
2
- # This file is distributed under the same license as the Page Links To package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Page Links To 2.7-beta\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
- "POT-Creation-Date: 2012-01-05 22:58:34+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: 2012-04-25 16:10+0100\n"
12
- "Last-Translator: Ove Kaufeldt <ove.kaufeldt@shin-ken.se>\n"
13
- "Language-Team: Ove Kaufeldt\n"
14
- "X-Poedit-Language: Swedish\n"
15
- "X-Poedit-Country: SWEDEN\n"
16
-
17
- #: page-links-to.php:153
18
- msgid "Point this content to:"
19
- msgstr "Länka följande innehåll mot:"
20
-
21
- #: page-links-to.php:154
22
- msgid "Its normal WordPress URL"
23
- msgstr "Det är en vanlig Wordpress-adress (URL)"
24
-
25
- #: page-links-to.php:155
26
- msgid "An alternate URL"
27
- msgstr "En alternativ adress (URL)"
28
-
29
- #: page-links-to.php:158
30
- msgid "Open this link in a new window"
31
- msgstr "Öppna länken i ett nytt fönster"
32
-
33
- #: page-links-to.php:286
34
- msgid "<strong>Note</strong>: This content is pointing to an alternate URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
35
- msgstr "<strong>Observera</strong>: Innehållet pekar på en alternativ adress (URL). Använd &#8220;Page Links To&#8221;-rutan för att ändra detta."
36
-
37
- #. Plugin Name of the plugin/theme
38
- msgid "Page Links To"
39
- msgstr "Sidan länkar till"
40
-
41
- #. Plugin URI of the plugin/theme
42
- msgid "http://txfx.net/wordpress-plugins/page-links-to/"
43
- msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
44
-
45
- #. Description of the plugin/theme
46
- msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
47
- msgstr "Låter dig länka sidor och inlägg i Wordpress till en adress (URL) som du själv väljer. Praktiskt fö ratt sätta upp navigeringslänkar till delar av webbplatsen som inte är Wordpress, och till externa webbplatser."
48
-
49
- #. Author of the plugin/theme
50
- msgid "Mark Jaquith"
51
- msgstr "Mark Jaquith"
52
-
53
- #. Author URI of the plugin/theme
54
- msgid "http://coveredwebservices.com/"
55
- msgstr "http://coveredwebservices.com/"
56
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/page-links-to-sv_SE.mo ADDED
Binary file
languages/page-links-to-sv_SE.po ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Page Links To in Swedish
2
+ # This file is distributed under the same license as the Page Links To package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2013-06-22 04:51:59+0000\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
10
+ "X-Generator: GlotPress/0.1\n"
11
+ "Project-Id-Version: Page Links To\n"
12
+
13
+ #: page-links-to.php:209
14
+ msgctxt "Meta box title"
15
+ msgid "Page Links To"
16
+ msgstr "Sidan länkar till"
17
+
18
+ #: page-links-to.php:230
19
+ msgid "A custom URL"
20
+ msgstr "En anpassad URL"
21
+
22
+ #: page-links-to.php:233
23
+ msgid "Open this link in a new tab"
24
+ msgstr "Öppna denna länk i en ny flik"
25
+
26
+ #: page-links-to.php:492
27
+ msgid "<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior."
28
+ msgstr "<strong>Obs</strong>: Detta innehåll pekar på en anpassad webbadress. Använd &#8220;sida länkar till&#8221; rutan för att ändra detta beteende."
29
+
30
+ #: page-links-to.php:228
31
+ msgid "Point this content to:"
32
+ msgstr "Länka följande innehåll mot:"
33
+
34
+ #: page-links-to.php:229
35
+ msgid "Its normal WordPress URL"
36
+ msgstr "Det är en vanlig Wordpress-adress (URL)"
37
+
38
+ msgid "Page Links To"
39
+ msgstr "Page Links To"
40
+
41
+ msgid "http://txfx.net/wordpress-plugins/page-links-to/"
42
+ msgstr "http://txfx.net/wordpress-plugins/page-links-to/"
43
+
44
+ msgid "Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources."
45
+ msgstr "Låter dig länka sidor och inlägg i Wordpress till en adress (URL) som du själv väljer. Praktiskt fö ratt sätta upp navigeringslänkar till delar av webbplatsen som inte är Wordpress, och till externa webbplatser."
46
+
47
+ msgid "Mark Jaquith"
48
+ msgstr "Mark Jaquith"
49
+
50
+ msgid "http://coveredwebservices.com/"
51
+ msgstr "http://coveredwebservices.com/"
languages/page-links-to.pot CHANGED
@@ -1,36 +1,41 @@
1
- # Copyright (C) 2012 Page Links To
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Page Links To 2.7-beta\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
- "POT-Creation-Date: 2012-01-05 22:58:34+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: 2012-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: page-links-to.php:153
 
 
 
 
 
16
  msgid "Point this content to:"
17
  msgstr ""
18
 
19
- #: page-links-to.php:154
20
  msgid "Its normal WordPress URL"
21
  msgstr ""
22
 
23
- #: page-links-to.php:155
24
- msgid "An alternate URL"
25
  msgstr ""
26
 
27
- #: page-links-to.php:158
28
- msgid "Open this link in a new window"
29
  msgstr ""
30
 
31
- #: page-links-to.php:286
32
  msgid ""
33
- "<strong>Note</strong>: This content is pointing to an alternate URL. Use the "
34
  "&#8220;Page Links To&#8221; box to change this behavior."
35
  msgstr ""
36
 
1
+ # Copyright (C) 2013 Page Links To
2
  # This file is distributed under the same license as the Page Links To package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Page Links To 2.9-beta\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/page-links-to\n"
7
+ "POT-Creation-Date: 2013-06-08 17:42:50+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: 2013-MO-DA HO:MI+ZONE\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: page-links-to.php:209
16
+ msgctxt "Meta box title"
17
+ msgid "Page Links To"
18
+ msgstr ""
19
+
20
+ #: page-links-to.php:228
21
  msgid "Point this content to:"
22
  msgstr ""
23
 
24
+ #: page-links-to.php:229
25
  msgid "Its normal WordPress URL"
26
  msgstr ""
27
 
28
+ #: page-links-to.php:230
29
+ msgid "A custom URL"
30
  msgstr ""
31
 
32
+ #: page-links-to.php:233
33
+ msgid "Open this link in a new tab"
34
  msgstr ""
35
 
36
+ #: page-links-to.php:492
37
  msgid ""
38
+ "<strong>Note</strong>: This content is pointing to a custom URL. Use the "
39
  "&#8220;Page Links To&#8221; box to change this behavior."
40
  msgstr ""
41
 
lib/wp-stack-plugin.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Convenience methods
4
+ if ( !class_exists( 'WP_Stack_Plugin' ) ) {
5
+ class WP_Stack_Plugin {
6
+ public function hook( $hook ) {
7
+ $priority = 10;
8
+ $method = $this->sanitize_method( $hook );
9
+ $args = func_get_args();
10
+ unset( $args[0] );
11
+ foreach( (array) $args as $arg ) {
12
+ if ( is_int( $arg ) )
13
+ $priority = $arg;
14
+ else
15
+ $method = $arg;
16
+ }
17
+ return add_action( $hook, array( $this, $method ), $priority, 999 );
18
+ }
19
+
20
+ private function sanitize_method( $method ) {
21
+ return str_replace( array( '.', '-' ), array( '_DOT_', '_DASH_' ), $method );
22
+ }
23
+ }
24
+ }
page-links-to.php CHANGED
@@ -3,9 +3,11 @@
3
  Plugin Name: Page Links To
4
  Plugin URI: http://txfx.net/wordpress-plugins/page-links-to/
5
  Description: Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources.
6
- Version: 2.8
7
  Author: Mark Jaquith
8
  Author URI: http://coveredwebservices.com/
 
 
9
  */
10
 
11
  /* Copyright 2005-2013 Mark Jaquith
@@ -25,55 +27,103 @@ Author URI: http://coveredwebservices.com/
25
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
  */
27
 
28
- class CWS_PageLinksTo {
 
 
 
29
  static $instance;
30
- var $targets;
31
- var $links;
32
- var $targets_on_this_page;
 
 
 
 
 
33
 
34
  function __construct() {
35
  self::$instance = $this;
36
- add_action( 'init', array( $this, 'init' ) );
37
  }
38
 
39
  /**
40
  * Bootstraps the upgrade process and registers all the hooks.
41
  */
42
  function init() {
 
43
  $this->maybe_upgrade();
44
 
45
- load_plugin_textdomain( 'page-links-to', false, basename( dirname( __FILE__ ) ) . '/languages' );
 
46
 
47
- add_filter( 'wp_list_pages', array( $this, 'wp_list_pages' ) );
48
- add_action( 'template_redirect', array( $this, 'template_redirect' ) );
49
- add_filter( 'page_link', array( $this, 'link' ), 20, 2 );
50
- add_filter( 'post_link', array( $this, 'link' ), 20, 2 );
51
- add_filter( 'post_type_link', array( $this, 'link', ), 20, 2 );
52
- add_action( 'do_meta_boxes', array( $this, 'do_meta_boxes' ), 20, 2 );
53
- add_action( 'save_post', array( $this, 'save_post' ) );
54
- add_filter( 'wp_nav_menu_objects', array( $this, 'wp_nav_menu_objects' ), 10, 2 );
55
- add_action( 'load-post.php', array( $this, 'load_post' ) );
56
- add_filter( 'the_posts', array( $this, 'the_posts' ) );
57
  }
58
 
59
- /**
60
- * Performs an upgrade for older versions. Hides the keys so they only show in the plugin's UI
61
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  function maybe_upgrade() {
63
- if ( get_option( 'txfx_plt_schema_version' ) < 3 ) {
 
 
64
  global $wpdb;
65
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to' WHERE meta_key = 'links_to' " );
66
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to_target' WHERE meta_key = 'links_to_target' " );
67
- $wpdb->query( "UPDATE $wpdb->postmeta SET meta_key = '_links_to_type' WHERE meta_key = 'links_to_type' " );
68
- wp_cache_flush();
69
- update_option( 'txfx_plt_schema_version', 3 );
 
 
 
 
 
 
 
 
 
70
  }
71
  }
72
 
 
 
 
 
 
 
 
 
73
  /**
74
  * Returns post ids and meta values that have a given key
 
75
  * @param string $key post meta key
76
- * @return array an array of objects with post_id and meta_value properties
77
  */
78
  function meta_by_key( $key ) {
79
  global $wpdb;
@@ -82,70 +132,95 @@ class CWS_PageLinksTo {
82
 
83
  /**
84
  * Returns all links for the current site
 
85
  * @return array an array of links, keyed by post ID
86
  */
87
  function get_links() {
88
- global $wpdb, $blog_id;
 
 
 
 
 
 
 
 
 
 
 
89
 
90
- if ( !isset( $this->links[$blog_id] ) )
91
- $links_to = $this->meta_by_key( '_links_to' );
 
 
 
 
 
 
 
 
92
  else
93
- return $this->links[$blog_id];
94
-
95
- if ( !$links_to ) {
96
- $this->links[$blog_id] = false;
97
  return false;
98
- }
99
-
100
- foreach ( (array) $links_to as $link )
101
- $this->links[$blog_id][$link->post_id] = $link->meta_value;
102
-
103
- return $this->links[$blog_id];
104
  }
105
 
106
  /**
107
  * Returns all targets for the current site
 
108
  * @return array an array of targets, keyed by post ID
109
  */
110
- function get_targets () {
111
- global $wpdb, $page_links_to_target_cache, $blog_id;
 
 
 
 
 
 
 
 
 
 
 
112
 
113
- if ( !isset( $this->targets[$blog_id] ) )
114
- $links_to = $this->meta_by_key( '_links_to_target' );
 
 
 
 
 
 
 
 
115
  else
116
- return $this->targets[$blog_id];
117
-
118
- if ( !$links_to ) {
119
- $this->targets[$blog_id] = false;
120
  return false;
121
- }
122
-
123
- foreach ( (array) $links_to as $link )
124
- $this->targets[$blog_id][$link->post_id] = $link->meta_value;
125
-
126
- return $this->targets[$blog_id];
127
  }
128
 
129
  /**
130
  * Adds the meta box to the post or page edit screen
 
131
  * @param string $page the name of the current page
132
  * @param string $context the current context
133
  */
134
  function do_meta_boxes( $page, $context ) {
135
- // Plugins that use custom post types can use this filter to hide the PLT UI in their post type.
 
136
  $plt_post_types = apply_filters( 'page-links-to-post-types', array_keys( get_post_types( array('show_ui' => true ) ) ) );
137
 
138
  if ( in_array( $page, $plt_post_types ) && 'advanced' === $context )
139
- add_meta_box( 'page-links-to', 'Page Links To', array( $this, 'meta_box' ), $page, 'advanced', 'low' );
140
  }
141
 
 
 
 
142
  function meta_box() {
143
- global $post;
144
  echo '<p>';
145
- wp_nonce_field( 'txfx_plt', '_txfx_pl2_nonce', false, true );
146
  echo '</p>';
147
- $url = get_post_meta( $post->ID, '_links_to', true);
148
- if ( !$url ) {
149
  $linked = false;
150
  $url = 'http://';
151
  } else {
@@ -153,55 +228,175 @@ class CWS_PageLinksTo {
153
  }
154
  ?>
155
  <p><?php _e( 'Point this content to:', 'page-links-to' ); ?></p>
156
- <p><label><input type="radio" id="txfx-links-to-choose-wp" name="txfx_links_to_choice" value="wp" <?php checked( !$linked ); ?> /> <?php _e( 'Its normal WordPress URL', 'page-links-to' ); ?></label></p>
157
- <p><label><input type="radio" id="txfx-links-to-choose-alternate" name="txfx_links_to_choice" value="alternate" <?php checked( $linked ); ?> /> <?php _e( 'An alternate URL', 'page-links-to' ); ?></label></p>
158
- <div style="margin-left: 30px;" id="txfx-links-to-alternate-section" class="<?php echo !$linked ? 'hide-if-js' : ''; ?>">
159
- <p><input name="txfx_links_to" type="text" style="width:75%" id="txfx-links-to" value="<?php echo esc_attr( $url ); ?>" /></p>
160
- <p><label for="txfx-links-to-new-window"><input type="checkbox" name="txfx_links_to_new_window" id="txfx-links-to-new-window" value="_blank" <?php checked( '_blank', get_post_meta( $post->ID, '_links_to_target', true ) ); ?>> <?php _e( 'Open this link in a new window', 'page-links-to' ); ?></label></p>
161
  </div>
162
- <script src="<?php echo trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/page-links-to.dev.js'; ?>"></script>
163
  <?php
164
  }
165
 
166
  /**
167
  * Saves data on post save
168
- * @param int $post_ID a post ID
 
169
  * @return int the post ID that was passed in
170
  */
171
- function save_post( $post_ID ) {
172
- if ( isset( $_REQUEST['_txfx_pl2_nonce'] ) && wp_verify_nonce( $_REQUEST['_txfx_pl2_nonce'], 'txfx_plt' ) ) {
173
- if ( ( !isset( $_POST['txfx_links_to_choice'] ) || 'alternate' == $_POST['txfx_links_to_choice'] ) && isset( $_POST['txfx_links_to'] ) && strlen( $_POST['txfx_links_to'] ) > 0 && $_POST['txfx_links_to'] !== 'http://' ) {
174
- $link = trim( stripslashes( $_POST['txfx_links_to'] ) );
175
- if ( 0 === strpos( $link, 'www.' ) )
176
- $link = 'http://' . $link; // Starts with www., so add http://
177
- update_post_meta( $post_ID, '_links_to', $link );
178
- if ( isset( $_POST['txfx_links_to_new_window'] ) )
179
- update_post_meta( $post_ID, '_links_to_target', '_blank' );
180
  else
181
- delete_post_meta( $post_ID, '_links_to_target' );
182
  } else {
183
- delete_post_meta( $post_ID, '_links_to' );
184
- delete_post_meta( $post_ID, '_links_to_target' );
185
- delete_post_meta( $post_ID, '_links_to_type' );
186
  }
187
  }
188
- return $post_ID;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  }
190
 
191
  /**
192
- * Filter for post or page links
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  * @param string $link the URL for the post or page
194
- * @param int|object $post Either a post ID or a post object
195
  * @return string output URL
196
  */
197
  function link( $link, $post ) {
198
- $links = $this->get_links();
199
 
200
- // Really strange, but page_link gives us an ID and post_link gives us a post object
201
- $id = ( is_object( $post ) && $post->ID ) ? $post->ID : $post;
202
 
203
- if ( isset( $links[$id] ) && $links[$id] )
204
- $link = esc_url( $links[$id] );
 
 
 
205
 
206
  return $link;
207
  }
@@ -210,14 +405,17 @@ class CWS_PageLinksTo {
210
  * Performs a redirect, if appropriate
211
  */
212
  function template_redirect() {
213
- if ( !is_single() && !is_page() )
 
 
214
  return;
215
 
216
- global $wp_query;
 
217
 
218
- $link = get_post_meta( $wp_query->post->ID, '_links_to', true );
219
 
220
- if ( !$link )
221
  return;
222
 
223
  wp_redirect( $link, 301 );
@@ -226,25 +424,25 @@ class CWS_PageLinksTo {
226
 
227
  /**
228
  * Filters the list of pages to alter the links and targets
 
229
  * @param string $pages the wp_list_pages() HTML block from WordPress
230
  * @return string the modified HTML block
231
  */
232
  function wp_list_pages( $pages ) {
233
  $highlight = false;
234
  $links = $this->get_links();
235
- $page_links_to_target_cache = $this->get_targets();
236
 
237
- if ( !$links && !$page_links_to_target_cache )
238
  return $pages;
239
 
240
  $this_url = ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
241
  $targets = array();
242
 
243
  foreach ( (array) $links as $id => $page ) {
244
- if ( isset( $page_links_to_target_cache[$id] ) )
245
- $targets[$page] = $page_links_to_target_cache[$id];
246
 
247
- if ( str_replace( 'http://www.', 'http://', $this_url ) == str_replace( 'http://www.', 'http://', $page ) || ( is_home() && str_replace( 'http://www.', 'http://', trailingslashit( get_bloginfo( 'url' ) ) ) == str_replace( 'http://www.', 'http://', trailingslashit( $page ) ) ) ) {
248
  $highlight = true;
249
  $current_page = esc_url( $page );
250
  }
@@ -265,55 +463,88 @@ class CWS_PageLinksTo {
265
  return $pages;
266
  }
267
 
268
- function wp_nav_menu_objects( $items, $args ) {
269
- $page_links_to_target_cache = $this->get_targets();
 
 
 
 
 
270
  $new_items = array();
271
  foreach ( $items as $item ) {
272
- if ( isset( $page_links_to_target_cache[$item->object_id] ) )
273
- $item->target = $page_links_to_target_cache[$item->object_id];
274
  $new_items[] = $item;
275
  }
276
  return $new_items;
277
  }
278
 
 
 
 
279
  function load_post() {
280
  if ( isset( $_GET['post'] ) ) {
281
- if ( get_post_meta( absint( $_GET['post'] ), '_links_to', true ) ) {
282
- add_action( 'admin_notices', array( $this, 'notify_of_external_link' ) );
283
  }
284
  }
285
  }
286
 
 
 
 
287
  function notify_of_external_link() {
288
- ?><div class="updated"><p><?php _e( '<strong>Note</strong>: This content is pointing to an alternate URL. Use the &#8220;Page Links To&#8221; box to change this behavior.', 'page-links-to' ); ?></p></div><?php
289
- }
290
-
291
- function id_to_url_callback( &$val, $key ) {
292
- $val = get_permalink( $val );
293
- }
294
-
295
- function the_posts( $posts ) {
296
- $page_links_to_target_cache = $this->get_targets();
297
- if ( is_array( $page_links_to_target_cache) && count( $page_links_to_target_cache ) ) {
298
- $pids = array();
299
- foreach ( (array) $posts as $p )
300
- $pids[$p->ID] = $p->ID;
301
- $targets = array_keys( array_intersect_key( $page_links_to_target_cache, $pids ) );
302
- if ( count( $targets ) ) {
303
- array_walk( $targets, array( $this, 'id_to_url_callback' ) );
304
- $targets = array_unique( $targets );
305
- $this->targets_on_this_page = $targets;
306
- wp_enqueue_script( 'jquery' );
307
- add_action( 'wp_head', array( $this, 'targets_in_new_window_via_js' ) );
308
- }
309
- }
310
- return $posts;
311
  }
312
 
313
- function targets_in_new_window_via_js() {
314
- ?><script>(function($){var t=<?php echo json_encode( $this->targets_on_this_page ); ?>;$(document).ready(function(){var a=$('a');$.each(t,function(i,v){a.filter('[href="'+v+'"]').attr('target','_blank');});});})(jQuery);</script><?php
 
 
 
 
 
 
 
 
 
 
315
  }
316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  }
318
 
 
319
  new CWS_PageLinksTo;
3
  Plugin Name: Page Links To
4
  Plugin URI: http://txfx.net/wordpress-plugins/page-links-to/
5
  Description: Allows you to point WordPress pages or posts to a URL of your choosing. Good for setting up navigational links to non-WP sections of your site or to off-site resources.
6
+ Version: 2.9
7
  Author: Mark Jaquith
8
  Author URI: http://coveredwebservices.com/
9
+ Text Domain: page-links-to
10
+ Domain Path: /languages
11
  */
12
 
13
  /* Copyright 2005-2013 Mark Jaquith
27
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28
  */
29
 
30
+ // Pull in WP Stack plugin library
31
+ include( dirname( __FILE__ ) . '/lib/wp-stack-plugin.php' );
32
+
33
+ class CWS_PageLinksTo extends WP_Stack_Plugin {
34
  static $instance;
35
+ const LINKS_CACHE_KEY = 'plt_cache__links';
36
+ const TARGETS_CACHE_KEY = 'plt_cache__targets';
37
+ const LINK_META_KEY = '_links_to';
38
+ const TARGET_META_KEY = '_links_to_target';
39
+ const VERSION = 'txfx_plt_schema_version';
40
+ const FILE = __FILE__;
41
+
42
+ var $targets_on_this_page = array();
43
 
44
  function __construct() {
45
  self::$instance = $this;
46
+ $this->hook( 'init' );
47
  }
48
 
49
  /**
50
  * Bootstraps the upgrade process and registers all the hooks.
51
  */
52
  function init() {
53
+ // Check to see if any of our data needs to be upgraded
54
  $this->maybe_upgrade();
55
 
56
+ // Load translation files
57
+ load_plugin_textdomain( 'page-links-to', false, basename( dirname( self::FILE ) ) . '/languages' );
58
 
59
+ // Register hooks
60
+ $this->register_hooks();
 
 
 
 
 
 
 
 
61
  }
62
 
63
+ /**
64
+ * Registers all the hooks
65
+ */
66
+ function register_hooks() {
67
+ // Hook in to URL generation
68
+ $this->hook( 'page_link', 'link', 20 );
69
+ $this->hook( 'post_link', 'link', 20 );
70
+ $this->hook( 'post_type_link', 'link', 20 );
71
+
72
+ // Non-standard priority hooks
73
+ $this->hook( 'do_meta_boxes', 20 );
74
+ $this->hook( 'wp_footer', 19 );
75
+
76
+ // Non-standard callback hooks
77
+ $this->hook( 'load-post.php', 'load_post' );
78
+
79
+ // Standard hooks
80
+ $this->hook( 'wp_list_pages' );
81
+ $this->hook( 'template_redirect' );
82
+ $this->hook( 'save_post' );
83
+ $this->hook( 'wp_nav_menu_objects' );
84
+ $this->hook( 'plugin_row_meta' );
85
+ }
86
+
87
+ /**
88
+ * Performs an upgrade for older versions
89
+ *
90
+ * * Version 3: Underscores the keys so they only show in the plugin's UI.
91
+ */
92
  function maybe_upgrade() {
93
+ // In earlier versions, the meta keys were stored without a leading underscore.
94
+ // Since then, underscore has been codified as the standard for "something manages this" post meta.
95
+ if ( get_option( self::VERSION ) < 3 ) {
96
  global $wpdb;
97
+ $total_affected = 0;
98
+ foreach ( array( '', '_target', '_type' ) as $meta_key ) {
99
+ $meta_key = 'links_to' . $meta_key;
100
+ $affected = $wpdb->update( $wpdb->postmeta, array( 'meta_key' => '_' . $meta_key ), compact( 'meta_key' ) );
101
+ if ( $affected )
102
+ $total_affected += $affected;
103
+ }
104
+ // Only flush the cache if something changed
105
+ if ( $total_affected > 0 )
106
+ wp_cache_flush();
107
+ if ( update_option( self::VERSION, 3 ) ) {
108
+ $this->flush_links_cache();
109
+ $this->flush_targets_cache();
110
+ }
111
  }
112
  }
113
 
114
+ /**
115
+ * Enqueues jQuery, if we think we are going to need it
116
+ */
117
+ function wp_footer() {
118
+ if ( count( $this->targets_on_this_page ) )
119
+ wp_enqueue_script( 'jquery' );
120
+ }
121
+
122
  /**
123
  * Returns post ids and meta values that have a given key
124
+ *
125
  * @param string $key post meta key
126
+ * @return array|false objects with post_id and meta_value properties
127
  */
128
  function meta_by_key( $key ) {
129
  global $wpdb;
132
 
133
  /**
134
  * Returns all links for the current site
135
+ *
136
  * @return array an array of links, keyed by post ID
137
  */
138
  function get_links() {
139
+ if ( false === $links = get_transient( self::LINKS_CACHE_KEY ) ) {
140
+ $db_links = $this->meta_by_key( self::LINK_META_KEY );
141
+ $links = array();
142
+ if ( $db_links ) {
143
+ foreach ( $db_links as $link ) {
144
+ $links[ intval( $link->post_id ) ] = $link->meta_value;
145
+ }
146
+ }
147
+ set_transient( self::LINKS_CACHE_KEY, $links );
148
+ }
149
+ return $links;
150
+ }
151
 
152
+ /**
153
+ * Returns the link for the specified post ID
154
+ *
155
+ * @param integer $post_id a post ID
156
+ * @return mixed either a URL or false
157
+ */
158
+ function get_link( $post_id ) {
159
+ $links = $this->get_links();
160
+ if ( isset( $links[$post_id] ) )
161
+ return $links[$post_id];
162
  else
 
 
 
 
163
  return false;
 
 
 
 
 
 
164
  }
165
 
166
  /**
167
  * Returns all targets for the current site
168
+ *
169
  * @return array an array of targets, keyed by post ID
170
  */
171
+ function get_targets() {
172
+ if ( false === $targets = get_transient( self::TARGETS_CACHE_KEY ) ) {
173
+ $db_targets = $this->meta_by_key( self::TARGET_META_KEY );
174
+ $targets = array();
175
+ if ( $db_targets ) {
176
+ foreach ( $db_targets as $target ) {
177
+ $targets[ intval( $target->post_id ) ] = true;
178
+ }
179
+ }
180
+ set_transient( self::TARGETS_CACHE_KEY, $targets );
181
+ }
182
+ return $targets;
183
+ }
184
 
185
+ /**
186
+ * Returns the _blank target status for the specified post ID
187
+ *
188
+ * @param integer $post_id a post ID
189
+ * @return bool whether it should open in a new tab
190
+ */
191
+ function get_target( $post_id ) {
192
+ $targets = $this->get_targets();
193
+ if ( isset( $targets[$post_id] ) )
194
+ return true;
195
  else
 
 
 
 
196
  return false;
 
 
 
 
 
 
197
  }
198
 
199
  /**
200
  * Adds the meta box to the post or page edit screen
201
+ *
202
  * @param string $page the name of the current page
203
  * @param string $context the current context
204
  */
205
  function do_meta_boxes( $page, $context ) {
206
+ // Plugins that use custom post types can use this filter to hide the
207
+ // PLT UI in their post type.
208
  $plt_post_types = apply_filters( 'page-links-to-post-types', array_keys( get_post_types( array('show_ui' => true ) ) ) );
209
 
210
  if ( in_array( $page, $plt_post_types ) && 'advanced' === $context )
211
+ add_meta_box( 'page-links-to', _x( 'Page Links To', 'Meta box title', 'page-links-to'), array( $this, 'meta_box' ), $page, 'advanced', 'low' );
212
  }
213
 
214
+ /**
215
+ * Outputs the Page Links To post screen meta box
216
+ */
217
  function meta_box() {
218
+ $post = get_post();
219
  echo '<p>';
220
+ wp_nonce_field( 'cws_plt_' . $post->ID, '_cws_plt_nonce', false, true );
221
  echo '</p>';
222
+ $url = get_post_meta( $post->ID, self::LINK_META_KEY, true);
223
+ if ( ! $url ) {
224
  $linked = false;
225
  $url = 'http://';
226
  } else {
228
  }
229
  ?>
230
  <p><?php _e( 'Point this content to:', 'page-links-to' ); ?></p>
231
+ <p><label><input type="radio" id="cws-links-to-choose-wp" name="cws_links_to_choice" value="wp" <?php checked( !$linked ); ?> /> <?php _e( 'Its normal WordPress URL', 'page-links-to' ); ?></label></p>
232
+ <p><label><input type="radio" id="cws-links-to-choose-custom" name="cws_links_to_choice" value="custom" <?php checked( $linked ); ?> /> <?php _e( 'A custom URL', 'page-links-to' ); ?></label></p>
233
+ <div style="webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-left: 30px;" id="cws-links-to-custom-section" class="<?php echo ! $linked ? 'hide-if-js' : ''; ?>">
234
+ <p><input name="cws_links_to" type="text" style="width:75%" id="cws-links-to" value="<?php echo esc_attr( $url ); ?>" /></p>
235
+ <p><label for="cws-links-to-new-tab"><input type="checkbox" name="cws_links_to_new_tab" id="cws-links-to-new-tab" value="_blank" <?php checked( '_blank', get_post_meta( $post->ID, self::TARGET_META_KEY, true ) ); ?>> <?php _e( 'Open this link in a new tab', 'page-links-to' ); ?></label></p>
236
  </div>
237
+ <script src="<?php echo trailingslashit( plugin_dir_url( self::FILE ) ) . 'js/page-links-to.js?v=4'; ?>"></script>
238
  <?php
239
  }
240
 
241
  /**
242
  * Saves data on post save
243
+ *
244
+ * @param int $post_id a post ID
245
  * @return int the post ID that was passed in
246
  */
247
+ function save_post( $post_id ) {
248
+ if ( isset( $_REQUEST['_cws_plt_nonce'] ) && wp_verify_nonce( $_REQUEST['_cws_plt_nonce'], 'cws_plt_' . $post_id ) ) {
249
+ if ( ( ! isset( $_POST['cws_links_to_choice'] ) || 'custom' == $_POST['cws_links_to_choice'] ) && isset( $_POST['cws_links_to'] ) && strlen( $_POST['cws_links_to'] ) > 0 && $_POST['cws_links_to'] !== 'http://' ) {
250
+ $url = $this->clean_url( stripslashes( $_POST['cws_links_to'] ) );
251
+ $this->flush_links_if( $this->set_link( $post_id, $url ) );
252
+ if ( isset( $_POST['cws_links_to_new_tab'] ) )
253
+ $this->flush_targets_if( $this->set_link_new_tab( $post_id ) );
 
 
254
  else
255
+ $this->flush_targets_if( $this->set_link_same_tab( $post_id ) );
256
  } else {
257
+ $this->flush_links_if( $this->delete_link( $post_id ) );
 
 
258
  }
259
  }
260
+ return $post_id;
261
+ }
262
+
263
+ /**
264
+ * Cleans up a URL
265
+ *
266
+ * @param string $url URL
267
+ * @return string cleaned up URL
268
+ */
269
+ function clean_url( $url ) {
270
+ $url = trim( $url );
271
+ // Starts with 'www.'. Probably a mistake. So add 'http://'.
272
+ if ( 0 === strpos( $url, 'www.' ) )
273
+ $url = 'http://' . $url;
274
+ return $url;
275
+ }
276
+
277
+ /**
278
+ * Have a post point to a custom URL
279
+ *
280
+ * @param int $post_id post ID
281
+ * @param string $url the URL to point the post to
282
+ * @return bool whether anything changed
283
+ */
284
+ function set_link( $post_id, $url ) {
285
+ return $this->flush_links_if( (bool) update_post_meta( $post_id, self::LINK_META_KEY, $url ) );
286
+ }
287
+
288
+ /**
289
+ * Tell an custom URL post to open in a new tab
290
+ *
291
+ * @param int $post_id post ID
292
+ * @return bool whether anything changed
293
+ */
294
+ function set_link_new_tab( $post_id ) {
295
+ return $this->flush_targets_if( (bool) update_post_meta( $post_id, self::TARGET_META_KEY, '_blank' ) );
296
  }
297
 
298
  /**
299
+ * Tell an custom URL post to open in the same tab
300
+ *
301
+ * @param int $post_id post ID
302
+ * @return bool whether anything changed
303
+ */
304
+ function set_link_same_tab( $post_id ) {
305
+ return $this->flush_targets_if( delete_post_meta( $post_id, self::TARGET_META_KEY ) );
306
+ }
307
+
308
+ /**
309
+ * Discard a custom URL and point a post to its normal URL
310
+ *
311
+ * @param int $post_id post ID
312
+ * @return bool whether the link was deleted
313
+ */
314
+ function delete_link( $post_id ) {
315
+ $return = $this->flush_links_if( delete_post_meta( $post_id, self::LINK_META_KEY ) );
316
+ $this->flush_targets_if( delete_post_meta( $post_id, self::TARGET_META_KEY ) );
317
+
318
+ // Old, unused data that we can delete on the fly
319
+ delete_post_meta( $post_id, '_links_to_type' );
320
+
321
+ return $return;
322
+ }
323
+
324
+ /**
325
+ * Flushes the links transient cache if the condition is true
326
+ *
327
+ * @param bool $condition whether to proceed with the flush
328
+ * @return bool whether the flush happened
329
+ */
330
+ function flush_links_if( $condition ) {
331
+ if ( ! $condition )
332
+ return false;
333
+ $this->flush_links_cache();
334
+ return true;
335
+ }
336
+
337
+ /**
338
+ * Flushes the targets transient cache if the condition is true
339
+ *
340
+ * @param bool $condition whether to proceed with the flush
341
+ * @return bool whether the flush happened
342
+ */
343
+ function flush_targets_if( $condition ) {
344
+ if ( ! $condition )
345
+ return false;
346
+ $this->flush_targets_cache();
347
+ return true;
348
+ }
349
+
350
+ /**
351
+ * Flushes the links transient cache
352
+ *
353
+ * @param bool $condition whether to flush the cache
354
+ * @param string $type which cache to flush
355
+ * @return bool whether the flush attempt occurred
356
+ */
357
+ function flush_links_cache() {
358
+ delete_transient( self::LINKS_CACHE_KEY );
359
+ }
360
+
361
+ /**
362
+ * Flushes the targets transient cache
363
+ *
364
+ * @param bool $condition whether to flush the cache
365
+ * @param string $type which cache to flush
366
+ * @return bool whether the flush attempt occurred
367
+ */
368
+ function flush_targets_cache() {
369
+ delete_transient( self::TARGETS_CACHE_KEY );
370
+ }
371
+
372
+ /**
373
+ * Logs that a target=_blank PLT item has been used, so we know to trigger footer JS
374
+ *
375
+ * @param int|WP_Post $post post ID or object
376
+ */
377
+ function log_target( $post ) {
378
+ $post = get_post( $post );
379
+ $this->targets_on_this_page[$post->ID] = true;
380
+ $this->hook( 'wp_footer', 'targets_in_new_window_via_js_footer', 999 );
381
+ }
382
+
383
+ /**
384
+ * Filter for Post links
385
+ *
386
  * @param string $link the URL for the post or page
387
+ * @param int|WP_Post $post post ID or object
388
  * @return string output URL
389
  */
390
  function link( $link, $post ) {
391
+ $post = get_post( $post );
392
 
393
+ $meta_link = $this->get_link( $post->ID );
 
394
 
395
+ if ( $meta_link ) {
396
+ $link = esc_url( $meta_link );
397
+ if ( $this->get_target( $post->ID ) )
398
+ $this->log_target( $post->ID );
399
+ }
400
 
401
  return $link;
402
  }
405
  * Performs a redirect, if appropriate
406
  */
407
  function template_redirect() {
408
+ global $wp_query;
409
+
410
+ if ( ! is_singular() )
411
  return;
412
 
413
+ if ( !isset( $wp_query->post_ID ) )
414
+ return;
415
 
416
+ $link = $this->get_link( $wp_query->post_ID );
417
 
418
+ if ( ! $link )
419
  return;
420
 
421
  wp_redirect( $link, 301 );
424
 
425
  /**
426
  * Filters the list of pages to alter the links and targets
427
+ *
428
  * @param string $pages the wp_list_pages() HTML block from WordPress
429
  * @return string the modified HTML block
430
  */
431
  function wp_list_pages( $pages ) {
432
  $highlight = false;
433
  $links = $this->get_links();
 
434
 
435
+ if ( ! $links )
436
  return $pages;
437
 
438
  $this_url = ( is_ssl() ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
439
  $targets = array();
440
 
441
  foreach ( (array) $links as $id => $page ) {
442
+ if ( $this->get_target( $id ) )
443
+ $targets[$page] = '_blank';
444
 
445
+ if ( str_replace( 'http://www.', 'http://', $this_url ) === str_replace( 'http://www.', 'http://', $page ) || ( is_home() && str_replace( 'http://www.', 'http://', trailingslashit( get_bloginfo( 'url' ) ) ) === str_replace( 'http://www.', 'http://', trailingslashit( $page ) ) ) ) {
446
  $highlight = true;
447
  $current_page = esc_url( $page );
448
  }
463
  return $pages;
464
  }
465
 
466
+ /**
467
+ * Filters nav menu objects and adds target=_blank to the ones that need it
468
+ *
469
+ * @param array $items nav menu items
470
+ * @return array modified nav menu items
471
+ */
472
+ function wp_nav_menu_objects( $items ) {
473
  $new_items = array();
474
  foreach ( $items as $item ) {
475
+ if ( $this->get_target( $item->object_id ) )
476
+ $item->target = '_blank';
477
  $new_items[] = $item;
478
  }
479
  return $new_items;
480
  }
481
 
482
+ /**
483
+ * Hooks in as a post is being loaded for editing and conditionally adds a notice
484
+ */
485
  function load_post() {
486
  if ( isset( $_GET['post'] ) ) {
487
+ if ( get_post_meta( absint( $_GET['post'] ), self::LINK_META_KEY, true ) ) {
488
+ $this->hook( 'admin_notices', 'notify_of_external_link' );
489
  }
490
  }
491
  }
492
 
493
+ /**
494
+ * Outputs a notice that the current post item is pointed to a custom URL
495
+ */
496
  function notify_of_external_link() {
497
+ ?><div class="updated"><p><?php _e( '<strong>Note</strong>: This content is pointing to a custom URL. Use the &#8220;Page Links To&#8221; box to change this behavior.', 'page-links-to' ); ?></p></div><?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  }
499
 
500
+ /**
501
+ * Return a JS file as a string
502
+ *
503
+ * Takes a plugin-relative path to a CS-produced JS file
504
+ * and returns its second line (no CS comment line)
505
+ * @param string $path plugin-relative path to CoffeeScript-produced JS file
506
+ * @return string the JS string
507
+ */
508
+ function inline_coffeescript( $path ) {
509
+ $inline_script = file_get_contents( trailingslashit( plugin_dir_path( self::FILE ) ) . $path );
510
+ $inline_script = explode( "\n", $inline_script );
511
+ return $inline_script[1];
512
  }
513
 
514
+ /**
515
+ * Adds inline JS to the footer to handle "open in new tab" links
516
+ */
517
+ function targets_in_new_window_via_js_footer() {
518
+ $target_ids = $this->targets_on_this_page;
519
+ $target_urls = array();
520
+ foreach ( array_keys( $target_ids ) as $id ) {
521
+ $link = $this->get_link( $id );
522
+ if ( $link )
523
+ $target_urls[$link] = true;
524
+ }
525
+ $targets = array_keys( $target_urls );
526
+ if ( $targets ) {
527
+ ?><script>var pltNewTabURLs = <?php echo json_encode( $targets ) . ';' . $this->inline_coffeescript( 'js/new-tab.js' ); ?></script><?php
528
+ }
529
+ }
530
+
531
+ /**
532
+ * Adds a GitHub link to the plugin meta
533
+ *
534
+ * @param array $links the current array of links
535
+ * @param string $file the current plugin being processed
536
+ * @return array the modified array of links
537
+ */
538
+ function plugin_row_meta( $links, $file ) {
539
+ if ( $file === plugin_basename( self::FILE ) ) {
540
+ return array_merge(
541
+ $links,
542
+ array( '<a href="https://github.com/markjaquith/page-links-to" target="_blank">GitHub</a>' )
543
+ );
544
+ }
545
+ return $links;
546
+ }
547
  }
548
 
549
+ // Bootstrap everything
550
  new CWS_PageLinksTo;
phpunit.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <phpunit
2
+ bootstrap="tests/bootstrap.php"
3
+ backupGlobals="false"
4
+ colors="true"
5
+ convertErrorsToExceptions="true"
6
+ convertNoticesToExceptions="true"
7
+ convertWarningsToExceptions="true"
8
+ >
9
+ <testsuites>
10
+ <testsuite>
11
+ <directory prefix="test-" suffix=".php">./tests/</directory>
12
+ </testsuite>
13
+ </testsuites>
14
+ </phpunit>
readme.txt CHANGED
@@ -1,10 +1,13 @@
1
  === Page Links To ===
 
 
 
2
  Contributors: markjaquith
3
  Donate link: http://txfx.net/wordpress-plugins/donate
4
  Tags: page, redirect, link, external link, repoint
5
- Requires at least: 3.3
6
- Tested up to: 3.5.1
7
- Stable tag: 2.7.1
8
 
9
  Lets you make a WordPress page (or other content type) link to an external URL of your choosing, instead of its WordPress URL.
10
 
@@ -44,9 +47,9 @@ Just use "#" as the link. That won't go anywhere.
44
 
45
  = Can this be used to repoint categories to an arbitrary URL? =
46
 
47
- No.
48
 
49
- = My links are sending me to http://myblog.com/www.site-i-wanted-to-link-to.com ... why? =
50
 
51
  If you want to link to a full URL, you *must* include the `http://` portion.
52
 
@@ -56,6 +59,12 @@ Yes. Linking to `/my-photos.php` is a good idea, as it'll still work if you move
56
 
57
  == Changelog ==
58
 
 
 
 
 
 
 
59
  = 2.8 =
60
  * Added translations for: Swedish, Hebrew.
61
 
1
  === Page Links To ===
2
+
3
+ [![Build Status](https://travis-ci.org/markjaquith/page-links-to.png?branch=master)](https://travis-ci.org/markjaquith/page-links-to)
4
+
5
  Contributors: markjaquith
6
  Donate link: http://txfx.net/wordpress-plugins/donate
7
  Tags: page, redirect, link, external link, repoint
8
+ Requires at least: 3.4
9
+ Tested up to: 3.6
10
+ Stable tag: 2.8
11
 
12
  Lets you make a WordPress page (or other content type) link to an external URL of your choosing, instead of its WordPress URL.
13
 
47
 
48
  = Can this be used to repoint categories to an arbitrary URL? =
49
 
50
+ Not currently. Please contact me if you're interested in that functionality.
51
 
52
+ = My links are sending me to http://myblog.com/site-i-wanted-to-link-to.com ... why? =
53
 
54
  If you want to link to a full URL, you *must* include the `http://` portion.
55
 
59
 
60
  == Changelog ==
61
 
62
+ = 2.9 =
63
+ * Respect "open in new tab" setting in more custom situations, like custom loops and widgets.
64
+ * Add unit tests
65
+ * Massive code refactoring
66
+ * Added translations for: Spanish, Catalan, French.
67
+
68
  = 2.8 =
69
  * Added translations for: Swedish, Hebrew.
70
 
tests/bootstrap.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once getenv( 'WP_TESTS_DIR' ) . '/includes/functions.php';
4
+
5
+ function _manually_load_plugin() {
6
+ require dirname( __FILE__ ) . '/../page-links-to.php';
7
+ }
8
+ tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
9
+
10
+ require getenv( 'WP_TESTS_DIR' ) . '/includes/bootstrap.php';
11
+
12
+ class CWS_PLT_TestCase extends WP_UnitTestCase {
13
+ function plugin() {
14
+ return CWS_PageLinksTo::$instance;
15
+ }
16
+
17
+ function set_post( $key, $value ) {
18
+ $_POST[$key] = $_REQUEST[$key] = addslashes( $value );
19
+ }
20
+
21
+ function unset_post( $key ) {
22
+ unset( $_POST[$key], $_REQUEST[$key] );
23
+ }
24
+ }
tests/test-admin.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CWS_PLT_Test_Admin extends CWS_PLT_TestCase {
4
+ function test_plugin_row_meta() {
5
+ $metas = apply_filters( 'plugin_row_meta', array( 'one', 'two' ), plugin_basename( CWS_PageLinksTo::FILE ) );
6
+ $this->assertEquals( 3, count( $metas ) );
7
+ $this->assertContains( 'GitHub', array_pop( $metas ) );
8
+ }
9
+ }
tests/test-default-options.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CWS_PLT_Test_Default_Options extends CWS_PLT_TestCase {
4
+ function test_schema_option() {
5
+ $this->assertEquals( 3, get_option( CWS_PageLinksTo::VERSION ) );
6
+ }
7
+ }
tests/test-filtering.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CWS_PLT_Test_Filtering extends CWS_PLT_TestCase {
4
+ function test_get_permalink_filter() {
5
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
6
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
7
+ $this->assertEquals( 'http://example.com/', get_permalink( $post_id ) );
8
+ }
9
+
10
+ function test_wp_list_posts_filter() {
11
+ $post_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
12
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
13
+ $this->assertTrue( $this->plugin()->set_link_new_tab( $post_id ) );
14
+ ob_start();
15
+ wp_list_pages();
16
+ $wp_list_pages = ob_get_clean();
17
+ $this->assertContains( 'target="_blank"', $wp_list_pages );
18
+ }
19
+
20
+ function test_nav_menu_items_filter() {
21
+ $post_id = $this->factory->post->create( array( 'post_type' => 'page', 'post_status' => 'publish' ) );
22
+ $post = get_post( $post_id );
23
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
24
+ $this->assertTrue( $this->plugin()->set_link_new_tab( $post_id ) );
25
+
26
+ // Need a user with sufficient permissions because wp_insert_post() is not low level enough — WTF?
27
+ $user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
28
+ wp_set_current_user( $user_id );
29
+ $menu_id = wp_create_nav_menu( 'plt' );
30
+ $this->assertInternalType( 'int', $menu_id, "Menu creation failed" );
31
+ $item_id = wp_update_nav_menu_item( $menu_id, 0, array(
32
+ 'menu-item-object-id' => $post_id,
33
+ 'menu-item-object' => $post->post_type,
34
+ 'menu-item-type' => 'post_type',
35
+ 'menu-item-status' => 'publish',
36
+ ));
37
+ $wp_nav_menu = wp_nav_menu( array( 'echo' => false, 'menu' => $menu_id, 'fallback_cb' => false ) );
38
+ $this->assertInternalType( 'string', $wp_nav_menu, 'Menu is empty' );
39
+ $this->assertContains( 'target="_blank"', $wp_nav_menu );
40
+ }
41
+ }
tests/test-js.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CWS_PLT_Test_JS extends CWS_PLT_TestCase {
4
+ function test_footer_js() {
5
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
6
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
7
+ $this->assertTrue( $this->plugin()->set_link_new_tab( $post_id ) );
8
+ $this->assertEquals( 'http://example.com/', get_permalink( $post_id ) );
9
+ ob_start();
10
+ $this->plugin()->targets_in_new_window_via_js_footer();
11
+ $footer_js = ob_get_clean();
12
+ $this->assertContains( 'example.com', $footer_js );
13
+ }
14
+ }
tests/test-saving.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CWS_PLT_Test_Saving extends CWS_PLT_TestCase {
4
+ function test_get_links() {
5
+ $this->assertEquals( array(), $this->plugin()->get_links() );
6
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
7
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
8
+ $this->assertEquals( array( $post_id => 'http://example.com/' ), $this->plugin()->get_links() );
9
+ $this->assertTrue( $this->plugin()->delete_link( $post_id ) );
10
+ $this->assertEquals( array(), $this->plugin()->get_links() );
11
+ }
12
+
13
+ function test_get_targets() {
14
+ $this->assertEquals( array(), $this->plugin()->get_targets() );
15
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
16
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
17
+ $this->assertTrue( $this->plugin()->set_link_new_tab( $post_id ) );
18
+ $this->assertEquals( array( $post_id => true ), $this->plugin()->get_targets() );
19
+ $this->assertTrue( $this->plugin()->set_link_same_tab( $post_id ) );
20
+ $this->assertEquals( array(), $this->plugin()->get_targets() );
21
+ }
22
+
23
+ function test_setting_and_updating_url() {
24
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
25
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
26
+ $this->assertEquals( 'http://example.com/', $this->plugin()->get_link( $post_id ) );
27
+ // This update changes nothing, so should return false
28
+ $this->assertFalse( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
29
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/updated' ) );
30
+ $this->assertEquals( 'http://example.com/updated', $this->plugin()->get_link( $post_id ) );
31
+ }
32
+
33
+ function test_deleting_url() {
34
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
35
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
36
+ $this->assertTrue( $this->plugin()->delete_link( $post_id ) );
37
+ $this->assertFalse( $this->plugin()->get_link( $post_id ) );
38
+ }
39
+
40
+ function test_setting_new_tab() {
41
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
42
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
43
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
44
+ $this->assertTrue( $this->plugin()->set_link_new_tab( $post_id ) );
45
+ $this->assertTrue( $this->plugin()->get_target( $post_id ) );
46
+ // This update changes nothing, so should return false
47
+ $this->assertFalse( $this->plugin()->set_link_new_tab( $post_id ) );
48
+ $this->assertTrue( $this->plugin()->set_link_same_tab( $post_id ) );
49
+ // This update changes nothing, so should return false
50
+ $this->assertFalse( $this->plugin()->set_link_same_tab( $post_id ) );
51
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
52
+ }
53
+
54
+ function test_deleting_url_also_deletes_target() {
55
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post' ) );
56
+ $this->assertTrue( $this->plugin()->set_link( $post_id, 'http://example.com/' ) );
57
+ $this->assertTrue( $this->plugin()->set_link_new_tab( $post_id ) );
58
+ $this->assertTrue( $this->plugin()->get_target( $post_id ) );
59
+ $this->assertTrue( $this->plugin()->delete_link( $post_id ) );
60
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
61
+ }
62
+
63
+ function test_updating_post() {
64
+ $user_id = $this->factory->user->create( array( 'role' => 'editor' ) );
65
+ wp_set_current_user( $user_id );
66
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => $user_id ) );
67
+
68
+ $this->set_post( '_cws_plt_nonce', wp_create_nonce( 'cws_plt_' . $post_id ) );
69
+
70
+ // example.org in same window
71
+ $this->set_post( 'cws_links_to_choice', 'custom' );
72
+ $this->set_post( 'cws_links_to', 'http://example.org/' );
73
+ $this->unset_post( 'cws_links_to_new_tab' );
74
+ $this->plugin()->save_post( $post_id );
75
+ $this->assertEquals( 'http://example.org/', $this->plugin()->get_link( $post_id ) );
76
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
77
+
78
+ // example.com in new window
79
+ $this->set_post( 'cws_links_to_choice', 'custom' );
80
+ $this->set_post( 'cws_links_to', 'http://example.com/' );
81
+ $this->set_post( 'cws_links_to_new_tab', '_blank' );
82
+ $this->plugin()->save_post( $post_id );
83
+ $this->assertEquals( 'http://example.com/', $this->plugin()->get_link( $post_id ) );
84
+ $this->assertTrue( $this->plugin()->get_target( $post_id ) );
85
+
86
+ // WP link selected
87
+ $this->set_post( 'cws_links_to_choice', 'wp' );
88
+ $this->set_post( 'cws_links_to', 'http://example.com/' );
89
+ $this->set_post( 'cws_links_to_new_tab', '_blank' );
90
+ $this->plugin()->save_post( $post_id );
91
+ $this->assertFalse( $this->plugin()->get_link( $post_id ) );
92
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
93
+
94
+ // No radio selected, but link provided
95
+ $this->unset_post( 'cws_links_to_choice' );
96
+ $this->set_post( 'cws_links_to', 'http://example.com/link-no-radio' );
97
+ $this->set_post( 'cws_links_to_new_tab', '_blank' );
98
+ $this->plugin()->save_post( $post_id );
99
+ $this->assertEquals( 'http://example.com/link-no-radio', $this->plugin()->get_link( $post_id ) );
100
+ $this->assertTrue( $this->plugin()->get_target( $post_id ) );
101
+
102
+ // New post
103
+ $post_id = $this->factory->post->create( array( 'post_type' => 'post', 'post_author' => $user_id ) );
104
+
105
+ // Nonce missing
106
+ $this->unset_post( '_cws_plt_nonce' );
107
+ $this->set_post( 'cws_links_to_choice', 'custom' );
108
+ $this->set_post( 'cws_links_to', 'http://example.com/nonce-test' );
109
+ $this->set_post( 'cws_links_to_new_tab', '_blank' );
110
+ $this->plugin()->save_post( $post_id );
111
+ $this->assertFalse( $this->plugin()->get_link( $post_id ) );
112
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
113
+
114
+ // Nonce wrong
115
+ $this->set_post( '_cws_plt_nonce', wp_create_nonce( 'WRONG_INPUT' ) );
116
+ $this->plugin()->save_post( $post_id );
117
+ $this->assertFalse( $this->plugin()->get_link( $post_id ) );
118
+ $this->assertFalse( $this->plugin()->get_target( $post_id ) );
119
+ }
120
+ }
tests/test-utils.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class CWS_PLT_Test_Utils extends CWS_PLT_TestCase {
4
+ function test_clean_url() {
5
+ foreach ( array(
6
+ 'http://example.com/' => 'http://example.com/',
7
+ ' http://example.com/ ' => 'http://example.com/',
8
+ 'www.example.com/' => 'http://www.example.com/',
9
+ ' www.example.com/' => 'http://www.example.com/',
10
+ ) as $in => $out ) {
11
+ $this->assertEquals( $out, $this->plugin()->clean_url( $in ) );
12
+ }
13
+ }
14
+
15
+ function test_inline_coffeescript() {
16
+ $this->assertNotContains( 'CoffeeScript', $this->plugin()->inline_coffeescript( 'js/new-tab.js' ) );
17
+ }
18
+ }