Version Description
Download this release
Release Info
Developer | stephenharris |
Plugin | Post Type Archive Link |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2 to 1.3.0
- lang/hptal-textdomain-de_DE.mo +0 -0
- lang/hptal-textdomain-de_DE.po +11 -6
- lang/hptal-textdomain-it_IT.mo +0 -0
- lang/hptal-textdomain-it_IT.po +68 -0
- metabox.min.js +2 -0
- post-type-archive-links.php +148 -57
- readme.md +32 -10
- readme.txt +29 -7
lang/hptal-textdomain-de_DE.mo
CHANGED
Binary file
|
lang/hptal-textdomain-de_DE.po
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
-
"Project-Id-Version: WordPress Post Type Archive Links v1.
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: \n"
|
6 |
-
"PO-Revision-Date:
|
7 |
"Last-Translator: admin <joern@flyingletters.com>\n"
|
8 |
"Language-Team: \n"
|
9 |
"MIME-Version: 1.0\n"
|
@@ -50,14 +50,19 @@ msgstr ""
|
|
50 |
msgid "https://github.com/stephenharris/"
|
51 |
msgstr ""
|
52 |
|
|
|
|
|
|
|
|
|
|
|
53 |
#. translators: plugin header field 'Version'
|
54 |
#: post-type-archive-links.php:0
|
55 |
#@ hptal-textdomain
|
56 |
-
msgid "1.
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: post-type-archive-links.php:
|
60 |
#@ hptal-textdomain
|
61 |
-
msgid "
|
62 |
-
msgstr "
|
63 |
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
+
"Project-Id-Version: WordPress Post Type Archive Links v1.3\n"
|
4 |
"Report-Msgid-Bugs-To: \n"
|
5 |
"POT-Creation-Date: \n"
|
6 |
+
"PO-Revision-Date: 2014-04-26 21:15:34+0000\n"
|
7 |
"Last-Translator: admin <joern@flyingletters.com>\n"
|
8 |
"Language-Team: \n"
|
9 |
"MIME-Version: 1.0\n"
|
50 |
msgid "https://github.com/stephenharris/"
|
51 |
msgstr ""
|
52 |
|
53 |
+
#: post-type-archive-links.php:194
|
54 |
+
#@ hptal-textdomain
|
55 |
+
msgid "Post Type Archives"
|
56 |
+
msgstr "Post-Type Archive"
|
57 |
+
|
58 |
#. translators: plugin header field 'Version'
|
59 |
#: post-type-archive-links.php:0
|
60 |
#@ hptal-textdomain
|
61 |
+
msgid "1.3"
|
62 |
msgstr ""
|
63 |
|
64 |
+
#: post-type-archive-links.php:378
|
65 |
#@ hptal-textdomain
|
66 |
+
msgid "Archive"
|
67 |
+
msgstr ""
|
68 |
|
lang/hptal-textdomain-it_IT.mo
ADDED
Binary file
|
lang/hptal-textdomain-it_IT.po
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: WordPress Post Type Archive Links v1.3\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: \n"
|
6 |
+
"PO-Revision-Date: 2014-04-26 21:16:22+0000\n"
|
7 |
+
"Last-Translator: admin <admin@local.dev>\n"
|
8 |
+
"Language-Team: \n"
|
9 |
+
"MIME-Version: 1.0\n"
|
10 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
+
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
13 |
+
"X-Generator: CSL v1.x\n"
|
14 |
+
"X-Poedit-Language: Italian\n"
|
15 |
+
"X-Poedit-Country: ITALY\n"
|
16 |
+
"X-Poedit-SourceCharset: utf-8\n"
|
17 |
+
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
|
18 |
+
"X-Poedit-Basepath: ../\n"
|
19 |
+
"X-Poedit-Bookmarks: \n"
|
20 |
+
"X-Poedit-SearchPath-0: .\n"
|
21 |
+
"X-Textdomain-Support: yes"
|
22 |
+
|
23 |
+
#. translators: plugin header field 'Name'
|
24 |
+
#: post-type-archive-links.php:0
|
25 |
+
#@ hptal-textdomain
|
26 |
+
msgid "WordPress Post Type Archive Links"
|
27 |
+
msgstr ""
|
28 |
+
|
29 |
+
#. translators: plugin header field 'PluginURI'
|
30 |
+
#: post-type-archive-links.php:0
|
31 |
+
#@ hptal-textdomain
|
32 |
+
msgid "https://github.com/stephenharris/WordPress-Post-Type-Archive-Links"
|
33 |
+
msgstr ""
|
34 |
+
|
35 |
+
#. translators: plugin header field 'Description'
|
36 |
+
#: post-type-archive-links.php:0
|
37 |
+
#@ hptal-textdomain
|
38 |
+
msgid "Adds a MetaBox to the Appearance > Menu page to add post type archive links"
|
39 |
+
msgstr "Aggiunge una MetaBox alla pagina Aspetto > Menu per aggiungere i link agli archivi dei CPT"
|
40 |
+
|
41 |
+
#. translators: plugin header field 'Author'
|
42 |
+
#: post-type-archive-links.php:0
|
43 |
+
#@ hptal-textdomain
|
44 |
+
msgid "Stephen Harris"
|
45 |
+
msgstr ""
|
46 |
+
|
47 |
+
#. translators: plugin header field 'AuthorURI'
|
48 |
+
#: post-type-archive-links.php:0
|
49 |
+
#@ hptal-textdomain
|
50 |
+
msgid "https://github.com/stephenharris/"
|
51 |
+
msgstr ""
|
52 |
+
|
53 |
+
#: post-type-archive-links.php:194
|
54 |
+
#@ hptal-textdomain
|
55 |
+
msgid "Post Type Archives"
|
56 |
+
msgstr "Tipi Post Personalizzati"
|
57 |
+
|
58 |
+
#: post-type-archive-links.php:378
|
59 |
+
#@ hptal-textdomain
|
60 |
+
msgid "Archive"
|
61 |
+
msgstr "Archivio"
|
62 |
+
|
63 |
+
#. translators: plugin header field 'Version'
|
64 |
+
#: post-type-archive-links.php:0
|
65 |
+
#@ hptal-textdomain
|
66 |
+
msgid "1.3"
|
67 |
+
msgstr ""
|
68 |
+
|
metabox.min.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
/*! post-type-archive-links 1.3.0 2014-09-10 13:06 */
|
2 |
+
jQuery(document).ready(function(a){a("#submit-post-type-archives").click(function(b){b.preventDefault();var c=a("#"+hptal_obj.metabox_list_id+" li :checked"),d=a("input#submit-post-type-archives"),e=[];c.each(function(){e.push(a(this).val())}),a("#"+hptal_obj.metabox_id).find(".spinner").show(),d.prop("disabled",!0),a.post(hptal_obj.ajaxurl,{action:hptal_obj.action,posttypearchive_nonce:hptal_obj.nonce,post_types:e,nonce:hptal_obj.nonce},function(b){a("#menu-to-edit").append(b),a("#"+hptal_obj.metabox_id).find(".spinner").hide(),c.prop("checked",!1),d.prop("disabled",!1)})})});
|
post-type-archive-links.php
CHANGED
@@ -4,7 +4,7 @@ defined( 'ABSPATH' ) OR exit;
|
|
4 |
Plugin Name: WordPress Post Type Archive Links
|
5 |
Plugin URI: https://github.com/stephenharris/WordPress-Post-Type-Archive-Links
|
6 |
Description: Adds a MetaBox to the Appearance > Menu page to add post type archive links
|
7 |
-
Version: 1.
|
8 |
Author: Stephen Harris
|
9 |
Author URI: https://github.com/stephenharris/
|
10 |
Author Email: contact@stephenharris.info
|
@@ -32,56 +32,91 @@ Domain Path: /lang/
|
|
32 |
*/
|
33 |
|
34 |
// Load at the default priority of 10
|
35 |
-
add_action( 'plugins_loaded', array(
|
36 |
|
37 |
class Post_Type_Archive_Links {
|
38 |
/**
|
39 |
-
*
|
40 |
-
* @
|
41 |
-
* @
|
42 |
-
* @var object
|
43 |
*/
|
44 |
-
|
45 |
|
46 |
/**
|
47 |
* Nonce Value
|
48 |
-
* @
|
49 |
*/
|
50 |
-
|
51 |
|
52 |
/**
|
53 |
* ID of the custom metabox
|
54 |
-
* @
|
55 |
*/
|
56 |
-
|
57 |
|
58 |
/**
|
59 |
* ID of the custom post type list items
|
60 |
-
* @
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
*/
|
62 |
-
public $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
/**
|
65 |
-
* Instantiates the class
|
66 |
-
* @return
|
|
|
67 |
*/
|
68 |
-
public
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
|
74 |
|
75 |
/**
|
76 |
-
*
|
77 |
-
* @return
|
|
|
78 |
*/
|
79 |
-
|
80 |
-
load_plugin_textdomain( 'hptal-textdomain' , false , dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
|
81 |
|
82 |
-
|
83 |
|
84 |
-
add_action( '
|
|
|
|
|
85 |
|
86 |
add_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_archive_item' ) );
|
87 |
|
@@ -89,19 +124,59 @@ class Post_Type_Archive_Links {
|
|
89 |
|
90 |
add_action( 'admin_enqueue_scripts', array( $this, 'metabox_script' ) );
|
91 |
|
92 |
-
add_action( "wp_ajax_" .
|
93 |
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
|
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
/**
|
98 |
-
*
|
99 |
-
*
|
100 |
* @return void
|
101 |
*/
|
102 |
-
public function
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
106 |
|
107 |
|
@@ -110,8 +185,9 @@ class Post_Type_Archive_Links {
|
|
110 |
* @return void
|
111 |
*/
|
112 |
public function add_meta_box() {
|
|
|
113 |
add_meta_box(
|
114 |
-
|
115 |
__( 'Post Type Archives', 'hptal-textdomain' ),
|
116 |
array( $this, 'metabox' ),
|
117 |
'nav-menus',
|
@@ -130,12 +206,17 @@ class Post_Type_Archive_Links {
|
|
130 |
public function metabox_script( $hook ) {
|
131 |
if ( 'nav-menus.php' !== $hook )
|
132 |
return;
|
|
|
|
|
|
|
133 |
|
|
|
|
|
134 |
wp_register_script(
|
135 |
'hptal-ajax-script',
|
136 |
-
plugins_url(
|
137 |
array( 'jquery' ),
|
138 |
-
filemtime( plugin_dir_path( __FILE__ ).
|
139 |
true
|
140 |
);
|
141 |
wp_enqueue_script( 'hptal-ajax-script' );
|
@@ -146,10 +227,10 @@ class Post_Type_Archive_Links {
|
|
146 |
'hptal_obj',
|
147 |
array(
|
148 |
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
149 |
-
'nonce' => wp_create_nonce(
|
150 |
-
'metabox_id' =>
|
151 |
-
'metabox_list_id' =>
|
152 |
-
'action' =>
|
153 |
)
|
154 |
);
|
155 |
}
|
@@ -160,19 +241,17 @@ class Post_Type_Archive_Links {
|
|
160 |
* @return string $html
|
161 |
*/
|
162 |
public function metabox() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
global $nav_menu_selected_id;
|
164 |
|
165 |
-
|
166 |
-
$
|
167 |
-
array(
|
168 |
-
'has_archive' => true,
|
169 |
-
'_builtin' => false
|
170 |
-
),
|
171 |
-
'object'
|
172 |
-
);
|
173 |
-
|
174 |
-
$html = '<ul id="'. $this->metabox_list_id .'">';
|
175 |
-
foreach ( $post_types as $pt ) {
|
176 |
$html .= sprintf(
|
177 |
'<li><label><input type="checkbox" value ="%s" /> %s</label></li>',
|
178 |
esc_attr( $pt->name ),
|
@@ -184,7 +263,7 @@ class Post_Type_Archive_Links {
|
|
184 |
// 'Add to Menu' button
|
185 |
$html .= '<p class="button-controls"><span class="add-to-menu">';
|
186 |
$html .= '<input type="submit"'. disabled( $nav_menu_selected_id, 0, false ) .' class="button-secondary
|
187 |
-
submit-add-to-menu right" value="'.
|
188 |
name="add-post-type-menu-item" id="submit-post-type-archives" />';
|
189 |
$html .= '<span class="spinner"></span>';
|
190 |
$html .= '</span></p>';
|
@@ -195,15 +274,14 @@ class Post_Type_Archive_Links {
|
|
195 |
/**
|
196 |
* AJAX Callback to create the menu item and add it to menu
|
197 |
* @return string $HTML built with walk_nav_menu_tree()
|
|
|
198 |
*/
|
199 |
-
public function ajax_add_post_type()
|
200 |
-
|
201 |
-
$this->is_allowed();
|
202 |
|
203 |
// Create menu items and store IDs in array
|
204 |
$item_ids = array();
|
205 |
-
foreach (
|
206 |
-
{
|
207 |
$post_type_obj = get_post_type_object( $post_type );
|
208 |
|
209 |
if( ! $post_type_obj )
|
@@ -270,10 +348,22 @@ class Post_Type_Archive_Links {
|
|
270 |
! current_user_can( 'edit_theme_options' ) AND die( '-1' );
|
271 |
|
272 |
// Nonce check
|
273 |
-
check_ajax_referer(
|
274 |
|
275 |
// Is a post type chosen?
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
|
279 |
|
@@ -287,6 +377,7 @@ class Post_Type_Archive_Links {
|
|
287 |
return $menu_item;
|
288 |
|
289 |
$post_type = $menu_item->object;
|
|
|
290 |
$menu_item->url = get_post_type_archive_link( $post_type );
|
291 |
|
292 |
return $menu_item;
|
4 |
Plugin Name: WordPress Post Type Archive Links
|
5 |
Plugin URI: https://github.com/stephenharris/WordPress-Post-Type-Archive-Links
|
6 |
Description: Adds a MetaBox to the Appearance > Menu page to add post type archive links
|
7 |
+
Version: 1.3.0
|
8 |
Author: Stephen Harris
|
9 |
Author URI: https://github.com/stephenharris/
|
10 |
Author Email: contact@stephenharris.info
|
32 |
*/
|
33 |
|
34 |
// Load at the default priority of 10
|
35 |
+
add_action( 'plugins_loaded', array( new Post_Type_Archive_Links, 'init' ) );
|
36 |
|
37 |
class Post_Type_Archive_Links {
|
38 |
/**
|
39 |
+
* True if class already inited
|
40 |
+
* @access private
|
41 |
+
* @var bool
|
|
|
42 |
*/
|
43 |
+
private $ininited;
|
44 |
|
45 |
/**
|
46 |
* Nonce Value
|
47 |
+
* @const \Post_Type_Archive_Links::NONCE
|
48 |
*/
|
49 |
+
const NONCE = 'hptal_nonce';
|
50 |
|
51 |
/**
|
52 |
* ID of the custom metabox
|
53 |
+
* @const \Post_Type_Archive_Links::METABOXID
|
54 |
*/
|
55 |
+
const METABOXID = 'hptal-metabox';
|
56 |
|
57 |
/**
|
58 |
* ID of the custom post type list items
|
59 |
+
* @const \Post_Type_Archive_Links::METABOXLISTID
|
60 |
+
*/
|
61 |
+
const METABOXLISTID = 'post-type-archive-checklist';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* CPT objects that plugin should handle: having true
|
65 |
+
* 'has_archive', 'publicly_queryable' and 'show_in_nav_menu'
|
66 |
+
* @var array
|
67 |
+
* @access protected
|
68 |
+
*/
|
69 |
+
protected $cpts;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Handle backward compatibility for removed object variables
|
73 |
*/
|
74 |
+
public function __get( $name ) {
|
75 |
+
switch ( $name ) {
|
76 |
+
case 'metabox_id' :
|
77 |
+
return self::METABOXID;
|
78 |
+
case 'metabox_list_id' :
|
79 |
+
return self::METABOXLISTID;
|
80 |
+
case 'nonce' :
|
81 |
+
return self::NONCE;
|
82 |
+
case 'instance' :
|
83 |
+
return $this;
|
84 |
+
}
|
85 |
+
}
|
86 |
|
87 |
/**
|
88 |
+
* Instantiates the class, add hooks and load domain
|
89 |
+
* @return \Post_Type_Archive_Links
|
90 |
+
* @use \Post_Type_Archive_Links::enable() Add hooks, load domain
|
91 |
*/
|
92 |
+
public function init() {
|
93 |
+
if ( ! $this->ininited ) {
|
94 |
+
$this->ininited = true;
|
95 |
+
$this->enable( dirname( plugin_basename( __FILE__ ) ) );
|
96 |
+
|
97 |
+
/**
|
98 |
+
This filter allow to access to current class instance
|
99 |
+
by calling $hptal = apply_filters( 'post_type_archive_links', NULL );
|
100 |
+
No singleton was harmed in the making of this plugin.
|
101 |
+
*/
|
102 |
+
add_filter( 'post_type_archive_links', array( $this, __FUNCTION__ ) );
|
103 |
+
}
|
104 |
+
return $this;
|
105 |
}
|
106 |
|
107 |
|
108 |
/**
|
109 |
+
* Add plugin hooks and load domain.
|
110 |
+
* @return void
|
111 |
+
* @access private
|
112 |
*/
|
113 |
+
private function enable( $path ) {
|
|
|
114 |
|
115 |
+
load_plugin_textdomain( 'hptal-textdomain' , false , $path . '/lang/' );
|
116 |
|
117 |
+
add_action( 'admin_init', array( $this, 'get_cpts' ) );
|
118 |
+
|
119 |
+
add_action( 'admin_init', array( $this, 'add_meta_box' ), 20 );
|
120 |
|
121 |
add_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_archive_item' ) );
|
122 |
|
124 |
|
125 |
add_action( 'admin_enqueue_scripts', array( $this, 'metabox_script' ) );
|
126 |
|
127 |
+
add_action( "wp_ajax_" . self::NONCE, array( $this, 'ajax_add_post_type' ) );
|
128 |
|
129 |
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Remove plugin hooks and unset domain if exists.
|
133 |
+
* @return void
|
134 |
+
*/
|
135 |
+
public function disable() {
|
136 |
+
if ( $this->ininited ) {
|
137 |
+
|
138 |
+
if ( isset( $GLOBALS['l10n']['hptal-textdomain'] ) ) {
|
139 |
+
unset( $GLOBALS['l10n']['hptal-textdomain'] );
|
140 |
+
}
|
141 |
+
|
142 |
+
remove_action( 'admin_init', array( $this, 'get_cpts' ) );
|
143 |
+
|
144 |
+
remove_action( 'admin_init', array( $this, 'add_meta_box' ), 20 );
|
145 |
|
146 |
+
remove_filter( 'wp_setup_nav_menu_item', array( $this, 'setup_archive_item' ) );
|
147 |
|
148 |
+
remove_filter( 'wp_nav_menu_objects', array( $this, 'maybe_make_current' ) );
|
149 |
+
|
150 |
+
remove_action( 'admin_enqueue_scripts', array( $this, 'metabox_script' ) );
|
151 |
+
|
152 |
+
remove_action( "wp_ajax_" . self::NONCE, array( $this, 'ajax_add_post_type' ) );
|
153 |
+
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
/**
|
158 |
+
* Get CPTs that plugin should handle: having true
|
159 |
+
* 'has_archive', 'publicly_queryable' and 'show_in_nav_menu'
|
160 |
* @return void
|
161 |
*/
|
162 |
+
public function get_cpts() {
|
163 |
+
$cpts = array();
|
164 |
+
$has_archive_cps = get_post_types(
|
165 |
+
array(
|
166 |
+
'has_archive' => true,
|
167 |
+
'_builtin' => false
|
168 |
+
),
|
169 |
+
'object'
|
170 |
+
);
|
171 |
+
foreach ( $has_archive_cps as $ptid => $pt ) {
|
172 |
+
$to_show = $pt->show_in_nav_menus && $pt->publicly_queryable;
|
173 |
+
if ( apply_filters( "show_{$ptid}_archive_in_nav_menus", $to_show, $pt ) ) {
|
174 |
+
$cpts[] = $pt;
|
175 |
+
}
|
176 |
+
}
|
177 |
+
if ( ! empty( $cpts ) ) {
|
178 |
+
$this->cpts = $cpts;
|
179 |
+
}
|
180 |
}
|
181 |
|
182 |
|
185 |
* @return void
|
186 |
*/
|
187 |
public function add_meta_box() {
|
188 |
+
|
189 |
add_meta_box(
|
190 |
+
self::METABOXID,
|
191 |
__( 'Post Type Archives', 'hptal-textdomain' ),
|
192 |
array( $this, 'metabox' ),
|
193 |
'nav-menus',
|
206 |
public function metabox_script( $hook ) {
|
207 |
if ( 'nav-menus.php' !== $hook )
|
208 |
return;
|
209 |
+
|
210 |
+
// Do nothing if no CPTs to handle
|
211 |
+
if ( empty( $this->cpts ) ) return;
|
212 |
|
213 |
+
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG) ? '' : '.min';
|
214 |
+
|
215 |
wp_register_script(
|
216 |
'hptal-ajax-script',
|
217 |
+
plugins_url( "metabox{$suffix}.js", __FILE__ ),
|
218 |
array( 'jquery' ),
|
219 |
+
filemtime( plugin_dir_path( __FILE__ ) . "metabox{$suffix}.js" ),
|
220 |
true
|
221 |
);
|
222 |
wp_enqueue_script( 'hptal-ajax-script' );
|
227 |
'hptal_obj',
|
228 |
array(
|
229 |
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
230 |
+
'nonce' => wp_create_nonce( self::NONCE ),
|
231 |
+
'metabox_id' => self::METABOXID,
|
232 |
+
'metabox_list_id' => self::METABOXLISTID,
|
233 |
+
'action' => self::NONCE
|
234 |
)
|
235 |
);
|
236 |
}
|
241 |
* @return string $html
|
242 |
*/
|
243 |
public function metabox() {
|
244 |
+
|
245 |
+
// Inform user no CPTs available to be shown.
|
246 |
+
if ( empty( $this->cpts ) ) {
|
247 |
+
echo '<p>' . __( 'No items.' ) . '</p>';
|
248 |
+
return;
|
249 |
+
}
|
250 |
+
|
251 |
global $nav_menu_selected_id;
|
252 |
|
253 |
+
$html = '<ul id="'. self::METABOXLISTID .'">';
|
254 |
+
foreach ( $this->cpts as $pt ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
$html .= sprintf(
|
256 |
'<li><label><input type="checkbox" value ="%s" /> %s</label></li>',
|
257 |
esc_attr( $pt->name ),
|
263 |
// 'Add to Menu' button
|
264 |
$html .= '<p class="button-controls"><span class="add-to-menu">';
|
265 |
$html .= '<input type="submit"'. disabled( $nav_menu_selected_id, 0, false ) .' class="button-secondary
|
266 |
+
submit-add-to-menu right" value="'. esc_attr__( 'Add to Menu', 'hptal-textdomain' ) .'"
|
267 |
name="add-post-type-menu-item" id="submit-post-type-archives" />';
|
268 |
$html .= '<span class="spinner"></span>';
|
269 |
$html .= '</span></p>';
|
274 |
/**
|
275 |
* AJAX Callback to create the menu item and add it to menu
|
276 |
* @return string $HTML built with walk_nav_menu_tree()
|
277 |
+
* use \Post_Type_Archive_Links::is_allowed() Check request and return choosen post types
|
278 |
*/
|
279 |
+
public function ajax_add_post_type() {
|
280 |
+
$post_types = $this->is_allowed();
|
|
|
281 |
|
282 |
// Create menu items and store IDs in array
|
283 |
$item_ids = array();
|
284 |
+
foreach ( $post_types as $post_type ) {
|
|
|
285 |
$post_type_obj = get_post_type_object( $post_type );
|
286 |
|
287 |
if( ! $post_type_obj )
|
348 |
! current_user_can( 'edit_theme_options' ) AND die( '-1' );
|
349 |
|
350 |
// Nonce check
|
351 |
+
check_ajax_referer( self::NONCE, 'nonce' );
|
352 |
|
353 |
// Is a post type chosen?
|
354 |
+
$post_types = filter_input_array(
|
355 |
+
INPUT_POST,
|
356 |
+
array(
|
357 |
+
'post_types' => array(
|
358 |
+
'filter' => FILTER_SANITIZE_STRING,
|
359 |
+
'flags' => FILTER_REQUIRE_ARRAY
|
360 |
+
)
|
361 |
+
),
|
362 |
+
true
|
363 |
+
);
|
364 |
+
empty( $post_types['post_types'] ) AND exit;
|
365 |
+
// return post types if chosen
|
366 |
+
return array_values( $post_types['post_types'] );
|
367 |
}
|
368 |
|
369 |
|
377 |
return $menu_item;
|
378 |
|
379 |
$post_type = $menu_item->object;
|
380 |
+
$menu_item->type_label = __( 'Archive', 'hptal-textdomain' );
|
381 |
$menu_item->url = get_post_type_archive_link( $post_type );
|
382 |
|
383 |
return $menu_item;
|
readme.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
# Post Type Archive Link #
|
2 |
-
**Contributors:** stephenharris, F J Kaiser, ryancurban
|
3 |
**Tags:** post type archives, menu link, archives, navigation, metabox, administration user interface
|
4 |
**Requires at least:** 3.3
|
5 |
-
**Tested up to:**
|
6 |
-
**Stable tag:** 1.
|
7 |
**License:** GPLv3 or later
|
8 |
**License URI:** http://www.gnu.org/licenses/gpl.txt
|
9 |
|
@@ -11,9 +11,13 @@ Creates a metabox to the Appearance > Menu page to add custom post type archive
|
|
11 |
|
12 |
## Description ##
|
13 |
|
14 |
-
Post Type Archive Link creates a metabox on the Appearance > Menu admin page.
|
|
|
15 |
|
16 |
-
The
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
## Installation ##
|
@@ -27,28 +31,46 @@ Installation is standard and straight forward.
|
|
27 |
|
28 |
## Frequently Asked Questions ##
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
### Why are some post types missing? ###
|
31 |
|
32 |
-
The metabox will only list
|
|
|
|
|
33 |
|
34 |
|
35 |
## Screenshots ##
|
36 |
|
37 |
### 1. Custom post types admin menu metabox ###
|
38 |
-
![Custom post types admin menu metabox](http://s.
|
39 |
|
40 |
### 2. Custom post types added to your menu ###
|
41 |
-
![Custom post types added to your menu](http://s.
|
42 |
|
43 |
### 3. Custom post type 'Clients' in front-end menu with WordPress menu classes and current item styles ###
|
44 |
-
![Custom post type 'Clients' in front-end menu with WordPress menu classes and current item styles](http://s.
|
45 |
|
46 |
|
47 |
|
48 |
## Changelog ##
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
### 1.2 ###
|
51 |
-
* Use has_archive rather
|
52 |
* Fixes bug where "disabled" is printed if no menu has been created.
|
53 |
* Tested up to 3.7.1
|
54 |
* Added German language. Thanks to [@mcguffin](https://github.com/mcguffin).
|
1 |
# Post Type Archive Link #
|
2 |
+
**Contributors:** stephenharris, F J Kaiser, ryancurban, giuseppe.mazzapica
|
3 |
**Tags:** post type archives, menu link, archives, navigation, metabox, administration user interface
|
4 |
**Requires at least:** 3.3
|
5 |
+
**Tested up to:** 4.0
|
6 |
+
**Stable tag:** 1.3.0
|
7 |
**License:** GPLv3 or later
|
8 |
**License URI:** http://www.gnu.org/licenses/gpl.txt
|
9 |
|
11 |
|
12 |
## Description ##
|
13 |
|
14 |
+
Post Type Archive Link creates a metabox on the Appearance > Menu admin page.
|
15 |
+
This lists your custom post types and allows you to add links to each archive page in your WordPress menus.
|
16 |
|
17 |
+
The plug-in uses WordPress' default menu classes for current pages, current page parent and current page ancestor.
|
18 |
+
|
19 |
+
By default all post types with archives (and not registered by core) are available for adding to your menu.
|
20 |
+
You can forcibly revent a particlar post type from appearing using the `show_{$posttype}_archive_in_nav_menus` hook.
|
21 |
|
22 |
|
23 |
## Installation ##
|
31 |
|
32 |
## Frequently Asked Questions ##
|
33 |
|
34 |
+
### I can't see in the 'post type' metabox on the Apperance > Menus screen ###
|
35 |
+
|
36 |
+
View the "screen options" (top right), and ensure that "Post Type Archives" is checked.
|
37 |
+
|
38 |
+
|
39 |
### Why are some post types missing? ###
|
40 |
|
41 |
+
The metabox will only list custom post types registered with non-falsey `has_archive`, `publicly_queryable` or `show_in_vav_menus`.
|
42 |
+
|
43 |
+
CPTs having true `has_archive' but false `publicly_queryable` and/or `show_in_vav_menus` can be shown using `show_{$cpt_slug}_archive_in_nav_menus` filter hook.
|
44 |
|
45 |
|
46 |
## Screenshots ##
|
47 |
|
48 |
### 1. Custom post types admin menu metabox ###
|
49 |
+
![Custom post types admin menu metabox](http://s.w.org/plugins/post-type-archive-links/screenshot-1.png)
|
50 |
|
51 |
### 2. Custom post types added to your menu ###
|
52 |
+
![Custom post types added to your menu](http://s.w.org/plugins/post-type-archive-links/screenshot-2.png)
|
53 |
|
54 |
### 3. Custom post type 'Clients' in front-end menu with WordPress menu classes and current item styles ###
|
55 |
+
![Custom post type 'Clients' in front-end menu with WordPress menu classes and current item styles](http://s.w.org/plugins/post-type-archive-links/screenshot-3.png)
|
56 |
|
57 |
|
58 |
|
59 |
## Changelog ##
|
60 |
|
61 |
+
### 1.3 ###
|
62 |
+
* Make submit button available for translation. Thanks to [@antwortzeit](https://github.com/antwortzeit).
|
63 |
+
* Removed hooks from constructor, allowed plugin disabling: removing all hooks and text domain
|
64 |
+
* Introduced "post_type_archive_links" filter hook to get an instance of plugin class
|
65 |
+
* Hide CPTs having 'has_archive' true, but 'publicly_queryable' and/or 'show_in_vav_menus' set to false
|
66 |
+
* Introduced "show_{$cpt_slug}_archive_in_nav_menus" filter to force CPTs be added on metabox
|
67 |
+
* Show "No items." when there are no CPTs available
|
68 |
+
* Tested up to 4.0
|
69 |
+
* Added Italian language. Thanks to [@giuseppe.mazzapica](http://gm.zoomlab.it).
|
70 |
+
* Updated readme
|
71 |
+
|
72 |
### 1.2 ###
|
73 |
+
* Use has_archive rather than public. [See #13](https://github.com/stephenharris/WordPress-Post-Type-Archive-Links/issues/13)
|
74 |
* Fixes bug where "disabled" is printed if no menu has been created.
|
75 |
* Tested up to 3.7.1
|
76 |
* Added German language. Thanks to [@mcguffin](https://github.com/mcguffin).
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Post Type Archive Link ===
|
2 |
-
Contributors: stephenharris, F J Kaiser, ryancurban
|
3 |
Tags: post type archives, menu link, archives, navigation, metabox, administration user interface
|
4 |
Requires at least: 3.3
|
5 |
-
Tested up to:
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl.txt
|
9 |
|
@@ -11,9 +11,13 @@ Creates a metabox to the Appearance > Menu page to add custom post type archive
|
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
Post Type Archive Link creates a metabox on the Appearance > Menu admin page.
|
|
|
15 |
|
16 |
-
The
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
== Installation ==
|
@@ -27,9 +31,16 @@ Installation is standard and straight forward.
|
|
27 |
|
28 |
== Frequently Asked Questions ==
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
= Why are some post types missing? =
|
31 |
|
32 |
-
The metabox will only list
|
|
|
|
|
33 |
|
34 |
|
35 |
== Screenshots ==
|
@@ -41,8 +52,19 @@ The metabox will only list public custom post types
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
= 1.2 =
|
45 |
-
* Use has_archive rather
|
46 |
* Fixes bug where "disabled" is printed if no menu has been created.
|
47 |
* Tested up to 3.7.1
|
48 |
* Added German language. Thanks to [@mcguffin](https://github.com/mcguffin).
|
1 |
=== Post Type Archive Link ===
|
2 |
+
Contributors: stephenharris, F J Kaiser, ryancurban, giuseppe.mazzapica
|
3 |
Tags: post type archives, menu link, archives, navigation, metabox, administration user interface
|
4 |
Requires at least: 3.3
|
5 |
+
Tested up to: 4.0
|
6 |
+
Stable tag: 1.3.0
|
7 |
License: GPLv3 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl.txt
|
9 |
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Post Type Archive Link creates a metabox on the Appearance > Menu admin page.
|
15 |
+
This lists your custom post types and allows you to add links to each archive page in your WordPress menus.
|
16 |
|
17 |
+
The plug-in uses WordPress' default menu classes for current pages, current page parent and current page ancestor.
|
18 |
+
|
19 |
+
By default all post types with archives (and not registered by core) are available for adding to your menu.
|
20 |
+
You can forcibly revent a particlar post type from appearing using the `show_{$posttype}_archive_in_nav_menus` hook.
|
21 |
|
22 |
|
23 |
== Installation ==
|
31 |
|
32 |
== Frequently Asked Questions ==
|
33 |
|
34 |
+
= I can't see in the 'post type' metabox on the Apperance > Menus screen =
|
35 |
+
|
36 |
+
View the "screen options" (top right), and ensure that "Post Type Archives" is checked.
|
37 |
+
|
38 |
+
|
39 |
= Why are some post types missing? =
|
40 |
|
41 |
+
The metabox will only list custom post types registered with non-falsey `has_archive`, `publicly_queryable` or `show_in_vav_menus`.
|
42 |
+
|
43 |
+
CPTs having true `has_archive' but false `publicly_queryable` and/or `show_in_vav_menus` can be shown using `show_{$cpt_slug}_archive_in_nav_menus` filter hook.
|
44 |
|
45 |
|
46 |
== Screenshots ==
|
52 |
|
53 |
== Changelog ==
|
54 |
|
55 |
+
= 1.3 =
|
56 |
+
* Make submit button available for translation. Thanks to [@antwortzeit](https://github.com/antwortzeit).
|
57 |
+
* Removed hooks from constructor, allowed plugin disabling: removing all hooks and text domain
|
58 |
+
* Introduced "post_type_archive_links" filter hook to get an instance of plugin class
|
59 |
+
* Hide CPTs having 'has_archive' true, but 'publicly_queryable' and/or 'show_in_vav_menus' set to false
|
60 |
+
* Introduced "show_{$cpt_slug}_archive_in_nav_menus" filter to force CPTs be added on metabox
|
61 |
+
* Show "No items." when there are no CPTs available
|
62 |
+
* Tested up to 4.0
|
63 |
+
* Added Italian language. Thanks to [@giuseppe.mazzapica](http://gm.zoomlab.it).
|
64 |
+
* Updated readme
|
65 |
+
|
66 |
= 1.2 =
|
67 |
+
* Use has_archive rather than public. [See #13](https://github.com/stephenharris/WordPress-Post-Type-Archive-Links/issues/13)
|
68 |
* Fixes bug where "disabled" is printed if no menu has been created.
|
69 |
* Tested up to 3.7.1
|
70 |
* Added German language. Thanks to [@mcguffin](https://github.com/mcguffin).
|